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( $ ){
//id hash for private properties;
var THIS = {};
/**
* @class
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -61,8 +61,6 @@ $.ReferenceStrip = function( options ){
var _this = this,
viewer = options.viewer,
viewerSize = $.getElementSize( viewer.element ),
miniViewer,
minPixelRatio,
element,
style,
i;
@ -273,14 +271,12 @@ $.extend( $.ReferenceStrip.prototype, $.EventHandler.prototype, $.Viewer.prototy
* @function
* @name OpenSeadragon.ReferenceStrip.prototype.update
*/
update: function( viewport ){
if( THIS[ this.id ].animating ){
update: function() {
if ( THIS[ this.id ].animating ) {
$.console.log('image reference strip update');
return true;
}
return false;
}
});
@ -484,15 +480,7 @@ function onStripEnter( tracker ) {
* @function
*/
function onStripExit( tracker ) {
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 ){
if ( 'horizontal' == this.scroll ) {
//tracker.element.style.paddingTop = "10px";
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.
*/
$.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLevel ) {
var _this = this,
callback = null,
readyHandler = null,
var callback = null,
args = arguments,
options,
i;
@ -274,16 +272,14 @@ $.TileSource.prototype = {
* @throws {Error}
*/
getImageInfo: function( url ) {
var _this = this,
error,
var _this = this,
callbackName,
callback,
readySource,
options,
urlParts,
filename,
lastDot,
tilesUrl;
lastDot;
if( url ) {

View File

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

View File

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

View File

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