diff --git a/.eslintrc.hound.json b/.eslintrc.hound.json new file mode 100644 index 00000000..027542f4 --- /dev/null +++ b/.eslintrc.hound.json @@ -0,0 +1,285 @@ +{ + "env": { + "browser": true + }, + "extends": "eslint:recommended", + "rules": { + "indent": [ + "error", + 4 + ], + "linebreak-style": [ + "error", + "unix" + ], + "quotes": [ + "error", + "double" + ], + "semi": [ + "error", + "always" + ], + "no-unused-vars": [ + "error", + { + "args": "none" + } + ], + "block-scoped-var": [ + "error" + ], + "consistent-return": [ + "error" + ], + "curly": [ + "error", + "all" + ], + "eqeqeq": [ + "error" + ], + "no-eval": [ + "error" + ], + "no-implicit-globals": [ + "error" + ], + "no-implied-eval": [ + "error" + ], + "no-invalid-this": [ + "error" + ], + "no-multi-spaces": [ + "error", + { + "exceptions": { + "Property": true, + "VariableDeclarator": true, + "AssignmentExpression": true + } + } + ], + "no-new-wrappers": [ + "error" + ], + "no-new": [ + "error" + ], + "no-return-assign": [ + "error" + ], + "no-self-compare": [ + "error" + ], + "no-unmodified-loop-condition": [ + "error" + ], + "no-unused-expressions": [ + "error" + ], + "no-useless-call": [ + "error" + ], + "no-useless-concat": [ + "error" + ], + "no-useless-escape": [ + "error" + ], + "no-useless-return": [ + "error" + ], + "no-with": [ + "error" + ], + "radix": [ + "error" + ], + "yoda": [ + "error" + ], + "no-undef-init": [ + "error" + ], + "no-use-before-define": [ + "error", + { + "functions": false + } + ], + "array-bracket-spacing": [ + "error", + "never" + ], + "block-spacing": [ + "error" + ], + "brace-style": [ + "error" + ], + "camelcase": [ + "error" + ], + "comma-spacing": [ + "error" + ], + "comma-style": [ + "error" + ], + "computed-property-spacing": [ + "error" + ], + "consistent-this": [ + "error", + "self" + ], + "eol-last": [ + "error" + ], + "func-call-spacing": [ + "error" + ], + "func-name-matching": [ + "error" + ], + "key-spacing": [ + "error", + { + "mode": "minimum" + } + ], + "keyword-spacing": [ + "error" + ], + "max-len": [ + "error", + 80 + ], + "max-statements-per-line": [ + "error", + { + "max": 1 + } + ], + "new-cap": [ + "error" + ], + "new-parens": [ + "error" + ], + "no-array-constructor": [ + "error" + ], + "no-mixed-operators": [ + "error", + { + "groups": [ + [ + "&", + "|", + "^", + "~", + "<<", + ">>", + ">>>" + ], + [ + "==", + "!=", + "===", + "!==", + ">", + ">=", + "<", + "<=" + ], + [ + "&&", + "||" + ], + [ + "in", + "instanceof" + ] + ] + } + ], + "no-new-object": [ + "error" + ], + "no-tabs": [ + "error" + ], + "no-trailing-spaces": [ + "error" + ], + "no-unneeded-ternary": [ + "error" + ], + "no-whitespace-before-property": [ + "error" + ], + "object-curly-spacing": [ + "error", + "always" + ], + "one-var-declaration-per-line": [ + "error" + ], + "one-var": [ + "error", + "never" + ], + "operator-assignment": [ + "error" + ], + "operator-linebreak": [ + "error", + "after" + ], + "quote-props": [ + "error", + "as-needed" + ], + "semi-spacing": [ + "error" + ], + "space-before-blocks": [ + "error" + ], + "space-before-function-paren": [ + "error", + "never" + ], + "space-in-parens": [ + "error", + "never" + ], + "space-infix-ops": [ + "error" + ], + "space-unary-ops": [ + "error", + { + "words": false, + "nonwords": false + } + ], + "unicode-bom": [ + "error" + ], + "no-caller": [ + "error" + ], + "no-loop-func": [ + "error" + ] + }, + "globals": { + "OpenSeadragon": true, + "define": false, + "module": false + } +} diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..7e027656 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,285 @@ +{ + "env": { + "browser": true + }, + "extends": "eslint:recommended", + "rules": { + "indent": [ + "off", + 4 + ], + "linebreak-style": [ + "error", + "unix" + ], + "quotes": [ + "off", + "double" + ], + "semi": [ + "error", + "always" + ], + "no-unused-vars": [ + "error", + { + "args": "none" + } + ], + "block-scoped-var": [ + "error" + ], + "consistent-return": [ + "off" + ], + "curly": [ + "error", + "all" + ], + "eqeqeq": [ + "off" + ], + "no-eval": [ + "error" + ], + "no-implicit-globals": [ + "error" + ], + "no-implied-eval": [ + "error" + ], + "no-invalid-this": [ + "error" + ], + "no-multi-spaces": [ + "error", + { + "exceptions": { + "Property": true, + "VariableDeclarator": true, + "AssignmentExpression": true + } + } + ], + "no-new-wrappers": [ + "error" + ], + "no-new": [ + "error" + ], + "no-return-assign": [ + "error" + ], + "no-self-compare": [ + "error" + ], + "no-unmodified-loop-condition": [ + "error" + ], + "no-unused-expressions": [ + "error" + ], + "no-useless-call": [ + "error" + ], + "no-useless-concat": [ + "error" + ], + "no-useless-escape": [ + "off" + ], + "no-useless-return": [ + "error" + ], + "no-with": [ + "error" + ], + "radix": [ + "error" + ], + "yoda": [ + "off" + ], + "no-undef-init": [ + "error" + ], + "no-use-before-define": [ + "error", + { + "functions": false + } + ], + "array-bracket-spacing": [ + "off", + "never" + ], + "block-spacing": [ + "off" + ], + "brace-style": [ + "off" + ], + "camelcase": [ + "error" + ], + "comma-spacing": [ + "error" + ], + "comma-style": [ + "error" + ], + "computed-property-spacing": [ + "off" + ], + "consistent-this": [ + "off", + "self" + ], + "eol-last": [ + "error" + ], + "func-call-spacing": [ + "error" + ], + "func-name-matching": [ + "error" + ], + "key-spacing": [ + "error", + { + "mode": "minimum" + } + ], + "keyword-spacing": [ + "off" + ], + "max-len": [ + "off", + 80 + ], + "max-statements-per-line": [ + "error", + { + "max": 1 + } + ], + "new-cap": [ + "error" + ], + "new-parens": [ + "error" + ], + "no-array-constructor": [ + "error" + ], + "no-mixed-operators": [ + "error", + { + "groups": [ + [ + "&", + "|", + "^", + "~", + "<<", + ">>", + ">>>" + ], + [ + "==", + "!=", + "===", + "!==", + ">", + ">=", + "<", + "<=" + ], + [ + "&&", + "||" + ], + [ + "in", + "instanceof" + ] + ] + } + ], + "no-new-object": [ + "error" + ], + "no-tabs": [ + "error" + ], + "no-trailing-spaces": [ + "error" + ], + "no-unneeded-ternary": [ + "error" + ], + "no-whitespace-before-property": [ + "error" + ], + "object-curly-spacing": [ + "off", + "always" + ], + "one-var-declaration-per-line": [ + "error" + ], + "one-var": [ + "off", + "never" + ], + "operator-assignment": [ + "error" + ], + "operator-linebreak": [ + "error", + "after" + ], + "quote-props": [ + "off", + "as-needed" + ], + "semi-spacing": [ + "error" + ], + "space-before-blocks": [ + "off" + ], + "space-before-function-paren": [ + "off", + "never" + ], + "space-in-parens": [ + "off", + "never" + ], + "space-infix-ops": [ + "error" + ], + "space-unary-ops": [ + "error", + { + "words": false, + "nonwords": false + } + ], + "unicode-bom": [ + "error" + ], + "no-caller": [ + "error" + ], + "no-loop-func": [ + "error" + ] + }, + "globals": { + "OpenSeadragon": true, + "define": false, + "module": false + } +} diff --git a/.hound.yml b/.hound.yml new file mode 100644 index 00000000..ef1551ba --- /dev/null +++ b/.hound.yml @@ -0,0 +1,6 @@ +jshint: + config_file: .jshintrc + +eslint: + enabled: true + config_file: .eslintrc.hound.json diff --git a/Gruntfile.js b/Gruntfile.js index a48002b1..c339e8ae 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -11,6 +11,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks("grunt-contrib-connect"); grunt.loadNpmTasks("grunt-contrib-watch"); grunt.loadNpmTasks("grunt-contrib-clean"); + grunt.loadNpmTasks("grunt-eslint"); grunt.loadNpmTasks("grunt-git-describe"); grunt.loadNpmTasks('grunt-text-replace'); @@ -194,6 +195,12 @@ module.exports = function(grunt) { beforeconcat: sources, afterconcat: [ distribution ] }, + eslint: { + options: { + configFile: '.eslintrc.json' + }, + target: sources + }, "git-describe": { build: {} } @@ -266,7 +273,7 @@ module.exports = function(grunt) { // Cleans out the build folder and builds the code and images into it, checking lint. grunt.registerTask("build", [ "clean:build", "jshint:beforeconcat", "git-describe", "concat", "jshint:afterconcat", - "uglify", "replace:cleanPaths", "copy:build" + "eslint", "uglify", "replace:cleanPaths", "copy:build" ]); // ---------- diff --git a/package.json b/package.json index a1fe2301..2ef3b31c 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "grunt-contrib-uglify": "^2.0.0", "grunt-contrib-watch": "^0.6.1", "grunt-git-describe": "^2.3.2", + "grunt-eslint": "^19.0.0", "grunt-qunit-istanbul": "^0.6.0", "grunt-text-replace": "^0.4.0", "qunitjs": "^1.20.0" diff --git a/src/button.js b/src/button.js index 42f68afc..09010322 100644 --- a/src/button.js +++ b/src/button.js @@ -120,7 +120,7 @@ $.Button = function( options ) { * @member {Element} element * @memberof OpenSeadragon.Button# */ - this.element = options.element || $.makeNeutralElement( "div" ); + this.element = options.element || $.makeNeutralElement("div"); //if the user has specified the element to bind the control to explicitly //then do not add the default control images @@ -158,7 +158,7 @@ $.Button = function( options ) { this.imgDown.style.visibility = "hidden"; - if ( $.Browser.vendor == $.BROWSERS.FIREFOX && $.Browser.version < 3 ){ + if ($.Browser.vendor == $.BROWSERS.FIREFOX && $.Browser.version < 3) { this.imgGroup.style.top = this.imgHover.style.top = this.imgDown.style.top = @@ -172,13 +172,13 @@ $.Button = function( options ) { } - this.addHandler( "press", this.onPress ); - this.addHandler( "release", this.onRelease ); - this.addHandler( "click", this.onClick ); - this.addHandler( "enter", this.onEnter ); - this.addHandler( "exit", this.onExit ); - this.addHandler( "focus", this.onFocus ); - this.addHandler( "blur", this.onBlur ); + this.addHandler("press", this.onPress); + this.addHandler("release", this.onRelease); + this.addHandler("click", this.onClick); + this.addHandler("enter", this.onEnter); + this.addHandler("exit", this.onExit); + this.addHandler("focus", this.onFocus); + this.addHandler("blur", this.onBlur); /** * The button's current state. diff --git a/src/control.js b/src/control.js index c1ba2186..5a63c517 100644 --- a/src/control.js +++ b/src/control.js @@ -115,10 +115,10 @@ $.Control = function ( element, options, container ) { if ( this.anchor == $.ControlAnchor.ABSOLUTE ) { this.wrapper = $.makeNeutralElement( "div" ); this.wrapper.style.position = "absolute"; - this.wrapper.style.top = typeof ( options.top ) == "number" ? ( options.top + 'px' ) : options.top; - this.wrapper.style.left = typeof ( options.left ) == "number" ? (options.left + 'px' ) : options.left; - this.wrapper.style.height = typeof ( options.height ) == "number" ? ( options.height + 'px' ) : options.height; - this.wrapper.style.width = typeof ( options.width ) == "number" ? ( options.width + 'px' ) : options.width; + this.wrapper.style.top = typeof (options.top) == "number" ? (options.top + 'px') : options.top; + this.wrapper.style.left = typeof (options.left) == "number" ? (options.left + 'px') : options.left; + this.wrapper.style.height = typeof (options.height) == "number" ? (options.height + 'px') : options.height; + this.wrapper.style.width = typeof (options.width) == "number" ? (options.width + 'px') : options.width; this.wrapper.style.margin = "0px"; this.wrapper.style.padding = "0px"; diff --git a/src/controldock.js b/src/controldock.js index 2ee2d0f1..81443bf9 100644 --- a/src/controldock.js +++ b/src/controldock.js @@ -45,7 +45,7 @@ i; $.extend( true, this, { - id: 'controldock-'+$.now()+'-'+Math.floor(Math.random()*1000000), + id: 'controldock-' + $.now() + '-' + Math.floor(Math.random() * 1000000), container: $.makeNeutralElement( 'div' ), controls: [] }, options ); diff --git a/src/drawer.js b/src/drawer.js index 2355a828..8321b6fe 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -285,8 +285,8 @@ $.Drawer.prototype = { return new $.Rect( topLeft.x * $.pixelDensityRatio, topLeft.y * $.pixelDensityRatio, - size.x * $.pixelDensityRatio, - size.y * $.pixelDensityRatio + size.x * $.pixelDensityRatio, + size.y * $.pixelDensityRatio ); }, @@ -474,7 +474,7 @@ $.Drawer.prototype = { position.x - widthExt * scale, position.y - heightExt * scale, (this.canvas.width + 2 * widthExt) * scale, - (this.canvas.height + 2 * heightExt) * scale, + (this.canvas.height + 2 * heightExt) * scale, -widthExt, -heightExt, this.canvas.width + 2 * widthExt, diff --git a/src/iiiftilesource.js b/src/iiiftilesource.js index 4584f1cd..0af45c8b 100644 --- a/src/iiiftilesource.js +++ b/src/iiiftilesource.js @@ -45,6 +45,7 @@ */ $.IIIFTileSource = function( options ){ + /* eslint-disable camelcase */ $.extend( true, this, options ); @@ -86,7 +87,7 @@ $.IIIFTileSource = function( options ){ } else if ( canBeTiled(options.profile) ) { // use the largest of tileOptions that is smaller than the short dimension var shortDim = Math.min( this.height, this.width ), - tileOptions = [256,512,1024], + tileOptions = [256, 512, 1024], smallerTiles = []; for ( var c = 0; c < tileOptions.length; c++ ) { @@ -102,11 +103,11 @@ $.IIIFTileSource = function( options ){ options.tileSize = shortDim; } } else if (this.sizes && this.sizes.length > 0) { - // This info.json can't be tiled, but we can still construct a legacy pyramid from the sizes array. - // In this mode, IIIFTileSource will call functions from the abstract baseTileSource or the - // LegacyTileSource instead of performing IIIF tiling. + // This info.json can't be tiled, but we can still construct a legacy pyramid from the sizes array. + // In this mode, IIIFTileSource will call functions from the abstract baseTileSource or the + // LegacyTileSource instead of performing IIIF tiling. this.emulateLegacyImagePyramid = true; - + options.levels = constructLevels( this ); // use the largest available size to define tiles $.extend( true, options, { @@ -141,7 +142,7 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea * @param {Object|Array} data * @param {String} optional - url */ - + supports: function( data, url ) { // Version 2.0 and forwards if (data.protocol && data.protocol == 'http://iiif.io/api/image') { @@ -393,14 +394,16 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea */ function constructLevels(options) { var levels = []; - for(var i=0; i= 0 ) { $.Browser.vendor = $.BROWSERS.FIREFOX; $.Browser.version = parseFloat( diff --git a/src/referencestrip.js b/src/referencestrip.js index 9d88a6a3..5559f85a 100644 --- a/src/referencestrip.js +++ b/src/referencestrip.js @@ -592,6 +592,4 @@ function onKeyPress( event ) { } } - - -} ( OpenSeadragon ) ); +}(OpenSeadragon)); diff --git a/src/spring.js b/src/spring.js index 71c94d06..c4342892 100644 --- a/src/spring.js +++ b/src/spring.js @@ -226,7 +226,7 @@ $.Spring.prototype = { transform( this.springStiffness, ( this.current.time - this.start.time ) / - ( this.target.time - this.start.time ) + ( this.target.time - this.start.time ) ); if (this._exponential) { diff --git a/src/strings.js b/src/strings.js index 03f4ed42..670ed01d 100644 --- a/src/strings.js +++ b/src/strings.js @@ -75,7 +75,7 @@ $.extend( $, /** @lends OpenSeadragon */{ container = I18N, i; - for ( i = 0; i < props.length-1; i++ ) { + for (i = 0; i < props.length - 1; i++) { // in case not a subproperty container = container[ props[ i ] ] || {}; } diff --git a/src/tiledimage.js b/src/tiledimage.js index 21497a76..2fa48782 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -577,7 +577,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag viewportToImageZoom: function( viewportZoom ) { var ratio = this._scaleSpring.current.value * this.viewport._containerInnerSize.x / this.source.dimensions.x; - return ratio * viewportZoom ; + return ratio * viewportZoom; }, /** diff --git a/src/tilesource.js b/src/tilesource.js index b095a2db..271fca7d 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -187,8 +187,8 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve //explicit configuration via positional args in constructor //or the more idiomatic 'options' object this.ready = true; - this.aspectRatio = ( options.width && options.height ) ? - ( options.width / options.height ) : 1; + this.aspectRatio = (options.width && options.height) ? + (options.width / options.height) : 1; this.dimensions = new $.Point( options.width, options.height ); if ( this.tileSize ){ @@ -454,7 +454,7 @@ $.TileSource.prototype = { //TODO: Its not very flexible to require tile sources to end jsonp // request for info with a url that ends with '.js' but for // now it's the only way I see to distinguish uniformly. - callbackName = url.split( '/' ).pop().replace('.js',''); + callbackName = url.split('/').pop().replace('.js', ''); $.jsonp({ url: url, async: false, @@ -574,12 +574,12 @@ $.TileSource.prototype = { */ tileExists: function( level, x, y ) { var numTiles = this.getNumTiles( level ); - return level >= this.minLevel && - level <= this.maxLevel && - x >= 0 && - y >= 0 && - x < numTiles.x && - y < numTiles.y; + return level >= this.minLevel && + level <= this.maxLevel && + x >= 0 && + y >= 0 && + x < numTiles.x && + y < numTiles.y; } }; diff --git a/src/tilesourcecollection.js b/src/tilesourcecollection.js index a180aa52..e019741f 100644 --- a/src/tilesourcecollection.js +++ b/src/tilesourcecollection.js @@ -32,11 +32,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -(function( $ ){ +(function($) { // deprecated -$.TileSourceCollection = function( tileSize, tileSources, rows, layout ) { +$.TileSourceCollection = function(tileSize, tileSources, rows, layout) { $.console.error('TileSourceCollection is deprecated; use World instead'); }; -}( OpenSeadragon )); +}(OpenSeadragon)); diff --git a/src/tmstilesource.js b/src/tmstilesource.js index 4c3d0ab0..e7640b15 100644 --- a/src/tmstilesource.js +++ b/src/tmstilesource.js @@ -83,7 +83,7 @@ $.TmsTileSource = function( width, height, tileSize, tileOverlap, tilesUrl ) { } else { max = bufferedHeight / 256; } - options.maxLevel = Math.ceil(Math.log(max)/Math.log(2)) - 1; + options.maxLevel = Math.ceil(Math.log(max) / Math.log(2)) - 1; options.tileSize = 256; options.width = bufferedWidth; options.height = bufferedHeight; @@ -129,7 +129,7 @@ $.extend( $.TmsTileSource.prototype, $.TileSource.prototype, /** @lends OpenSead // Convert from Deep Zoom definition to TMS zoom definition var yTiles = this.getNumTiles( level ).y - 1; - return this.tilesUrl + level + "/" + x + "/" + (yTiles - y) + ".png"; + return this.tilesUrl + level + "/" + x + "/" + (yTiles - y) + ".png"; } }); diff --git a/src/viewer.js b/src/viewer.js index 06b224e0..cea725a3 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -221,7 +221,7 @@ $.Viewer = function( options ) { $.ControlDock.call( this, options ); //Deal with tile sources - if ( this.xmlPath ){ + if (this.xmlPath) { //Deprecated option. Now it is preferred to use the tileSources option this.tileSources = [ this.xmlPath ]; } @@ -268,7 +268,7 @@ $.Viewer = function( options ) { this.innerTracker = new $.MouseTracker({ element: this.canvas, - startDisabled: this.mouseNavEnabled ? false : true, + startDisabled: !this.mouseNavEnabled, clickTimeThreshold: this.clickTimeThreshold, clickDistThreshold: this.clickDistThreshold, dblClickTimeThreshold: this.dblClickTimeThreshold, @@ -291,7 +291,7 @@ $.Viewer = function( options ) { this.outerTracker = new $.MouseTracker({ element: this.container, - startDisabled: this.mouseNavEnabled ? false : true, + startDisabled: !this.mouseNavEnabled, clickTimeThreshold: this.clickTimeThreshold, clickDistThreshold: this.clickDistThreshold, dblClickTimeThreshold: this.dblClickTimeThreshold, @@ -674,7 +674,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, this.navigator.close(); } - if( ! this.preserveOverlays) { + if (!this.preserveOverlays) { this.clearOverlays(); this.overlaysContainer.innerHTML = ""; } @@ -869,7 +869,6 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, bodyStyle = body.style, docStyle = document.documentElement.style, _this = this, - hash, nodes, i; @@ -1031,9 +1030,9 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, $.setPageScroll( _this.pageScroll ); var pageScroll = $.getPageScroll(); restoreScrollCounter++; - if ( restoreScrollCounter < 10 && - pageScroll.x !== _this.pageScroll.x || - pageScroll.y !== _this.pageScroll.y ) { + if (restoreScrollCounter < 10 && + (pageScroll.x !== _this.pageScroll.x || + pageScroll.y !== _this.pageScroll.y)) { $.requestAnimationFrame( restoreScroll ); } }; @@ -1526,7 +1525,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, onNextHandler = $.delegate( this, onNext ), onPreviousHandler = $.delegate( this, onPrevious ), navImages = this.navImages, - useGroup = true ; + useGroup = true; if( this.showSequenceControl ){ @@ -1622,7 +1621,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, onBlurHandler = $.delegate( this, onBlur ), navImages = this.navImages, buttons = [], - useGroup = true ; + useGroup = true; if ( this.showNavigationControl ) { @@ -1993,7 +1992,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, element = $.getElement( element ); i = getOverlayIndex( this.currentOverlays, element ); - if (i>=0) { + if (i >= 0) { return this.currentOverlays[i]; } else { return null; diff --git a/src/viewport.js b/src/viewport.js index 4cac87c3..7d5418bd 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -60,11 +60,11 @@ $.Viewport = function( options ) { //backward compatibility for positional args while prefering more //idiomatic javascript options object as the only argument var args = arguments; - if( args.length && args[ 0 ] instanceof $.Point ){ + if (args.length && args[0] instanceof $.Point) { options = { - containerSize: args[ 0 ], - contentSize: args[ 1 ], - config: args[ 2 ] + containerSize: args[0], + contentSize: args[1], + config: args[2] }; } diff --git a/src/world.js b/src/world.js index e68590b3..213aeaaa 100644 --- a/src/world.js +++ b/src/world.js @@ -212,7 +212,8 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W // We need to make sure any pending images are canceled so the world items don't get messed up this.viewer._cancelPendingImages(); var item; - for (var i = 0; i < this._items.length; i++) { + var i; + for (i = 0; i < this._items.length; i++) { item = this._items[i]; item.removeHandler('bounds-change', this._delegatedFigureSizes); item.removeHandler('clip-change', this._delegatedFigureSizes);