Remove unused variables

Mostly unused function arguments but there were also a fair number
of legacy names which are now no longer used.

One question which comes up – mostly in tilesource.js – is whether
there is any value in leaving unused variables for functions which
are intended to be overridden anyway. I'm inclined to say that the
docs + tests need to be sufficient as there's no enforcement that
whatever is in the base implementation will actually be followed by
any of the real functions.
This commit is contained in:
Chris Adams 2013-06-18 17:55:19 -04:00
parent 6a214347d6
commit 643ee211ca
12 changed files with 22 additions and 65 deletions

View File

@ -33,10 +33,6 @@
*/ */
(function( $ ){ (function( $ ){
//id hash for private properties;
var THIS = {};
/** /**
* @class * @class
*/ */

View File

@ -672,8 +672,7 @@ function updateTile( drawer, drawLevel, haveDrawn, x, y, level, levelOpacity, le
numberOfTiles, numberOfTiles,
drawer.normHeight drawer.normHeight
), ),
drawTile = drawLevel, drawTile = drawLevel;
newbest;
if( drawer.viewer ){ if( drawer.viewer ){
drawer.viewer.raiseEvent( 'update-tile', { drawer.viewer.raiseEvent( 'update-tile', {

View File

@ -126,11 +126,7 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
*/ */
configure: function( data, url ){ configure: function( data, url ){
var dziPath, var options;
dziName,
tilesUrl,
options,
host;
if( !$.isPlainObject(data) ){ if( !$.isPlainObject(data) ){

View File

@ -112,7 +112,7 @@
element[this.prefix + 'RequestFullScreen'](); element[this.prefix + 'RequestFullScreen']();
}; };
fullScreenApi.cancelFullScreen = function( element ) { fullScreenApi.cancelFullScreen = function() {
return (this.prefix === '') ? return (this.prefix === '') ?
document.cancelFullScreen() : document.cancelFullScreen() :
document[this.prefix + 'CancelFullScreen'](); document[this.prefix + 'CancelFullScreen']();
@ -130,7 +130,6 @@
fullScreenApi.cancelFullScreen = fullScreenApi.requestFullScreen; fullScreenApi.cancelFullScreen = fullScreenApi.requestFullScreen;
} }
// export api // export api
$.extend( $, fullScreenApi ); $.extend( $, fullScreenApi );

View File

@ -111,7 +111,6 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, {
*/ */
configure: function( data, url ){ configure: function( data, url ){
var service, var service,
identifier,
options, options,
host; host;
@ -236,11 +235,7 @@ function configureFromXml( tileSource, xmlDoc ){
var root = xmlDoc.documentElement, var root = xmlDoc.documentElement,
rootName = root.tagName, rootName = root.tagName,
configuration = null, configuration = null;
scale_factors,
formats,
qualities,
i;
if ( rootName == "info" ) { if ( rootName == "info" ) {

View File

@ -49,8 +49,7 @@
*/ */
$.Navigator = function( options ){ $.Navigator = function( options ){
var _this = this, var viewer = options.viewer,
viewer = options.viewer,
viewerSize = $.getElementSize( viewer.element), viewerSize = $.getElementSize( viewer.element),
unneededElement; unneededElement;
@ -199,7 +198,7 @@ $.extend( $.Navigator.prototype, $.EventHandler.prototype, $.Viewer.prototype, {
bottomright = this.viewport.pixelFromPoint( bounds.getBottomRight()).minus(this.totalBorderWidths); bottomright = this.viewport.pixelFromPoint( bounds.getBottomRight()).minus(this.totalBorderWidths);
//update style for navigator-box //update style for navigator-box
(function(style, borderWidth){ (function(style) {
style.top = topleft.y + 'px'; style.top = topleft.y + 'px';
style.left = topleft.x + 'px'; style.left = topleft.x + 'px';

View File

@ -747,11 +747,11 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
*/ */
getEvent: function( event ) { getEvent: function( event ) {
if( event ){ if( event ){
$.getEvent = function( event ){ $.getEvent = function( event ) {
return event; return event;
}; };
} else { } else {
$.getEvent = function( event ){ $.getEvent = function() {
return window.event; return window.event;
}; };
} }
@ -1283,7 +1283,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
request = new XMLHttpRequest(); request = new XMLHttpRequest();
} else if ( window.ActiveXObject ) { } else if ( window.ActiveXObject ) {
/*jshint loopfunc:true*/ /*jshint loopfunc:true*/
for ( i = 0; i < ACTIVEX.length; i++ ) { for ( var i = 0; i < ACTIVEX.length; i++ ) {
try { try {
request = new ActiveXObject( ACTIVEX[ i ] ); request = new ActiveXObject( ACTIVEX[ i ] );
$.createAjaxRequest = function( ){ $.createAjaxRequest = function( ){
@ -1316,9 +1316,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
var async = true, var async = true,
request = $.createAjaxRequest(), request = $.createAjaxRequest(),
actual, options;
options,
i;
if( $.isPlainObject( url ) ){ if( $.isPlainObject( url ) ){
@ -1453,12 +1451,9 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
* Fully deprecated. Will throw an error. * Fully deprecated. Will throw an error.
* @function * @function
* @name OpenSeadragon.createFromDZI * @name OpenSeadragon.createFromDZI
* @param {String} xmlUrl
* @param {String} xmlString
* @param {Function} callback
* @deprecated - use OpenSeadragon.Viewer.prototype.open * @deprecated - use OpenSeadragon.Viewer.prototype.open
*/ */
createFromDZI: function( dzi, callback, tileHost ) { createFromDZI: function() {
throw "OpenSeadragon.createFromDZI is deprecated, use Viewer.open."; throw "OpenSeadragon.createFromDZI is deprecated, use Viewer.open.";
}, },
@ -1476,8 +1471,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
if ( window.ActiveXObject ) { if ( window.ActiveXObject ) {
$.parseXml = function( string ){ $.parseXml = function( string ){
var xmlDoc = null, var xmlDoc = null;
parser;
xmlDoc = new ActiveXObject( "Microsoft.XMLDOM" ); xmlDoc = new ActiveXObject( "Microsoft.XMLDOM" );
xmlDoc.async = false; xmlDoc.async = false;

View File

@ -61,8 +61,6 @@ $.ReferenceStrip = function( options ){
var _this = this, var _this = this,
viewer = options.viewer, viewer = options.viewer,
viewerSize = $.getElementSize( viewer.element ), viewerSize = $.getElementSize( viewer.element ),
miniViewer,
minPixelRatio,
element, element,
style, style,
i; i;
@ -273,14 +271,12 @@ $.extend( $.ReferenceStrip.prototype, $.EventHandler.prototype, $.Viewer.prototy
* @function * @function
* @name OpenSeadragon.ReferenceStrip.prototype.update * @name OpenSeadragon.ReferenceStrip.prototype.update
*/ */
update: function( viewport ){ update: function() {
if ( THIS[ this.id ].animating ) {
if( THIS[ this.id ].animating ){
$.console.log('image reference strip update'); $.console.log('image reference strip update');
return true; return true;
} }
return false; return false;
} }
}); });
@ -484,15 +480,7 @@ function onStripEnter( tracker ) {
* @function * @function
*/ */
function onStripExit( tracker ) { function onStripExit( tracker ) {
if ( 'horizontal' == this.scroll ) {
var viewerSize = $.getElementSize( this.viewer.element );
//$.setElementOpacity(tracker.element, 0.4);
//tracker.element.style.border = 'none';
//tracker.element.style.background = '#fff';
if( 'horizontal' == this.scroll ){
//tracker.element.style.paddingTop = "10px"; //tracker.element.style.paddingTop = "10px";
tracker.element.style.marginBottom = "-" + ( $.getElementSize( tracker.element ).y / 2 ) + "px"; tracker.element.style.marginBottom = "-" + ( $.getElementSize( tracker.element ).y / 2 ) + "px";

View File

@ -84,9 +84,7 @@
* The maximum pyramid level this tile source supports or should attempt to load. * The maximum pyramid level this tile source supports or should attempt to load.
*/ */
$.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLevel ) { $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLevel ) {
var _this = this, var callback = null,
callback = null,
readyHandler = null,
args = arguments, args = arguments,
options, options,
i; i;
@ -274,16 +272,14 @@ $.TileSource.prototype = {
* @throws {Error} * @throws {Error}
*/ */
getImageInfo: function( url ) { getImageInfo: function( url ) {
var _this = this, var _this = this,
error,
callbackName, callbackName,
callback, callback,
readySource, readySource,
options, options,
urlParts, urlParts,
filename, filename,
lastDot, lastDot;
tilesUrl;
if( url ) { if( url ) {

View File

@ -39,7 +39,7 @@
* @extends OpenSeadragon.TileSource * @extends OpenSeadragon.TileSource
*/ */
$.TileSourceCollection = function( tileSize, tileSources, rows, layout ) { $.TileSourceCollection = function( tileSize, tileSources, rows, layout ) {
var options;
if( $.isPlainObject( tileSize ) ){ if( $.isPlainObject( tileSize ) ){
options = tileSize; options = tileSize;

View File

@ -174,8 +174,7 @@ $.Viewer = function( options ) {
$.ControlDock.call( this, options ); $.ControlDock.call( this, options );
//Deal with tile sources //Deal with tile sources
var initialTileSource, var initialTileSource;
customTileSource;
if ( this.xmlPath ){ if ( this.xmlPath ){
//Deprecated option. Now it is preferred to use the tileSources option //Deprecated option. Now it is preferred to use the tileSources option
@ -569,7 +568,6 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
var body = document.body, var body = document.body,
bodyStyle = body.style, bodyStyle = body.style,
docStyle = document.documentElement.style, docStyle = document.documentElement.style,
containerStyle = this.element.style,
canvasStyle = this.canvas.style, canvasStyle = this.canvas.style,
_this = this, _this = this,
oldBounds, oldBounds,
@ -635,7 +633,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
body.appendChild( this.element ); body.appendChild( this.element );
if( $.supportsFullScreen ){ if( $.supportsFullScreen ){
THIS[ this.hash ].onfullscreenchange = function( event ) { THIS[ this.hash ].onfullscreenchange = function() {
// The event object doesn't carry information about the // The event object doesn't carry information about the
// fullscreen state of the browser, but it is possible to // fullscreen state of the browser, but it is possible to
// retrieve it through the fullscreen API // retrieve it through the fullscreen API
@ -817,7 +815,6 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
onNextHandler = $.delegate( this, onNext ), onNextHandler = $.delegate( this, onNext ),
onPreviousHandler = $.delegate( this, onPrevious ), onPreviousHandler = $.delegate( this, onPrevious ),
navImages = this.navImages, navImages = this.navImages,
buttons = [],
useGroup = true ; useGroup = true ;
if( this.showSequenceControl && THIS[ this.hash ].sequenced ){ if( this.showSequenceControl && THIS[ this.hash ].sequenced ){

View File

@ -309,10 +309,8 @@ $.Viewport.prototype = {
right, right,
top, top,
bottom, bottom,
center,
dx = 0, dx = 0,
dy = 0, dy = 0;
dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
if ( actualZoom != constrainedZoom ) { if ( actualZoom != constrainedZoom ) {
this.zoomTo( constrainedZoom, this.zoomPoint, immediately ); this.zoomTo( constrainedZoom, this.zoomPoint, immediately );