diff --git a/changelog.txt b/changelog.txt index 2430d5f1..0bff9545 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,8 @@ OPENSEADRAGON CHANGELOG 1.2.1: (in progress) +* Added preserveOverlays option (#561) +* Fixed: DZI tilesource was broken (#563) * Exposed secondary pointer button (middle, right, etc.) events from MouseTracker and through viewer (#479) * MouseTracker - Improved IE 8 compatibility (#562) diff --git a/src/dzitilesource.js b/src/dzitilesource.js index eb283fab..99dd92d1 100644 --- a/src/dzitilesource.js +++ b/src/dzitilesource.js @@ -107,8 +107,10 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, /** @lends OpenSead var ns; if ( data.Image ) { ns = data.Image.xmlns; - } else if ( data.documentElement && "Image" == data.documentElement.localName ) { - ns = data.documentElement.namespaceURI; + } else if ( data.documentElement) { + if ("Image" == data.documentElement.localName || "Image" == data.documentElement.tagName) { + ns = data.documentElement.namespaceURI; + } } return ( "http://schemas.microsoft.com/deepzoom/2008" == ns || @@ -221,7 +223,7 @@ function configureFromXML( tileSource, xmlDoc ){ } var root = xmlDoc.documentElement, - rootName = root.localName, + rootName = root.localName || root.tagName, ns = xmlDoc.documentElement.namespaceURI, configuration = null, displayRects = [], @@ -234,7 +236,10 @@ function configureFromXML( tileSource, xmlDoc ){ if ( rootName == "Image" ) { try { - sizeNode = root.getElementsByTagNameNS(ns, "Size" )[ 0 ]; + sizeNode = root.getElementsByTagName("Size" )[ 0 ]; + if (sizeNode === undefined) { + sizeNode = root.getElementsByTagNameNS(ns, "Size" )[ 0 ]; + } configuration = { Image: { @@ -257,11 +262,17 @@ function configureFromXML( tileSource, xmlDoc ){ ); } - dispRectNodes = root.getElementsByTagNameNS(ns, "DisplayRect" ); + dispRectNodes = root.getElementsByTagName("DisplayRect" ); + if (dispRectNodes === undefined) { + dispRectNodes = root.getElementsByTagNameNS(ns, "DisplayRect" )[ 0 ]; + } for ( i = 0; i < dispRectNodes.length; i++ ) { dispRectNode = dispRectNodes[ i ]; - rectNode = dispRectNode.getElementsByTagNameNS(ns, "Rect" )[ 0 ]; + rectNode = dispRectNode.getElementsByTagName("Rect" )[ 0 ]; + if (rectNode === undefined) { + rectNode = dispRectNode.getElementsByTagNameNS(ns, "Rect" )[ 0 ]; + } displayRects.push({ Rect: { diff --git a/src/openseadragon.js b/src/openseadragon.js index f8b744de..27d3262c 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -515,10 +515,18 @@ * * @property {Boolean} [preserveViewport=false] * If the viewer has been configured with a sequence of tile sources, then - * normally navigating to through each image resets the viewport to 'home' + * normally navigating through each image resets the viewport to 'home' * position. If preserveViewport is set to true, then the viewport position * is preserved when navigating between images in the sequence. * + * @property {Boolean} [preserveOverlays=false] + * If the viewer has been configured with a sequence of tile sources, then + * normally navigating through each image resets the overlays. + * If preserveOverlays is set to true, then the overlays + * are preserved when navigating between images in the sequence. + * Note: setting preserveOverlays overrides any overlays specified in the + * "overlays" property. + * * @property {Boolean} [showReferenceStrip=false] * If the viewer has been configured with a sequence of tile sources, then * display a scrolling strip of image thumbnails for navigating through the images. @@ -945,6 +953,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ showSequenceControl: true, //SEQUENCE sequenceControlAnchor: null, //SEQUENCE preserveViewport: false, //SEQUENCE + preserveOverlays: false, //SEQUENCE navPrevNextWrap: false, //SEQUENCE showNavigationControl: true, //ZOOM/HOME/FULL/ROTATION navigationControlAnchor: null, //ZOOM/HOME/FULL/ROTATION diff --git a/src/viewer.js b/src/viewer.js index 909e65b1..2d2604d9 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -541,9 +541,13 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, this.navigator.close(); } - this.clearOverlays(); + if( ! this.preserveOverlays) + { + this.clearOverlays(); + this.overlaysContainer.innerHTML = ""; + } + this.drawersContainer.innerHTML = ""; - this.overlaysContainer.innerHTML = ""; if ( this.drawer ) { this.drawer.destroy(); @@ -1970,6 +1974,10 @@ function openTileSource( viewer, source ) { _this.viewport.resetContentSize( _this.source.dimensions ); } + if( _this.preserveOverlays ){ + _this.overlays = _this.currentOverlays; + } + _this.source.overlays = _this.source.overlays || []; _this.drawer = new $.Drawer({