-
Notifications
You must be signed in to change notification settings - Fork 3
/
Preloader.js
47 lines (43 loc) · 1.55 KB
/
Preloader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/***************************/
//@Author: Ryan Corradini
//@website: www.buyog.com
//@email: ryancorradini@yahoo.com
//@license: Free to use & modify, but please keep this credits message
/***************************/
dojo.provide("loc.Preloader");
dojo.require("loc.ImageCache");
dojo.addOnLoad(function() {
if (!window.imageCache) { window.imageCache = new loc.ImageCache(); }
});
dojo.declare("loc.Preloader", null, {
images: {},
modules: [],
_isReady: false,
constructor: function preloader_constructor(args){
dojo.mixin(this, args);
for (var i in this.images) {
// treat item as a key:value pair
window.imageCache.addImage( i, this.images[i] );
}
for (i in this.modules) {
// load each requested item and then register an OnLoad handler to be notified when they're all done
dojo.require(this.modules[i]);
}
dojo.addOnLoad(function() {
if (window.imageCache.ready()) {
dojo.publish("loc.Preloader.onReady",[]);
} else {
this.listener = dojo.subscribe("loc.ImageCache.onReady", function() {
console.log("(preloader):: all images are now loaded and ready.");
dojo.unsubscribe(this.listener);
delete this.listener;
this._isReady = true;
dojo.publish("loc.Preloader.onReady",[]);
});
}
});
},
ready: function preloader_ready() {
return this._isReady;
}
});