From 76a16464a29b6aac43b2de79fc4a14e554c9f31f Mon Sep 17 00:00:00 2001 From: Ventero Date: Fri, 28 Sep 2012 20:02:22 +0200 Subject: [PATCH 01/11] Allow overriding the default navImages prefix url. --- openseadragon.js | 52 ++++++++++++++++++++++---------------------- src/openseadragon.js | 52 ++++++++++++++++++++++---------------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index b002a24f..3598b65e 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -222,7 +222,7 @@ * position. If preserveViewport is set to true, then the viewport position * is preserved when navigating between images in the sequence. * - * @param {String} [options.prefixUrl=''] + * @param {String} [options.prefixUrl='/images/'] * Appends the prefixUrl to navImages paths, which is very useful * since the default paths are rarely useful for production * environments. @@ -522,43 +522,43 @@ OpenSeadragon = window.OpenSeadragon || function( options ){ maxZoomPixelRatio: 2, //INTERFACE RESOURCE SETTINGS - prefixUrl: null, + prefixUrl: "/images/", navImages: { zoomIn: { - REST: '/images/zoomin_rest.png', - GROUP: '/images/zoomin_grouphover.png', - HOVER: '/images/zoomin_hover.png', - DOWN: '/images/zoomin_pressed.png' + REST: 'zoomin_rest.png', + GROUP: 'zoomin_grouphover.png', + HOVER: 'zoomin_hover.png', + DOWN: 'zoomin_pressed.png' }, zoomOut: { - REST: '/images/zoomout_rest.png', - GROUP: '/images/zoomout_grouphover.png', - HOVER: '/images/zoomout_hover.png', - DOWN: '/images/zoomout_pressed.png' + REST: 'zoomout_rest.png', + GROUP: 'zoomout_grouphover.png', + HOVER: 'zoomout_hover.png', + DOWN: 'zoomout_pressed.png' }, home: { - REST: '/images/home_rest.png', - GROUP: '/images/home_grouphover.png', - HOVER: '/images/home_hover.png', - DOWN: '/images/home_pressed.png' + REST: 'home_rest.png', + GROUP: 'home_grouphover.png', + HOVER: 'home_hover.png', + DOWN: 'home_pressed.png' }, fullpage: { - REST: '/images/fullpage_rest.png', - GROUP: '/images/fullpage_grouphover.png', - HOVER: '/images/fullpage_hover.png', - DOWN: '/images/fullpage_pressed.png' + REST: 'fullpage_rest.png', + GROUP: 'fullpage_grouphover.png', + HOVER: 'fullpage_hover.png', + DOWN: 'fullpage_pressed.png' }, previous: { - REST: '/images/previous_rest.png', - GROUP: '/images/previous_grouphover.png', - HOVER: '/images/previous_hover.png', - DOWN: '/images/previous_pressed.png' + REST: 'previous_rest.png', + GROUP: 'previous_grouphover.png', + HOVER: 'previous_hover.png', + DOWN: 'previous_pressed.png' }, next: { - REST: '/images/next_rest.png', - GROUP: '/images/next_grouphover.png', - HOVER: '/images/next_hover.png', - DOWN: '/images/next_pressed.png' + REST: 'next_rest.png', + GROUP: 'next_grouphover.png', + HOVER: 'next_hover.png', + DOWN: 'next_pressed.png' } } }, diff --git a/src/openseadragon.js b/src/openseadragon.js index b32412f0..05ea3c62 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -222,7 +222,7 @@ * position. If preserveViewport is set to true, then the viewport position * is preserved when navigating between images in the sequence. * - * @param {String} [options.prefixUrl=''] + * @param {String} [options.prefixUrl='/images/'] * Appends the prefixUrl to navImages paths, which is very useful * since the default paths are rarely useful for production * environments. @@ -522,43 +522,43 @@ OpenSeadragon = window.OpenSeadragon || function( options ){ maxZoomPixelRatio: 2, //INTERFACE RESOURCE SETTINGS - prefixUrl: null, + prefixUrl: "/images/", navImages: { zoomIn: { - REST: '/images/zoomin_rest.png', - GROUP: '/images/zoomin_grouphover.png', - HOVER: '/images/zoomin_hover.png', - DOWN: '/images/zoomin_pressed.png' + REST: 'zoomin_rest.png', + GROUP: 'zoomin_grouphover.png', + HOVER: 'zoomin_hover.png', + DOWN: 'zoomin_pressed.png' }, zoomOut: { - REST: '/images/zoomout_rest.png', - GROUP: '/images/zoomout_grouphover.png', - HOVER: '/images/zoomout_hover.png', - DOWN: '/images/zoomout_pressed.png' + REST: 'zoomout_rest.png', + GROUP: 'zoomout_grouphover.png', + HOVER: 'zoomout_hover.png', + DOWN: 'zoomout_pressed.png' }, home: { - REST: '/images/home_rest.png', - GROUP: '/images/home_grouphover.png', - HOVER: '/images/home_hover.png', - DOWN: '/images/home_pressed.png' + REST: 'home_rest.png', + GROUP: 'home_grouphover.png', + HOVER: 'home_hover.png', + DOWN: 'home_pressed.png' }, fullpage: { - REST: '/images/fullpage_rest.png', - GROUP: '/images/fullpage_grouphover.png', - HOVER: '/images/fullpage_hover.png', - DOWN: '/images/fullpage_pressed.png' + REST: 'fullpage_rest.png', + GROUP: 'fullpage_grouphover.png', + HOVER: 'fullpage_hover.png', + DOWN: 'fullpage_pressed.png' }, previous: { - REST: '/images/previous_rest.png', - GROUP: '/images/previous_grouphover.png', - HOVER: '/images/previous_hover.png', - DOWN: '/images/previous_pressed.png' + REST: 'previous_rest.png', + GROUP: 'previous_grouphover.png', + HOVER: 'previous_hover.png', + DOWN: 'previous_pressed.png' }, next: { - REST: '/images/next_rest.png', - GROUP: '/images/next_grouphover.png', - HOVER: '/images/next_hover.png', - DOWN: '/images/next_pressed.png' + REST: 'next_rest.png', + GROUP: 'next_grouphover.png', + HOVER: 'next_hover.png', + DOWN: 'next_pressed.png' } } }, From 0aba38c88cc3f09a133ddfd74e4e369c44291297 Mon Sep 17 00:00:00 2001 From: Ventero Date: Fri, 28 Sep 2012 20:03:45 +0200 Subject: [PATCH 02/11] Fix a typo in the documentation for options.prefixUrl. --- openseadragon.js | 2 +- src/openseadragon.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index 3598b65e..8048fe6e 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -223,7 +223,7 @@ * is preserved when navigating between images in the sequence. * * @param {String} [options.prefixUrl='/images/'] - * Appends the prefixUrl to navImages paths, which is very useful + * Prepends the prefixUrl to navImages paths, which is very useful * since the default paths are rarely useful for production * environments. * diff --git a/src/openseadragon.js b/src/openseadragon.js index 05ea3c62..cb72319a 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -223,7 +223,7 @@ * is preserved when navigating between images in the sequence. * * @param {String} [options.prefixUrl='/images/'] - * Appends the prefixUrl to navImages paths, which is very useful + * Prepends the prefixUrl to navImages paths, which is very useful * since the default paths are rarely useful for production * environments. * From 5c74c7b415f3077528290a4a35b660db932072a6 Mon Sep 17 00:00:00 2001 From: Ventero Date: Sat, 29 Sep 2012 12:29:43 +0200 Subject: [PATCH 03/11] Always clear the image load timeout job. --- openseadragon.js | 4 ++-- src/drawer.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index b002a24f..7a89136d 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -7995,11 +7995,11 @@ $.Drawer.prototype = { }; image.onload = function(){ - finishLoadingImage( image, complete, true ); + finishLoadingImage( image, complete, true, jobid ); }; image.onabort = image.onerror = function(){ - finishLoadingImage( image, complete, false ); + finishLoadingImage( image, complete, false, jobid ); }; jobid = window.setTimeout( function(){ diff --git a/src/drawer.js b/src/drawer.js index 1cc5082a..c64ae86d 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -311,11 +311,11 @@ $.Drawer.prototype = { }; image.onload = function(){ - finishLoadingImage( image, complete, true ); + finishLoadingImage( image, complete, true, jobid ); }; image.onabort = image.onerror = function(){ - finishLoadingImage( image, complete, false ); + finishLoadingImage( image, complete, false, jobid ); }; jobid = window.setTimeout( function(){ From bb0ac1f9d1e8401b19900973ea001d2d7cc0dacc Mon Sep 17 00:00:00 2001 From: Ventero Date: Sat, 29 Sep 2012 12:14:27 +0200 Subject: [PATCH 04/11] Pass the correct object to image load callbacks. Previously, the image object was passed on to onTileLoad regardless if it loaded successfully or not. In case an image failed to load, this would result in trying to draw a non-existing image onto the canvas, which (at least in Firefox) throws a DOM exception and results in the drawer being stuck mid-update. --- openseadragon.js | 4 ++-- src/drawer.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index 7a89136d..8a792d54 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -7977,11 +7977,11 @@ $.Drawer.prototype = { image = new Image(); - complete = function( imagesrc ){ + complete = function( imagesrc, img ){ _this.downloading--; if (typeof ( callback ) == "function") { try { - callback( image ); + callback( img ); } catch ( e ) { $.console.error( "%s while executing %s callback: %s", diff --git a/src/drawer.js b/src/drawer.js index c64ae86d..d04c287e 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -293,11 +293,11 @@ $.Drawer.prototype = { image = new Image(); - complete = function( imagesrc ){ + complete = function( imagesrc, img ){ _this.downloading--; if (typeof ( callback ) == "function") { try { - callback( image ); + callback( img ); } catch ( e ) { $.console.error( "%s while executing %s callback: %s", From 31716bf56d2082b6deeb33fe19dc4a4abb84d017 Mon Sep 17 00:00:00 2001 From: Ventero Date: Sat, 29 Sep 2012 14:18:32 +0200 Subject: [PATCH 05/11] Use correct option name (displayRects, not dispRects) in DziTileSource. --- openseadragon.js | 8 ++++---- src/dzitilesource.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index b002a24f..7b0efbf6 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -5604,7 +5604,7 @@ $.DziTileSource = function( width, height, tileSize, tileOverlap, tilesUrl, file tileOverlap: arguments[ 3 ], tilesUrl: arguments[ 4 ], fileFormat: arguments[ 5 ], - dispRects: arguments[ 6 ] + displayRects: arguments[ 6 ] }; } @@ -5856,7 +5856,7 @@ function configureFromObject( tileSource, configuration ){ height = parseInt( sizeData.Height ), tileSize = parseInt( imageData.TileSize ), tileOverlap = parseInt( imageData.Overlap ), - dispRects = [], + displayRects = [], rectData, i; @@ -5876,7 +5876,7 @@ function configureFromObject( tileSource, configuration ){ for ( i = 0; i < dispRectData.length; i++ ) { rectData = dispRectData[ i ].Rect; - dispRects.push( new $.DisplayRect( + displayRects.push( new $.DisplayRect( parseInt( rectData.X ), parseInt( rectData.Y ), parseInt( rectData.Width ), @@ -5896,7 +5896,7 @@ function configureFromObject( tileSource, configuration ){ maxLevel: null, /* maxLevel */ tilesUrl: tilesUrl, /* tilesUrl */ fileFormat: fileFormat, /* fileFormat */ - dispRects: dispRects /* dispRects */ + displayRects: displayRects /* displayRects */ }; }; diff --git a/src/dzitilesource.js b/src/dzitilesource.js index b6f8db63..cfdfe436 100644 --- a/src/dzitilesource.js +++ b/src/dzitilesource.js @@ -32,7 +32,7 @@ $.DziTileSource = function( width, height, tileSize, tileOverlap, tilesUrl, file tileOverlap: arguments[ 3 ], tilesUrl: arguments[ 4 ], fileFormat: arguments[ 5 ], - dispRects: arguments[ 6 ] + displayRects: arguments[ 6 ] }; } @@ -284,7 +284,7 @@ function configureFromObject( tileSource, configuration ){ height = parseInt( sizeData.Height ), tileSize = parseInt( imageData.TileSize ), tileOverlap = parseInt( imageData.Overlap ), - dispRects = [], + displayRects = [], rectData, i; @@ -304,7 +304,7 @@ function configureFromObject( tileSource, configuration ){ for ( i = 0; i < dispRectData.length; i++ ) { rectData = dispRectData[ i ].Rect; - dispRects.push( new $.DisplayRect( + displayRects.push( new $.DisplayRect( parseInt( rectData.X ), parseInt( rectData.Y ), parseInt( rectData.Width ), @@ -324,7 +324,7 @@ function configureFromObject( tileSource, configuration ){ maxLevel: null, /* maxLevel */ tilesUrl: tilesUrl, /* tilesUrl */ fileFormat: fileFormat, /* fileFormat */ - dispRects: dispRects /* dispRects */ + displayRects: displayRects /* displayRects */ }; }; From 9620272ebb571064527a55b5b04b93b0baa16e9c Mon Sep 17 00:00:00 2001 From: Ventero Date: Fri, 25 Jan 2013 14:17:35 +0100 Subject: [PATCH 06/11] Make sure navigator has non-negative width/height Older versions of IE throw if we try to assign a negative width/height. Fixes #24. --- src/navigator.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index 93729e0b..2fdde096 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -209,8 +209,11 @@ $.extend( $.Navigator.prototype, $.EventHandler.prototype, $.Viewer.prototype, { style.top = topleft.y + 'px'; style.left = topleft.x + 'px'; - style.width = ( Math.abs( topleft.x - bottomright.x ) - 3 ) + 'px'; - style.height = ( Math.abs( topleft.y - bottomright.y ) - 3 ) + 'px'; + var width = Math.abs( topleft.x - bottomright.x ) - 3; + var height = Math.abs( topleft.y - bottomright.y ) - 3; + // make sure width and height are non-negative so IE doesn't throw + style.width = Math.max( width, 0 ) + 'px'; + style.height = Math.max( height, 0 ) + 'px'; }( this.displayRegion.style )); } @@ -285,4 +288,4 @@ function onCanvasScroll( tracker, position, scroll, shift ) { }; -}( OpenSeadragon )); \ No newline at end of file +}( OpenSeadragon )); From 9b6de523c716a77ef43b98503ef8dd2f89ecadde Mon Sep 17 00:00:00 2001 From: Ventero Date: Fri, 25 Jan 2013 19:53:06 +0100 Subject: [PATCH 07/11] Add TODO comment about magic number --- src/navigator.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/navigator.js b/src/navigator.js index 2fdde096..20d77882 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -209,6 +209,7 @@ $.extend( $.Navigator.prototype, $.EventHandler.prototype, $.Viewer.prototype, { style.top = topleft.y + 'px'; style.left = topleft.x + 'px'; + // TODO: What's this magic number mean? var width = Math.abs( topleft.x - bottomright.x ) - 3; var height = Math.abs( topleft.y - bottomright.y ) - 3; // make sure width and height are non-negative so IE doesn't throw From 8f085c83ca6be8b54bb2db66023450fc8020c3c2 Mon Sep 17 00:00:00 2001 From: Ventero Date: Fri, 25 Jan 2013 20:36:41 +0100 Subject: [PATCH 08/11] Update documentation for Drawer#loadImage. Additionally, improve name of the parameter passed to the complete listener. --- openseadragon.js | 12 ++++++------ src/drawer.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index 8a792d54..7db28fa4 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -7957,10 +7957,10 @@ $.Drawer.prototype = { * @method * @param {String} src - The url of the image to load. * @param {Function} callback - The function that will be called with the - * Image object as the only parameter, whether on 'load' or on 'abort'. - * For now this means the callback is expected to distinguish between - * error and success conditions by inspecting the Image object. - * @return {Boolean} loading - Wheter the request was submitted or ignored + * Image object as the only parameter if it was loaded successfully. + * If an error occured, or the request timed out or was aborted, + * the parameter is null instead. + * @return {Boolean} loading - Wheter the request was submitted or ignored * based on OpenSeadragon.DEFAULT_SETTINGS.imageLoaderLimit. */ loadImage: function( src, callback ) { @@ -7977,11 +7977,11 @@ $.Drawer.prototype = { image = new Image(); - complete = function( imagesrc, img ){ + complete = function( imagesrc, resultingImage ){ _this.downloading--; if (typeof ( callback ) == "function") { try { - callback( img ); + callback( resultingImage ); } catch ( e ) { $.console.error( "%s while executing %s callback: %s", diff --git a/src/drawer.js b/src/drawer.js index d04c287e..6c0fa02e 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -273,10 +273,10 @@ $.Drawer.prototype = { * @method * @param {String} src - The url of the image to load. * @param {Function} callback - The function that will be called with the - * Image object as the only parameter, whether on 'load' or on 'abort'. - * For now this means the callback is expected to distinguish between - * error and success conditions by inspecting the Image object. - * @return {Boolean} loading - Wheter the request was submitted or ignored + * Image object as the only parameter if it was loaded successfully. + * If an error occured, or the request timed out or was aborted, + * the parameter is null instead. + * @return {Boolean} loading - Wheter the request was submitted or ignored * based on OpenSeadragon.DEFAULT_SETTINGS.imageLoaderLimit. */ loadImage: function( src, callback ) { @@ -293,11 +293,11 @@ $.Drawer.prototype = { image = new Image(); - complete = function( imagesrc, img ){ + complete = function( imagesrc, resultingImage ){ _this.downloading--; if (typeof ( callback ) == "function") { try { - callback( img ); + callback( resultingImage ); } catch ( e ) { $.console.error( "%s while executing %s callback: %s", From 5e2443234909bac42d347e19ebb94696af5bd134 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 28 Jan 2013 10:11:14 -0800 Subject: [PATCH 09/11] Comment tweak --- src/navigator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index 20d77882..c038bd3f 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -209,8 +209,8 @@ $.extend( $.Navigator.prototype, $.EventHandler.prototype, $.Viewer.prototype, { style.top = topleft.y + 'px'; style.left = topleft.x + 'px'; - // TODO: What's this magic number mean? - var width = Math.abs( topleft.x - bottomright.x ) - 3; + + var width = Math.abs( topleft.x - bottomright.x ) - 3; // TODO: What's this magic number mean? var height = Math.abs( topleft.y - bottomright.y ) - 3; // make sure width and height are non-negative so IE doesn't throw style.width = Math.max( width, 0 ) + 'px'; From cb6234e37c3cf74ea802ed292bbd52280ab65a04 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 28 Jan 2013 10:11:25 -0800 Subject: [PATCH 10/11] Built latest --- openseadragon.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index 5bccf420..15a4bd2b 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -4914,8 +4914,12 @@ $.extend( $.Navigator.prototype, $.EventHandler.prototype, $.Viewer.prototype, { style.top = topleft.y + 'px'; style.left = topleft.x + 'px'; - style.width = ( Math.abs( topleft.x - bottomright.x ) - 3 ) + 'px'; - style.height = ( Math.abs( topleft.y - bottomright.y ) - 3 ) + 'px'; + + var width = Math.abs( topleft.x - bottomright.x ) - 3; // TODO: What's this magic number mean? + var height = Math.abs( topleft.y - bottomright.y ) - 3; + // make sure width and height are non-negative so IE doesn't throw + style.width = Math.max( width, 0 ) + 'px'; + style.height = Math.max( height, 0 ) + 'px'; }( this.displayRegion.style )); } @@ -4991,6 +4995,7 @@ function onCanvasScroll( tracker, position, scroll, shift ) { }( OpenSeadragon )); + (function( $ ){ //TODO: I guess this is where the i18n needs to be reimplemented. I'll look From 624fbd97b955de9e493d2804b96676f9c6cc61cb Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 28 Jan 2013 10:24:13 -0800 Subject: [PATCH 11/11] Comment typo --- openseadragon.js | 2 +- src/drawer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index 1d80d42c..aeb38e5d 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -8184,7 +8184,7 @@ $.Drawer.prototype = { * Image object as the only parameter if it was loaded successfully. * If an error occured, or the request timed out or was aborted, * the parameter is null instead. - * @return {Boolean} loading - Wheter the request was submitted or ignored + * @return {Boolean} loading - Whether the request was submitted or ignored * based on OpenSeadragon.DEFAULT_SETTINGS.imageLoaderLimit. */ loadImage: function( src, callback ) { diff --git a/src/drawer.js b/src/drawer.js index b974c447..aaefe4d8 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -278,7 +278,7 @@ $.Drawer.prototype = { * Image object as the only parameter if it was loaded successfully. * If an error occured, or the request timed out or was aborted, * the parameter is null instead. - * @return {Boolean} loading - Wheter the request was submitted or ignored + * @return {Boolean} loading - Whether the request was submitted or ignored * based on OpenSeadragon.DEFAULT_SETTINGS.imageLoaderLimit. */ loadImage: function( src, callback ) {