removed psuedo-privacy anti-patterns from imageloader.js in favor of simple pinning and public properties.

This commit is contained in:
thatcher 2011-12-13 18:51:35 -05:00
parent c7706ba66c
commit de14271399
2 changed files with 34 additions and 34 deletions

View File

@ -2472,32 +2472,32 @@ $.Job.prototype = {
(function( $ ){ (function( $ ){
$.ImageLoader = function(imageLoaderLimit) { $.ImageLoader = function( imageLoaderLimit ) {
this._downloading = 0; this.downloading = 0;
this.imageLoaderLimit = imageLoaderLimit; this.imageLoaderLimit = imageLoaderLimit;
}; };
$.ImageLoader.prototype = { $.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) { loadImage: function(src, callback) {
if (this._downloading >= this.imageLoaderLimit) { var _this = this;
if (this.downloading >= this.imageLoaderLimit) {
return false; return false;
} }
var func = $.Utils.createCallback(null, $.delegate(this, this._onComplete), callback); var job = new $.Job(src, function(src, image){
var job = new $.Job(src, func);
_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(); job.start();
return true; return true;

View File

@ -1,32 +1,32 @@
(function( $ ){ (function( $ ){
$.ImageLoader = function(imageLoaderLimit) { $.ImageLoader = function( imageLoaderLimit ) {
this._downloading = 0; this.downloading = 0;
this.imageLoaderLimit = imageLoaderLimit; this.imageLoaderLimit = imageLoaderLimit;
}; };
$.ImageLoader.prototype = { $.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) { loadImage: function(src, callback) {
if (this._downloading >= this.imageLoaderLimit) { var _this = this;
if (this.downloading >= this.imageLoaderLimit) {
return false; return false;
} }
var func = $.Utils.createCallback(null, $.delegate(this, this._onComplete), callback); var job = new $.Job(src, function(src, image){
var job = new $.Job(src, func);
_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(); job.start();
return true; return true;