From de14271399269cd6c6b4c78a106f771a76485ef3 Mon Sep 17 00:00:00 2001 From: thatcher Date: Tue, 13 Dec 2011 18:51:35 -0500 Subject: [PATCH] removed psuedo-privacy anti-patterns from imageloader.js in favor of simple pinning and public properties. --- openseadragon.js | 34 +++++++++++++++++----------------- src/imageloader.js | 34 +++++++++++++++++----------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index a38ef5e1..5906c54c 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -2472,32 +2472,32 @@ $.Job.prototype = { (function( $ ){ -$.ImageLoader = function(imageLoaderLimit) { - this._downloading = 0; +$.ImageLoader = function( imageLoaderLimit ) { + this.downloading = 0; this.imageLoaderLimit = imageLoaderLimit; }; $.ImageLoader.prototype = { - _onComplete: function(callback, src, image) { - this._downloading--; - if (typeof (callback) == "function") { - try { - callback(image); - } catch (e) { - $.Debug.error(e.name + " while executing " + src + - " callback: " + e.message, e); - } - } - }, loadImage: function(src, callback) { - if (this._downloading >= this.imageLoaderLimit) { + var _this = this; + if (this.downloading >= this.imageLoaderLimit) { return false; } - var func = $.Utils.createCallback(null, $.delegate(this, this._onComplete), callback); - var job = new $.Job(src, func); + var job = new $.Job(src, function(src, image){ + + _this.downloading--; + if (typeof (callback) == "function") { + try { + callback(image); + } catch (e) { + $.Debug.error(e.name + " while executing " + src + + " callback: " + e.message, e); + } + } + }); - this._downloading++; + this.downloading++; job.start(); return true; diff --git a/src/imageloader.js b/src/imageloader.js index 82efd531..a1f1260c 100644 --- a/src/imageloader.js +++ b/src/imageloader.js @@ -1,32 +1,32 @@ (function( $ ){ -$.ImageLoader = function(imageLoaderLimit) { - this._downloading = 0; +$.ImageLoader = function( imageLoaderLimit ) { + this.downloading = 0; this.imageLoaderLimit = imageLoaderLimit; }; $.ImageLoader.prototype = { - _onComplete: function(callback, src, image) { - this._downloading--; - if (typeof (callback) == "function") { - try { - callback(image); - } catch (e) { - $.Debug.error(e.name + " while executing " + src + - " callback: " + e.message, e); - } - } - }, loadImage: function(src, callback) { - if (this._downloading >= this.imageLoaderLimit) { + var _this = this; + if (this.downloading >= this.imageLoaderLimit) { return false; } - var func = $.Utils.createCallback(null, $.delegate(this, this._onComplete), callback); - var job = new $.Job(src, func); + var job = new $.Job(src, function(src, image){ + + _this.downloading--; + if (typeof (callback) == "function") { + try { + callback(image); + } catch (e) { + $.Debug.error(e.name + " while executing " + src + + " callback: " + e.message, e); + } + } + }); - this._downloading++; + this.downloading++; job.start(); return true;