diff --git a/build.properties b/build.properties index 30f105d4..1ef55a72 100644 --- a/build.properties +++ b/build.properties @@ -6,7 +6,7 @@ PROJECT: openseadragon BUILD_MAJOR: 0 BUILD_MINOR: 9 -BUILD_ID: 13 +BUILD_ID: 14 BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID} VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID} diff --git a/openseadragon.js b/openseadragon.js index f94d73c5..4f5db3e1 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -1,5 +1,5 @@ /** - * @version OpenSeadragon 0.9.13 + * @version OpenSeadragon 0.9.14 * * @fileOverview *

@@ -90,6 +90,58 @@ OpenSeadragon = window.OpenSeadragon || (function(){ indexOf = Array.prototype.indexOf; return { + + DEFAULT_SETTINGS: { + debugMode: true, + animationTime: 1.5, + blendTime: 0.5, + alwaysBlend: false, + autoHideControls: true, + immediateRender: false, + wrapHorizontal: false, + wrapVertical: false, + minZoomImageRatio: 0.8, + maxZoomPixelRatio: 2, + visibilityRatio: 0.5, + springStiffness: 5.0, + imageLoaderLimit: 0, + clickTimeThreshold: 200, + clickDistThreshold: 5, + zoomPerClick: 2.0, + zoomPerScroll: 1.2, + zoomPerSecond: 2.0, + showNavigationControl: true, + maxImageCacheCount: 100, + minPixelRatio: 0.5, + mouseNavEnabled: true, + navImages: { + zoomIn: { + REST: '/images/zoomin_rest.png', + GROUP: '/images/zoomin_grouphover.png', + HOVER: '/images/zoomin_hover.png', + DOWN: '/images/zoomin_pressed.png' + }, + zoomOut: { + REST: '/images/zoomout_rest.png', + GROUP: '/images/zoomout_grouphover.png', + HOVER: '/images/zoomout_hover.png', + DOWN: '/images/zoomout_pressed.png' + }, + home: { + REST: '/images/home_rest.png', + GROUP: '/images/home_grouphover.png', + HOVER: '/images/home_hover.png', + DOWN: '/images/home_pressed.png' + }, + fullpage: { + REST: '/images/fullpage_rest.png', + GROUP: '/images/fullpage_grouphover.png', + HOVER: '/images/fullpage_hover.png', + DOWN: '/images/fullpage_pressed.png' + } + } + }, + // See test/unit/core.js for details concerning isFunction. // Since version 1.3, DOM methods and functions like alert // aren't supported. They return false on IE (#2968). @@ -2445,7 +2497,7 @@ $.Viewer = function( options ) { $.EventHandler.call( this ); - if( typeof( options ) != 'object' ){ + if( !$.isPlainObject( options ) ){ options = { id: args[ 0 ], xmlPath: args.length > 1 ? args[ 1 ] : undefined, @@ -2462,60 +2514,11 @@ $.Viewer = function( options ) { id: options.id, xmlPath: null, tileSources: null, - prefixUrl: '', + prefixUrl: null, controls: [], overlays: [], overlayControls: [], - config: { - debugMode: true, - animationTime: 1.5, - blendTime: 0.5, - alwaysBlend: false, - autoHideControls: true, - immediateRender: false, - wrapHorizontal: false, - wrapVertical: false, - minZoomImageRatio: 0.8, - maxZoomPixelRatio: 2, - visibilityRatio: 0.5, - springStiffness: 5.0, - imageLoaderLimit: 0, - clickTimeThreshold: 200, - clickDistThreshold: 5, - zoomPerClick: 2.0, - zoomPerScroll: 1.2, - zoomPerSecond: 2.0, - showNavigationControl: true, - maxImageCacheCount: 100, - minPixelRatio: 0.5, - mouseNavEnabled: true, - navImages: { - zoomIn: { - REST: '/images/zoomin_rest.png', - GROUP: '/images/zoomin_grouphover.png', - HOVER: '/images/zoomin_hover.png', - DOWN: '/images/zoomin_pressed.png' - }, - zoomOut: { - REST: '/images/zoomout_rest.png', - GROUP: '/images/zoomout_grouphover.png', - HOVER: '/images/zoomout_hover.png', - DOWN: '/images/zoomout_pressed.png' - }, - home: { - REST: '/images/home_rest.png', - GROUP: '/images/home_grouphover.png', - HOVER: '/images/home_hover.png', - DOWN: '/images/home_pressed.png' - }, - fullpage: { - REST: '/images/fullpage_rest.png', - GROUP: '/images/fullpage_grouphover.png', - HOVER: '/images/fullpage_hover.png', - DOWN: '/images/fullpage_pressed.png' - } - } - }, + config: $.DEFAULT_SETTINGS, //These were referenced but never defined controlsFadeDelay: 2000, @@ -2643,12 +2646,13 @@ $.Viewer = function( options ) { onFullPageHandler = $.delegate( this, onFullPage ), navImages = this.config.navImages, zoomIn = new $.Button({ - config: this.config, + clickTimeThreshold: this.config.clickTimeThreshold, + clickDistThreshold: this.config.clickDistThreshold, tooltip: $.getString( "Tooltips.ZoomIn" ), - srcRest: resolveUrl( this.urlPrefix, navImages.zoomIn.REST ), - srcGroup: resolveUrl( this.urlPrefix, navImages.zoomIn.GROUP ), - srcHover: resolveUrl( this.urlPrefix, navImages.zoomIn.HOVER ), - srcDown: resolveUrl( this.urlPrefix, navImages.zoomIn.DOWN ), + srcRest: resolveUrl( this.config.prefixUrl, navImages.zoomIn.REST ), + srcGroup: resolveUrl( this.config.prefixUrl, navImages.zoomIn.GROUP ), + srcHover: resolveUrl( this.config.prefixUrl, navImages.zoomIn.HOVER ), + srcDown: resolveUrl( this.config.prefixUrl, navImages.zoomIn.DOWN ), onPress: beginZoomingInHandler, onRelease: endZoomingHandler, onClick: doSingleZoomInHandler, @@ -2656,12 +2660,13 @@ $.Viewer = function( options ) { onExit: endZoomingHandler }), zoomOut = new $.Button({ - config: this.config, + clickTimeThreshold: this.config.clickTimeThreshold, + clickDistThreshold: this.config.clickDistThreshold, tooltip: $.getString( "Tooltips.ZoomOut" ), - srcRest: resolveUrl( this.urlPrefix, navImages.zoomOut.REST ), - srcGroup: resolveUrl( this.urlPrefix, navImages.zoomOut.GROUP ), - srcHover: resolveUrl( this.urlPrefix, navImages.zoomOut.HOVER ), - srcDown: resolveUrl( this.urlPrefix, navImages.zoomOut.DOWN ), + srcRest: resolveUrl( this.config.prefixUrl, navImages.zoomOut.REST ), + srcGroup: resolveUrl( this.config.prefixUrl, navImages.zoomOut.GROUP ), + srcHover: resolveUrl( this.config.prefixUrl, navImages.zoomOut.HOVER ), + srcDown: resolveUrl( this.config.prefixUrl, navImages.zoomOut.DOWN ), onPress: beginZoomingOutHandler, onRelease: endZoomingHandler, onClick: doSingleZoomOutHandler, @@ -2669,21 +2674,23 @@ $.Viewer = function( options ) { onExit: endZoomingHandler }), goHome = new $.Button({ - config: this.config, + clickTimeThreshold: this.config.clickTimeThreshold, + clickDistThreshold: this.config.clickDistThreshold, tooltip: $.getString( "Tooltips.Home" ), - srcRest: resolveUrl( this.urlPrefix, navImages.home.REST ), - srcGroup: resolveUrl( this.urlPrefix, navImages.home.GROUP ), - srcHover: resolveUrl( this.urlPrefix, navImages.home.HOVER ), - srcDown: resolveUrl( this.urlPrefix, navImages.home.DOWN ), + srcRest: resolveUrl( this.config.prefixUrl, navImages.home.REST ), + srcGroup: resolveUrl( this.config.prefixUrl, navImages.home.GROUP ), + srcHover: resolveUrl( this.config.prefixUrl, navImages.home.HOVER ), + srcDown: resolveUrl( this.config.prefixUrl, navImages.home.DOWN ), onRelease: onHomeHandler }), fullPage = new $.Button({ - config: this.config, + clickTimeThreshold: this.config.clickTimeThreshold, + clickDistThreshold: this.config.clickDistThreshold, tooltip: $.getString( "Tooltips.FullPage" ), - srcRest: resolveUrl( this.urlPrefix, navImages.fullpage.REST ), - srcGroup: resolveUrl( this.urlPrefix, navImages.fullpage.GROUP ), - srcHover: resolveUrl( this.urlPrefix, navImages.fullpage.HOVER ), - srcDown: resolveUrl( this.urlPrefix, navImages.fullpage.DOWN ), + srcRest: resolveUrl( this.config.prefixUrl, navImages.fullpage.REST ), + srcGroup: resolveUrl( this.config.prefixUrl, navImages.fullpage.GROUP ), + srcHover: resolveUrl( this.config.prefixUrl, navImages.fullpage.HOVER ), + srcDown: resolveUrl( this.config.prefixUrl, navImages.fullpage.DOWN ), onRelease: onFullPageHandler }); @@ -2882,11 +2889,13 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, { if( source ){ this.source = source; } - this.viewport = new $.Viewport( - THIS[ this.hash ].prevContainerSize, - this.source.dimensions, - this.config - ); + + this.viewport = new $.Viewport({ + containerSize: THIS[ this.hash ].prevContainerSize, + contentSize: this.source.dimensions, + config: this.config + }); + this.drawer = new $.Drawer( this.source, this.viewport, @@ -4146,7 +4155,7 @@ $.ButtonState = { * @property {String} srcGroup URL of image to use in 'up' state * @property {String} srcHover URL of image to use in 'hover' state * @property {String} srcDown URL of image to use in 'domn' state - * @property {Object} config Configurable settings for this button. + * @property {Object} config Configurable settings for this button. DEPRECATED. * @property {Element} [element] Element to use as a container for the * button. * @property {Number} fadeDelay How long to wait before fading @@ -4165,48 +4174,45 @@ $.Button = function( options ) { $.EventHandler.call( this ); - this.tooltip = options.tooltip; - this.srcRest = options.srcRest; - this.srcGroup = options.srcGroup; - this.srcHover = options.srcHover; - this.srcDown = options.srcDown; + $.extend( true, this, { + + tooltip: null, + srcRest: null, + srcGroup: null, + srcHover: null, + srcDown: null, + clickTimeThreshold: $.DEFAULT_SETTINGS.clickTimeThreshold, + clickDistThreshold: $.DEFAULT_SETTINGS.clickDistThreshold, + // begin fading immediately + fadeDelay: 0, + // fade over a period of 2 seconds + fadeLength: 2000, + onPress: null, + onRelease: null, + onClick: null, + onEnter: null, + onExit: null + + }, options ); //TODO: make button elements accessible by making them a-tags // maybe even consider basing them on the element and adding // methods jquery-style. - this.element = options.element || $.makeNeutralElement( "a" ); - this.element.href = '#'; - this.config = options.config; + this.element = options.element || $.makeNeutralElement( "a" ); + this.element.href = '#'; - if ( options.onPress ){ - this.addHandler( "onPress", options.onPress ); - } - if ( options.onRelease ){ - this.addHandler( "onRelease", options.onRelease ); - } - if ( options.onClick ){ - this.addHandler( "onClick", options.onClick ); - } - if ( options.onEnter ){ - this.addHandler( "onEnter", options.onEnter ); - } - if ( options.onExit ){ - this.addHandler( "onExit", options.onExit ); - } + this.addHandler( "onPress", this.onPress ); + this.addHandler( "onRelease", this.onRelease ); + this.addHandler( "onClick", this.onClick ); + this.addHandler( "onEnter", this.onEnter ); + this.addHandler( "onExit", this.onExit ); this.currentState = $.ButtonState.GROUP; - this.tracker = new $.MouseTracker( - this.element, - this.config.clickTimeThreshold, - this.config.clickDistThreshold - ); - this.imgRest = $.makeTransparentImage( this.config.prefixUrl + this.srcRest ); - this.imgGroup = $.makeTransparentImage( this.config.prefixUrl + this.srcGroup ); - this.imgHover = $.makeTransparentImage( this.config.prefixUrl + this.srcHover ); - this.imgDown = $.makeTransparentImage( this.config.prefixUrl + this.srcDown ); + this.imgRest = $.makeTransparentImage( this.srcRest ); + this.imgGroup = $.makeTransparentImage( this.srcGroup ); + this.imgHover = $.makeTransparentImage( this.srcHover ); + this.imgDown = $.makeTransparentImage( this.srcDown ); - this.fadeDelay = 0; // begin fading immediately - this.fadeLength = 2000; // fade over a period of 2 seconds this.fadeBeginTime = null; this.shouldFade = false; @@ -4219,40 +4225,37 @@ $.Button = function( options ) { this.element.appendChild( this.imgHover ); this.element.appendChild( this.imgDown ); - var styleRest = this.imgRest.style, - styleGroup = this.imgGroup.style, - styleHover = this.imgHover.style, - styleDown = this.imgDown.style; + this.imgGroup.style.position = + this.imgHover.style.position = + this.imgDown.style.position = + "absolute"; - styleGroup.position = - styleHover.position = - styleDown.position = - "absolute"; + this.imgGroup.style.top = + this.imgHover.style.top = + this.imgDown.style.top = + "0px"; - styleGroup.top = - styleHover.top = - styleDown.top = - "0px"; + this.imgGroup.style.left = + this.imgHover.style.left = + this.imgDown.style.left = + "0px"; - styleGroup.left = - styleHover.left = - styleDown.left = - "0px"; + this.imgHover.style.visibility = + this.imgDown.style.visibility = + "hidden"; - styleHover.visibility = - styleDown.visibility = - "hidden"; - - if ( $.Browser.vendor == $.BROWSERS.FIREFOX - && $.Browser.version < 3 ){ - - styleGroup.top = - styleHover.top = - styleDown.top = ""; + if ( $.Browser.vendor == $.BROWSERS.FIREFOX && $.Browser.version < 3 ){ + this.imgGroup.style.top = + this.imgHover.style.top = + this.imgDown.style.top = + ""; } - //TODO - refactor mousetracer next to avoid this extension - $.extend( this.tracker, { + this.tracker = new $.MouseTracker({ + + element: this.element, + clickTimeThreshold: this.clickTimeThreshold, + clickDistThreshold: this.clickDistThreshold, enterHandler: function( tracker, position, buttonDownElement, buttonDownAny ) { if ( buttonDownElement ) { inTo( _this, $.ButtonState.DOWN ); @@ -4286,9 +4289,9 @@ $.Button = function( options ) { _this.raiseEvent("onClick", _this); } } - }); - this.tracker.setTracking( true ); + }).setTracking( true ); + outTo( this, $.ButtonState.REST ); }; @@ -5995,7 +5998,6 @@ function drawTiles( drawer, lastDrawn ){ */ $.Viewport = function( options ) { - var options; if( arguments.length && arguments[ 0 ] instanceof $.Point ){ options = { @@ -6003,8 +6005,6 @@ $.Viewport = function( options ) { contentSize: arguments[ 1 ], config: arguments[ 2 ] }; - } else { - options = arguments[ 0 ]; } //TODO: this.config is something that should go away but currently the @@ -6025,7 +6025,7 @@ $.Viewport = function( options ) { springStiffness: this.config.springStiffness, animationTime: this.config.animationTime }); - this.zoomSpring = new $.Spring({ + this.zoomSpring = new $.Spring({ initial: 1, springStiffness: this.config.springStiffness, animationTime: this.config.animationTime @@ -6035,7 +6035,8 @@ $.Viewport = function( options ) { this.visibilityRatio = this.config.visibilityRatio; this.wrapHorizontal = this.config.wrapHorizontal; this.wrapVertical = this.config.wrapVertical; - this.homeBounds = new $.Rect( 0, 0, 1, this.contentHeight ); + this.homeBounds = new $.Rect( 0, 0, 1, this.contentHeight ); + this.goHome( true ); this.update(); }; diff --git a/src/button.js b/src/button.js index 36000f83..21acbf70 100644 --- a/src/button.js +++ b/src/button.js @@ -34,7 +34,7 @@ $.ButtonState = { * @property {String} srcGroup URL of image to use in 'up' state * @property {String} srcHover URL of image to use in 'hover' state * @property {String} srcDown URL of image to use in 'domn' state - * @property {Object} config Configurable settings for this button. + * @property {Object} config Configurable settings for this button. DEPRECATED. * @property {Element} [element] Element to use as a container for the * button. * @property {Number} fadeDelay How long to wait before fading @@ -53,48 +53,45 @@ $.Button = function( options ) { $.EventHandler.call( this ); - this.tooltip = options.tooltip; - this.srcRest = options.srcRest; - this.srcGroup = options.srcGroup; - this.srcHover = options.srcHover; - this.srcDown = options.srcDown; + $.extend( true, this, { + + tooltip: null, + srcRest: null, + srcGroup: null, + srcHover: null, + srcDown: null, + clickTimeThreshold: $.DEFAULT_SETTINGS.clickTimeThreshold, + clickDistThreshold: $.DEFAULT_SETTINGS.clickDistThreshold, + // begin fading immediately + fadeDelay: 0, + // fade over a period of 2 seconds + fadeLength: 2000, + onPress: null, + onRelease: null, + onClick: null, + onEnter: null, + onExit: null + + }, options ); //TODO: make button elements accessible by making them a-tags // maybe even consider basing them on the element and adding // methods jquery-style. - this.element = options.element || $.makeNeutralElement( "a" ); - this.element.href = '#'; - this.config = options.config; + this.element = options.element || $.makeNeutralElement( "a" ); + this.element.href = '#'; - if ( options.onPress ){ - this.addHandler( "onPress", options.onPress ); - } - if ( options.onRelease ){ - this.addHandler( "onRelease", options.onRelease ); - } - if ( options.onClick ){ - this.addHandler( "onClick", options.onClick ); - } - if ( options.onEnter ){ - this.addHandler( "onEnter", options.onEnter ); - } - if ( options.onExit ){ - this.addHandler( "onExit", options.onExit ); - } + this.addHandler( "onPress", this.onPress ); + this.addHandler( "onRelease", this.onRelease ); + this.addHandler( "onClick", this.onClick ); + this.addHandler( "onEnter", this.onEnter ); + this.addHandler( "onExit", this.onExit ); this.currentState = $.ButtonState.GROUP; - this.tracker = new $.MouseTracker( - this.element, - this.config.clickTimeThreshold, - this.config.clickDistThreshold - ); - this.imgRest = $.makeTransparentImage( this.config.prefixUrl + this.srcRest ); - this.imgGroup = $.makeTransparentImage( this.config.prefixUrl + this.srcGroup ); - this.imgHover = $.makeTransparentImage( this.config.prefixUrl + this.srcHover ); - this.imgDown = $.makeTransparentImage( this.config.prefixUrl + this.srcDown ); + this.imgRest = $.makeTransparentImage( this.srcRest ); + this.imgGroup = $.makeTransparentImage( this.srcGroup ); + this.imgHover = $.makeTransparentImage( this.srcHover ); + this.imgDown = $.makeTransparentImage( this.srcDown ); - this.fadeDelay = 0; // begin fading immediately - this.fadeLength = 2000; // fade over a period of 2 seconds this.fadeBeginTime = null; this.shouldFade = false; @@ -107,40 +104,37 @@ $.Button = function( options ) { this.element.appendChild( this.imgHover ); this.element.appendChild( this.imgDown ); - var styleRest = this.imgRest.style, - styleGroup = this.imgGroup.style, - styleHover = this.imgHover.style, - styleDown = this.imgDown.style; + this.imgGroup.style.position = + this.imgHover.style.position = + this.imgDown.style.position = + "absolute"; - styleGroup.position = - styleHover.position = - styleDown.position = - "absolute"; + this.imgGroup.style.top = + this.imgHover.style.top = + this.imgDown.style.top = + "0px"; - styleGroup.top = - styleHover.top = - styleDown.top = - "0px"; + this.imgGroup.style.left = + this.imgHover.style.left = + this.imgDown.style.left = + "0px"; - styleGroup.left = - styleHover.left = - styleDown.left = - "0px"; + this.imgHover.style.visibility = + this.imgDown.style.visibility = + "hidden"; - styleHover.visibility = - styleDown.visibility = - "hidden"; - - if ( $.Browser.vendor == $.BROWSERS.FIREFOX - && $.Browser.version < 3 ){ - - styleGroup.top = - styleHover.top = - styleDown.top = ""; + if ( $.Browser.vendor == $.BROWSERS.FIREFOX && $.Browser.version < 3 ){ + this.imgGroup.style.top = + this.imgHover.style.top = + this.imgDown.style.top = + ""; } - //TODO - refactor mousetracer next to avoid this extension - $.extend( this.tracker, { + this.tracker = new $.MouseTracker({ + + element: this.element, + clickTimeThreshold: this.clickTimeThreshold, + clickDistThreshold: this.clickDistThreshold, enterHandler: function( tracker, position, buttonDownElement, buttonDownAny ) { if ( buttonDownElement ) { inTo( _this, $.ButtonState.DOWN ); @@ -174,9 +168,9 @@ $.Button = function( options ) { _this.raiseEvent("onClick", _this); } } - }); - this.tracker.setTracking( true ); + }).setTracking( true ); + outTo( this, $.ButtonState.REST ); }; diff --git a/src/openseadragon.js b/src/openseadragon.js index 1d4978f6..c3ce49cc 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -90,6 +90,58 @@ OpenSeadragon = window.OpenSeadragon || (function(){ indexOf = Array.prototype.indexOf; return { + + DEFAULT_SETTINGS: { + debugMode: true, + animationTime: 1.5, + blendTime: 0.5, + alwaysBlend: false, + autoHideControls: true, + immediateRender: false, + wrapHorizontal: false, + wrapVertical: false, + minZoomImageRatio: 0.8, + maxZoomPixelRatio: 2, + visibilityRatio: 0.5, + springStiffness: 5.0, + imageLoaderLimit: 0, + clickTimeThreshold: 200, + clickDistThreshold: 5, + zoomPerClick: 2.0, + zoomPerScroll: 1.2, + zoomPerSecond: 2.0, + showNavigationControl: true, + maxImageCacheCount: 100, + minPixelRatio: 0.5, + mouseNavEnabled: true, + navImages: { + zoomIn: { + REST: '/images/zoomin_rest.png', + GROUP: '/images/zoomin_grouphover.png', + HOVER: '/images/zoomin_hover.png', + DOWN: '/images/zoomin_pressed.png' + }, + zoomOut: { + REST: '/images/zoomout_rest.png', + GROUP: '/images/zoomout_grouphover.png', + HOVER: '/images/zoomout_hover.png', + DOWN: '/images/zoomout_pressed.png' + }, + home: { + REST: '/images/home_rest.png', + GROUP: '/images/home_grouphover.png', + HOVER: '/images/home_hover.png', + DOWN: '/images/home_pressed.png' + }, + fullpage: { + REST: '/images/fullpage_rest.png', + GROUP: '/images/fullpage_grouphover.png', + HOVER: '/images/fullpage_hover.png', + DOWN: '/images/fullpage_pressed.png' + } + } + }, + // See test/unit/core.js for details concerning isFunction. // Since version 1.3, DOM methods and functions like alert // aren't supported. They return false on IE (#2968). diff --git a/src/viewer.js b/src/viewer.js index 99301026..981e7c95 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -35,7 +35,7 @@ $.Viewer = function( options ) { $.EventHandler.call( this ); - if( typeof( options ) != 'object' ){ + if( !$.isPlainObject( options ) ){ options = { id: args[ 0 ], xmlPath: args.length > 1 ? args[ 1 ] : undefined, @@ -52,60 +52,11 @@ $.Viewer = function( options ) { id: options.id, xmlPath: null, tileSources: null, - prefixUrl: '', + prefixUrl: null, controls: [], overlays: [], overlayControls: [], - config: { - debugMode: true, - animationTime: 1.5, - blendTime: 0.5, - alwaysBlend: false, - autoHideControls: true, - immediateRender: false, - wrapHorizontal: false, - wrapVertical: false, - minZoomImageRatio: 0.8, - maxZoomPixelRatio: 2, - visibilityRatio: 0.5, - springStiffness: 5.0, - imageLoaderLimit: 0, - clickTimeThreshold: 200, - clickDistThreshold: 5, - zoomPerClick: 2.0, - zoomPerScroll: 1.2, - zoomPerSecond: 2.0, - showNavigationControl: true, - maxImageCacheCount: 100, - minPixelRatio: 0.5, - mouseNavEnabled: true, - navImages: { - zoomIn: { - REST: '/images/zoomin_rest.png', - GROUP: '/images/zoomin_grouphover.png', - HOVER: '/images/zoomin_hover.png', - DOWN: '/images/zoomin_pressed.png' - }, - zoomOut: { - REST: '/images/zoomout_rest.png', - GROUP: '/images/zoomout_grouphover.png', - HOVER: '/images/zoomout_hover.png', - DOWN: '/images/zoomout_pressed.png' - }, - home: { - REST: '/images/home_rest.png', - GROUP: '/images/home_grouphover.png', - HOVER: '/images/home_hover.png', - DOWN: '/images/home_pressed.png' - }, - fullpage: { - REST: '/images/fullpage_rest.png', - GROUP: '/images/fullpage_grouphover.png', - HOVER: '/images/fullpage_hover.png', - DOWN: '/images/fullpage_pressed.png' - } - } - }, + config: $.DEFAULT_SETTINGS, //These were referenced but never defined controlsFadeDelay: 2000, @@ -233,12 +184,13 @@ $.Viewer = function( options ) { onFullPageHandler = $.delegate( this, onFullPage ), navImages = this.config.navImages, zoomIn = new $.Button({ - config: this.config, + clickTimeThreshold: this.config.clickTimeThreshold, + clickDistThreshold: this.config.clickDistThreshold, tooltip: $.getString( "Tooltips.ZoomIn" ), - srcRest: resolveUrl( this.urlPrefix, navImages.zoomIn.REST ), - srcGroup: resolveUrl( this.urlPrefix, navImages.zoomIn.GROUP ), - srcHover: resolveUrl( this.urlPrefix, navImages.zoomIn.HOVER ), - srcDown: resolveUrl( this.urlPrefix, navImages.zoomIn.DOWN ), + srcRest: resolveUrl( this.config.prefixUrl, navImages.zoomIn.REST ), + srcGroup: resolveUrl( this.config.prefixUrl, navImages.zoomIn.GROUP ), + srcHover: resolveUrl( this.config.prefixUrl, navImages.zoomIn.HOVER ), + srcDown: resolveUrl( this.config.prefixUrl, navImages.zoomIn.DOWN ), onPress: beginZoomingInHandler, onRelease: endZoomingHandler, onClick: doSingleZoomInHandler, @@ -246,12 +198,13 @@ $.Viewer = function( options ) { onExit: endZoomingHandler }), zoomOut = new $.Button({ - config: this.config, + clickTimeThreshold: this.config.clickTimeThreshold, + clickDistThreshold: this.config.clickDistThreshold, tooltip: $.getString( "Tooltips.ZoomOut" ), - srcRest: resolveUrl( this.urlPrefix, navImages.zoomOut.REST ), - srcGroup: resolveUrl( this.urlPrefix, navImages.zoomOut.GROUP ), - srcHover: resolveUrl( this.urlPrefix, navImages.zoomOut.HOVER ), - srcDown: resolveUrl( this.urlPrefix, navImages.zoomOut.DOWN ), + srcRest: resolveUrl( this.config.prefixUrl, navImages.zoomOut.REST ), + srcGroup: resolveUrl( this.config.prefixUrl, navImages.zoomOut.GROUP ), + srcHover: resolveUrl( this.config.prefixUrl, navImages.zoomOut.HOVER ), + srcDown: resolveUrl( this.config.prefixUrl, navImages.zoomOut.DOWN ), onPress: beginZoomingOutHandler, onRelease: endZoomingHandler, onClick: doSingleZoomOutHandler, @@ -259,21 +212,23 @@ $.Viewer = function( options ) { onExit: endZoomingHandler }), goHome = new $.Button({ - config: this.config, + clickTimeThreshold: this.config.clickTimeThreshold, + clickDistThreshold: this.config.clickDistThreshold, tooltip: $.getString( "Tooltips.Home" ), - srcRest: resolveUrl( this.urlPrefix, navImages.home.REST ), - srcGroup: resolveUrl( this.urlPrefix, navImages.home.GROUP ), - srcHover: resolveUrl( this.urlPrefix, navImages.home.HOVER ), - srcDown: resolveUrl( this.urlPrefix, navImages.home.DOWN ), + srcRest: resolveUrl( this.config.prefixUrl, navImages.home.REST ), + srcGroup: resolveUrl( this.config.prefixUrl, navImages.home.GROUP ), + srcHover: resolveUrl( this.config.prefixUrl, navImages.home.HOVER ), + srcDown: resolveUrl( this.config.prefixUrl, navImages.home.DOWN ), onRelease: onHomeHandler }), fullPage = new $.Button({ - config: this.config, + clickTimeThreshold: this.config.clickTimeThreshold, + clickDistThreshold: this.config.clickDistThreshold, tooltip: $.getString( "Tooltips.FullPage" ), - srcRest: resolveUrl( this.urlPrefix, navImages.fullpage.REST ), - srcGroup: resolveUrl( this.urlPrefix, navImages.fullpage.GROUP ), - srcHover: resolveUrl( this.urlPrefix, navImages.fullpage.HOVER ), - srcDown: resolveUrl( this.urlPrefix, navImages.fullpage.DOWN ), + srcRest: resolveUrl( this.config.prefixUrl, navImages.fullpage.REST ), + srcGroup: resolveUrl( this.config.prefixUrl, navImages.fullpage.GROUP ), + srcHover: resolveUrl( this.config.prefixUrl, navImages.fullpage.HOVER ), + srcDown: resolveUrl( this.config.prefixUrl, navImages.fullpage.DOWN ), onRelease: onFullPageHandler }); @@ -472,11 +427,13 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, { if( source ){ this.source = source; } - this.viewport = new $.Viewport( - THIS[ this.hash ].prevContainerSize, - this.source.dimensions, - this.config - ); + + this.viewport = new $.Viewport({ + containerSize: THIS[ this.hash ].prevContainerSize, + contentSize: this.source.dimensions, + config: this.config + }); + this.drawer = new $.Drawer( this.source, this.viewport, diff --git a/src/viewport.js b/src/viewport.js index 776d20fd..8f3cdb16 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -7,7 +7,6 @@ */ $.Viewport = function( options ) { - var options; if( arguments.length && arguments[ 0 ] instanceof $.Point ){ options = { @@ -15,8 +14,6 @@ $.Viewport = function( options ) { contentSize: arguments[ 1 ], config: arguments[ 2 ] }; - } else { - options = arguments[ 0 ]; } //TODO: this.config is something that should go away but currently the @@ -37,7 +34,7 @@ $.Viewport = function( options ) { springStiffness: this.config.springStiffness, animationTime: this.config.animationTime }); - this.zoomSpring = new $.Spring({ + this.zoomSpring = new $.Spring({ initial: 1, springStiffness: this.config.springStiffness, animationTime: this.config.animationTime @@ -47,7 +44,8 @@ $.Viewport = function( options ) { this.visibilityRatio = this.config.visibilityRatio; this.wrapHorizontal = this.config.wrapHorizontal; this.wrapVertical = this.config.wrapVertical; - this.homeBounds = new $.Rect( 0, 0, 1, this.contentHeight ); + this.homeBounds = new $.Rect( 0, 0, 1, this.contentHeight ); + this.goHome( true ); this.update(); };