Merge pull request #15 from Ventero/imageload

Pass the correct object to image load callbacks.
This commit is contained in:
iangilman 2013-01-28 10:21:36 -08:00
commit d23851d5e5
2 changed files with 16 additions and 16 deletions

View File

@ -8181,9 +8181,9 @@ $.Drawer.prototype = {
* @method * @method
* @param {String} src - The url of the image to load. * @param {String} src - The url of the image to load.
* @param {Function} callback - The function that will be called with the * @param {Function} callback - The function that will be called with the
* Image object as the only parameter, whether on 'load' or on 'abort'. * Image object as the only parameter if it was loaded successfully.
* For now this means the callback is expected to distinguish between * If an error occured, or the request timed out or was aborted,
* error and success conditions by inspecting the Image object. * the parameter is null instead.
* @return {Boolean} loading - Wheter the request was submitted or ignored * @return {Boolean} loading - Wheter the request was submitted or ignored
* based on OpenSeadragon.DEFAULT_SETTINGS.imageLoaderLimit. * based on OpenSeadragon.DEFAULT_SETTINGS.imageLoaderLimit.
*/ */
@ -8201,11 +8201,11 @@ $.Drawer.prototype = {
image = new Image(); image = new Image();
complete = function( imagesrc ){ complete = function( imagesrc, resultingImage ){
_this.downloading--; _this.downloading--;
if (typeof ( callback ) == "function") { if (typeof ( callback ) == "function") {
try { try {
callback( image ); callback( resultingImage );
} catch ( e ) { } catch ( e ) {
$.console.error( $.console.error(
"%s while executing %s callback: %s", "%s while executing %s callback: %s",
@ -8219,11 +8219,11 @@ $.Drawer.prototype = {
}; };
image.onload = function(){ image.onload = function(){
finishLoadingImage( image, complete, true ); finishLoadingImage( image, complete, true, jobid );
}; };
image.onabort = image.onerror = function(){ image.onabort = image.onerror = function(){
finishLoadingImage( image, complete, false ); finishLoadingImage( image, complete, false, jobid );
}; };
jobid = window.setTimeout( function(){ jobid = window.setTimeout( function(){

View File

@ -275,9 +275,9 @@ $.Drawer.prototype = {
* @method * @method
* @param {String} src - The url of the image to load. * @param {String} src - The url of the image to load.
* @param {Function} callback - The function that will be called with the * @param {Function} callback - The function that will be called with the
* Image object as the only parameter, whether on 'load' or on 'abort'. * Image object as the only parameter if it was loaded successfully.
* For now this means the callback is expected to distinguish between * If an error occured, or the request timed out or was aborted,
* error and success conditions by inspecting the Image object. * the parameter is null instead.
* @return {Boolean} loading - Wheter the request was submitted or ignored * @return {Boolean} loading - Wheter the request was submitted or ignored
* based on OpenSeadragon.DEFAULT_SETTINGS.imageLoaderLimit. * based on OpenSeadragon.DEFAULT_SETTINGS.imageLoaderLimit.
*/ */
@ -295,11 +295,11 @@ $.Drawer.prototype = {
image = new Image(); image = new Image();
complete = function( imagesrc ){ complete = function( imagesrc, resultingImage ){
_this.downloading--; _this.downloading--;
if (typeof ( callback ) == "function") { if (typeof ( callback ) == "function") {
try { try {
callback( image ); callback( resultingImage );
} catch ( e ) { } catch ( e ) {
$.console.error( $.console.error(
"%s while executing %s callback: %s", "%s while executing %s callback: %s",
@ -313,11 +313,11 @@ $.Drawer.prototype = {
}; };
image.onload = function(){ image.onload = function(){
finishLoadingImage( image, complete, true ); finishLoadingImage( image, complete, true, jobid );
}; };
image.onabort = image.onerror = function(){ image.onabort = image.onerror = function(){
finishLoadingImage( image, complete, false ); finishLoadingImage( image, complete, false, jobid );
}; };
jobid = window.setTimeout( function(){ jobid = window.setTimeout( function(){