diff --git a/openseadragon.js b/openseadragon.js index d3de1584..8d727515 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -1221,7 +1221,7 @@ $.Utils = new $.Utils(); (function( $ ){ -$.NavControl = function(viewer) { +$.NavControl = function( viewer ) { this._group = null; this._zooming = false; // whether we should be continuously zooming this._zoomFactor = null; // how much we should be continuously zooming by @@ -1230,74 +1230,73 @@ $.NavControl = function(viewer) { this.config = this._viewer.config; this.elmt = null; - this.initialize(); + + var beginZoomingInHandler = $.delegate(this, this._beginZoomingIn); + var endZoomingHandler = $.delegate(this, this._endZooming); + var doSingleZoomInHandler = $.delegate(this, this._doSingleZoomIn); + var beginZoomingOutHandler = $.delegate(this, this._beginZoomingOut); + var doSingleZoomOutHandler = $.delegate(this, this._doSingleZoomOut); + var onHomeHandler = $.delegate(this, this._onHome); + var onFullPageHandler = $.delegate(this, this._onFullPage); + + var navImages = this._viewer.config.navImages; + + var zoomIn = new $.Button({ + config: this._viewer.config, + tooltip: $.Strings.getString("Tooltips.ZoomIn"), + srcRest: this._resolveUrl(navImages.zoomIn.REST), + srcGroup: this._resolveUrl(navImages.zoomIn.GROUP), + srcHover: this._resolveUrl(navImages.zoomIn.HOVER), + srcDown: this._resolveUrl(navImages.zoomIn.DOWN), + onPress: beginZoomingInHandler, + onRelease: endZoomingHandler, + onClick: doSingleZoomInHandler, + onEnter: beginZoomingInHandler, + onExit: endZoomingHandler + }); + var zoomOut = new $.Button({ + config: this._viewer.config, + tooltip: $.Strings.getString("Tooltips.ZoomOut"), + srcRest: this._resolveUrl(navImages.zoomOut.REST), + srcGroup: this._resolveUrl(navImages.zoomOut.GROUP), + srcHover: this._resolveUrl(navImages.zoomOut.HOVER), + srcDown: this._resolveUrl(navImages.zoomOut.DOWN), + onPress: beginZoomingOutHandler, + onRelease: endZoomingHandler, + onClick: doSingleZoomOutHandler, + onEnter: beginZoomingOutHandler, + onExit: endZoomingHandler + }); + var goHome = new $.Button({ + config: this._viewer.config, + tooltip: $.Strings.getString("Tooltips.Home"), + srcRest: this._resolveUrl(navImages.home.REST), + srcGroup: this._resolveUrl(navImages.home.GROUP), + srcHover: this._resolveUrl(navImages.home.HOVER), + srcDown: this._resolveUrl(navImages.home.DOWN), + onRelease: onHomeHandler + }); + var fullPage = new $.Button({ + config: this._viewer.config, + tooltip: $.Strings.getString("Tooltips.FullPage"), + srcRest: this._resolveUrl(navImages.fullpage.REST), + srcGroup: this._resolveUrl(navImages.fullpage.GROUP), + srcHover: this._resolveUrl(navImages.fullpage.HOVER), + srcDown: this._resolveUrl(navImages.fullpage.DOWN), + onRelease: onFullPageHandler + }); + this._group = new $.ButtonGroup({ + config: this._viewer.config, + buttons: [zoomIn, zoomOut, goHome, fullPage] + }); + + this.elmt = this._group.element; + this.elmt[ $.SIGNAL ] = true; // hack to get our controls to fade + this._viewer.addHandler('open', $.delegate(this, this._lightUp)); }; $.NavControl.prototype = { - initialize: function() { - var beginZoomingInHandler = $.delegate(this, this._beginZoomingIn); - var endZoomingHandler = $.delegate(this, this._endZooming); - var doSingleZoomInHandler = $.delegate(this, this._doSingleZoomIn); - var beginZoomingOutHandler = $.delegate(this, this._beginZoomingOut); - var doSingleZoomOutHandler = $.delegate(this, this._doSingleZoomOut); - var onHomeHandler = $.delegate(this, this._onHome); - var onFullPageHandler = $.delegate(this, this._onFullPage); - var navImages = this._viewer.config.navImages; - - var zoomIn = new $.Button({ - config: this._viewer.config, - tooltip: $.Strings.getString("Tooltips.ZoomIn"), - srcRest: this._resolveUrl(navImages.zoomIn.REST), - srcGroup: this._resolveUrl(navImages.zoomIn.GROUP), - srcHover: this._resolveUrl(navImages.zoomIn.HOVER), - srcDown: this._resolveUrl(navImages.zoomIn.DOWN), - onPress: beginZoomingInHandler, - onRelease: endZoomingHandler, - onClick: doSingleZoomInHandler, - onEnter: beginZoomingInHandler, - onExit: endZoomingHandler - }); - var zoomOut = new $.Button({ - config: this._viewer.config, - tooltip: $.Strings.getString("Tooltips.ZoomOut"), - srcRest: this._resolveUrl(navImages.zoomOut.REST), - srcGroup: this._resolveUrl(navImages.zoomOut.GROUP), - srcHover: this._resolveUrl(navImages.zoomOut.HOVER), - srcDown: this._resolveUrl(navImages.zoomOut.DOWN), - onPress: beginZoomingOutHandler, - onRelease: endZoomingHandler, - onClick: doSingleZoomOutHandler, - onEnter: beginZoomingOutHandler, - onExit: endZoomingHandler - }); - var goHome = new $.Button({ - config: this._viewer.config, - tooltip: $.Strings.getString("Tooltips.Home"), - srcRest: this._resolveUrl(navImages.home.REST), - srcGroup: this._resolveUrl(navImages.home.GROUP), - srcHover: this._resolveUrl(navImages.home.HOVER), - srcDown: this._resolveUrl(navImages.home.DOWN), - onRelease: onHomeHandler - }); - var fullPage = new $.Button({ - config: this._viewer.config, - tooltip: $.Strings.getString("Tooltips.FullPage"), - srcRest: this._resolveUrl(navImages.fullpage.REST), - srcGroup: this._resolveUrl(navImages.fullpage.GROUP), - srcHover: this._resolveUrl(navImages.fullpage.HOVER), - srcDown: this._resolveUrl(navImages.fullpage.DOWN), - onRelease: onFullPageHandler - }); - this._group = new $.ButtonGroup({ - config: this._viewer.config, - buttons: [zoomIn, zoomOut, goHome, fullPage] - }); - - this.elmt = this._group.element; - this.elmt[$.SIGNAL] = true; // hack to get our controls to fade - this._viewer.addHandler('open', $.delegate(this, this._lightUp)); - }, _resolveUrl: function(url) { var prefix = this._viewer.prefixUrl; return prefix ? prefix + url : url; diff --git a/src/navcontrol.js b/src/navcontrol.js index 21347ea6..c1ff5179 100644 --- a/src/navcontrol.js +++ b/src/navcontrol.js @@ -1,7 +1,7 @@ (function( $ ){ -$.NavControl = function(viewer) { +$.NavControl = function( viewer ) { this._group = null; this._zooming = false; // whether we should be continuously zooming this._zoomFactor = null; // how much we should be continuously zooming by @@ -10,74 +10,73 @@ $.NavControl = function(viewer) { this.config = this._viewer.config; this.elmt = null; - this.initialize(); + + var beginZoomingInHandler = $.delegate(this, this._beginZoomingIn); + var endZoomingHandler = $.delegate(this, this._endZooming); + var doSingleZoomInHandler = $.delegate(this, this._doSingleZoomIn); + var beginZoomingOutHandler = $.delegate(this, this._beginZoomingOut); + var doSingleZoomOutHandler = $.delegate(this, this._doSingleZoomOut); + var onHomeHandler = $.delegate(this, this._onHome); + var onFullPageHandler = $.delegate(this, this._onFullPage); + + var navImages = this._viewer.config.navImages; + + var zoomIn = new $.Button({ + config: this._viewer.config, + tooltip: $.Strings.getString("Tooltips.ZoomIn"), + srcRest: this._resolveUrl(navImages.zoomIn.REST), + srcGroup: this._resolveUrl(navImages.zoomIn.GROUP), + srcHover: this._resolveUrl(navImages.zoomIn.HOVER), + srcDown: this._resolveUrl(navImages.zoomIn.DOWN), + onPress: beginZoomingInHandler, + onRelease: endZoomingHandler, + onClick: doSingleZoomInHandler, + onEnter: beginZoomingInHandler, + onExit: endZoomingHandler + }); + var zoomOut = new $.Button({ + config: this._viewer.config, + tooltip: $.Strings.getString("Tooltips.ZoomOut"), + srcRest: this._resolveUrl(navImages.zoomOut.REST), + srcGroup: this._resolveUrl(navImages.zoomOut.GROUP), + srcHover: this._resolveUrl(navImages.zoomOut.HOVER), + srcDown: this._resolveUrl(navImages.zoomOut.DOWN), + onPress: beginZoomingOutHandler, + onRelease: endZoomingHandler, + onClick: doSingleZoomOutHandler, + onEnter: beginZoomingOutHandler, + onExit: endZoomingHandler + }); + var goHome = new $.Button({ + config: this._viewer.config, + tooltip: $.Strings.getString("Tooltips.Home"), + srcRest: this._resolveUrl(navImages.home.REST), + srcGroup: this._resolveUrl(navImages.home.GROUP), + srcHover: this._resolveUrl(navImages.home.HOVER), + srcDown: this._resolveUrl(navImages.home.DOWN), + onRelease: onHomeHandler + }); + var fullPage = new $.Button({ + config: this._viewer.config, + tooltip: $.Strings.getString("Tooltips.FullPage"), + srcRest: this._resolveUrl(navImages.fullpage.REST), + srcGroup: this._resolveUrl(navImages.fullpage.GROUP), + srcHover: this._resolveUrl(navImages.fullpage.HOVER), + srcDown: this._resolveUrl(navImages.fullpage.DOWN), + onRelease: onFullPageHandler + }); + this._group = new $.ButtonGroup({ + config: this._viewer.config, + buttons: [zoomIn, zoomOut, goHome, fullPage] + }); + + this.elmt = this._group.element; + this.elmt[ $.SIGNAL ] = true; // hack to get our controls to fade + this._viewer.addHandler('open', $.delegate(this, this._lightUp)); }; $.NavControl.prototype = { - initialize: function() { - var beginZoomingInHandler = $.delegate(this, this._beginZoomingIn); - var endZoomingHandler = $.delegate(this, this._endZooming); - var doSingleZoomInHandler = $.delegate(this, this._doSingleZoomIn); - var beginZoomingOutHandler = $.delegate(this, this._beginZoomingOut); - var doSingleZoomOutHandler = $.delegate(this, this._doSingleZoomOut); - var onHomeHandler = $.delegate(this, this._onHome); - var onFullPageHandler = $.delegate(this, this._onFullPage); - var navImages = this._viewer.config.navImages; - - var zoomIn = new $.Button({ - config: this._viewer.config, - tooltip: $.Strings.getString("Tooltips.ZoomIn"), - srcRest: this._resolveUrl(navImages.zoomIn.REST), - srcGroup: this._resolveUrl(navImages.zoomIn.GROUP), - srcHover: this._resolveUrl(navImages.zoomIn.HOVER), - srcDown: this._resolveUrl(navImages.zoomIn.DOWN), - onPress: beginZoomingInHandler, - onRelease: endZoomingHandler, - onClick: doSingleZoomInHandler, - onEnter: beginZoomingInHandler, - onExit: endZoomingHandler - }); - var zoomOut = new $.Button({ - config: this._viewer.config, - tooltip: $.Strings.getString("Tooltips.ZoomOut"), - srcRest: this._resolveUrl(navImages.zoomOut.REST), - srcGroup: this._resolveUrl(navImages.zoomOut.GROUP), - srcHover: this._resolveUrl(navImages.zoomOut.HOVER), - srcDown: this._resolveUrl(navImages.zoomOut.DOWN), - onPress: beginZoomingOutHandler, - onRelease: endZoomingHandler, - onClick: doSingleZoomOutHandler, - onEnter: beginZoomingOutHandler, - onExit: endZoomingHandler - }); - var goHome = new $.Button({ - config: this._viewer.config, - tooltip: $.Strings.getString("Tooltips.Home"), - srcRest: this._resolveUrl(navImages.home.REST), - srcGroup: this._resolveUrl(navImages.home.GROUP), - srcHover: this._resolveUrl(navImages.home.HOVER), - srcDown: this._resolveUrl(navImages.home.DOWN), - onRelease: onHomeHandler - }); - var fullPage = new $.Button({ - config: this._viewer.config, - tooltip: $.Strings.getString("Tooltips.FullPage"), - srcRest: this._resolveUrl(navImages.fullpage.REST), - srcGroup: this._resolveUrl(navImages.fullpage.GROUP), - srcHover: this._resolveUrl(navImages.fullpage.HOVER), - srcDown: this._resolveUrl(navImages.fullpage.DOWN), - onRelease: onFullPageHandler - }); - this._group = new $.ButtonGroup({ - config: this._viewer.config, - buttons: [zoomIn, zoomOut, goHome, fullPage] - }); - - this.elmt = this._group.element; - this.elmt[$.SIGNAL] = true; // hack to get our controls to fade - this._viewer.addHandler('open', $.delegate(this, this._lightUp)); - }, _resolveUrl: function(url) { var prefix = this._viewer.prefixUrl; return prefix ? prefix + url : url;