From eff17208e083a8bab6a71167805c1e9a43dc4467 Mon Sep 17 00:00:00 2001 From: thatcher Date: Thu, 14 Mar 2013 17:38:23 -0400 Subject: [PATCH 01/10] updated package.json for release, unfortunately i forgot to commit it --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 71698851..193b912e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "OpenSeadragon", - "version": "0.9.123", + "version": "0.9.124", "description": "Provides a smooth, zoomable user interface for HTML/Javascript.", "devDependencies": { "grunt": "~0.4.0", From f792af9eb925129ae654c6b55f5cfd53beada3b7 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 25 Mar 2013 09:51:58 -0700 Subject: [PATCH 02/10] Added changelog.txt --- Gruntfile.js | 2 ++ changelog.txt | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 changelog.txt diff --git a/Gruntfile.js b/Gruntfile.js index 6a94d6a3..eef1363b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -149,6 +149,8 @@ module.exports = function(grunt) { grunt.file.recurse("images", function(abspath, rootdir, subdir, filename) { grunt.file.copy(abspath, "build/openseadragon/images/" + (subdir || "") + filename); }); + + grunt.file.copy("changelog.txt", "build/changelog.txt"); }); // ---------- diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 00000000..ccbcc5d6 --- /dev/null +++ b/changelog.txt @@ -0,0 +1,23 @@ +OPENSEADRAGON CHANGELOG +======================= + + +0.9.124: + +* Performance enhancements. + + +0.9.123: + +* Real fullscreen support. + + +0.9.122: + +* Performance enhancements. + + +0.9.121: + +* Touch pan now works on Android. +* Pinch zoom is better on all devices. From 6c4643d4472b0d474a5436fc8f3e904af84f12e4 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 25 Mar 2013 10:02:41 -0700 Subject: [PATCH 03/10] Grunt publish now publishes into the new folder in site-build --- Gruntfile.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index eef1363b..e20b5e7c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -14,6 +14,7 @@ module.exports = function(grunt) { // ---------- var distribution = "build/openseadragon/openseadragon.js", minified = "build/openseadragon/openseadragon.min.js", + releaseRoot = "../site-build/built-openseadragon/", sources = [ "src/openseadragon.js", "src/fullscreen.js", @@ -52,11 +53,7 @@ module.exports = function(grunt) { clean: { build: ["build"], release: { - src: [ - "../site-build/openseadragon", - "../site-build/openseadragon.zip", - "../site-build/openseadragon.tar" - ], + src: [releaseRoot], options: { force: true } @@ -155,10 +152,10 @@ module.exports = function(grunt) { // ---------- // Copy:release task. - // Copies the contents of the build folder into ../site-build. + // Copies the contents of the build folder into the release folder. grunt.registerTask("copy:release", function() { grunt.file.recurse("build", function(abspath, rootdir, subdir, filename) { - var dest = "../site-build/" + var dest = releaseRoot + (subdir ? subdir + "/" : '/') + filename; @@ -185,7 +182,7 @@ module.exports = function(grunt) { // ---------- // Publish task. - // Cleans the built files out of ../site-build and copies newly built ones over. + // Cleans the built files out of the release folder and copies newly built ones over. grunt.registerTask("publish", ["package", "clean:release", "copy:release"]); // ---------- From deb229eb78b79a408d4af27983390f8a6022ff5c Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Mon, 25 Mar 2013 13:42:23 -0400 Subject: [PATCH 04/10] Update qunit version qunit 0.1.1 fails on node v0.10.1 with the new streaming api --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 49bcd9af..34ecb4df 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "grunt-contrib-concat": "~0.1.2", "grunt-contrib-jshint": "~0.1.1", "grunt-contrib-uglify": "~0.1.1", - "grunt-contrib-qunit": "~0.1.1", + "grunt-contrib-qunit": "~0.2.0", "grunt-contrib-connect": "~0.1.2", "grunt-contrib-watch": "~0.2.0", "grunt-contrib-clean": "~0.4.0", From 266f33094c9be0cd77105198341f848b38d6fe38 Mon Sep 17 00:00:00 2001 From: thatcher Date: Tue, 26 Mar 2013 09:02:34 -0400 Subject: [PATCH 05/10] addresses #54, dont use openDZI, use open. openDZI now calls open. all the details of tileHost were already handled in DZITileSource.configure. $.createFromDZI is fully deprecated and will throw an error. --- src/dzitilesource.js | 5 +- src/navigator.js | 2 +- src/openseadragon.js | 95 +--------- src/tilesource.js | 4 +- src/viewer.js | 416 ++++++++++++++++++++++--------------------- 5 files changed, 222 insertions(+), 300 deletions(-) diff --git a/src/dzitilesource.js b/src/dzitilesource.js index 7e37caa7..6a9b0a30 100644 --- a/src/dzitilesource.js +++ b/src/dzitilesource.js @@ -315,8 +315,9 @@ function configureFromObject( tileSource, configuration ){ )); } + delete configuration.Image; - return { + return $.extend(true, { width: width, /* width *required */ height: height, /* height *required */ tileSize: tileSize, /* tileSize *required */ @@ -326,7 +327,7 @@ function configureFromObject( tileSource, configuration ){ tilesUrl: tilesUrl, /* tilesUrl */ fileFormat: fileFormat, /* fileFormat */ displayRects: displayRects /* displayRects */ - }; + }, configuration ); } diff --git a/src/navigator.js b/src/navigator.js index 1a5defdd..d63acef2 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -242,7 +242,7 @@ $.extend( $.Navigator.prototype, $.EventHandler.prototype, $.Viewer.prototype, { containerSize.y ) / source.tileSize; } else { - this.minPixelRatio = thie.viewer.minPixelRatio; + this.minPixelRatio = this.viewer.minPixelRatio; } return $.Viewer.prototype.open.apply( this, [ source ] ); } diff --git a/src/openseadragon.js b/src/openseadragon.js index d5ab3231..3b6528f2 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -1392,101 +1392,10 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ * @param {String} xmlUrl * @param {String} xmlString * @param {Function} callback - * @deprecated + * @deprecated - use Viewer.openTileSource */ createFromDZI: function( dzi, callback, tileHost ) { - var async = typeof ( callback ) == "function", - dziUrl = ( - dzi.substring(0,1) != '<' && - dzi.substring(0,1) != '{' - ) ? dzi : null, - dziString = dziUrl ? null : dzi, - error = null, - urlParts, - filename, - lastDot, - tilesUrl, - callbackName; - - - if( tileHost ){ - - tilesUrl = tileHost + "/_files/"; - - } else if( dziUrl ) { - - urlParts = dziUrl.split( '/' ); - filename = urlParts[ urlParts.length - 1 ]; - if( filename.match(/_dzi\.js$/) ){ - //for jsonp dzi specification, the '_dzi' needs to be removed - //from the filename to be consistent with the spec - filename = filename.replace('_dzi.js', '.js'); - } - - lastDot = filename.lastIndexOf( '.' ); - - if ( lastDot > -1 ) { - urlParts[ urlParts.length - 1 ] = filename.slice( 0, lastDot ); - } - - - tilesUrl = urlParts.join( '/' ) + "_files/"; - - } - - function finish( func, obj ) { - try { - return func( obj, tilesUrl ); - } catch ( e ) { - if ( async ) { - return null; - } else { - throw e; - } - } - } - - if ( async ) { - if ( dziString ) { - window.setTimeout( function() { - var source = finish( processDZIXml, $.parseXml( xmlString ) ); - // call after finish sets error - callback( source, error ); - }, 1); - } else { - if( dziUrl.match(/_dzi\.js$/) ){ - callbackName = dziUrl.split( '/' ).pop().replace('.js',''); - $.jsonp({ - url: dziUrl, - callbackName: callbackName, - callback: function( imageData ){ - var source = finish( processDZIJSON, imageData.Image ); - callback( source ); - } - }); - } else { - $.makeAjaxRequest( dziUrl, function( xhr ) { - var source = finish( processDZIResponse, xhr ); - // call after finish sets error - callback( source, error ); - }); - } - } - - return null; - } - - if ( dziString ) { - return finish( - processDZIXml, - $.parseXml( dziString ) - ); - } else { - return finish( - processDZIResponse, - $.makeAjaxRequest( dziUrl ) - ); - } + throw "OpenSeadragon.createFromDZI is deprecated, use Viewer.openTileSource."; }, /** diff --git a/src/tilesource.js b/src/tilesource.js index 11cc499a..e8e44173 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -281,9 +281,7 @@ $.TileSource.prototype = { callback: callback }); } else { - //TODO: struggling a little with TileSource rewrite to make info - // requests work asyncronously. For now I'm opting to make - // all xhr info request syncronous. + // request info via xhr asyncronously. $.makeAjaxRequest( url, function( xhr ) { var data = processResponse( xhr ); callback( data ); diff --git a/src/viewer.js b/src/viewer.js index cc431d83..a48a5af4 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -129,6 +129,7 @@ $.Viewer = function( options ) { // did we decide this viewer has a sequence of tile sources "sequenced": false, "sequence": 0, + "fullPage": false, "onfullscreenchange": null }; @@ -163,7 +164,7 @@ $.Viewer = function( options ) { initialTileSource = this.tileSources; } - this.openTileSource( initialTileSource ); + this.open( initialTileSource ); } this.element = this.element || document.getElementById( this.id ); @@ -254,29 +255,36 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, }, /** - * If the string is xml is simply parsed and opened, otherwise the string - * is treated as an URL and an xml document is requested via ajax, parsed - * and then opened in the viewer. + * A deprecated function, renamed to 'open' to match event name and + * match current 'close' method. * @function * @name OpenSeadragon.Viewer.prototype.openDzi - * @param {String} dzi and xml string or the url to a DZI xml document. + * @param {String} dzi xml string or the url to a DZI xml document. * @return {OpenSeadragon.Viewer} Chainable. * * @deprecated - use 'open' instead. */ openDzi: function ( dzi ) { - var _this = this; - $.createFromDZI( - dzi, - function( source ){ - _this.open( source ); - }, - this.tileHost - ); - return this; + return this.open( dzi ); }, /** + * A deprecated function, renamed to 'open' to match event name and + * match current 'close' method. + * @function + * @name OpenSeadragon.Viewer.prototype.openTileSource + * @param {String|Object|Function} See OpenSeadragon.Viewer.prototype.open + * @return {OpenSeadragon.Viewer} Chainable. + * + * @deprecated - use 'open' instead. + */ + openTileSource: function ( tileSource ) { + return this.open( tileSource ); + }, + + /** + * Open a TileSource object into the viewer. + * * tileSources is a complex option... * * It can be a string, object, function, or an array of any of these: @@ -291,9 +299,10 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, * named 'getTileUrl', it is treated as a custom TileSource. * @function * @name OpenSeadragon.Viewer.prototype.openTileSource + * @param {String|Object|Function} * @return {OpenSeadragon.Viewer} Chainable. */ - openTileSource: function ( tileSource ) { + open: function ( tileSource ) { var _this = this, customTileSource, readySource, @@ -308,7 +317,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, //if its better to use file extension or url pattern, or to //inspect the resulting info object. tileSource = new $.TileSource( tileSource, function( readySource ){ - _this.open( readySource ); + openTileSource( _this, readySource ); }); } else if ( $.isPlainObject( tileSource ) ){ @@ -316,202 +325,24 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, //Custom tile source customTileSource = new $.TileSource(tileSource); customTileSource.getTileUrl = tileSource.getTileUrl; - _this.open( customTileSource ); + openTileSource( _this, customTileSource ); } else { //inline configuration $TileSource = $.TileSource.determineType( _this, tileSource ); options = $TileSource.prototype.configure.apply( _this, [ tileSource ]); readySource = new $TileSource( options ); - _this.open( readySource ); + openTileSource( _this, readySource ); } } else { //can assume it's already a tile source implementation - _this.open( tileSource ); + openTileSource( _this, tileSource ); } }, 1); return this; }, - /** - * @function - * @name OpenSeadragon.Viewer.prototype.open - * @return {OpenSeadragon.Viewer} Chainable. - */ - open: function( source ) { - var _this = this, - overlay, - i; - - if ( this.source ) { - this.close( ); - } - - // to ignore earlier opens - THIS[ this.hash ].lastOpenStartTime = +new Date(); - - window.setTimeout( function () { - if ( THIS[ _this.hash ].lastOpenStartTime > THIS[ _this.hash ].lastOpenEndTime ) { - THIS[ _this.hash ].setMessage( $.getString( "Messages.Loading" ) ); - } - }, 2000); - - THIS[ this.hash ].lastOpenEndTime = +new Date(); - this.canvas.innerHTML = ""; - THIS[ this.hash ].prevContainerSize = $.getElementSize( this.container ); - - - if( this.collectionMode ){ - this.source = new $.TileSourceCollection({ - rows: this.collectionRows, - layout: this.collectionLayout, - tileSize: this.collectionTileSize, - tileSources: this.tileSources, - tileMargin: this.collectionTileMargin - }); - this.viewport = this.viewport ? this.viewport : new $.Viewport({ - collectionMode: true, - collectionTileSource: this.source, - containerSize: THIS[ this.hash ].prevContainerSize, - contentSize: this.source.dimensions, - springStiffness: this.springStiffness, - animationTime: this.animationTime, - showNavigator: false, - minZoomImageRatio: 1, - maxZoomPixelRatio: 1, - viewer: this //, - //TODO: figure out how to support these in a way that makes sense - //minZoomLevel: this.minZoomLevel, - //maxZoomLevel: this.maxZoomLevel - }); - }else{ - if( source ){ - this.source = source; - } - this.viewport = this.viewport ? this.viewport : new $.Viewport({ - containerSize: THIS[ this.hash ].prevContainerSize, - contentSize: this.source.dimensions, - springStiffness: this.springStiffness, - animationTime: this.animationTime, - minZoomImageRatio: this.minZoomImageRatio, - maxZoomPixelRatio: this.maxZoomPixelRatio, - visibilityRatio: this.visibilityRatio, - wrapHorizontal: this.wrapHorizontal, - wrapVertical: this.wrapVertical, - defaultZoomLevel: this.defaultZoomLevel, - minZoomLevel: this.minZoomLevel, - maxZoomLevel: this.maxZoomLevel, - viewer: this - }); - } - - if( this.preserveVewport ){ - this.viewport.resetContentSize( this.source.dimensions ); - } - - this.source.overlays = this.source.overlays || []; - - this.drawer = new $.Drawer({ - source: this.source, - viewport: this.viewport, - element: this.canvas, - overlays: [].concat( this.overlays ).concat( this.source.overlays ), - maxImageCacheCount: this.maxImageCacheCount, - imageLoaderLimit: this.imageLoaderLimit, - minZoomImageRatio: this.minZoomImageRatio, - wrapHorizontal: this.wrapHorizontal, - wrapVertical: this.wrapVertical, - immediateRender: this.immediateRender, - blendTime: this.blendTime, - alwaysBlend: this.alwaysBlend, - minPixelRatio: this.collectionMode ? 0 : this.minPixelRatio, - timeout: this.timeout, - debugMode: this.debugMode, - debugGridColor: this.debugGridColor - }); - - //Instantiate a navigator if configured - if ( this.showNavigator && ! this.navigator && !this.collectionMode ){ - this.navigator = new $.Navigator({ - id: this.navigatorElement, - position: this.navigatorPosition, - sizeRatio: this.navigatorSizeRatio, - height: this.navigatorHeight, - width: this.navigatorWidth, - tileSources: this.tileSources, - tileHost: this.tileHost, - prefixUrl: this.prefixUrl, - overlays: this.overlays, - viewer: this - }); - } - - //Instantiate a referencestrip if configured - if ( this.showReferenceStrip && ! this.referenceStrip ){ - this.referenceStrip = new $.ReferenceStrip({ - id: this.referenceStripElement, - position: this.referenceStripPosition, - sizeRatio: this.referenceStripSizeRatio, - scroll: this.referenceStripScroll, - height: this.referenceStripHeight, - width: this.referenceStripWidth, - tileSources: this.tileSources, - tileHost: this.tileHost, - prefixUrl: this.prefixUrl, - overlays: this.overlays, - viewer: this - }); - } - - //this.profiler = new $.Profiler(); - - THIS[ this.hash ].animating = false; - THIS[ this.hash ].forceRedraw = true; - scheduleUpdate( this, updateMulti ); - - //Assuming you had programatically created a bunch of overlays - //and added them via configuration - for ( i = 0; i < this.overlayControls.length; i++ ) { - - overlay = this.overlayControls[ i ]; - - if ( overlay.point ) { - - this.drawer.addOverlay( - overlay.id, - new $.Point( - overlay.point.X, - overlay.point.Y - ), - $.OverlayPlacement.TOP_LEFT - ); - - } else { - - this.drawer.addOverlay( - overlay.id, - new $.Rect( - overlay.rect.Point.X, - overlay.rect.Point.Y, - overlay.rect.Width, - overlay.rect.Height - ), - overlay.placement - ); - - } - } - VIEWERS[ this.hash ] = this; - - if( this.navigator ){ - this.navigator.open( source ); - } - - this.raiseEvent( 'open', { source: source, viewer: this } ); - - return this; - }, - + /** * @function * @name OpenSeadragon.Viewer.prototype.close @@ -597,7 +428,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, * @return {Boolean} */ isFullPage: function () { - return this.element.parentNode == document.body; + return THIS[ this.hash ].fullPage; }, @@ -654,7 +485,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, //the bodies elements and replace them when we leave full screen. this.previousBody = []; THIS[ this.hash ].prevElementParent = this.element.parentNode; - THIS[ this.hash ].prevNextSibling = this.element.prevNextSibling; + THIS[ this.hash ].prevNextSibling = this.element.nextSibling; THIS[ this.hash ].prevElementSize = $.getElementSize( this.element ); nodes = body.childNodes.length; for ( i = 0; i < nodes; i ++ ){ @@ -715,6 +546,8 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, ) + 'px'; } + THIS[ this.hash ].fullPage = true; + // mouse will be inside container now $.delegate( this, onContainerEnter )(); @@ -776,6 +609,8 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, this.element.style.height = THIS[ this.hash ].prevElementSize.y + 'px'; this.element.style.width = THIS[ this.hash ].prevElementSize.x + 'px'; + THIS[ this.hash ].fullPage = false; + // mouse will likely be outside now $.delegate( this, onContainerExit )(); @@ -1085,7 +920,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, } } - this.openTileSource( this.tileSources[ page ] ); + this.open( this.tileSources[ page ] ); } if( $.isFunction( this.onPageChange ) ){ @@ -1102,6 +937,185 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, }); +/** + * @function + * @private + */ +function openTileSource( viewer, source ) { + var _this = viewer, + overlay, + i; + + if ( _this.source ) { + _this.close( ); + } + + // to ignore earlier opens + THIS[ _this.hash ].lastOpenStartTime = +new Date(); + + window.setTimeout( function () { + if ( THIS[ _this.hash ].lastOpenStartTime > THIS[ _this.hash ].lastOpenEndTime ) { + THIS[ _this.hash ].setMessage( $.getString( "Messages.Loading" ) ); + } + }, 2000); + + THIS[ _this.hash ].lastOpenEndTime = +new Date(); + _this.canvas.innerHTML = ""; + THIS[ _this.hash ].prevContainerSize = $.getElementSize( _this.container ); + + + if( _this.collectionMode ){ + _this.source = new $.TileSourceCollection({ + rows: _this.collectionRows, + layout: _this.collectionLayout, + tileSize: _this.collectionTileSize, + tileSources: _this.tileSources, + tileMargin: _this.collectionTileMargin + }); + _this.viewport = _this.viewport ? _this.viewport : new $.Viewport({ + collectionMode: true, + collectionTileSource: _this.source, + containerSize: THIS[ _this.hash ].prevContainerSize, + contentSize: _this.source.dimensions, + springStiffness: _this.springStiffness, + animationTime: _this.animationTime, + showNavigator: false, + minZoomImageRatio: 1, + maxZoomPixelRatio: 1, + viewer: _this //, + //TODO: figure out how to support these in a way that makes sense + //minZoomLevel: this.minZoomLevel, + //maxZoomLevel: this.maxZoomLevel + }); + }else{ + if( source ){ + _this.source = source; + } + _this.viewport = _this.viewport ? _this.viewport : new $.Viewport({ + containerSize: THIS[ _this.hash ].prevContainerSize, + contentSize: _this.source.dimensions, + springStiffness: _this.springStiffness, + animationTime: _this.animationTime, + minZoomImageRatio: _this.minZoomImageRatio, + maxZoomPixelRatio: _this.maxZoomPixelRatio, + visibilityRatio: _this.visibilityRatio, + wrapHorizontal: _this.wrapHorizontal, + wrapVertical: _this.wrapVertical, + defaultZoomLevel: _this.defaultZoomLevel, + minZoomLevel: _this.minZoomLevel, + maxZoomLevel: _this.maxZoomLevel, + viewer: _this + }); + } + + if( _this.preserveVewport ){ + _this.viewport.resetContentSize( _this.source.dimensions ); + } + + _this.source.overlays = _this.source.overlays || []; + + _this.drawer = new $.Drawer({ + source: _this.source, + viewport: _this.viewport, + element: _this.canvas, + overlays: [].concat( _this.overlays ).concat( _this.source.overlays ), + maxImageCacheCount: _this.maxImageCacheCount, + imageLoaderLimit: _this.imageLoaderLimit, + minZoomImageRatio: _this.minZoomImageRatio, + wrapHorizontal: _this.wrapHorizontal, + wrapVertical: _this.wrapVertical, + immediateRender: _this.immediateRender, + blendTime: _this.blendTime, + alwaysBlend: _this.alwaysBlend, + minPixelRatio: _this.collectionMode ? 0 : _this.minPixelRatio, + timeout: _this.timeout, + debugMode: _this.debugMode, + debugGridColor: _this.debugGridColor + }); + + //Instantiate a navigator if configured + if ( _this.showNavigator && ! _this.navigator && !_this.collectionMode ){ + _this.navigator = new $.Navigator({ + id: _this.navigatorElement, + position: _this.navigatorPosition, + sizeRatio: _this.navigatorSizeRatio, + height: _this.navigatorHeight, + width: _this.navigatorWidth, + tileSources: _this.tileSources, + tileHost: _this.tileHost, + prefixUrl: _this.prefixUrl, + overlays: _this.overlays, + viewer: _this + }); + } + + //Instantiate a referencestrip if configured + if ( _this.showReferenceStrip && !_this.referenceStrip ){ + _this.referenceStrip = new $.ReferenceStrip({ + id: _this.referenceStripElement, + position: _this.referenceStripPosition, + sizeRatio: _this.referenceStripSizeRatio, + scroll: _this.referenceStripScroll, + height: _this.referenceStripHeight, + width: _this.referenceStripWidth, + tileSources: _this.tileSources, + tileHost: _this.tileHost, + prefixUrl: _this.prefixUrl, + overlays: _this.overlays, + viewer: _this + }); + } + + //this.profiler = new $.Profiler(); + + THIS[ _this.hash ].animating = false; + THIS[ _this.hash ].forceRedraw = true; + scheduleUpdate( _this, updateMulti ); + + //Assuming you had programatically created a bunch of overlays + //and added them via configuration + for ( i = 0; i < _this.overlayControls.length; i++ ) { + + overlay = _this.overlayControls[ i ]; + + if ( overlay.point ) { + + _this.drawer.addOverlay( + overlay.id, + new $.Point( + overlay.point.X, + overlay.point.Y + ), + $.OverlayPlacement.TOP_LEFT + ); + + } else { + + _this.drawer.addOverlay( + overlay.id, + new $.Rect( + overlay.rect.Point.X, + overlay.rect.Point.Y, + overlay.rect.Width, + overlay.rect.Height + ), + overlay.placement + ); + + } + } + VIEWERS[ _this.hash ] = _this; + + if( _this.navigator ){ + _this.navigator.open( source ); + } + + _this.raiseEvent( 'open', { source: source, viewer: _this } ); + + return _this; +} + + /////////////////////////////////////////////////////////////////////////////// From a90ac76c3885ab6c699ecc43572bc8bd39e607fe Mon Sep 17 00:00:00 2001 From: thatcher Date: Tue, 26 Mar 2013 09:14:11 -0400 Subject: [PATCH 06/10] updating changelog to reflect issues addressed on current master branch (0.9.125 in progress) --- changelog.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/changelog.txt b/changelog.txt index ccbcc5d6..871d7f84 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,12 @@ OPENSEADRAGON CHANGELOG ======================= +0.9.125: In Progress + +* Fully deprecated OpenSeadragon.createFromDZI, safely deprecated Viewer.openTileSource and + Viewer.openDZI to use Viewer.open internally. (#53 & #54). +* Full page bug fix for when viewer is child of document body (#43). +* Overlays for DZI bug fix (#45). 0.9.124: From 86f101f02cad4b7cb6dd3681cc2c7bfa44946f44 Mon Sep 17 00:00:00 2001 From: thatcher Date: Tue, 26 Mar 2013 09:25:56 -0400 Subject: [PATCH 07/10] refs #54 - pointing deprecated method at correct current method. --- src/openseadragon.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index 3b6528f2..186f48c1 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -1385,17 +1385,16 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ /** - * Loads a Deep Zoom Image description from a url, XML string or JSON string - * and provides a callback hook for the resulting Document + * Fully deprecated. Will throw an error. * @function * @name OpenSeadragon.createFromDZI * @param {String} xmlUrl * @param {String} xmlString * @param {Function} callback - * @deprecated - use Viewer.openTileSource + * @deprecated - use OpenSeadragon.Viewer.prototype.open */ createFromDZI: function( dzi, callback, tileHost ) { - throw "OpenSeadragon.createFromDZI is deprecated, use Viewer.openTileSource."; + throw "OpenSeadragon.createFromDZI is deprecated, use Viewer.open."; }, /** From 9aecfddcbf74fa871f50eebc536e372a269c5c51 Mon Sep 17 00:00:00 2001 From: thatcher Date: Tue, 26 Mar 2013 14:35:43 -0400 Subject: [PATCH 08/10] refs #54 - added missing support for tilesource configuration as xml string or json string via Viewer.open --- src/dzitilesource.js | 3 +-- src/tilesource.js | 2 +- src/viewer.js | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/dzitilesource.js b/src/dzitilesource.js index 6a9b0a30..fbb4d2dc 100644 --- a/src/dzitilesource.js +++ b/src/dzitilesource.js @@ -216,6 +216,7 @@ function configureFromXML( tileSource, xmlDoc ){ configuration = { Image: { xmlns: "http://schemas.microsoft.com/deepzoom/2008", + Url: root.getAttribute( "Url" ), Format: root.getAttribute( "Format" ), DisplayRect: null, Overlap: parseInt( root.getAttribute( "Overlap" ), 10 ), @@ -315,8 +316,6 @@ function configureFromObject( tileSource, configuration ){ )); } - delete configuration.Image; - return $.extend(true, { width: width, /* width *required */ height: height, /* height *required */ diff --git a/src/tilesource.js b/src/tilesource.js index e8e44173..650a9477 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -413,7 +413,7 @@ function processResponse( xhr ){ * @eprivate * @inner * @function - * @param {Object|Array} data - the tile source configuration object + * @param {Object|Array|Document} data - the tile source configuration object * @param {String} url - the url where the tile source configuration object was * loaded from, if any. */ diff --git a/src/viewer.js b/src/viewer.js index a48a5af4..a87c52e9 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -309,18 +309,24 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, $TileSource, options; + //allow plain xml strings or json strings to be parsed here + if( $.type( tileSource ) == 'string' ){ + if( tileSource.match(/\s*<.*/) ){ + tileSource = $.parseXml( tileSource ); + }else if( tileSource.match(/\s*[\{\[].*/) ){ + /*jshint evil:true*/ + tileSource = eval( '('+tileSource+')' ); + } + } + setTimeout(function(){ if ( $.type( tileSource ) == 'string') { - //TODO: We cant assume a string implies a dzi since all - //complete TileSource implementations should have a getInfo - //which allows them to be configured via AJAX. Im not sure - //if its better to use file extension or url pattern, or to - //inspect the resulting info object. + //If its still a string it means it must be a url at this point tileSource = new $.TileSource( tileSource, function( readySource ){ openTileSource( _this, readySource ); }); - } else if ( $.isPlainObject( tileSource ) ){ + } else if ( $.isPlainObject( tileSource ) || tileSource.nodeType ){ if( $.isFunction( tileSource.getTileUrl ) ){ //Custom tile source customTileSource = new $.TileSource(tileSource); From 2345f9b21763ea93996f1ae873d8e052113f608d Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 26 Mar 2013 16:03:07 -0400 Subject: [PATCH 09/10] DziTileSource: avoid changing relative paths For cases where DZI files aren't explicitly configured with a tilesUrl, the logic for generating a URL from the DZI source URL would inject an extra leading `/` which would either cause an unnecessary redirect or break depending on whether the webserver in use attempts to normalize `//` to `/`. This change also removes some URL processing logic which duplicates the browser's default behaviour --- src/dzitilesource.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/dzitilesource.js b/src/dzitilesource.js index fbb4d2dc..2a8150c4 100644 --- a/src/dzitilesource.js +++ b/src/dzitilesource.js @@ -108,19 +108,8 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, { options = configureFromObject( this, data ); } - if( url && !options.tilesUrl ){ - if( 'http' !== url.substring( 0, 4 ) ){ - host = location.protocol + '//' + location.host; - } - dziPath = url.split('/'); - dziName = dziPath.pop(); - dziName = dziName.substring(0, dziName.lastIndexOf('.')); - dziPath = '/' + dziPath.join('/') + '/' + dziName + '_files/'; - tilesUrl = dziPath; - if( host ){ - tilesUrl = host + tilesUrl; - } - options.tilesUrl = tilesUrl; + if (url && !options.tilesUrl) { + options.tilesUrl = url.replace(/([^\/]+)\.dzi$/, '$1_files/'); } return options; From c8cc050abf57bf7c9762f586a8b06c511dd5f8d2 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 28 Mar 2013 09:43:11 -0700 Subject: [PATCH 10/10] Added "contributing" section to readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index ae259f02..3c194552 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,12 @@ If you wish to work interactively with the tests or test your changes: and open `http://localhost:8000/` in your browser +## Contributing + +OpenSeadragon is truly a community project; we welcome your involvement! + +When contributing, please attempt to match the code style already in the codebase. Note that we use four spaces per indentation stop. For more thoughts on code style, see https://github.com/rwldrn/idiomatic.js/. + ## Licenses OpenSeadragon was initially released with a New BSD License ( preserved below ), while work done by Chris Thatcher is additionally licensed under the MIT License.