finally managed to remove final psuedo-private method _multiUpdate from Viewer, moving it into private closure scope.

This commit is contained in:
thatcher 2011-12-22 20:47:21 -05:00
parent 4d4016dbea
commit 103c545beb
2 changed files with 48 additions and 42 deletions

View File

@ -1585,19 +1585,6 @@ $.Viewer = function( options ) {
}; };
$.extend($.Viewer.prototype, $.EventHandler.prototype, { $.extend($.Viewer.prototype, $.EventHandler.prototype, {
_updateMulti: function () {
if (!this.source) {
return;
}
var beginTime = new Date().getTime();
updateOnce( viewer );
scheduleUpdate( this, arguments.callee, beginTime );
},
addControl: function ( elmt, anchor ) { addControl: function ( elmt, anchor ) {
var elmt = $.Utils.getElement( elmt ), var elmt = $.Utils.getElement( elmt ),
@ -1636,9 +1623,11 @@ $.extend($.Viewer.prototype, $.EventHandler.prototype, {
); );
elmt.style.display = "inline-block"; elmt.style.display = "inline-block";
}, },
isOpen: function () { isOpen: function () {
return !!this.source; return !!this.source;
}, },
openDzi: function (xmlUrl, xmlString) { openDzi: function (xmlUrl, xmlString) {
var _this = this; var _this = this;
$.DziTileSourceHelper.createFromXml( $.DziTileSourceHelper.createFromXml(
@ -1649,12 +1638,14 @@ $.extend($.Viewer.prototype, $.EventHandler.prototype, {
} }
); );
}, },
openTileSource: function ( tileSource ) { openTileSource: function ( tileSource ) {
var _this = this; var _this = this;
window.setTimeout( function () { window.setTimeout( function () {
_this.open( tileSource ); _this.open( tileSource );
}, 1); }, 1 );
}, },
open: function( source ) { open: function( source ) {
var _this = this; var _this = this;
@ -1698,7 +1689,7 @@ $.extend($.Viewer.prototype, $.EventHandler.prototype, {
this._animating = false; this._animating = false;
this._forceRedraw = true; this._forceRedraw = true;
scheduleUpdate( this, this._updateMulti ); scheduleUpdate( this, updateMulti );
for ( var i = 0; i < this.overlayControls.length; i++ ) { for ( var i = 0; i < this.overlayControls.length; i++ ) {
var overlay = this.overlayControls[ i ]; var overlay = this.overlayControls[ i ];
@ -1881,15 +1872,13 @@ $.extend($.Viewer.prototype, $.EventHandler.prototype, {
function scheduleUpdate( viewer, updateFunc, prevUpdateTime ){ function scheduleUpdate( viewer, updateFunc, prevUpdateTime ){
var currentTime, var currentTime,
prevUpdateTime,
targetTime, targetTime,
deltaTime; deltaTime;
if (this._animating) { if (this._animating) {
return window.setTimeout( return window.setTimeout( function(){
$.delegate(viewer, updateFunc), updateFunc( viewer );
1 }, 1 );
);
} }
currentTime = +new Date(); currentTime = +new Date();
@ -1897,7 +1886,9 @@ function scheduleUpdate( viewer, updateFunc, prevUpdateTime ){
targetTime = prevUpdateTime + 1000 / 60; // 60 fps ideal targetTime = prevUpdateTime + 1000 / 60; // 60 fps ideal
deltaTime = Math.max(1, targetTime - currentTime); deltaTime = Math.max(1, targetTime - currentTime);
return window.setTimeout($.delegate(viewer, updateFunc), deltaTime); return window.setTimeout( function(){
updateFunc( viewer );
}, deltaTime );
}; };
//provides a sequence in the fade animation //provides a sequence in the fade animation
@ -2032,6 +2023,18 @@ function getControlIndex( viewer, elmt ) {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Page update routines ( aka Views - for future reference ) // Page update routines ( aka Views - for future reference )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
function updateMulti( viewer ) {
if (!viewer.source) {
return;
}
var beginTime = new Date().getTime();
updateOnce( viewer );
scheduleUpdate( viewer, arguments.callee, beginTime );
};
function updateOnce( viewer ) { function updateOnce( viewer ) {
if ( !viewer.source ) { if ( !viewer.source ) {
return; return;

View File

@ -300,19 +300,6 @@ $.Viewer = function( options ) {
}; };
$.extend($.Viewer.prototype, $.EventHandler.prototype, { $.extend($.Viewer.prototype, $.EventHandler.prototype, {
_updateMulti: function () {
if (!this.source) {
return;
}
var beginTime = new Date().getTime();
updateOnce( viewer );
scheduleUpdate( this, arguments.callee, beginTime );
},
addControl: function ( elmt, anchor ) { addControl: function ( elmt, anchor ) {
var elmt = $.Utils.getElement( elmt ), var elmt = $.Utils.getElement( elmt ),
@ -351,9 +338,11 @@ $.extend($.Viewer.prototype, $.EventHandler.prototype, {
); );
elmt.style.display = "inline-block"; elmt.style.display = "inline-block";
}, },
isOpen: function () { isOpen: function () {
return !!this.source; return !!this.source;
}, },
openDzi: function (xmlUrl, xmlString) { openDzi: function (xmlUrl, xmlString) {
var _this = this; var _this = this;
$.DziTileSourceHelper.createFromXml( $.DziTileSourceHelper.createFromXml(
@ -364,12 +353,14 @@ $.extend($.Viewer.prototype, $.EventHandler.prototype, {
} }
); );
}, },
openTileSource: function ( tileSource ) { openTileSource: function ( tileSource ) {
var _this = this; var _this = this;
window.setTimeout( function () { window.setTimeout( function () {
_this.open( tileSource ); _this.open( tileSource );
}, 1); }, 1 );
}, },
open: function( source ) { open: function( source ) {
var _this = this; var _this = this;
@ -413,7 +404,7 @@ $.extend($.Viewer.prototype, $.EventHandler.prototype, {
this._animating = false; this._animating = false;
this._forceRedraw = true; this._forceRedraw = true;
scheduleUpdate( this, this._updateMulti ); scheduleUpdate( this, updateMulti );
for ( var i = 0; i < this.overlayControls.length; i++ ) { for ( var i = 0; i < this.overlayControls.length; i++ ) {
var overlay = this.overlayControls[ i ]; var overlay = this.overlayControls[ i ];
@ -596,15 +587,13 @@ $.extend($.Viewer.prototype, $.EventHandler.prototype, {
function scheduleUpdate( viewer, updateFunc, prevUpdateTime ){ function scheduleUpdate( viewer, updateFunc, prevUpdateTime ){
var currentTime, var currentTime,
prevUpdateTime,
targetTime, targetTime,
deltaTime; deltaTime;
if (this._animating) { if (this._animating) {
return window.setTimeout( return window.setTimeout( function(){
$.delegate(viewer, updateFunc), updateFunc( viewer );
1 }, 1 );
);
} }
currentTime = +new Date(); currentTime = +new Date();
@ -612,7 +601,9 @@ function scheduleUpdate( viewer, updateFunc, prevUpdateTime ){
targetTime = prevUpdateTime + 1000 / 60; // 60 fps ideal targetTime = prevUpdateTime + 1000 / 60; // 60 fps ideal
deltaTime = Math.max(1, targetTime - currentTime); deltaTime = Math.max(1, targetTime - currentTime);
return window.setTimeout($.delegate(viewer, updateFunc), deltaTime); return window.setTimeout( function(){
updateFunc( viewer );
}, deltaTime );
}; };
//provides a sequence in the fade animation //provides a sequence in the fade animation
@ -747,6 +738,18 @@ function getControlIndex( viewer, elmt ) {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Page update routines ( aka Views - for future reference ) // Page update routines ( aka Views - for future reference )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
function updateMulti( viewer ) {
if (!viewer.source) {
return;
}
var beginTime = new Date().getTime();
updateOnce( viewer );
scheduleUpdate( viewer, arguments.callee, beginTime );
};
function updateOnce( viewer ) { function updateOnce( viewer ) {
if ( !viewer.source ) { if ( !viewer.source ) {
return; return;