mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
removed initialize anti pattern from constructor in favor of doing initialization in constructor in navcontrol.js
This commit is contained in:
parent
114a26b1a9
commit
b061a4d830
129
openseadragon.js
129
openseadragon.js
@ -1221,7 +1221,7 @@ $.Utils = new $.Utils();
|
|||||||
|
|
||||||
(function( $ ){
|
(function( $ ){
|
||||||
|
|
||||||
$.NavControl = function(viewer) {
|
$.NavControl = function( viewer ) {
|
||||||
this._group = null;
|
this._group = null;
|
||||||
this._zooming = false; // whether we should be continuously zooming
|
this._zooming = false; // whether we should be continuously zooming
|
||||||
this._zoomFactor = null; // how much we should be continuously zooming by
|
this._zoomFactor = null; // how much we should be continuously zooming by
|
||||||
@ -1230,74 +1230,73 @@ $.NavControl = function(viewer) {
|
|||||||
this.config = this._viewer.config;
|
this.config = this._viewer.config;
|
||||||
|
|
||||||
this.elmt = null;
|
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 = {
|
$.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) {
|
_resolveUrl: function(url) {
|
||||||
var prefix = this._viewer.prefixUrl;
|
var prefix = this._viewer.prefixUrl;
|
||||||
return prefix ? prefix + url : url;
|
return prefix ? prefix + url : url;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
(function( $ ){
|
(function( $ ){
|
||||||
|
|
||||||
$.NavControl = function(viewer) {
|
$.NavControl = function( viewer ) {
|
||||||
this._group = null;
|
this._group = null;
|
||||||
this._zooming = false; // whether we should be continuously zooming
|
this._zooming = false; // whether we should be continuously zooming
|
||||||
this._zoomFactor = null; // how much we should be continuously zooming by
|
this._zoomFactor = null; // how much we should be continuously zooming by
|
||||||
@ -10,74 +10,73 @@ $.NavControl = function(viewer) {
|
|||||||
this.config = this._viewer.config;
|
this.config = this._viewer.config;
|
||||||
|
|
||||||
this.elmt = null;
|
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 = {
|
$.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) {
|
_resolveUrl: function(url) {
|
||||||
var prefix = this._viewer.prefixUrl;
|
var prefix = this._viewer.prefixUrl;
|
||||||
return prefix ? prefix + url : url;
|
return prefix ? prefix + url : url;
|
||||||
|
Loading…
Reference in New Issue
Block a user