diff options
| author | Julie Lala <jules@okfoc.us> | 2015-04-09 06:02:55 -0400 |
|---|---|---|
| committer | Julie Lala <jules@okfoc.us> | 2015-04-09 06:02:55 -0400 |
| commit | 36da66908e8b124c4846a82ad4ccc2d1749e0b15 (patch) | |
| tree | 0b46b2b9e18f1155d0474cafa23d76c2b8046df6 /site/public/javascripts/vendor/loader.js | |
| parent | c65de768ccd5111567732854ca4ce50dbeebd6ea (diff) | |
moving assets
Diffstat (limited to 'site/public/javascripts/vendor/loader.js')
| -rw-r--r-- | site/public/javascripts/vendor/loader.js | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/site/public/javascripts/vendor/loader.js b/site/public/javascripts/vendor/loader.js deleted file mode 100644 index 4c1c8cd..0000000 --- a/site/public/javascripts/vendor/loader.js +++ /dev/null @@ -1,68 +0,0 @@ -var Loader = Loader || (function(){ - function Loader (readyCallback){ - this.assets = {}; - this.images = []; - this.readyCallback = readyCallback; - } - - // Register an asset as loading - Loader.prototype.register = function(s){ - this.assets[s] = false; - } - - // Signal that an asset has loaded - Loader.prototype.ready = function(s){ - window.debug && console.log("ready >> " + s); - - this.assets[s] = true; - if (this.loaded) return; - if (! this.isReady()) return; - - this.loaded = true; - this.readyCallback && this.readyCallback(); - } - - // (boolean) Is the loader ready? - Loader.prototype.isReady = function(){ - for (var s in this.assets) { - if (this.assets.hasOwnProperty(s) && this.assets[s] != true) { - return false; - } - } - return true; - } - - // (int) Number of assets remaining - Loader.prototype.remainingAssets = function(){ - var n = 0; - for (var s in this.assets) { - if (this.assets.hasOwnProperty(s) && this.assets[s] != true) { - n++; - console.log('remaining: ' + s); - } - } - return n; - } - - // Preload the images in config.images - Loader.prototype.preloadImages = function(images){ - this.register("preload"); - for (var i = 0; i < images.length; i++) { - this.preloadImage(images[i]); - } - this.ready("preload"); - } - Loader.prototype.preloadImage = function(src){ - var _this = this; - this.register(src); - var img = new Image(); - img.onload = function(){ - _this.ready(src); - } - img.src = src; - if (img.complete) img.onload(); - _this.images.push(img); - } - - return Loader; -})(); |
