From 37dcc3e21df5f1373ff9963217073a9faecfc057 Mon Sep 17 00:00:00 2001 From: Jo Liss Date: Mon, 27 Feb 2012 01:49:51 +0100 Subject: Protect all copyright notices against minification For instance, this is useful for the jquery-ui-rails gem, which does not use jQuery UI's own minification, but relies on Rails to minify the files where necessary. Rails in turn uses UglifyJS for JS and YUI for CSS, both of which respect the /*! ... */ convention. --- ui/jquery.effects.explode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/jquery.effects.explode.js') diff --git a/ui/jquery.effects.explode.js b/ui/jquery.effects.explode.js index 08908d3eb..d030efc70 100644 --- a/ui/jquery.effects.explode.js +++ b/ui/jquery.effects.explode.js @@ -1,4 +1,4 @@ -/* +/*! * jQuery UI Effects Explode @VERSION * * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) -- cgit v1.2.3 From 639afa595465f6a1f61e080f2b671af4aac69b4a Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 2 Apr 2012 19:12:21 -0400 Subject: Lint fixes. --- ui/jquery.effects.core.js | 74 +++++++++++++++++++++++++++----------------- ui/jquery.effects.explode.js | 16 +++++----- ui/jquery.effects.fold.js | 5 +-- ui/jquery.effects.scale.js | 37 ++++++++++++---------- ui/jquery.effects.shake.js | 5 ++- ui/jquery.effects.slide.js | 4 +-- ui/jquery.ui.accordion.js | 36 +++++++++++---------- ui/jquery.ui.autocomplete.js | 8 ++--- ui/jquery.ui.button.js | 9 +++--- ui/jquery.ui.core.js | 20 ++++++------ ui/jquery.ui.dialog.js | 45 ++++++++++++++------------- ui/jquery.ui.menu.js | 42 +++++++++++++------------ ui/jquery.ui.mouse.js | 6 ++-- ui/jquery.ui.progressbar.js | 4 +-- ui/jquery.ui.slider.js | 5 +-- ui/jquery.ui.tabs.js | 33 ++++++++++++-------- ui/jquery.ui.tooltip.js | 2 +- ui/jquery.ui.widget.js | 20 ++++++------ 18 files changed, 207 insertions(+), 164 deletions(-) (limited to 'ui/jquery.effects.explode.js') diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js index 62d6b2c38..1d56ae62f 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -7,9 +7,11 @@ * * http://docs.jquery.com/UI/Effects/ */ -;jQuery.effects || (function($, undefined) { +;(jQuery.effects || (function($, undefined) { -var backCompat = $.uiBackCompat !== false; +var backCompat = $.uiBackCompat !== false, + // prefix used for storing data on .data() + dataSpace = "ui-effects-"; $.effects = { effect: {} @@ -18,6 +20,7 @@ $.effects = { /******************************************************************************/ /****************************** COLOR ANIMATIONS ******************************/ /******************************************************************************/ +(function() { // override the animation for color styles $.each(["backgroundColor", "borderBottomColor", "borderLeftColor", @@ -46,28 +49,34 @@ function getRGB(color) { var result; // Check if we're already dealing with an array of colors - if ( color && color.constructor === Array && color.length === 3 ) - return color; + if ( color && color.constructor === Array && color.length === 3 ) { + return color; + } // Look for rgb(num,num,num) - if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) - return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)]; + if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) { + return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)]; + } // Look for rgb(num%,num%,num%) - if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) - return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55]; + if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) { + return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55]; + } // Look for #a0b1c2 - if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) - return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)]; + if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) { + return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)]; + } // Look for #fff - if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) - return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)]; + if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) { + return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)]; + } // Look for rgba(0, 0, 0, 0) == transparent in Safari 3 - if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) - return colors["transparent"]; + if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) { + return colors.transparent; + } // Otherwise, we're most likely dealing with a named color return colors[$.trim(color).toLowerCase()]; @@ -80,14 +89,15 @@ function getColor(elem, attr) { color = $.css(elem, attr); // Keep going until we find an element that has color, or we hit the body - if ( color != "" && color !== "transparent" || $.nodeName(elem, "body") ) - break; + if ( color && color !== "transparent" || $.nodeName(elem, "body") ) { + break; + } attr = "backgroundColor"; } while ( elem = elem.parentNode ); return getRGB(color); -}; +} // Some named colors to work with // From Interface by Stefan Petre @@ -140,11 +150,12 @@ var colors = { transparent: [255,255,255] }; - +})(); /******************************************************************************/ /****************************** CLASS ANIMATIONS ******************************/ /******************************************************************************/ +(function() { var classAnimationActions = [ "add", "remove", "toggle" ], shorthandStyles = { @@ -157,9 +168,7 @@ var classAnimationActions = [ "add", "remove", "toggle" ], borderWidth: 1, margin: 1, padding: 1 - }, - // prefix used for storing data on .data() - dataSpace = "ui-effects-"; + }; $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { $.fx.step[ prop ] = function( fx ) { @@ -206,7 +215,7 @@ function styleDifference( oldStyle, newStyle ) { for ( name in newStyle ) { value = newStyle[ name ]; - if ( oldStyle[ name ] != value ) { + if ( oldStyle[ name ] !== value ) { if ( !shorthandStyles[ name ] ) { if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { diff[ name ] = value; @@ -332,12 +341,14 @@ $.fn.extend({ } }); - +})(); /******************************************************************************/ /*********************************** EFFECTS **********************************/ /******************************************************************************/ +(function() { + $.extend( $.effects, { version: "@VERSION", @@ -473,9 +484,11 @@ $.extend( $.effects, { setTransition: function( element, list, factor, value ) { value = value || {}; - $.each( list, function(i, x){ + $.each( list, function( i, x ) { var unit = element.cssUnit( x ); - if ( unit[ 0 ] > 0 ) value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; + if ( unit[ 0 ] > 0 ) { + value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; + } }); return value; } @@ -651,19 +664,22 @@ $.fn.extend({ val = []; $.each( [ "em", "px", "%", "pt" ], function( i, unit ) { - if ( style.indexOf( unit ) > 0 ) + if ( style.indexOf( unit ) > 0 ) { val = [ parseFloat( style ), unit ]; + } }); return val; } }); - +})(); /******************************************************************************/ /*********************************** EASING ***********************************/ /******************************************************************************/ +(function() { + // based on easing equations from Robert Penner (http://www.robertpenner.com/easing) var baseEasings = {}; @@ -709,4 +725,6 @@ $.each( baseEasings, function( name, easeIn ) { }; }); -})(jQuery); +})(); + +})(jQuery)); diff --git a/ui/jquery.effects.explode.js b/ui/jquery.effects.explode.js index d030efc70..ae3efb21e 100644 --- a/ui/jquery.effects.explode.js +++ b/ui/jquery.effects.explode.js @@ -31,6 +31,14 @@ $.effects.effect.explode = function( o, done ) { // loop i, j, left, top, mx, my; + // children animate complete: + function childComplete() { + pieces.push( this ); + if ( pieces.length === rows * cells ) { + animComplete(); + } + } + // clone the element for each row and cell. for( i = 0; i < rows ; i++ ) { // ===> top = offset.top + i * height; @@ -73,14 +81,6 @@ $.effects.effect.explode = function( o, done ) { } } - // children animate complete: - function childComplete() { - pieces.push( this ); - if ( pieces.length == rows * cells ) { - animComplete(); - } - } - function animComplete() { el.css({ visibility: "visible" diff --git a/ui/jquery.effects.fold.js b/ui/jquery.effects.fold.js index f33c2d050..17aa9a36b 100644 --- a/ui/jquery.effects.fold.js +++ b/ui/jquery.effects.fold.js @@ -23,11 +23,12 @@ $.effects.effect.fold = function( o, done ) { size = o.size || 15, percent = /([0-9]+)%/.exec( size ), horizFirst = !!o.horizFirst, - widthFirst = show != horizFirst, + widthFirst = show !== horizFirst, ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ], duration = o.duration / 2, wrapper, distance, - animation1 = {}, animation2 = {}; + animation1 = {}, + animation2 = {}; $.effects.save( el, props ); el.show(); diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index 63b95275c..83b41d3c2 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -47,7 +47,8 @@ $.effects.effect.scale = function( o, done ) { var el = $( this ), options = $.extend( true, {}, o ), mode = $.effects.setMode( el, o.mode || "effect" ), - percent = parseInt( o.percent, 10 ) || ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode == "hide" ? 0 : 100 ) ), + percent = parseInt( o.percent, 10 ) || + ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ), direction = o.direction || "both", origin = o.origin, original = { @@ -57,8 +58,8 @@ $.effects.effect.scale = function( o, done ) { outerWidth: el.outerWidth() }, factor = { - y: direction != "horizontal" ? (percent / 100) : 1, - x: direction != "vertical" ? (percent / 100) : 1 + y: direction !== "horizontal" ? (percent / 100) : 1, + x: direction !== "vertical" ? (percent / 100) : 1 }; // We are going to pass this effect to the size effect: @@ -67,12 +68,12 @@ $.effects.effect.scale = function( o, done ) { options.complete = done; // Set default origin and restore for show/hide - if ( mode != "effect" ) { + if ( mode !== "effect" ) { options.origin = origin || ["middle","center"]; options.restore = true; } - options.from = o.from || ( mode == "show" ? { height: 0, width: 0 } : original ); + options.from = o.from || ( mode === "show" ? { height: 0, width: 0 } : original ); options.to = { height: original.height * factor.y, width: original.width * factor.x, @@ -82,11 +83,11 @@ $.effects.effect.scale = function( o, done ) { // Fade option to support puff if ( options.fade ) { - if ( mode == "show" ) { + if ( mode === "show" ) { options.from.opacity = 0; options.to.opacity = 1; } - if ( mode == "hide" ) { + if ( mode === "hide" ) { options.from.opacity = 1; options.to.opacity = 0; } @@ -146,7 +147,7 @@ $.effects.effect.size = function( o, done ) { }; // Scale the css box - if ( scale == "box" || scale == "both" ) { + if ( scale === "box" || scale === "both" ) { // Vertical props scaling if ( factor.from.y !== factor.to.y ) { @@ -164,7 +165,7 @@ $.effects.effect.size = function( o, done ) { } // Scale the content - if ( scale == "content" || scale == "both" ) { + if ( scale === "content" || scale === "both" ) { // Vertical props scaling if ( factor.from.y !== factor.to.y ) { @@ -190,7 +191,7 @@ $.effects.effect.size = function( o, done ) { el.css( el.from ); // set top & left // Animate - if ( scale == "content" || scale == "both" ) { // Scale the children + if ( scale === "content" || scale === "both" ) { // Scale the children // Add margins/font-size vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps); @@ -203,8 +204,10 @@ $.effects.effect.size = function( o, done ) { height: child.height(), width: child.width() }; - if (restore) $.effects.save(child, props2); - + if (restore) { + $.effects.save(child, props2); + } + child.from = { height: c_original.height * factor.from.y, width: c_original.width * factor.from.x @@ -215,13 +218,13 @@ $.effects.effect.size = function( o, done ) { }; // Vertical props scaling - if ( factor.from.y != factor.to.y ) { + if ( factor.from.y !== factor.to.y ) { child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from ); child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to ); } // Horizontal props scaling - if ( factor.from.x != factor.to.x ) { + if ( factor.from.x !== factor.to.x ) { child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from ); child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to ); } @@ -231,7 +234,9 @@ $.effects.effect.size = function( o, done ) { child.animate( child.to, o.duration, o.easing, function() { // Restore children - if (restore) $.effects.restore( child, props2 ); + if ( restore ) { + $.effects.restore( child, props2 ); + } }); }); } @@ -245,7 +250,7 @@ $.effects.effect.size = function( o, done ) { if ( el.to.opacity === 0 ) { el.css( "opacity", el.from.opacity ); } - if( mode == "hide" ) { + if( mode === "hide" ) { el.hide(); } $.effects.restore( el, restore ? props : props1 ); diff --git a/ui/jquery.effects.shake.js b/ui/jquery.effects.shake.js index c6276d15e..700c6df3d 100644 --- a/ui/jquery.effects.shake.js +++ b/ui/jquery.effects.shake.js @@ -22,8 +22,8 @@ $.effects.effect.shake = function( o, done ) { times = o.times || 3, anims = times * 2 + 1, speed = o.duration, - ref = (direction == "up" || direction == "down") ? "top" : "left", - positiveMotion = (direction == "up" || direction == "left"), + ref = (direction === "up" || direction === "down") ? "top" : "left", + positiveMotion = (direction === "up" || direction === "left"), animation = {}, animation1 = {}, animation2 = {}, @@ -32,7 +32,6 @@ $.effects.effect.shake = function( o, done ) { // we will need to re-assemble the queue to stack our animations in place queue = el.queue(), queuelen = queue.length; - $.effects.save( el, props ); el.show(); diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js index 5c8eb2566..77d540a9c 100644 --- a/ui/jquery.effects.slide.js +++ b/ui/jquery.effects.slide.js @@ -20,8 +20,8 @@ $.effects.effect.slide = function( o, done ) { mode = $.effects.setMode( el, o.mode || "show" ), show = mode === "show", direction = o.direction || "left", - ref = (direction == "up" || direction == "down") ? "top" : "left", - positiveMotion = (direction == "up" || direction == "left"), + ref = (direction === "up" || direction === "down") ? "top" : "left", + positiveMotion = (direction === "up" || direction === "left"), distance, animation = {}, size; diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 92245d28e..00ecd1b64 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -12,7 +12,22 @@ * jquery.ui.widget.js */ (function( $, undefined ) { - var uid = 0; + var uid = 0, + hideProps = {}, + showProps = {}, + showPropsAdjust = {}; + +hideProps.height = hideProps.paddingTop = hideProps.paddingBottom = + hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide"; +showProps.height = showProps.paddingTop = showProps.paddingBottom = + showProps.borderTopWidth = showProps.borderBottomWidth = "show"; +$.extend( showPropsAdjust, showProps, { accordionHeight: "show" } ); + +$.fx.step.accordionHeight = function( fx ) { + var elem = $( fx.elem ), + data = elem.data( "ui-accordion-height" ); + elem.height( data.total - elem.outerHeight() - data.toHide.outerHeight() + elem.height() ); +}; $.widget( "ui.accordion", { version: "@VERSION", @@ -151,7 +166,8 @@ $.widget( "ui.accordion", { }, _destroy: function() { - var accordionId = this.accordionId; + var contents, + accordionId = this.accordionId; // clean up main element this.element @@ -173,7 +189,7 @@ $.widget( "ui.accordion", { this._destroyIcons(); // clean up content panels - var contents = this.headers.next() + contents = this.headers.next() .css( "display", "" ) .removeAttr( "role" ) .removeAttr( "aria-expanded" ) @@ -514,20 +530,6 @@ $.widget( "ui.accordion", { } }); -$.fx.step.accordionHeight = function( fx ) { - var elem = $( fx.elem ), - data = elem.data( "ui-accordion-height" ); - elem.height( data.total - elem.outerHeight() - data.toHide.outerHeight() + elem.height() ); -}; -var hideProps = {}, - showProps = {}, - showPropsAdjust = {}; -hideProps.height = hideProps.paddingTop = hideProps.paddingBottom = - hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide"; -showProps.height = showProps.paddingTop = showProps.paddingBottom = - showProps.borderTopWidth = showProps.borderBottomWidth = "show"; -$.extend( showPropsAdjust, showProps, { accordionHeight: "show" } ); - // DEPRECATED diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 07992ab2e..5ec5790ed 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -1,4 +1,4 @@ -/*! +/* * jQuery UI Autocomplete @VERSION * * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) @@ -108,7 +108,7 @@ $.widget( "ui.autocomplete", { suppressKeyPress = true; event.preventDefault(); } - // passthrough - ENTER and TAB both select the current element + //passthrough - ENTER and TAB both select the current element case keyCode.TAB: if ( !self.menu.active ) { return; @@ -238,7 +238,7 @@ $.widget( "ui.autocomplete", { select: function( event, ui ) { // back compat for _renderItem using item.autocomplete, via #7810 // TODO remove the fallback, see #8156 - var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ); + var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ), previous = self.previous; // only trigger when focus was lost (click on menu) @@ -270,7 +270,7 @@ $.widget( "ui.autocomplete", { .data( "menu" ); if ( $.fn.bgiframe ) { - this.menu.element.bgiframe(); + this.menu.element.bgiframe(); } // turning off autocomplete prevents the browser from remembering the diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 701cb44d8..f84d748cf 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -186,7 +186,7 @@ $.widget( "ui.button", { if ( options.disabled ) { return false; } - if ( event.keyCode == $.ui.keyCode.SPACE || event.keyCode == $.ui.keyCode.ENTER ) { + if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) { $( this ).addClass( "ui-state-active" ); } }) @@ -212,6 +212,7 @@ $.widget( "ui.button", { }, _determineButtonType: function() { + var ancestor, labelSelector, checked; if ( this.element.is(":checkbox") ) { this.type = "checkbox"; @@ -226,8 +227,8 @@ $.widget( "ui.button", { if ( this.type === "checkbox" || this.type === "radio" ) { // we don't search against the document in case the element // is disconnected from the DOM - var ancestor = this.element.parents().last(), - labelSelector = "label[for='" + this.element.attr("id") + "']"; + ancestor = this.element.parents().last(); + labelSelector = "label[for='" + this.element.attr("id") + "']"; this.buttonElement = ancestor.find( labelSelector ); if ( !this.buttonElement.length ) { ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings(); @@ -238,7 +239,7 @@ $.widget( "ui.button", { } this.element.addClass( "ui-helper-hidden-accessible" ); - var checked = this.element.is( ":checked" ); + checked = this.element.is( ":checked" ); if ( checked ) { this.buttonElement.addClass( "ui-state-active" ); } diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index f66b71c6e..93353996e 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -165,11 +165,11 @@ $.each( [ "Width", "Height" ], function( i, name ) { // selectors function focusable( element, isTabIndexNotNaN ) { - var nodeName = element.nodeName.toLowerCase(); + var map, mapName, img, + nodeName = element.nodeName.toLowerCase(); if ( "area" === nodeName ) { - var map = element.parentNode, - mapName = map.name, - img; + map = element.parentNode; + mapName = map.name; if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { return false; } @@ -178,7 +178,7 @@ function focusable( element, isTabIndexNotNaN ) { } return ( /input|select|textarea|button|object/.test( nodeName ) ? !element.disabled : - "a" == nodeName ? + "a" === nodeName ? element.href || isTabIndexNotNaN : isTabIndexNotNaN) && // the element and all of its ancestors must be visible @@ -242,19 +242,21 @@ $.extend( $.ui, { // $.ui.plugin is deprecated. Use the proxy pattern instead. plugin: { add: function( module, option, set ) { - var proto = $.ui[ module ].prototype; - for ( var i in set ) { + var i, + proto = $.ui[ module ].prototype; + for ( i in set ) { proto.plugins[ i ] = proto.plugins[ i ] || []; proto.plugins[ i ].push( [ option, set[ i ] ] ); } }, call: function( instance, name, args ) { - var set = instance.plugins[ name ]; + var i, + set = instance.plugins[ name ]; if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) { return; } - for ( var i = 0; i < set.length; i++ ) { + for ( i = 0; i < set.length; i++ ) { if ( instance.options[ set[ i ][ 0 ] ] ) { set[ i ][ 1 ].apply( instance.element, args ); } diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 053b26ab8..3a9bd5dc6 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -201,13 +201,13 @@ $.widget("ui.dialog", { }, close: function( event ) { - if ( !this._isOpen ) { - return self; - } - var self = this, maxZ, thisZ; + if ( !this._isOpen ) { + return; + } + if ( false === self._trigger( "beforeClose", event ) ) { return; } @@ -292,7 +292,8 @@ $.widget("ui.dialog", { return; } - var self = this, + var hasFocus, + self = this, options = self.options, uiDialog = self.uiDialog; @@ -325,7 +326,7 @@ $.widget("ui.dialog", { // set focus to the first tabbable element in the content area or the first button // if there are no tabbable elements, set focus on the dialog itself - var hasFocus = self.element.find( ":tabbable" ); + hasFocus = self.element.find( ":tabbable" ); if ( !hasFocus.length ) { hasFocus = uiDialog.find( ".ui-dialog-buttonpane :tabbable" ); if ( !hasFocus.length ) { @@ -341,7 +342,8 @@ $.widget("ui.dialog", { }, _createButtons: function( buttons ) { - var self = this, + var uiDialogButtonPane, uiButtonSet, + self = this, hasButtons = false; // if we already have a button pane, remove it @@ -353,11 +355,11 @@ $.widget("ui.dialog", { }); } if ( hasButtons ) { - var uiDialogButtonPane = $( "
" ) - .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ), - uiButtonSet = $( "
" ) - .addClass( "ui-dialog-buttonset" ) - .appendTo( uiDialogButtonPane ); + uiDialogButtonPane = $( "
" ) + .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ); + uiButtonSet = $( "
" ) + .addClass( "ui-dialog-buttonset" ) + .appendTo( uiDialogButtonPane ); $.each( buttons, function( name, props ) { props = $.isFunction( props ) ? @@ -547,7 +549,8 @@ $.widget("ui.dialog", { }, _setOption: function( key, value ) { - var self = this, + var isDraggable, isResizable, + self = this, uiDialog = self.uiDialog; switch ( key ) { @@ -571,7 +574,7 @@ $.widget("ui.dialog", { } break; case "draggable": - var isDraggable = uiDialog.is( ":data(draggable)" ); + isDraggable = uiDialog.is( ":data(draggable)" ); if ( isDraggable && !value ) { uiDialog.draggable( "destroy" ); } @@ -585,7 +588,7 @@ $.widget("ui.dialog", { break; case "resizable": // currently resizable, becoming non-resizable - var isResizable = uiDialog.is( ":data(resizable)" ); + isResizable = uiDialog.is( ":data(resizable)" ); if ( isResizable && !value ) { uiDialog.resizable( "destroy" ); } @@ -614,9 +617,8 @@ $.widget("ui.dialog", { /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content * divs will both have width and height set, so we need to reset them */ - var options = this.options, - nonContentHeight, - minContentHeight, + var nonContentHeight, minContentHeight, autoHeight, + options = this.options, isVisible = this.uiDialog.is( ":visible" ); // reset content sizing @@ -648,7 +650,7 @@ $.widget("ui.dialog", { }); } else { this.uiDialog.show(); - var autoHeight = this.element.css( "height", "auto" ).height(); + autoHeight = this.element.css( "height", "auto" ).height(); if ( !isVisible ) { this.uiDialog.hide(); } @@ -740,7 +742,9 @@ $.extend( $.ui.dialog.overlay, { }, destroy: function( $el ) { - var indexOf = $.inArray( $el, this.instances ); + var indexOf = $.inArray( $el, this.instances ), + maxZ = 0; + if ( indexOf !== -1 ) { this.oldInstances.push( this.instances.splice( indexOf, 1 )[ 0 ] ); } @@ -752,7 +756,6 @@ $.extend( $.ui.dialog.overlay, { $el.height( 0 ).width( 0 ).remove(); // adjust the maxZ to allow other modal dialogs to continue to work (see #4309) - var maxZ = 0; $.each( this.instances, function() { maxZ = Math.max( maxZ, this.css( "z-index" ) ); }); diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 6d00f66ae..af22c19b0 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -85,9 +85,9 @@ $.widget( "ui.menu", { "mouseleave": "collapseAll", "mouseleave .ui-menu": "collapseAll", "focus": function( event ) { - var firstItem = this.element.children( ".ui-menu-item" ).not( ".ui-state-disabled" ).eq( 0 ); + var menu = this.element, + firstItem = menu.children( ".ui-menu-item" ).not( ".ui-state-disabled" ).eq( 0 ); if ( this._hasScroll() && !this.active ) { - var menu = this.element; menu.children().each( function() { var currentItem = $( this ); if ( currentItem.offset().top - menu.offset().top >= 0 ) { @@ -183,7 +183,7 @@ $.widget( "ui.menu", { character = String.fromCharCode( event.keyCode ), skip = false; - if (character == prev) { + if (character === prev) { skip = true; } else { character = prev + character; @@ -195,7 +195,7 @@ $.widget( "ui.menu", { return new RegExp("^" + escape(character), "i") .test( $( this ).children( "a" ).text() ); }); - match = skip && match.index(this.active.next()) != -1 ? this.active.nextAll(".ui-menu-item") : match; + match = skip && match.index(this.active.next()) !== -1 ? this.active.nextAll(".ui-menu-item") : match; if ( !match.length ) { character = String.fromCharCode(event.keyCode); match = this.activeMenu.children(".ui-menu-item").filter( function() { @@ -260,15 +260,18 @@ $.widget( "ui.menu", { refresh: function() { // initialize nested menus - var submenus = this.element.find( this.options.menus + ":not( .ui-menu )" ) - .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) - .attr( "role", "menu" ) - .hide() - .attr( "aria-hidden", "true" ) - .attr( "aria-expanded", "false" ); + var menuId, + submenus = this.element.find( this.options.menus + ":not( .ui-menu )" ) + .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) + .hide() + .attr({ + role: "menu", + "aria-hidden": "true", + "aria-expanded": "false" + }); // don't refresh list items that are already adapted - var menuId = this.menuId; + menuId = this.menuId; submenus.add( this.element ).children( ":not( .ui-menu-item ):has( a )" ) .addClass( "ui-menu-item" ) .attr( "role", "presentation" ) @@ -291,15 +294,16 @@ $.widget( "ui.menu", { }, focus: function( event, item ) { + var nested, borderTop, paddingTop, offset, scroll, elementHeight, itemHeight; this.blur( event ); if ( this._hasScroll() ) { - var borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0, - paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0, - offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop, - scroll = this.activeMenu.scrollTop(), - elementHeight = this.activeMenu.height(), - itemHeight = item.height(); + borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0; + paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0; + offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop; + scroll = this.activeMenu.scrollTop(); + elementHeight = this.activeMenu.height(); + itemHeight = item.height(); if ( offset < 0 ) { this.activeMenu.scrollTop( scroll + offset ); @@ -321,7 +325,7 @@ $.widget( "ui.menu", { this._close(); }, this.delay ); - var nested = $( "> .ui-menu", item ); + nested = $( "> .ui-menu", item ); if ( nested.length && ( /^mouse/.test( event.type ) ) ) { this._startOpening(nested); } @@ -368,7 +372,7 @@ $.widget( "ui.menu", { var position = $.extend({}, { of: this.active - }, $.type(this.options.position) == "function" ? + }, $.type(this.options.position) === "function" ? this.options.position(this.active) : this.options.position ); diff --git a/ui/jquery.ui.mouse.js b/ui/jquery.ui.mouse.js index 53b3dcc20..eaa953ad0 100644 --- a/ui/jquery.ui.mouse.js +++ b/ui/jquery.ui.mouse.js @@ -61,10 +61,10 @@ $.widget("ui.mouse", { this._mouseDownEvent = event; var that = this, - btnIsLeft = (event.which == 1), + btnIsLeft = (event.which === 1), // event.target.nodeName works around a bug in IE 8 with // disabled inputs (#7620) - elIsCancel = (typeof this.options.cancel == "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false); + elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false); if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { return true; } @@ -134,7 +134,7 @@ $.widget("ui.mouse", { if (this._mouseStarted) { this._mouseStarted = false; - if (event.target == this._mouseDownEvent.target) { + if (event.target === this._mouseDownEvent.target) { $.data(event.target, this.widgetName + '.preventClickEvent', true); } diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 1504e5bca..68cccc554 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -85,8 +85,8 @@ $.widget( "ui.progressbar", { }, _refreshValue: function() { - var value = this.value(); - var percentage = this._percentage(); + var value = this.value(), + percentage = this._percentage(); if ( this.oldValue !== value ) { this.oldValue = value; diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index a8bdb1948..b355f8c7e 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -35,7 +35,8 @@ $.widget( "ui.slider", $.ui.mouse, { }, _create: function() { - var self = this, + var i, + self = this, o = this.options, existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ), handle = "", @@ -78,7 +79,7 @@ $.widget( "ui.slider", $.ui.mouse, { ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) ); } - for ( var i = existingHandles.length; i < handleCount; i += 1 ) { + for ( i = existingHandles.length; i < handleCount; i++ ) { handles.push( handle ); } diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 45888220d..68c182c31 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -20,13 +20,13 @@ function getNextTabId() { return ++tabId; } -var isLocal = function( anchor ) { +function isLocal( anchor ) { // clone the node to work around IE 6 not normalizing the href property // if it's manually set, i.e., a.href = "#foo" kills the normalization anchor = anchor.cloneNode( false ); return anchor.hash.length > 1 && anchor.href.replace( rhash, "" ) === location.href.replace( rhash, "" ); -}; +} $.widget( "ui.tabs", { version: "@VERSION", @@ -44,7 +44,8 @@ $.widget( "ui.tabs", { }, _create: function() { - var that = this, + var panel, + that = this, options = that.options, active = options.active; @@ -110,7 +111,7 @@ $.widget( "ui.tabs", { // check for length avoids error when initializing empty list if ( options.active !== false && this.anchors.length ) { this.active = this._findActive( options.active ); - var panel = that._getPanelForTab( this.active ); + panel = that._getPanelForTab( this.active ); panel.show(); this.lis.eq( options.active ).addClass( "ui-tabs-active ui-state-active" ); @@ -128,7 +129,7 @@ $.widget( "ui.tabs", { }, _setOption: function( key, value ) { - if ( key == "active" ) { + if ( key === "active" ) { // _activate() will handle invalid values and update this.options this._activate( value ); return; @@ -166,7 +167,8 @@ $.widget( "ui.tabs", { }, refresh: function() { - var self = this, + var next, + self = this, options = this.options, lis = this.list.children( ":has(a[href])" ); @@ -187,7 +189,7 @@ $.widget( "ui.tabs", { // was active, but active tab is gone } else if ( this.active.length && !$.contains( this.list[ 0 ], this.active[ 0 ] ) ) { // activate previous tab - var next = options.active - 1; + next = options.active - 1; this._activate( next >= 0 ? next : 0 ); // was active, active tab still exists } else { @@ -224,7 +226,7 @@ $.widget( "ui.tabs", { this.panels = $( [] ); this.anchors.each(function( i, a ) { - var selector, panel; + var selector, panel, id; // inline tab if ( isLocal( a ) ) { @@ -232,7 +234,7 @@ $.widget( "ui.tabs", { panel = self.element.find( self._sanitizeSelector( selector ) ); // remote tab } else { - var id = self._tabId( a ); + id = self._tabId( a ); selector = "#" + id; panel = self.element.find( selector ); if ( !panel.length ) { @@ -433,7 +435,7 @@ $.widget( "ui.tabs", { _getIndex: function( index ) { // meta-function to give users option to provide a href string instead of a numerical index. // also sanitizes numerical indexes to valid values. - if ( typeof index == "string" ) { + if ( typeof index === "string" ) { index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) ); } @@ -747,7 +749,8 @@ if ( $.uiBackCompat !== false ) { index = this.anchors.length; } - var options = this.options, + var doInsertAfter, panel, + options = this.options, li = $( options.tabTemplate .replace( /#\{href\}/g, url ) .replace( /#\{label\}/g, label ) ), @@ -758,10 +761,10 @@ if ( $.uiBackCompat !== false ) { li.addClass( "ui-state-default ui-corner-top" ).data( "ui-tabs-destroy", true ); li.find( "a" ).attr( "aria-controls", id ); - var doInsertAfter = index >= this.lis.length; + doInsertAfter = index >= this.lis.length; // try to find an existing element before creating a new one - var panel = this.element.find( "#" + id ); + panel = this.element.find( "#" + id ); if ( !panel.length ) { panel = this._createPanel( id ); if ( doInsertAfter ) { @@ -946,6 +949,8 @@ if ( $.uiBackCompat !== false ) { }); // cookie option + (function() { + var listId = 0; $.widget( "ui.tabs", $.ui.tabs, { @@ -993,6 +998,8 @@ if ( $.uiBackCompat !== false ) { } }); + })(); + // load event $.widget( "ui.tabs", $.ui.tabs, { _trigger: function( type, event, data ) { diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 46c5befaa..97895a6a8 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -159,7 +159,7 @@ $.widget( "ui.tooltip", { mouseleave: "close", focusout: "close", keyup: function( event ) { - if ( event.keyCode == $.ui.keyCode.ESCAPE ) { + if ( event.keyCode === $.ui.keyCode.ESCAPE ) { var fakeEvent = $.Event(event); fakeEvent.currentTarget = target[0]; this.close( fakeEvent, true ); diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 1b7405e28..3e3723398 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -9,9 +9,8 @@ */ (function( $, undefined ) { -var slice = Array.prototype.slice; - -var _cleanData = $.cleanData; +var slice = Array.prototype.slice, + _cleanData = $.cleanData; $.cleanData = function( elems ) { for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { try { @@ -73,11 +72,11 @@ $.widget = function( name, base, prototype ) { if ( $.isFunction( value ) ) { prototype[ prop ] = (function() { var _super = function() { - return base.prototype[ prop ].apply( this, arguments ); - }; - var _superApply = function( args ) { - return base.prototype[ prop ].apply( this, args ); - }; + return base.prototype[ prop ].apply( this, arguments ); + }, + _superApply = function( args ) { + return base.prototype[ prop ].apply( this, args ); + }; return function() { var __super = this._super, __superApply = this._superApply, @@ -163,7 +162,8 @@ $.widget.bridge = function( name, object ) { if ( isMethodCall ) { this.each(function() { - var instance = $.data( this, fullName ); + var methodValue, + instance = $.data( this, fullName ); if ( !instance ) { return $.error( "cannot call methods on " + name + " prior to initialization; " + "attempted to call method '" + options + "'" ); @@ -171,7 +171,7 @@ $.widget.bridge = function( name, object ) { if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) { return $.error( "no such method '" + options + "' for " + name + " widget instance" ); } - var methodValue = instance[ options ].apply( instance, args ); + methodValue = instance[ options ].apply( instance, args ); if ( methodValue !== instance && methodValue !== undefined ) { returnValue = methodValue && methodValue.jquery ? returnValue.pushStack( methodValue.get() ) : -- cgit v1.2.3