From f632d9873062f15b23b5581662783ddbbcca4aed Mon Sep 17 00:00:00 2001 From: houseofyin Date: Sun, 26 May 2013 21:16:56 -0400 Subject: [PATCH 01/11] Working on follow-up on the initial pull request. Changing the default navigator display property, and starting work on the docs --- src/openseadragon.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index ed43ff77..ba9e4264 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -208,6 +208,13 @@ * @param {Boolean} [options.showNavigationControl=true] * Set to false to prevent the appearance of the default navigation controls. * + * @param {Boolean} [options.showNavigator=false] + * Set to true to make the navigator minimap appear. + * + * @param {Boolean} [options.navigatorId=navigator-GENERATED DATE] + * Set the ID of a div to hold the navigator minimap. If one is not specified, + * one will be generated and placed on top of the main image + * * @param {Number} [options.controlsFadeDelay=2000] * The number of milliseconds to wait once the user has stopped interacting * with the interface before begining to fade the controls. Assumes @@ -518,7 +525,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ mouseNavEnabled: true, //GENERAL MOUSE INTERACTIVITY //VIEWPORT NAVIGATOR SETTINGS - showNavigator: true, //promoted to default in 0.9.64 + showNavigator: false, navigatorId: null, navigatorHeight: null, navigatorWidth: null, From e36f7ed41400a7b88c6115501b2bc5bd35d5f773 Mon Sep 17 00:00:00 2001 From: houseofyin Date: Sat, 1 Jun 2013 14:11:56 -0400 Subject: [PATCH 02/11] Trying to remove the selector element --- src/viewer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/viewer.js b/src/viewer.js index 9ea2caed..0ec5b19e 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -236,6 +236,7 @@ $.Viewer = function( options ) { style.position = "absolute"; style.top = "0px"; style.left = "0px"; + style.resize = "none"; }( this.keyboardCommandArea.style )); this.container.insertBefore( this.canvas, this.container.firstChild ); From aca25d19793cdc7cd7ac7ab1646f9ba87bf74e82 Mon Sep 17 00:00:00 2001 From: houseofyin Date: Sat, 1 Jun 2013 16:08:23 -0400 Subject: [PATCH 03/11] Speeding up the tets --- test/navigator.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/test/navigator.js b/test/navigator.js index e876950a..63c7f6f1 100644 --- a/test/navigator.js +++ b/test/navigator.js @@ -16,6 +16,10 @@ QUnit.config.autostart = false; setup:function () { Util.resetDom(); resetTestVariables(); + }, + teardown:function () { + Util.resetDom(); + resetTestVariables(); } }); @@ -271,7 +275,7 @@ QUnit.config.autostart = false; assessmentOperation:assessViewerInCenter, assessmentMessage:"After drag on navigator from top left" } ], - autoHideWaitTime = 7500; + autoHideWaitTime = 3000; seadragonProperties.visibilityRatio = 1; viewer = OpenSeadragon(seadragonProperties); @@ -351,7 +355,9 @@ QUnit.config.autostart = false; id:'tallexample', prefixUrl:'/build/openseadragon/images/', tileSources:'/test/data/wide.dzi', - showNavigator:true + showNavigator:true, + animationTime:0, + controlsFadeDelay:0 }, { displayRegionLocator:'.navigator .displayregion', @@ -373,7 +379,9 @@ QUnit.config.autostart = false; navigatorId:'exampleNavigator', prefixUrl:'/build/openseadragon/images/', tileSources:'/test/data/wide.dzi', - showNavigator:true + showNavigator:true, + animationTime:0, + controlsFadeDelay:0 }, { displayRegionLocator:'#exampleNavigator .displayregion', @@ -396,7 +404,9 @@ QUnit.config.autostart = false; navigatorId:'exampleNavigator', prefixUrl:'/build/openseadragon/images/', tileSources:'/test/data/tall.dzi', - showNavigator:true + showNavigator:true, + animationTime:0, + controlsFadeDelay:0 }, { displayRegionLocator:'#exampleNavigator .displayregion', @@ -416,7 +426,9 @@ QUnit.config.autostart = false; id:'wideexample', prefixUrl:'/build/openseadragon/images/', tileSources:'/test/data/tall.dzi', - showNavigator:true + showNavigator:true, + animationTime:0, + controlsFadeDelay:0 }, { displayRegionLocator:'.navigator .displayregion', From dc7bc6920cbf3c721fc47159decada6fee7524af Mon Sep 17 00:00:00 2001 From: houseofyin Date: Sat, 1 Jun 2013 16:09:04 -0400 Subject: [PATCH 04/11] Updating the documentation --- src/control.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/control.js b/src/control.js index 3188f54a..81af7819 100644 --- a/src/control.js +++ b/src/control.js @@ -53,17 +53,23 @@ $.ControlAnchor = { * to interact with the zoomable interface. Any control can be anchored to any * element. * @class - * @param {Element} element - the contol element to be anchored in the container. - * @param {OpenSeadragon.ControlAnchor} anchor - the location to anchor at. + * @param {Element} element - the control element to be anchored in the container. + * @param {Object} options - All required and optional settings for configuring a control element + * @param {OpenSeadragon.ControlAnchor} [options.anchor=OpenSeadragon.ControlAnchor.NONE] - the position of the control + * relative to the container. + * @param {Boolean} [options.attachToViewer=true] - Whether the control should be added directly to the viewer, or + * directly to the container + * @param {Boolean} [options.autoFade=true] - Whether the control should have the autofade behavior * @param {Element} container - the element to control will be anchored too. - * - * @property {Element} element - the element providing the user interface with + * + * @property {Element} element - the element providing the user interface with * some type of control. Eg a zoom-in button * @property {OpenSeadragon.ControlAnchor} anchor - the position of the control * relative to the container. - * @property {Element} container - the element within with the control is + * @property {Boolean} autoFade - Whether the control should have the autofade behavior + * @property {Element} container - the element within with the control is * positioned. - * @property {Element} wrapper - a nuetral element surrounding the control + * @property {Element} wrapper - a neutral element surrounding the control * element. */ $.Control = function ( element, options, container ) { From 7a8ebd7d4c754f9d91eef0e4b55268f2031bad3e Mon Sep 17 00:00:00 2001 From: houseofyin Date: Sun, 2 Jun 2013 22:32:29 -0400 Subject: [PATCH 05/11] More reasonable handling of the navigator when interacting outside the bounds of the display region --- src/navigator.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index c09566f8..833b916e 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -138,6 +138,7 @@ $.Navigator = function( options ){ this.element.innerTracker = new $.MouseTracker({ element: this.element, + dragHandler: $.delegate( this, onCanvasDrag ), clickHandler: $.delegate( this, onCanvasClick ), releaseHandler: $.delegate( this, onCanvasRelease ), scrollHandler: function(){ @@ -147,16 +148,6 @@ $.Navigator = function( options ){ } }).setTracking( true ); - this.displayRegion.innerTracker = new $.MouseTracker({ - element: this.displayRegion, - clickTimeThreshold: this.clickTimeThreshold, - clickDistThreshold: this.clickDistThreshold, - - dragHandler: $.delegate( this, onCanvasDrag ), - releaseHandler: $.delegate( this, onCanvasRelease ), - scrollHandler: $.delegate( this, onCanvasScroll ) - }).setTracking( true ); // default state - /*this.displayRegion.outerTracker = new $.MouseTracker({ element: this.container, clickTimeThreshold: this.clickTimeThreshold, From 8a3ec975961ab421d4165e454226dfb6c1f24330 Mon Sep 17 00:00:00 2001 From: houseofyin Date: Fri, 7 Jun 2013 10:24:12 -0400 Subject: [PATCH 06/11] Implemented and documented fallback behavior --- src/control.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/control.js b/src/control.js index 81af7819..36987b75 100644 --- a/src/control.js +++ b/src/control.js @@ -54,7 +54,9 @@ $.ControlAnchor = { * element. * @class * @param {Element} element - the control element to be anchored in the container. - * @param {Object} options - All required and optional settings for configuring a control element + * @param {Object | OpenSeadragon.ControlAnchor } options - All required and optional settings for configuring a control element. A deprecated + * alternative to passing an object with properties is to just pass an OpenSeadragon.ControlAnchor. The target + * removal date for this deprecated alternative is December 2013. * @param {OpenSeadragon.ControlAnchor} [options.anchor=OpenSeadragon.ControlAnchor.NONE] - the position of the control * relative to the container. * @param {Boolean} [options.attachToViewer=true] - Whether the control should be added directly to the viewer, or @@ -74,6 +76,11 @@ $.ControlAnchor = { */ $.Control = function ( element, options, container ) { var parent = element.parentNode; + //Deprecated. Target removal date is December 2013 + if (typeof options === 'number') + { + options = {anchor: options}; + } options.attachToViewer = (typeof options.attachToViewer === 'undefined') ? true : options.attachToViewer; this.autoFade = (typeof options.autoFade === 'undefined') ? true : options.autoFade; this.element = element; From 867e6de85ab15f510b7cb331d8ee0d096fbf4985 Mon Sep 17 00:00:00 2001 From: houseofyin Date: Fri, 7 Jun 2013 10:25:26 -0400 Subject: [PATCH 07/11] Fixed a test that would fail if not scrolled to the top. Improved test speed. Changed some variables to better echo corresponding variables in the application code --- test/navigator.js | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/test/navigator.js b/test/navigator.js index 63c7f6f1..3945f219 100644 --- a/test/navigator.js +++ b/test/navigator.js @@ -16,6 +16,8 @@ QUnit.config.autostart = false; setup:function () { Util.resetDom(); resetTestVariables(); + $(document).scrollTop(0); + $(document).scrollLeft(0); }, teardown:function () { Util.resetDom(); @@ -154,6 +156,7 @@ QUnit.config.autostart = false; }(); var simulateNavigatorClick = function (viewer, locationX, locationY) { + //Assumes that the page has not been scrolled from the top or left var $canvas = $(viewer.element).find('.openseadragon-canvas'), offset = $canvas.offset(), event = { @@ -275,7 +278,7 @@ QUnit.config.autostart = false; assessmentOperation:assessViewerInCenter, assessmentMessage:"After drag on navigator from top left" } ], - autoHideWaitTime = 3000; + autoFadeWaitTime = 100; seadragonProperties.visibilityRatio = 1; viewer = OpenSeadragon(seadragonProperties); @@ -317,12 +320,12 @@ QUnit.config.autostart = false; waitForViewer(assessAfterZoomOnViewer); }; - var assessAutohideTriggered = function () { - ok($(testProperties.navigatorLocator).parent().css("opacity") == 0, "Expecting navigator to be autohide when in the default location"); + var assessAutoFadeTriggered = function () { + ok($(testProperties.navigatorLocator).parent().css("opacity") < 1, "Expecting navigator to be autofade when in the default location"); waitForViewer(captureInitialStateThenAct); }; - var assessAutohideDisabled = function () { + var assessAutoFadeDisabled = function () { ok($(testProperties.navigatorLocator).parent().css("opacity") > 0, "Expecting navigator to be always visible when in a custom location"); waitForViewer(captureInitialStateThenAct); }; @@ -338,12 +341,12 @@ QUnit.config.autostart = false; clientX:1, clientY:1 }; - var body = $("body").simulate('mouseover', event); - if (testProperties.expectedAutoHide) { - setTimeout(assessAutohideTriggered,autoHideWaitTime); + mainViewerElement.simulate('blur', event); + if (testProperties.expectedAutoFade) { + setTimeout(assessAutoFadeTriggered,autoFadeWaitTime); } else { - setTimeout(assessAutohideDisabled,autoHideWaitTime); + setTimeout(assessAutoFadeDisabled,autoFadeWaitTime); } } }; @@ -356,14 +359,12 @@ QUnit.config.autostart = false; prefixUrl:'/build/openseadragon/images/', tileSources:'/test/data/wide.dzi', showNavigator:true, - animationTime:0, - controlsFadeDelay:0 + animationTime:0 }, { displayRegionLocator:'.navigator .displayregion', navigatorLocator:'.navigator', - testAutohide: false, - expectedAutoHide: false, + testAutoFade: false, determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { var mainViewerElement = $("#" + seadragonProperties.id), navigatorElement = $(testProperties.navigatorLocator); @@ -380,14 +381,12 @@ QUnit.config.autostart = false; prefixUrl:'/build/openseadragon/images/', tileSources:'/test/data/wide.dzi', showNavigator:true, - animationTime:0, - controlsFadeDelay:0 + animationTime:0 }, { displayRegionLocator:'#exampleNavigator .displayregion', navigatorLocator:'#exampleNavigator', - testAutohide: false, - expectedAutoHide: true, + testAutoFade: false, determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { var mainViewerElement = $("#" + seadragonProperties.id), navigatorViewerElement = $("#" + seadragonProperties.navigatorId); @@ -406,13 +405,14 @@ QUnit.config.autostart = false; tileSources:'/test/data/tall.dzi', showNavigator:true, animationTime:0, - controlsFadeDelay:0 + controlsFadeDelay:0, + controlsFadeLength:1 }, { displayRegionLocator:'#exampleNavigator .displayregion', navigatorLocator:'#exampleNavigator', - testAutohide: true, - expectedAutoHide: false, + testAutoFade: true, + expectedAutoFade: false, determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { var jqueryDialog = $(testProperties.navigatorLocator); assessNavigatorLocation(jqueryDialog.offset().left, @@ -428,13 +428,14 @@ QUnit.config.autostart = false; tileSources:'/test/data/tall.dzi', showNavigator:true, animationTime:0, - controlsFadeDelay:0 + controlsFadeDelay:0, + controlsFadeLength:1 }, { displayRegionLocator:'.navigator .displayregion', navigatorLocator:'.navigator', - testAutohide: true, - expectedAutoHide: true, + testAutoFade: true, + expectedAutoFade: true, determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { var mainViewerElement = $("#" + seadragonProperties.id), navigatorElement = $(testProperties.navigatorLocator); From 9edd6ec1315b43720ad641568b50d2578e233962 Mon Sep 17 00:00:00 2001 From: houseofyin Date: Sat, 8 Jun 2013 12:03:51 -0400 Subject: [PATCH 08/11] Updated to turn on the navigator, since the navigator is no longer on my default --- test/demo/basic.html | 3 ++- test/demo/navigatorcustomlocationdemo.html | 1 + test/demo/navigatorjquerydemo.html | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/test/demo/basic.html b/test/demo/basic.html index af6ae3af..71cfba58 100644 --- a/test/demo/basic.html +++ b/test/demo/basic.html @@ -22,7 +22,8 @@ // debugMode: true, id: "contentDiv", prefixUrl: "../../build/openseadragon/images/", - tileSources: "/test/data/testpattern.dzi" + tileSources: "../data/testpattern.dzi", + showNavigator:true }); diff --git a/test/demo/navigatorcustomlocationdemo.html b/test/demo/navigatorcustomlocationdemo.html index a8de7297..44a55e40 100644 --- a/test/demo/navigatorcustomlocationdemo.html +++ b/test/demo/navigatorcustomlocationdemo.html @@ -27,6 +27,7 @@ var viewer = OpenSeadragon({ id:"contentDiv", navigatorId: "navigatorDiv", + showNavigator:true, prefixUrl:"../../build/openseadragon/images/", tileSources:{ Image:{ diff --git a/test/demo/navigatorjquerydemo.html b/test/demo/navigatorjquerydemo.html index d37a68b3..a99b7767 100644 --- a/test/demo/navigatorjquerydemo.html +++ b/test/demo/navigatorjquerydemo.html @@ -34,6 +34,7 @@ var viewer = OpenSeadragon({ id:"contentDiv", navigatorId: "navigatorDiv", + showNavigator:true, prefixUrl:"../../build/openseadragon/images/", tileSources:{ Image:{ From e9587808ecc3568d1947b8e39beb12d863931690 Mon Sep 17 00:00:00 2001 From: houseofyin Date: Tue, 11 Jun 2013 14:35:45 -0400 Subject: [PATCH 09/11] Tweaked how the deprecated API element has handled --- src/control.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/control.js b/src/control.js index 36987b75..6117ea52 100644 --- a/src/control.js +++ b/src/control.js @@ -54,9 +54,7 @@ $.ControlAnchor = { * element. * @class * @param {Element} element - the control element to be anchored in the container. - * @param {Object | OpenSeadragon.ControlAnchor } options - All required and optional settings for configuring a control element. A deprecated - * alternative to passing an object with properties is to just pass an OpenSeadragon.ControlAnchor. The target - * removal date for this deprecated alternative is December 2013. + * @param {Object } options - All required and optional settings for configuring a control element. * @param {OpenSeadragon.ControlAnchor} [options.anchor=OpenSeadragon.ControlAnchor.NONE] - the position of the control * relative to the container. * @param {Boolean} [options.attachToViewer=true] - Whether the control should be added directly to the viewer, or @@ -76,9 +74,11 @@ $.ControlAnchor = { */ $.Control = function ( element, options, container ) { var parent = element.parentNode; - //Deprecated. Target removal date is December 2013 if (typeof options === 'number') { + $.console.error("Passing an anchor directly into the OpenSeadragon.Control constructor is deprecated; " + + "please use an options object instead. " + + "Support for this deprecated variant is scheduled for removal in December 2013"); options = {anchor: options}; } options.attachToViewer = (typeof options.attachToViewer === 'undefined') ? true : options.attachToViewer; From af1f1b64af8ff9eb9293e1c9900135f34fb9f216 Mon Sep 17 00:00:00 2001 From: houseofyin Date: Tue, 11 Jun 2013 14:36:39 -0400 Subject: [PATCH 10/11] Removing the navigator demo files now that we have reasonable tests and examples for the navigator --- test/demo/navigatorcustomlocationdemo.html | 49 ------------------- test/demo/navigatorjquerydemo.html | 56 ---------------------- 2 files changed, 105 deletions(-) delete mode 100644 test/demo/navigatorcustomlocationdemo.html delete mode 100644 test/demo/navigatorjquerydemo.html diff --git a/test/demo/navigatorcustomlocationdemo.html b/test/demo/navigatorcustomlocationdemo.html deleted file mode 100644 index 44a55e40..00000000 --- a/test/demo/navigatorcustomlocationdemo.html +++ /dev/null @@ -1,49 +0,0 @@ - - - OpenSeadragon Navigator in a custom location Demo - - - - - -
- Simple demo page to show how to put the navigator in a custom location -
-
- - - - - diff --git a/test/demo/navigatorjquerydemo.html b/test/demo/navigatorjquerydemo.html deleted file mode 100644 index a99b7767..00000000 --- a/test/demo/navigatorjquerydemo.html +++ /dev/null @@ -1,56 +0,0 @@ - - - OpenSeadragon Navigator in a JQuery UI Dialog Demo - - - - - - - - -
- Simple demo page to show how to put the navigator in a moveable JQuery UI dialog. -
-
- - - - - From 1833f85232ae338f9b2443d208a18a3268b47081 Mon Sep 17 00:00:00 2001 From: houseofyin Date: Wed, 12 Jun 2013 15:06:17 -0400 Subject: [PATCH 11/11] Implemented fix for a test failure that shows up on Firefox in some situtions --- test/navigator.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/test/navigator.js b/test/navigator.js index 3945f219..bb4c06e3 100644 --- a/test/navigator.js +++ b/test/navigator.js @@ -10,7 +10,8 @@ QUnit.config.autostart = false; contentStartFromLeft, contentStartFromTop, displayRegionWidth, - displayRegionHeight; + displayRegionHeight, + topNavigatorClickAdjustment; module("navigator", { setup:function () { @@ -42,6 +43,7 @@ QUnit.config.autostart = false; contentStartFromTop = null; displayRegionWidth = null; displayRegionHeight = null; + topNavigatorClickAdjustment = 0; }; var assessNavigatorLocation = function (expectedX, expectedY) { @@ -222,11 +224,11 @@ QUnit.config.autostart = false; yPos; if (theContentCorner === "TOPLEFT") { xPos = contentStartFromLeft; - yPos = contentStartFromTop; + yPos = contentStartFromTop + topNavigatorClickAdjustment; } else if (theContentCorner === "TOPRIGHT") { xPos = contentStartFromLeft + displayRegionWidth; - yPos = contentStartFromTop; + yPos = contentStartFromTop+ topNavigatorClickAdjustment; } else if (theContentCorner === "BOTTOMRIGHT") { xPos = contentStartFromLeft + displayRegionWidth; @@ -283,6 +285,11 @@ QUnit.config.autostart = false; seadragonProperties.visibilityRatio = 1; viewer = OpenSeadragon(seadragonProperties); + if ($.isNumeric(testProperties.topNavigatorClickAdjustment)) + { + topNavigatorClickAdjustment = testProperties.topNavigatorClickAdjustment; + } + var assessNavigatorOperationAndTakeNextStep = function (step) { return function () { var nextStep = step + 1; @@ -298,12 +305,18 @@ QUnit.config.autostart = false; }; }; - var assessAfterDragOnViewer = function () { - assessDisplayRegion("After pan"); + var assessAfterSnapback = function () { + assessDisplayRegion("After snapback"); navigatorOperationScenarios[0].interactionOperation(); waitForViewer(assessNavigatorOperationAndTakeNextStep(0)); }; + var assessAfterDragOnViewer = function () { + assessDisplayRegion("After pan"); + viewer.viewport.applyConstraints(); + waitForViewer(assessAfterSnapback); + }; + var assessAfterZoomOnViewer = function () { var target = new OpenSeadragon.Point(0.4, 0.4); assessDisplayRegion("After image zoom"); @@ -413,6 +426,9 @@ QUnit.config.autostart = false; navigatorLocator:'#exampleNavigator', testAutoFade: true, expectedAutoFade: false, + //On Firefox at some screen size/resolution/magnification combinations, there is an issue with the + //simulated click. This property is a work around for that problem + topNavigatorClickAdjustment: 15, determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { var jqueryDialog = $(testProperties.navigatorLocator); assessNavigatorLocation(jqueryDialog.offset().left,