-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Diff #52
base: master
Are you sure you want to change the base?
Diff #52
Changes from all commits
566be50
5f2ff0a
4e76946
218529e
b8cd35d
a54a819
488d762
a38bb41
146c633
6bde19a
1e38dd7
b88ed32
af3a387
f660fea
a24b46e
e0690ad
d85b76e
a1ddb17
c1e5966
e300718
9ebd7e5
0f962ca
07f04e2
423a0c0
6ec858a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
/* | ||
* Fork of ClippyJS needed to work with Drupal.org. | ||
* | ||
* @see https://github.com/mherchel/clippy.js/tree/drupal | ||
*/ | ||
|
||
(function ($) { | ||
|
||
// Code to help debug Clippy (if necessary) | ||
var urlSearchParams = (new URL(document.location)).searchParams; | ||
if (urlSearchParams.get('debug') != null) { | ||
console.log('Clippy\'s jQuery version: ' + window.jQueryNew.fn.jquery);; | ||
} | ||
|
||
var clippy = {}; | ||
|
||
/****** | ||
* | ||
* | ||
* @constructor | ||
*/ | ||
clippy.Agent = function (path, data, sounds) { | ||
clippy.Agent = function (path, data) { | ||
this.path = path; | ||
|
||
this._queue = new clippy.Queue($.proxy(this._onQueueEmpty, this)); | ||
|
@@ -14,7 +28,7 @@ clippy.Agent = function (path, data, sounds) { | |
|
||
$(document.body).append(this._el); | ||
|
||
this._animator = new clippy.Animator(this._el, path, data, sounds); | ||
this._animator = new clippy.Animator(this._el, path, data); | ||
|
||
this._balloon = new clippy.Balloon(this._el); | ||
|
||
|
@@ -463,7 +477,7 @@ clippy.Agent.prototype = { | |
* | ||
* @constructor | ||
*/ | ||
clippy.Animator = function (el, path, data, sounds) { | ||
clippy.Animator = function (el, path, data) { | ||
this._el = el; | ||
this._data = data; | ||
this._path = path; | ||
|
@@ -473,9 +487,9 @@ clippy.Animator = function (el, path, data, sounds) { | |
this._currentAnimation = undefined; | ||
this._endCallback = undefined; | ||
this._started = false; | ||
this._sounds = {}; | ||
// this._sounds = {}; | ||
this.currentAnimationName = undefined; | ||
this.preloadSounds(sounds); | ||
// this.preloadSounds(sounds); | ||
this._overlays = [this._el]; | ||
var curr = this._el; | ||
|
||
|
@@ -510,13 +524,13 @@ clippy.Animator.prototype = { | |
|
||
preloadSounds:function (sounds) { | ||
|
||
for (var i = 0; i < this._data.sounds.length; i++) { | ||
var snd = this._data.sounds[i]; | ||
var uri = sounds[snd]; | ||
if (!uri) continue; | ||
this._sounds[snd] = new Audio(uri); | ||
// for (var i = 0; i < this._data.sounds.length; i++) { | ||
// var snd = this._data.sounds[i]; | ||
// var uri = sounds[snd]; | ||
// if (!uri) continue; | ||
// this._sounds[snd] = new Audio(uri); | ||
|
||
} | ||
// } | ||
}, | ||
hasAnimation:function (name) { | ||
return !!this._data.animations[name]; | ||
|
@@ -595,10 +609,10 @@ clippy.Animator.prototype = { | |
}, | ||
|
||
_playSound:function () { | ||
var s = this._currentFrame.sound; | ||
if (!s) return; | ||
var audio = this._sounds[s]; | ||
if (audio) audio.play(); | ||
// var s = this._currentFrame.sound; | ||
// if (!s) return; | ||
// var audio = this._sounds[s]; | ||
// if (audio) audio.play(); | ||
}, | ||
|
||
_atLastFrame:function () { | ||
|
@@ -617,7 +631,7 @@ clippy.Animator.prototype = { | |
} | ||
|
||
this._draw(); | ||
this._playSound(); | ||
// this._playSound(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't comment out code. Remove it if not needed. |
||
|
||
this._loop = window.setTimeout($.proxy(this._step, this), this._currentFrame.duration); | ||
|
||
|
@@ -664,8 +678,8 @@ clippy.Balloon = function (targetEl) { | |
|
||
clippy.Balloon.prototype = { | ||
|
||
WORD_SPEAK_TIME:320, | ||
CLOSE_BALLOON_DELAY:2000, | ||
WORD_SPEAK_TIME:300, | ||
CLOSE_BALLOON_DELAY:15000, | ||
|
||
_setup:function () { | ||
|
||
|
@@ -810,7 +824,7 @@ clippy.Balloon.prototype = { | |
this.hide(); | ||
} | ||
} else { | ||
el.text(words.slice(0, idx).join(' ')); | ||
el.html(words.slice(0, idx).join(' ')); | ||
idx++; | ||
this._loop = window.setTimeout($.proxy(this._addWord, this), time); | ||
} | ||
|
@@ -844,33 +858,33 @@ clippy.Balloon.prototype = { | |
|
||
}; | ||
|
||
clippy.BASE_PATH = '//s3.amazonaws.com/clippy.js/Agents/'; | ||
clippy.BASE_PATH = '/sites/all/libraries/clippy.js/agents/'; | ||
|
||
clippy.load = function (name, successCb, failCb) { | ||
var path = clippy.BASE_PATH + name; | ||
|
||
var mapDfd = clippy.load._loadMap(path); | ||
var agentDfd = clippy.load._loadAgent(name, path); | ||
var soundsDfd = clippy.load._loadSounds(name, path); | ||
// var soundsDfd = clippy.load._loadSounds(name, path); | ||
|
||
var data; | ||
agentDfd.done(function (d) { | ||
data = d; | ||
}); | ||
|
||
var sounds; | ||
// var sounds; | ||
|
||
soundsDfd.done(function (d) { | ||
sounds = d; | ||
}); | ||
// soundsDfd.done(function (d) { | ||
// sounds = d; | ||
// }); | ||
|
||
// wrapper to the success callback | ||
var cb = function () { | ||
var a = new clippy.Agent(path, data,sounds); | ||
var a = new clippy.Agent(path, data, null); | ||
successCb(a); | ||
}; | ||
|
||
$.when(mapDfd, agentDfd, soundsDfd).done(cb).fail(failCb); | ||
$.when(mapDfd, agentDfd).done(cb).fail(failCb); | ||
}; | ||
|
||
clippy.load._maps = {}; | ||
|
@@ -893,28 +907,28 @@ clippy.load._loadMap = function (path) { | |
return dfd.promise(); | ||
}; | ||
|
||
clippy.load._sounds = {}; | ||
// clippy.load._sounds = {}; | ||
|
||
clippy.load._loadSounds = function (name, path) { | ||
var dfd = clippy.load._sounds[name]; | ||
if (dfd) return dfd; | ||
// var dfd = clippy.load._sounds[name]; | ||
// if (dfd) return dfd; | ||
|
||
// set dfd if not defined | ||
dfd = clippy.load._sounds[name] = $.Deferred(); | ||
|
||
var audio = document.createElement('audio'); | ||
var canPlayMp3 = !!audio.canPlayType && "" != audio.canPlayType('audio/mpeg'); | ||
var canPlayOgg = !!audio.canPlayType && "" != audio.canPlayType('audio/ogg; codecs="vorbis"'); | ||
|
||
if (!canPlayMp3 && !canPlayOgg) { | ||
dfd.resolve({}); | ||
} else { | ||
var src = path + (canPlayMp3 ? '/sounds-mp3.js' : '/sounds-ogg.js'); | ||
// load | ||
clippy.load._loadScript(src); | ||
} | ||
// // set dfd if not defined | ||
// dfd = clippy.load._sounds[name] = $.Deferred(); | ||
|
||
// var audio = document.createElement('audio'); | ||
// var canPlayMp3 = !!audio.canPlayType && "" != audio.canPlayType('audio/mpeg'); | ||
// var canPlayOgg = !!audio.canPlayType && "" != audio.canPlayType('audio/ogg; codecs="vorbis"'); | ||
|
||
// if (!canPlayMp3 && !canPlayOgg) { | ||
// dfd.resolve({}); | ||
// } else { | ||
// var src = path + (canPlayMp3 ? '/sounds-mp3.js' : '/sounds-ogg.js'); | ||
// // load | ||
// clippy.load._loadScript(src); | ||
// } | ||
|
||
return dfd.promise() | ||
// return dfd.promise() | ||
}; | ||
|
||
|
||
|
@@ -955,12 +969,11 @@ clippy.ready = function (name, data) { | |
}; | ||
|
||
clippy.soundsReady = function (name, data) { | ||
var dfd = clippy.load._sounds[name]; | ||
if (!dfd) { | ||
dfd = clippy.load._sounds[name] = $.Deferred(); | ||
} | ||
|
||
dfd.resolve(data); | ||
// var dfd = clippy.load._sounds[name]; | ||
// if (!dfd) { | ||
// dfd = clippy.load._sounds[name] = $.Deferred(); | ||
// } | ||
// dfd.resolve(data); | ||
}; | ||
|
||
/****** | ||
|
@@ -1013,3 +1026,5 @@ clippy.Queue.prototype = { | |
} | ||
}; | ||
|
||
window.clippy = clippy; | ||
})(window.jQueryNew) |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?? very hacky