From 28b12961053b9ad0db1b21fea977584ded2e57e5 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 4 Dec 2014 12:00:04 -0800 Subject: [PATCH 1/2] IE8 fixes for DZI and World.removeItem --- src/dzitilesource.js | 23 +++++++++++++++++------ src/world.js | 2 +- test/demo/collections/main.js | 7 ++++--- 3 files changed, 22 insertions(+), 10 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: { diff --git a/src/world.js b/src/world.js index 9e67a1c1..a61e2f69 100644 --- a/src/world.js +++ b/src/world.js @@ -177,7 +177,7 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W removeItem: function( item ) { $.console.assert(item, "[World.removeItem] item is required"); - var index = this._items.indexOf( item ); + var index = $.indexOf(this._items, item ); if ( index === -1 ) { return; } diff --git a/test/demo/collections/main.js b/test/demo/collections/main.js index 51f91c83..c3a71958 100644 --- a/test/demo/collections/main.js +++ b/test/demo/collections/main.js @@ -6,23 +6,24 @@ init: function() { var self = this; - var testInitialOpen = false; + var testInitialOpen = true; var testOverlays = false; var testMargins = false; - var testNavigator = true; + var testNavigator = false; var margins; var config = { // debugMode: true, zoomPerScroll: 1.02, showNavigator: testNavigator, + useCanvas: true, // sequenceMode: true, // showReferenceStrip: true, // referenceStripScroll: 'vertical', navPrevNextWrap: false, preserveViewport: false, collectionMode: true, - // collectionRows: 3, + collectionRows: 1, // collectionLayout: 'vertical', // collectionTileSize: 10, // collectionTileMargin: 10, From 40d8f84187bde7bced61d11e17e1442df9929166 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Fri, 12 Dec 2014 16:28:02 -0800 Subject: [PATCH 2/2] Testing --- test/demo/collections/main.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/demo/collections/main.js b/test/demo/collections/main.js index c3a71958..cc18a064 100644 --- a/test/demo/collections/main.js +++ b/test/demo/collections/main.js @@ -98,8 +98,11 @@ this.viewer = OpenSeadragon(config); if (testInitialOpen) { - this.viewer.addHandler( "open", function() { - }); + function openHandler() { + self.viewer.removeHandler('open', openHandler); + } + + this.viewer.addHandler( "open", openHandler); } if (testMargins) {