From 9e07c96d29407f38108e9ee424bfc9eb37d5bec0 Mon Sep 17 00:00:00 2001 From: Younes El Alami Date: Fri, 9 Jan 2015 02:21:16 +0000 Subject: [PATCH 1/6] Added preserveOverlays option to Viewer --- src/openseadragon.js | 7 +++++++ src/viewer.js | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index f8b744de..e1a37e2f 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -519,6 +519,12 @@ * 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 to through each image resets the overlays. + * If preserveOverlays is set to true, then the overlays + * are preserved when navigating between images in the sequence. + * * @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 +951,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 39ed6294..32a18722 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -539,9 +539,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(); @@ -1968,7 +1972,12 @@ function openTileSource( viewer, source ) { _this.viewport.resetContentSize( _this.source.dimensions ); } - _this.source.overlays = _this.source.overlays || []; + if( _this.preserveOverlays ){ + _this.source.overlays = _this.currentOverlays; + } + else{ + _this.source.overlays = _this.source.overlays || []; + } _this.drawer = new $.Drawer({ viewer: _this, From 1d16b01a2863ef1268f093b09c082b4f8ab91687 Mon Sep 17 00:00:00 2001 From: Younes El Alami Date: Sat, 10 Jan 2015 12:11:45 +0000 Subject: [PATCH 2/6] Changed _this.source.overlays to _this.overlays, https://github.com/openseadragon/openseadragon/pull/561/files#r22730318 --- src/viewer.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/viewer.js b/src/viewer.js index 32a18722..a359a9d9 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1973,12 +1973,11 @@ function openTileSource( viewer, source ) { } if( _this.preserveOverlays ){ - _this.source.overlays = _this.currentOverlays; - } - else{ - _this.source.overlays = _this.source.overlays || []; + _this.overlays = _this.currentOverlays; } + _this.source.overlays = _this.source.overlays || []; + _this.drawer = new $.Drawer({ viewer: _this, source: _this.source, From 7b6f7d6a5b35ec2ff9dc0b5ed116e2c21c35e8c1 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 12 Jan 2015 13:40:33 -0800 Subject: [PATCH 3/6] Changelog for #561 --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index 779df7b5..f9a8cda9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,8 @@ OPENSEADRAGON CHANGELOG 1.2.1: (in progress) +* Added preserveOverlays option (#561) + 1.2.0: * New combined IIIF TileSource for 1.0 through 2.0 (#441) From 753bf64e8a4d9cb6ce0dfd16d89b0be278cdafbe Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 12 Jan 2015 14:18:39 -0800 Subject: [PATCH 4/6] * Fixed: DZI tilesource was broken --- src/dzitilesource.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) 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: { From 00edbe565a40cb192bda753d1d7807571cf0c82a Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 12 Jan 2015 14:21:57 -0800 Subject: [PATCH 5/6] Changelog for #563 --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index f9a8cda9..903e3062 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,7 @@ OPENSEADRAGON CHANGELOG 1.2.1: (in progress) * Added preserveOverlays option (#561) +* Fixed: DZI tilesource was broken (#563) 1.2.0: From 83b7d7597ac7c74422d23f16c94ad2dc287db15c Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 12 Jan 2015 14:22:10 -0800 Subject: [PATCH 6/6] Added a note about preserveOverlays --- src/openseadragon.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index e1a37e2f..27d3262c 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -515,15 +515,17 @@ * * @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 to through each image resets the overlays. + * 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