diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-09-02 13:31:36 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-09-02 13:31:36 -0400 |
| commit | de8b6ffa3c686256030df04a6dd56025fe6de8ac (patch) | |
| tree | 6e0f954f151060ccba3441e03409557f674e54c3 /site/public/assets/javascripts/vendor/loader.js | |
| parent | 98bb711e716b4e9770aa7299b43f630fb7262acc (diff) | |
remove 2h site and bump to 0.1.40v0.1.40
Diffstat (limited to 'site/public/assets/javascripts/vendor/loader.js')
| -rw-r--r-- | site/public/assets/javascripts/vendor/loader.js | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/site/public/assets/javascripts/vendor/loader.js b/site/public/assets/javascripts/vendor/loader.js deleted file mode 100644 index b939941..0000000 --- a/site/public/assets/javascripts/vendor/loader.js +++ /dev/null @@ -1,85 +0,0 @@ -var Loader = Loader || (function(){ - function Loader (readyCallback, view){ - this.assets = {}; - this.images = []; - this.readyCallback = readyCallback; - this.count = 0 - this.view = view - this.loaded = false - } - - // Register an asset as loading - Loader.prototype.register = function(s){ - this.assets[s] = false; - this.count += 1 - } - - // 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; - - this.view && this.view.update( this.percentRemaining() ) - - if (! this.isReady()) return; - - this.loaded = true; - if (this.view) { - this.view && this.view.finish(this.readyCallback) - } - else { - 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; - } - - // (float) Percentage of assets remaining - Loader.prototype.percentRemaining = function(){ - return this.remainingAssets() / this.count - } - - // (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; -})(); |
