Merge pull request #1103 from avandecreme/eslint

Add eslint and hound
This commit is contained in:
Ian Gilman 2017-01-19 09:24:58 -08:00 committed by GitHub
commit cfc339edea
25 changed files with 716 additions and 120 deletions

285
.eslintrc.hound.json Normal file
View File

@ -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
}
}

285
.eslintrc.json Normal file
View File

@ -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
}
}

3
.hound.yml Normal file
View File

@ -0,0 +1,3 @@
eslint:
enabled: true
config_file: .eslintrc.hound.json

View File

@ -1,16 +0,0 @@
{
"browser": true,
"curly": true,
"eqeqeq": false,
"loopfunc": false,
"noarg": true,
"trailing": true,
"undef": true,
"unused": false,
"globals": {
"OpenSeadragon": true,
"define": false,
"module": false
}
}

View File

@ -5,12 +5,12 @@ module.exports = function(grunt) {
// ----------
grunt.loadNpmTasks("grunt-contrib-compress");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-qunit-istanbul");
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');
@ -187,12 +187,11 @@ module.exports = function(grunt) {
files: [ "Gruntfile.js", "src/*.js", "images/*" ],
tasks: "watchTask"
},
jshint: {
eslint: {
options: {
jshintrc: '.jshintrc'
configFile: '.eslintrc.json'
},
beforeconcat: sources,
afterconcat: [ distribution ]
target: sources
},
"git-describe": {
build: {}
@ -265,8 +264,8 @@ module.exports = function(grunt) {
// Build task.
// 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"
"clean:build", "git-describe", "eslint", "concat", "uglify",
"replace:cleanPaths", "copy:build"
]);
// ----------

View File

@ -20,10 +20,10 @@
"grunt-contrib-compress": "^0.13.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-connect": "^0.11.2",
"grunt-contrib-jshint": "^0.11.0",
"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"

View File

@ -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.

View File

@ -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";

View File

@ -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 );

View File

@ -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,

View File

@ -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<options.sizes.length; i++) {
for(var i = 0; i < options.sizes.length; i++) {
levels.push({
url: options['@id'] + '/full/' + options.sizes[i].width + ',/0/default.jpg',
width: options.sizes[i].width,
height: options.sizes[i].height
});
}
return levels.sort(function(a,b){return a.width - b.width;});
return levels.sort(function(a, b) {
return a.width - b.width;
});
}

View File

@ -217,7 +217,7 @@ function filterFiles( files ){
}
}
return filtered.sort(function(a,b){
return filtered.sort(function(a, b) {
return a.height - b.height;
});
@ -253,7 +253,7 @@ function configureFromXML( tileSource, xmlDoc ){
for ( i = 0; i < levels.length; i++ ) {
level = levels[ i ];
conf.levels .push({
conf.levels.push({
url: level.getAttribute( "url" ),
width: parseInt( level.getAttribute( "width" ), 10 ),
height: parseInt( level.getAttribute( "height" ), 10 )

View File

@ -160,6 +160,7 @@
* @memberof OpenSeadragon.MouseTracker#
*/
this.dblClickDistThreshold = options.dblClickDistThreshold || $.DEFAULT_SETTINGS.dblClickDistThreshold;
/*eslint-disable no-multi-spaces*/
this.userData = options.userData || null;
this.stopDelay = options.stopDelay || 50;
@ -182,6 +183,7 @@
this.keyHandler = options.keyHandler || null;
this.focusHandler = options.focusHandler || null;
this.blurHandler = options.blurHandler || null;
/*eslint-enable no-multi-spaces*/
//Store private properties in a scope sealed hash map
var _this = this;
@ -1370,6 +1372,7 @@
eventParams = getCaptureEventParams( tracker, $.MouseTracker.havePointerEvents ? 'pointerevent' : pointerType );
// We emulate mouse capture by hanging listeners on the document object.
// (Note we listen on the capture phase so the captured handlers will get called first)
// eslint-disable-next-line no-use-before-define
if (isInIframe && canAccessEvents(window.top)) {
$.addEvent(
window.top,
@ -1413,6 +1416,7 @@
eventParams = getCaptureEventParams( tracker, $.MouseTracker.havePointerEvents ? 'pointerevent' : pointerType );
// We emulate mouse capture by hanging listeners on the document object.
// (Note we listen on the capture phase so the captured handlers will get called first)
// eslint-disable-next-line no-use-before-define
if (isInIframe && canAccessEvents(window.top)) {
$.removeEvent(
window.top,
@ -1703,7 +1707,7 @@
// Calculate deltaY
if ( $.MouseTracker.wheelEventName == "mousewheel" ) {
simulatedEvent.deltaY = - 1 / $.DEFAULT_SETTINGS.pixelsPerWheelLine * event.wheelDelta;
simulatedEvent.deltaY = -event.wheelDelta / $.DEFAULT_SETTINGS.pixelsPerWheelLine;
} else {
simulatedEvent.deltaY = event.detail;
}
@ -2207,11 +2211,8 @@
* @inner
*/
function onTouchCancel( tracker, event ) {
var i,
touchCount = event.changedTouches.length,
gPoints = [],
pointsList = tracker.getActivePointersListByType( 'touch' );
var pointsList = tracker.getActivePointersListByType('touch');
abortTouchContacts( tracker, event, pointsList );
}
@ -2565,8 +2566,7 @@
* Gesture points associated with the event.
*/
function updatePointersExit( tracker, event, gPoints ) {
var delegate = THIS[ tracker.hash ],
pointsList = tracker.getActivePointersListByType( gPoints[ 0 ].type ),
var pointsList = tracker.getActivePointersListByType(gPoints[0].type),
i,
gPointCount = gPoints.length,
curGPoint,
@ -2801,7 +2801,6 @@
var delegate = THIS[ tracker.hash ],
pointsList = tracker.getActivePointersListByType( gPoints[ 0 ].type ),
propagate,
insideElementReleased,
releasePoint,
releaseTime,
i,
@ -2866,7 +2865,7 @@
{
eventSource: tracker,
pointerType: gPoints[ 0 ].type,
position: getPointRelativeToAbsolute( gPoints[ 0 ].currentPos, tracker.element ),
position: getPointRelativeToAbsolute(gPoints[0].currentPos, tracker.element),
button: buttonChanged,
buttons: pointsList.buttons,
isTouchEvent: gPoints[ 0 ].type === 'touch',
@ -3267,7 +3266,7 @@
} );
}
}
// True if inside an iframe, otherwise false.
// @member {Boolean} isInIframe
// @private
@ -3279,7 +3278,7 @@
return true;
}
})();
// @function
// @private
// @inner
@ -3292,4 +3291,4 @@
}
}
} ( OpenSeadragon ) );
}(OpenSeadragon));

View File

@ -121,7 +121,7 @@ $.Navigator = function( options ){
//At some browser magnification levels the display regions lines up correctly, but at some there appears to
//be a one pixel gap.
this.fudge = new $.Point(1, 1);
this.totalBorderWidths = new $.Point(this.borderWidth*2, this.borderWidth*2).minus(this.fudge);
this.totalBorderWidths = new $.Point(this.borderWidth * 2, this.borderWidth * 2).minus(this.fudge);
if ( options.controlOptions.anchor != $.ControlAnchor.NONE ) {
@ -180,8 +180,8 @@ $.Navigator = function( options ){
if ( this._resizeWithViewer ) {
if ( options.width && options.height ) {
this.element.style.height = typeof ( options.height ) == "number" ? ( options.height + 'px' ) : options.height;
this.element.style.width = typeof ( options.width ) == "number" ? ( options.width + 'px' ) : options.width;
this.element.style.height = typeof (options.height) == "number" ? (options.height + 'px') : options.height;
this.element.style.width = typeof (options.width) == "number" ? (options.width + 'px') : options.width;
} else {
viewerSize = $.getElementSize( viewer.element );
this.element.style.height = Math.round( viewerSize.y * options.sizeRatio ) + 'px';

View File

@ -859,7 +859,7 @@ function OpenSeadragon( options ){
try {
// We test if the canvas is tainted by retrieving data from it.
// An exception will be raised if the canvas is tainted.
var data = canvas.getContext('2d').getImageData(0, 0, 1, 1);
canvas.getContext('2d').getImageData(0, 0, 1, 1);
} catch (e) {
isTainted = true;
}
@ -1026,10 +1026,46 @@ function OpenSeadragon( options ){
dblClickDistThreshold: 20,
springStiffness: 6.5,
animationTime: 1.2,
gestureSettingsMouse: { scrollToZoom: true, clickToZoom: true, dblClickToZoom: false, pinchToZoom: false, flickEnabled: false, flickMinSpeed: 120, flickMomentum: 0.25, pinchRotate: false },
gestureSettingsTouch: { scrollToZoom: false, clickToZoom: false, dblClickToZoom: true, pinchToZoom: true, flickEnabled: true, flickMinSpeed: 120, flickMomentum: 0.25, pinchRotate: false },
gestureSettingsPen: { scrollToZoom: false, clickToZoom: true, dblClickToZoom: false, pinchToZoom: false, flickEnabled: false, flickMinSpeed: 120, flickMomentum: 0.25, pinchRotate: false },
gestureSettingsUnknown: { scrollToZoom: false, clickToZoom: false, dblClickToZoom: true, pinchToZoom: true, flickEnabled: true, flickMinSpeed: 120, flickMomentum: 0.25, pinchRotate: false },
gestureSettingsMouse: {
scrollToZoom: true,
clickToZoom: true,
dblClickToZoom: false,
pinchToZoom: false,
flickEnabled: false,
flickMinSpeed: 120,
flickMomentum: 0.25,
pinchRotate: false
},
gestureSettingsTouch: {
scrollToZoom: false,
clickToZoom: false,
dblClickToZoom: true,
pinchToZoom: true,
flickEnabled: true,
flickMinSpeed: 120,
flickMomentum: 0.25,
pinchRotate: false
},
gestureSettingsPen: {
scrollToZoom: false,
clickToZoom: true,
dblClickToZoom: false,
pinchToZoom: false,
flickEnabled: false,
flickMinSpeed: 120,
flickMomentum: 0.25,
pinchRotate: false
},
gestureSettingsUnknown: {
scrollToZoom: false,
clickToZoom: false,
dblClickToZoom: true,
pinchToZoom: true,
flickEnabled: true,
flickMinSpeed: 120,
flickMomentum: 0.25,
pinchRotate: false
},
zoomPerClick: 2,
zoomPerScroll: 1.2,
zoomPerSecond: 1.0,
@ -1504,7 +1540,7 @@ function OpenSeadragon( options ){
};
} else {
// We can't reassign the function yet, as there was no scroll.
return new $.Point(0,0);
return new $.Point(0, 0);
}
return $.getPageScroll();
@ -1672,13 +1708,15 @@ function OpenSeadragon( options ){
* @function
*/
now: function( ) {
if (Date.now) {
$.now = Date.now;
} else {
$.now = function() { return new Date().getTime(); };
}
if (Date.now) {
$.now = Date.now;
} else {
$.now = function() {
return new Date().getTime();
};
}
return $.now();
return $.now();
},
@ -1788,7 +1826,7 @@ function OpenSeadragon( options ){
addClass: function( element, className ) {
element = $.getElement( element );
if ( ! element.className ) {
if (!element.className) {
element.className = className;
} else if ( ( ' ' + element.className + ' ' ).
indexOf( ' ' + className + ' ' ) === -1 ) {
@ -2012,6 +2050,7 @@ function OpenSeadragon( options ){
* @returns {String} The value of the url parameter or null if no param matches.
*/
getUrlParameter: function( key ) {
// eslint-disable-next-line no-use-before-define
var value = URLPARAMS[ key ];
return value ? value : null;
},
@ -2169,7 +2208,7 @@ function OpenSeadragon( options ){
}
};
xdr.onerror = function (e) {
if ( $.isFunction ( onError ) ) {
if ($.isFunction(onError)) {
onError({ // Faking an xhr object
responseText: xdr.responseText,
status: 444, // 444 No Response
@ -2332,6 +2371,7 @@ function OpenSeadragon( options ){
// Should only be used by IE8 in non standards mode
$.parseJSON = function(string) {
/*jshint evil:true*/
//eslint-disable-next-line no-eval
return eval('(' + string + ')');
};
}
@ -2347,6 +2387,7 @@ function OpenSeadragon( options ){
*/
imageFormatSupported: function( extension ) {
extension = extension ? extension : "";
// eslint-disable-next-line no-use-before-define
return !!FILEFORMATS[ extension.toLowerCase() ];
}
@ -2383,8 +2424,7 @@ function OpenSeadragon( options ){
(function() {
//A small auto-executing routine to determine the browser vendor,
//version and supporting feature sets.
var app = navigator.appName,
ver = navigator.appVersion,
var ver = navigator.appVersion,
ua = navigator.userAgent,
regex;
@ -2406,7 +2446,7 @@ function OpenSeadragon( options ){
}
break;
case "Netscape":
if( !!window.addEventListener ){
if (window.addEventListener) {
if ( ua.indexOf( "Firefox" ) >= 0 ) {
$.Browser.vendor = $.BROWSERS.FIREFOX;
$.Browser.version = parseFloat(

View File

@ -592,6 +592,4 @@ function onKeyPress( event ) {
}
}
} ( OpenSeadragon ) );
}(OpenSeadragon));

View File

@ -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) {

View File

@ -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 ] ] || {};
}

View File

@ -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;
},
/**

View File

@ -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;
}
};

View File

@ -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));

View File

@ -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";
}
});

View File

@ -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;

View File

@ -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]
};
}

View File

@ -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);