diff --git a/Gruntfile.js b/Gruntfile.js index 41961061b61..7797b5c777c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -55,19 +55,6 @@ var }, component = grunt.option( "component" ) || "**", - jscsBad = [ - "ui/button.js", - "ui/datepicker.js", - "ui/draggable.js", - "ui/droppable.js", - "ui/effect.js", - "ui/mouse.js", - "ui/resizable.js", - "ui/selectable.js", - "ui/slider.js", - "ui/sortable.js" - ], - htmllintBad = [ "demos/tabs/ajax/content*.html", "demos/tooltip/ajax/content*.html", @@ -150,35 +137,13 @@ grunt.initConfig({ // Remove the requireSpacesInsideParentheses override once everything is fixed jscs: { - "ui-good": [ "ui/*.js" ].concat( jscsBad.map( function( file ) { - return "!" + file; - } ) ), - "ui-bad": { - options: { - requireSpacesInsideParentheses: null - }, - src: jscsBad - }, - tests: { - options: { - requireSpacesInsideParentheses: null - }, - src: "tests/unit/**/*.js" - }, - grunt: { - options: { - requireSpacesInsideParentheses: null - }, - src: [ "Gruntfile.js", "build/tasks/*.js" ] - }, - demos: { + all: { options: { - - // While the style guide removed onevar upgrading jscs to allow it causes too many - // errors right now - disallowMultipleVarDecl: null + requireCapitalizedComments: null }, - src: "demos/**/*.js" + files: { + src: [ "demos/**/*.js", "build/**/*.js", "tests/**/*.js", "ui/**/*.js" ] + } } }, uglify: minify, diff --git a/demos/bootstrap.js b/demos/bootstrap.js index 1b28a4dc659..b96620d6a77 100644 --- a/demos/bootstrap.js +++ b/demos/bootstrap.js @@ -1,4 +1,4 @@ -/* globals window:true, document:true */ +/* globals window, document */ ( function() { // Find the script element @@ -80,7 +80,6 @@ require.config( { } } ); - // Replace effects all shortcut modules with all the effects modules if ( modules && modules.indexOf( "effects-all" ) !== -1 ) { modules = modules.replace( /effects-all/, effectsAll.join( " " ) ); diff --git a/demos/droppable/photo-manager.html b/demos/droppable/photo-manager.html index 2b324c1e961..d576e652479 100644 --- a/demos/droppable/photo-manager.html +++ b/demos/droppable/photo-manager.html @@ -22,11 +22,11 @@ - // there's the gallery and the trash + // There's the gallery and the trash var $gallery = $( "#gallery" ), $trash = $( "#trash" ); - // let the gallery items be draggable + // Let the gallery items be draggable $( "li", $gallery ).draggable({ cancel: "a.ui-icon", // clicking an icon won't initiate dragging revert: "invalid", // when not dropped, the item will revert back to its initial position @@ -35,7 +35,7 @@ cursor: "move" }); - // let the trash be droppable, accepting the gallery items + // Let the trash be droppable, accepting the gallery items $trash.droppable({ accept: "#gallery > li", classes: { @@ -46,7 +46,7 @@ } }); - // let the gallery be droppable as well, accepting items from the trash + // Let the gallery be droppable as well, accepting items from the trash $gallery.droppable({ accept: "#trash li", classes: { @@ -57,7 +57,7 @@ } }); - // image deletion function + // Image deletion function var recycle_icon = "Recycle image"; function deleteImage( $item ) { $item.fadeOut(function() { @@ -75,7 +75,7 @@ }); } - // image recycle function + // Image recycle function var trash_icon = "Delete image"; function recycleImage( $item ) { $item.fadeOut(function() { @@ -93,7 +93,7 @@ }); } - // image preview function, demonstrating the ui.dialog used as a modal window + // Image preview function, demonstrating the ui.dialog used as a modal window function viewLargerImage( $link ) { var src = $link.attr( "href" ), title = $link.siblings( "img" ).attr( "alt" ), @@ -114,7 +114,7 @@ } } - // resolve the icons behavior with event delegation + // Resolve the icons behavior with event delegation $( "ul.gallery > li" ).on( "click", function( event ) { var $item = $( this ), $target = $( event.target ); diff --git a/demos/effect/default.html b/demos/effect/default.html index bd28652a6b3..59479539f45 100644 --- a/demos/effect/default.html +++ b/demos/effect/default.html @@ -19,7 +19,7 @@ // get effect type from var selectedEffect = $( "#effectTypes" ).val(); - // most effect types need no options passed by default + // Most effect types need no options passed by default var options = {}; // some effects have required parameters if ( selectedEffect === "scale" ) { @@ -30,18 +30,18 @@ options = { to: { width: 200, height: 60 } }; } - // run the effect + // Run the effect $( "#effect" ).effect( selectedEffect, options, 500, callback ); }; - // callback function to bring a hidden box back + // Callback function to bring a hidden box back function callback() { setTimeout(function() { $( "#effect" ).removeAttr( "style" ).hide().fadeIn(); }, 1000 ); }; - // set effect from select menu value + // Set effect from select menu value $( "#button" ).on( "click", function() { runEffect(); return false; diff --git a/demos/effect/easing.html b/demos/effect/easing.html index 5985dc69919..7d5f4b98281 100644 --- a/demos/effect/easing.html +++ b/demos/effect/easing.html @@ -37,7 +37,7 @@ ctx = canvas.getContext( "2d" ); ctx.fillStyle = "black"; - // draw background + // Draw background ctx.beginPath(); ctx.moveTo( cradius, 0 ); ctx.quadraticCurveTo( 0, 0, 0, cradius ); @@ -49,21 +49,21 @@ ctx.lineTo( cradius, 0 ); ctx.fill(); - // draw bottom line + // Draw bottom line ctx.strokeStyle = "#555"; ctx.beginPath(); ctx.moveTo( width * 0.1, drawHeight + .5 ); ctx.lineTo( width * 0.9, drawHeight + .5 ); ctx.stroke(); - // draw top line + // Draw top line ctx.strokeStyle = "#555"; ctx.beginPath(); ctx.moveTo( width * 0.1, drawHeight * .3 - .5 ); ctx.lineTo( width * 0.9, drawHeight * .3 - .5 ); ctx.stroke(); - // plot easing + // Plot easing ctx.strokeStyle = "white"; ctx.beginPath(); ctx.lineWidth = 2; @@ -76,7 +76,7 @@ }); ctx.stroke(); - // animate on click + // Animate on click graph.on( "click", function() { wrap .animate( { height: "hide" }, 2000, name ) diff --git a/demos/effect/hide.html b/demos/effect/hide.html index 1fcd6477e1f..38ac3e157f8 100644 --- a/demos/effect/hide.html +++ b/demos/effect/hide.html @@ -18,7 +18,7 @@ // get effect type from var selectedEffect = $( "#effectTypes" ).val(); - // most effect types need no options passed by default + // Most effect types need no options passed by default var options = {}; // some effects have required parameters if ( selectedEffect === "scale" ) { @@ -27,18 +27,18 @@ options = { to: { width: 200, height: 60 } }; } - // run the effect + // Run the effect $( "#effect" ).hide( selectedEffect, options, 1000, callback ); }; - // callback function to bring a hidden box back + // Callback function to bring a hidden box back function callback() { setTimeout(function() { $( "#effect" ).removeAttr( "style" ).hide().fadeIn(); }, 1000 ); }; - // set effect from select menu value + // Set effect from select menu value $( "#button" ).on( "click", function() { runEffect(); }); diff --git a/demos/effect/show.html b/demos/effect/show.html index 4bb0919e485..19a6cca973d 100644 --- a/demos/effect/show.html +++ b/demos/effect/show.html @@ -18,7 +18,7 @@ // get effect type from var selectedEffect = $( "#effectTypes" ).val(); - // most effect types need no options passed by default + // Most effect types need no options passed by default var options = {}; // some effects have required parameters if ( selectedEffect === "scale" ) { @@ -27,7 +27,7 @@ options = { to: { width: 280, height: 185 } }; } - // run the effect + // Run the effect $( "#effect" ).show( selectedEffect, options, 500, callback ); }; @@ -38,7 +38,7 @@ }, 1000 ); }; - // set effect from select menu value + // Set effect from select menu value $( "#button" ).on( "click", function() { runEffect(); }); diff --git a/demos/effect/toggle.html b/demos/effect/toggle.html index 65c4747a907..7ecf8c9c0dd 100644 --- a/demos/effect/toggle.html +++ b/demos/effect/toggle.html @@ -33,7 +33,7 @@ // get effect type from var selectedEffect = $( "#effectTypes" ).val(); - // most effect types need no options passed by default + // Most effect types need no options passed by default var options = {}; // some effects have required parameters if ( selectedEffect === "scale" ) { @@ -42,11 +42,11 @@ options = { to: { width: 200, height: 60 } }; } - // run the effect + // Run the effect $( "#effect" ).toggle( selectedEffect, options, 500 ); }; - // set effect from select menu value + // Set effect from select menu value $( "#button" ).on( "click", function() { runEffect(); }); diff --git a/demos/tabs/manipulation.html b/demos/tabs/manipulation.html index bb4bb34c7ca..e10621bf344 100644 --- a/demos/tabs/manipulation.html +++ b/demos/tabs/manipulation.html @@ -22,7 +22,7 @@ var tabs = $( "#tabs" ).tabs(); - // modal dialog init: custom buttons and a "close" callback resetting the form inside + // Modal dialog init: custom buttons and a "close" callback resetting the form inside var dialog = $( "#dialog" ).dialog({ autoOpen: false, modal: true, @@ -40,14 +40,14 @@ } }); - // addTab form: calls addTab function on submit and closes the dialog + // AddTab form: calls addTab function on submit and closes the dialog var form = dialog.find( "form" ).on( "submit", function( event ) { addTab(); dialog.dialog( "close" ); event.preventDefault(); }); - // actual addTab function: adds new tab using the input from the form above + // Actual addTab function: adds new tab using the input from the form above function addTab() { var label = tabTitle.val() || "Tab " + tabCounter, id = "tabs-" + tabCounter, @@ -60,14 +60,14 @@ tabCounter++; } - // addTab button: just opens the dialog + // AddTab button: just opens the dialog $( "#add_tab" ) .button() .on( "click", function() { dialog.dialog( "open" ); }); - // close icon: removing the tab on click + // Close icon: removing the tab on click tabs.on( "click", "span.ui-icon-close", function() { var panelId = $( this ).closest( "li" ).remove().attr( "aria-controls" ); $( "#" + panelId ).remove(); diff --git a/demos/widget/default.html b/demos/widget/default.html index e545ef6adf2..80a420db47f 100644 --- a/demos/widget/default.html +++ b/demos/widget/default.html @@ -30,12 +30,12 @@ green: 0, blue: 0, - // callbacks + // Callbacks change: null, random: null }, - // the constructor + // The constructor _create: function() { this.element // add a class for theming @@ -50,7 +50,7 @@ .appendTo( this.element ) .button(); - // bind click events on the changer button to the random method + // Bind click events on the changer button to the random method this._on( this.changer, { // _on won't call random when widget is disabled click: "random" @@ -58,7 +58,7 @@ this._refresh(); }, - // called when created, and later when changing options + // Called when created, and later when changing options _refresh: function() { this.element.css( "background-color", "rgb(" + this.options.red +"," + @@ -66,11 +66,11 @@ this.options.blue + ")" ); - // trigger a callback/event + // Trigger a callback/event this._trigger( "change" ); }, - // a public method to change the color to a random value + // A public method to change the color to a random value // can be called directly via .colorize( "random" ) random: function( event ) { var colors = { @@ -79,13 +79,13 @@ blue: Math.floor( Math.random() * 256 ) }; - // trigger an event, check if it's canceled + // Trigger an event, check if it's canceled if ( this._trigger( "random", event, colors ) !== false ) { this.option( colors ); } }, - // events bound via _on are removed automatically + // Events bound via _on are removed automatically // revert other modifications here _destroy: function() { // remove generated elements @@ -115,16 +115,16 @@ } }); - // initialize with default options + // Initialize with default options $( "#my-widget1" ).colorize(); - // initialize with two customized options + // Initialize with two customized options $( "#my-widget2" ).colorize({ red: 60, blue: 60 }); - // initialize with custom green value + // Initialize with custom green value // and a random callback to allow only colors with enough green $( "#my-widget3" ).colorize( { green: 128, @@ -133,7 +133,7 @@ } }); - // click to toggle enabled/disabled + // Click to toggle enabled/disabled $( "#disable" ).on( "click", function() { // use the custom selector created for each widget to find all instances // all instances are toggled together, so we can check the state from the first @@ -144,7 +144,7 @@ } }); - // click to set options after initialization + // Click to set options after initialization $( "#green" ).on( "click", function() { $( ":custom-colorize" ).colorize( "option", { red: 64, diff --git a/tests/index.js b/tests/index.js index 26c07498f0c..30771f79492 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,4 +1,4 @@ -$(function() { +$( function() { $( "#main" ) .addClass( "ui-widget" ) @@ -7,4 +7,4 @@ $( "#main" ) .next() .addClass( "ui-widget-content ui-corner-bottom" ); -}); +} ); diff --git a/tests/lib/bootstrap.js b/tests/lib/bootstrap.js index 47289494cc3..46e0e8ad291 100644 --- a/tests/lib/bootstrap.js +++ b/tests/lib/bootstrap.js @@ -1,6 +1,6 @@ ( function() { -requirejs.config({ +requirejs.config( { paths: { "globalize": "../../../external/globalize/globalize", "globalize/ja-JP": "../../../external/globalize/globalize.culture.ja-JP", @@ -12,7 +12,7 @@ requirejs.config({ "qunit-assert-classes": "../../../external/qunit-assert-classes/qunit-assert-classes", "qunit-assert-close": "../../../external/qunit-assert-close/qunit-assert-close", "qunit": "../../../external/qunit/qunit", - "testswarm": "http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime(), + "testswarm": "http://swarm.jquery.org/js/inject.js?" + ( new Date() ).getTime(), "ui": "../../../ui" }, shim: { @@ -21,7 +21,7 @@ requirejs.config({ "qunit-assert-close": [ "qunit" ], "testswarm": [ "qunit" ] } -}); +} ); // Create a module that disables back compat for UI modules define( "jquery-no-back-compat", [ "jquery" ], function( $ ) { @@ -108,7 +108,7 @@ function jqueryUrl() { // - Automatically loads common, core, events, methods, and options // - data-deprecated: Loads the deprecated test modules for a widget // - data-no-back-compat: Set $.uiBackCompat to false -(function() { +( function() { // Find the script element var scripts = document.getElementsByTagName( "script" ); @@ -128,13 +128,13 @@ function jqueryUrl() { var noBackCompat = !!script.getAttribute( "data-no-back-compat" ); if ( widget ) { - modules = modules.concat([ + modules = modules.concat( [ ( deprecated ? "common-deprecated" : "common" ), "core", "events", "methods", "options" - ]); + ] ); if ( deprecated ) { modules = modules.concat( "deprecated" ); } diff --git a/tests/lib/common.js b/tests/lib/common.js index 8e4acbea819..c3e8985351d 100644 --- a/tests/lib/common.js +++ b/tests/lib/common.js @@ -1,4 +1,4 @@ -define([ +define( [ "jquery" ], function( $ ) { @@ -17,8 +17,8 @@ function testWidgetDefaults( widget, defaults ) { return; } deepEqual( pluginDefaults[ key ], val, key ); - }); - }); + } ); + } ); // Ensure that all defaults were tested test( "tested defaults", function() { @@ -26,15 +26,15 @@ function testWidgetDefaults( widget, defaults ) { $.each( pluginDefaults, function( key ) { expect( ++count ); ok( key in defaults, key ); - }); - }); + } ); + } ); } function testWidgetOverrides( widget ) { if ( $.uiBackCompat === false ) { test( "$.widget overrides", function() { expect( 4 ); - $.each([ + $.each( [ "_createWidget", "destroy", "option", @@ -42,8 +42,8 @@ function testWidgetOverrides( widget ) { ], function( i, method ) { strictEqual( $.ui[ widget ].prototype[ method ], $.Widget.prototype[ method ], "should not override " + method ); - }); - }); + } ); + } ); } } @@ -61,7 +61,7 @@ function testBasicUsage( widget ) { // Ensure manipulating removed elements works (#3664) $( defaultElement ).appendTo( "body" ).remove()[ widget ]().remove(); ok( true, "initialized on disconnected DOMElement - removed" ); - }); + } ); } exports.testWidget = function( widget, settings ) { @@ -74,7 +74,7 @@ exports.testWidget = function( widget, settings ) { test( "version", function() { expect( 1 ); ok( "version" in $.ui[ widget ].prototype, "version property exists" ); - }); + } ); }; exports.testJshint = function( module ) { @@ -120,14 +120,14 @@ exports.testJshint = function( module ) { ok( passed, errors ); start(); } ) - .fail(function( hintError, srcError ) { + .fail( function( hintError, srcError ) { ok( false, "error loading source: " + ( hintError || srcError ).statusText ); start(); } ); - }); - }); + } ); + } ); }; return exports; -}); +} ); diff --git a/tests/lib/css.js b/tests/lib/css.js index 37353e912ef..ab707ad2a3d 100644 --- a/tests/lib/css.js +++ b/tests/lib/css.js @@ -1,4 +1,4 @@ -(function() { +( function() { function includeStyle( url ) { document.write( "" ); diff --git a/tests/lib/helper.js b/tests/lib/helper.js index cc7d8c00032..400d854897c 100644 --- a/tests/lib/helper.js +++ b/tests/lib/helper.js @@ -1,4 +1,4 @@ -define([ +define( [ "jquery" ], function( $ ) { @@ -9,10 +9,10 @@ exports.forceScrollableWindow = function( appendTo ) { // The main testable area is 10000x10000 so to enforce scrolling, // this DIV must be greater than 10000 to work return $( "
" ) - .css({ + .css( { height: "11000px", width: "11000px" - }) + } ) .appendTo( appendTo || "#qunit-fixture" ); }; @@ -30,4 +30,4 @@ exports.onFocus = function( element, onFocus ) { return exports; -}); +} ); diff --git a/tests/lib/qunit-assert-domequal.js b/tests/lib/qunit-assert-domequal.js index ba516453d9d..e8083db77f1 100644 --- a/tests/lib/qunit-assert-domequal.js +++ b/tests/lib/qunit-assert-domequal.js @@ -100,20 +100,20 @@ function extract( selector, message ) { $.each( domEqual.properties, function( index, attr ) { var value = elem.prop( attr ); result[ attr ] = value != null ? value : ""; - }); + } ); $.each( domEqual.attributes, function( index, attr ) { var value = elem.attr( attr ); result[ attr ] = value != null ? value : ""; - }); + } ); result.style = getElementStyles( elem[ 0 ] ); result.events = $._data( elem[ 0 ], "events" ); result.data = $.extend( {}, elem.data() ); delete result.data[ $.expando ]; children = elem.children(); if ( children.length ) { - result.children = elem.children().map(function() { + result.children = elem.children().map( function() { return extract( $( this ) ); - }).get(); + } ).get(); } else { result.text = elem.text(); } diff --git a/tests/lib/qunit.js b/tests/lib/qunit.js index 87ef8b6625d..b421341eacd 100644 --- a/tests/lib/qunit.js +++ b/tests/lib/qunit.js @@ -10,13 +10,13 @@ define( [ QUnit.config.autostart = false; QUnit.config.requireExpects = true; -QUnit.config.urlConfig.push({ +QUnit.config.urlConfig.push( { id: "nojshint", label: "Skip JSHint", tooltip: "Skip running JSHint, e.g., within TestSwarm, where Jenkins runs it already" -}); +} ); -QUnit.config.urlConfig.push({ +QUnit.config.urlConfig.push( { id: "jquery", label: "jQuery version", value: [ @@ -30,7 +30,7 @@ QUnit.config.urlConfig.push({ "compat-git", "git", "custom" ], tooltip: "Which jQuery Core version to test against" -}); +} ); QUnit.reset = ( function( reset ) { return function() { diff --git a/tests/unit/accordion/common.js b/tests/unit/accordion/common.js index 1a8ce55c4a1..453506dbdfe 100644 --- a/tests/unit/accordion/common.js +++ b/tests/unit/accordion/common.js @@ -22,11 +22,11 @@ common.testWidget( "accordion", { "header": "ui-icon-triangle-1-e" }, - // callbacks + // Callbacks activate: null, beforeActivate: null, create: null } -}); +} ); } ); diff --git a/tests/unit/accordion/core.js b/tests/unit/accordion/core.js index ed538c368ea..75f4b4ee31b 100644 --- a/tests/unit/accordion/core.js +++ b/tests/unit/accordion/core.js @@ -32,33 +32,33 @@ $.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( typ deepEqual( element.find( ".ui-accordion-header" ).next().get(), element.find( ".ui-accordion-content" ).get(), "content panels come immediately after headers" ); - }); -}); + } ); +} ); test( "handle click on header-descendant", function() { expect( 1 ); var element = $( "#navigation" ).accordion(); $( "#navigation h2:eq(1) a" ).trigger( "click" ); state( element, 0, 1, 0 ); -}); +} ); -test( "accessibility", function () { +test( "accessibility", function() { expect( 61 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { active: 1, collapsible: true - }), + } ), headers = element.find( ".ui-accordion-header" ); equal( element.attr( "role" ), "tablist", "element role" ); - headers.each(function( i ) { + headers.each( function( i ) { var header = headers.eq( i ), panel = header.next(); equal( header.attr( "role" ), "tab", "header " + i + " role" ); equal( header.attr( "aria-controls" ), panel.attr( "id" ), "header " + i + " aria-controls" ); equal( panel.attr( "role" ), "tabpanel", "panel " + i + " role" ); equal( panel.attr( "aria-labelledby" ), header.attr( "id" ), "panel " + i + " aria-labelledby" ); - }); + } ); equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" ); equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" ); @@ -115,7 +115,7 @@ test( "accessibility", function () { equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" ); equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" ); -}); +} ); asyncTest( "keyboard support", function( assert ) { expect( 13 ); @@ -180,7 +180,7 @@ asyncTest( "keyboard support", function( assert ) { } function step9() { - equal( element.accordion( "option", "active" ) , 2, "ENTER activates panel" ); + equal( element.accordion( "option", "active" ), 2, "ENTER activates panel" ); headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.SPACE } ); setTimeout( step10 ); } @@ -202,6 +202,6 @@ asyncTest( "keyboard support", function( assert ) { assert.hasClasses( headers.eq( 1 ), "ui-state-focus", "CTRL+UP moves focus to header" ); start(); } -}); +} ); } ); diff --git a/tests/unit/accordion/events.js b/tests/unit/accordion/events.js index 03aee34343d..1634b402d0d 100644 --- a/tests/unit/accordion/events.js +++ b/tests/unit/accordion/events.js @@ -16,17 +16,17 @@ test( "create", function() { headers = element.children( "h3" ), contents = headers.next(); - element.accordion({ + element.accordion( { create: function( event, ui ) { equal( ui.header.length, 1, "header length" ); strictEqual( ui.header[ 0 ], headers[ 0 ], "header" ); equal( ui.panel.length, 1, "panel length" ); strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" ); } - }); + } ); element.accordion( "destroy" ); - element.accordion({ + element.accordion( { active: 2, create: function( event, ui ) { equal( ui.header.length, 1, "header length" ); @@ -34,26 +34,26 @@ test( "create", function() { equal( ui.panel.length, 1, "panel length" ); strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" ); } - }); + } ); element.accordion( "destroy" ); - element.accordion({ + element.accordion( { active: false, collapsible: true, create: function( event, ui ) { equal( ui.header.length, 0, "header length" ); equal( ui.panel.length, 0, "panel length" ); } - }); + } ); element.accordion( "destroy" ); -}); +} ); test( "beforeActivate", function() { expect( 38 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { active: false, collapsible: true - }), + } ), headers = element.find( ".ui-accordion-header" ), content = element.find( ".ui-accordion-content" ); @@ -66,7 +66,7 @@ test( "beforeActivate", function() { equal( ui.newPanel.length, 1 ); strictEqual( ui.newPanel[ 0 ], content[ 0 ] ); state( element, 0, 0, 0 ); - }); + } ); element.accordion( "option", "active", 0 ); state( element, 1, 0, 0 ); @@ -81,7 +81,7 @@ test( "beforeActivate", function() { equal( ui.newPanel.length, 1 ); strictEqual( ui.newPanel[ 0 ], content[ 1 ] ); state( element, 1, 0, 0 ); - }); + } ); headers.eq( 1 ).trigger( "click" ); state( element, 0, 1, 0 ); @@ -94,7 +94,7 @@ test( "beforeActivate", function() { equal( ui.newHeader.length, 0 ); equal( ui.newPanel.length, 0 ); state( element, 0, 1, 0 ); - }); + } ); element.accordion( "option", "active", false ); state( element, 0, 0, 0 ); @@ -108,17 +108,17 @@ test( "beforeActivate", function() { strictEqual( ui.newPanel[ 0 ], content[ 2 ] ); event.preventDefault(); state( element, 0, 0, 0 ); - }); + } ); element.accordion( "option", "active", 2 ); state( element, 0, 0, 0 ); -}); +} ); test( "activate", function() { expect( 21 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { active: false, collapsible: true - }), + } ), headers = element.find( ".ui-accordion-header" ), content = element.find( ".ui-accordion-content" ); @@ -129,7 +129,7 @@ test( "activate", function() { strictEqual( ui.newHeader[ 0 ], headers[ 0 ] ); equal( ui.newPanel.length, 1 ); strictEqual( ui.newPanel[ 0 ], content[ 0 ] ); - }); + } ); element.accordion( "option", "active", 0 ); element.one( "accordionactivate", function( event, ui ) { @@ -141,7 +141,7 @@ test( "activate", function() { strictEqual( ui.newHeader[ 0 ], headers[ 1 ] ); equal( ui.newPanel.length, 1 ); strictEqual( ui.newPanel[ 0 ], content[ 1 ] ); - }); + } ); headers.eq( 1 ).trigger( "click" ); element.one( "accordionactivate", function( event, ui ) { @@ -151,18 +151,18 @@ test( "activate", function() { strictEqual( ui.oldPanel[ 0 ], content[ 1 ] ); equal( ui.newHeader.length, 0 ); equal( ui.newPanel.length, 0 ); - }); + } ); element.accordion( "option", "active", false ); - // prevent activation + // Prevent activation element.one( "accordionbeforeactivate", function( event ) { ok( true ); event.preventDefault(); - }); + } ); element.one( "accordionactivate", function() { ok( false ); - }); + } ); element.accordion( "option", "active", 1 ); -}); +} ); } ); diff --git a/tests/unit/accordion/helper.js b/tests/unit/accordion/helper.js index ec9b7ecb8f3..b47510733f4 100644 --- a/tests/unit/accordion/helper.js +++ b/tests/unit/accordion/helper.js @@ -6,9 +6,9 @@ define( [ return $.extend( helper, { equalHeight: function( accordion, height ) { - accordion.find( ".ui-accordion-content" ).each(function() { + accordion.find( ".ui-accordion-content" ).each( function() { equal( $( this ).outerHeight(), height ); - }); + } ); }, setupTeardown: function() { @@ -25,10 +25,10 @@ return $.extend( helper, { state: function( accordion ) { var expected = $.makeArray( arguments ).slice( 1 ), - actual = accordion.find( ".ui-accordion-content" ).map(function() { + actual = accordion.find( ".ui-accordion-content" ).map( function() { return $( this ).css( "display" ) === "none" ? 0 : 1; - }).get(); - QUnit.push( QUnit.equiv(actual, expected), actual, expected ); + } ).get(); + QUnit.push( QUnit.equiv( actual, expected ), actual, expected ); } } ); diff --git a/tests/unit/accordion/methods.js b/tests/unit/accordion/methods.js index 455e80c58f3..3b1696e4504 100644 --- a/tests/unit/accordion/methods.js +++ b/tests/unit/accordion/methods.js @@ -14,8 +14,8 @@ test( "destroy", function( assert ) { expect( 1 ); assert.domEqual( "#list1", function() { $( "#list1" ).accordion().accordion( "destroy" ); - }); -}); + } ); +} ); test( "enable/disable", function( assert ) { expect( 7 ); @@ -28,16 +28,17 @@ test( "enable/disable", function( assert ) { equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" ); assert.hasClasses( element, "ui-accordion-disabled" ); - // event does nothing + // Event does nothing element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); state( element, 1, 0, 0 ); - // option still works + + // Option still works element.accordion( "option", "active", 1 ); state( element, 0, 1, 0 ); element.accordion( "enable" ); element.accordion( "option", "active", 2 ); state( element, 0, 0, 1 ); -}); +} ); test( "refresh", function() { expect( 19 ); @@ -45,9 +46,9 @@ test( "refresh", function() { .parent() .height( 300 ) .end() - .accordion({ + .accordion( { heightStyle: "fill" - }); + } ); equalHeight( element, 255 ); element.parent().height( 500 ); @@ -58,72 +59,72 @@ test( "refresh", function() { element.accordion(); state( element, 1, 0, 0 ); - // disable panel via markup + // Disable panel via markup element.find( "h3.bar" ).eq( 1 ).addClass( "ui-state-disabled" ); element.accordion( "refresh" ); state( element, 1, 0, 0 ); - // don't add multiple icons + // Don't add multiple icons element.accordion( "refresh" ); equal( element.find( ".ui-accordion-header-icon" ).length, 3 ); - // add a panel + // Add a panel element - .append("

new 1

") - .append("
new 1
"); + .append( "

new 1

" ) + .append( "
new 1
" ); element.accordion( "refresh" ); state( element, 1, 0, 0, 0 ); - // remove all tabs + // Remove all tabs element.find( "h3.bar, div.foo" ).remove(); element.accordion( "refresh" ); state( element ); equal( element.accordion( "option", "active" ), false, "no active accordion panel" ); - // add panels + // Add panels element - .append("

new 2

") - .append("
new 2
") - .append("

new 3

") - .append("
new 3
") - .append("

new 4

") - .append("
new 4
") - .append("

new 5

") - .append("
new 5
"); + .append( "

new 2

" ) + .append( "
new 2
" ) + .append( "

new 3

" ) + .append( "
new 3
" ) + .append( "

new 4

" ) + .append( "
new 4
" ) + .append( "

new 5

" ) + .append( "
new 5
" ); element.accordion( "refresh" ); state( element, 1, 0, 0, 0 ); - // activate third tab + // Activate third tab element.accordion( "option", "active", 2 ); state( element, 0, 0, 1, 0 ); - // remove fourth panel, third panel should stay active + // Remove fourth panel, third panel should stay active element.find( "h3.bar" ).eq( 3 ).remove(); element.find( "div.foo" ).eq( 3 ).remove(); element.accordion( "refresh" ); state( element, 0, 0, 1 ); - // remove third (active) panel, second panel should become active + // Remove third (active) panel, second panel should become active element.find( "h3.bar" ).eq( 2 ).remove(); element.find( "div.foo" ).eq( 2 ).remove(); element.accordion( "refresh" ); state( element, 0, 1 ); - // remove first panel, previously active panel (now first) should stay active + // Remove first panel, previously active panel (now first) should stay active element.find( "h3.bar" ).eq( 0 ).remove(); element.find( "div.foo" ).eq( 0 ).remove(); element.accordion( "refresh" ); state( element, 1 ); - // collapse all panels + // Collapse all panels element.accordion( "option", { collapsible: true, active: false - }); + } ); state( element, 0 ); element.accordion( "refresh" ); state( element, 0 ); -}); +} ); test( "widget", function() { expect( 2 ); @@ -131,6 +132,6 @@ test( "widget", function() { widgetElement = element.accordion( "widget" ); equal( widgetElement.length, 1, "one element" ); strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" ); -}); +} ); } ); diff --git a/tests/unit/accordion/options.js b/tests/unit/accordion/options.js index 06248d6cb67..c9b2e3aaf15 100644 --- a/tests/unit/accordion/options.js +++ b/tests/unit/accordion/options.js @@ -15,23 +15,23 @@ test( "{ active: default }", function() { var element = $( "#list1" ).accordion(); equal( element.accordion( "option", "active" ), 0 ); state( element, 1, 0, 0 ); -}); +} ); test( "{ active: null }", function() { expect( 2 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { active: null - }); + } ); equal( element.accordion( "option", "active" ), 0 ); state( element, 1, 0, 0 ); -}); +} ); test( "{ active: false }", function() { expect( 7 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { active: false, collapsible: true - }); + } ); state( element, 0, 0, 0 ); equal( element.find( ".ui-accordion-header.ui-state-active" ).length, 0, "no headers selected" ); equal( element.accordion( "option", "active" ), false ); @@ -41,18 +41,18 @@ test( "{ active: false }", function() { equal( element.accordion( "option", "active" ), 0 ); element.accordion( "destroy" ); - element.accordion({ + element.accordion( { active: false - }); + } ); state( element, 1, 0, 0 ); strictEqual( element.accordion( "option", "active" ), 0 ); -}); +} ); test( "{ active: Number }", function() { expect( 8 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { active: 2 - }); + } ); equal( element.accordion( "option", "active" ), 2 ); state( element, 0, 0, 1 ); @@ -67,13 +67,13 @@ test( "{ active: Number }", function() { element.accordion( "option", "active", 10 ); equal( element.accordion( "option", "active" ), 1 ); state( element, 0, 1, 0 ); -}); +} ); test( "{ active: -Number }", function() { expect( 8 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { active: -1 - }); + } ); equal( element.accordion( "option", "active" ), 2 ); state( element, 0, 0, 1 ); @@ -88,13 +88,13 @@ test( "{ active: -Number }", function() { element.accordion( "option", "active", -3 ); equal( element.accordion( "option", "active" ), 0 ); state( element, 1, 0, 0 ); -}); +} ); test( "{ animate: false }", function() { expect( 3 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { animate: false - }), + } ), panels = element.find( ".ui-accordion-content" ), animate = $.fn.animate; $.fn.animate = function() { @@ -106,16 +106,17 @@ test( "{ animate: false }", function() { ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; -}); +} ); asyncTest( "{ animate: Number }", function() { expect( 7 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { animate: 100 - }), + } ), panels = element.find( ".ui-accordion-content" ), animate = $.fn.animate; - // called twice (both panels) + + // Called twice (both panels) $.fn.animate = function( props, options ) { equal( options.duration, 100, "correct duration" ); equal( options.easing, undefined, "default easing" ); @@ -124,22 +125,23 @@ asyncTest( "{ animate: Number }", function() { ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 1 ); - panels.promise().done(function() { + panels.promise().done( function() { ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; start(); - }); -}); + } ); +} ); asyncTest( "{ animate: String }", function() { expect( 7 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { animate: "linear" - }), + } ), panels = element.find( ".ui-accordion-content" ), animate = $.fn.animate; - // called twice (both panels) + + // Called twice (both panels) $.fn.animate = function( props, options ) { equal( options.duration, undefined, "default duration" ); equal( options.easing, "linear", "correct easing" ); @@ -148,22 +150,23 @@ asyncTest( "{ animate: String }", function() { ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 1 ); - panels.promise().done(function() { + panels.promise().done( function() { ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; start(); - }); -}); + } ); +} ); asyncTest( "{ animate: {} }", function() { expect( 7 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { animate: {} - }), + } ), panels = element.find( ".ui-accordion-content" ), animate = $.fn.animate; - // called twice (both panels) + + // Called twice (both panels) $.fn.animate = function( props, options ) { equal( options.duration, undefined, "default duration" ); equal( options.easing, undefined, "default easing" ); @@ -172,22 +175,23 @@ asyncTest( "{ animate: {} }", function() { ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 1 ); - panels.promise().done(function() { + panels.promise().done( function() { ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; start(); - }); -}); + } ); +} ); asyncTest( "{ animate: { duration, easing } }", function() { expect( 7 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { animate: { duration: 100, easing: "linear" } - }), + } ), panels = element.find( ".ui-accordion-content" ), animate = $.fn.animate; - // called twice (both panels) + + // Called twice (both panels) $.fn.animate = function( props, options ) { equal( options.duration, 100, "correct duration" ); equal( options.easing, "linear", "correct easing" ); @@ -196,23 +200,24 @@ asyncTest( "{ animate: { duration, easing } }", function() { ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 1 ); - panels.promise().done(function() { + panels.promise().done( function() { ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; start(); - }); -}); + } ); +} ); asyncTest( "{ animate: { duration, easing } }, animate down", function() { expect( 7 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { active: 1, animate: { duration: 100, easing: "linear" } - }), + } ), panels = element.find( ".ui-accordion-content" ), animate = $.fn.animate; - // called twice (both panels) + + // Called twice (both panels) $.fn.animate = function( props, options ) { equal( options.duration, 100, "correct duration" ); equal( options.easing, "linear", "correct easing" ); @@ -221,17 +226,17 @@ asyncTest( "{ animate: { duration, easing } }, animate down", function() { ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 0 ); - panels.promise().done(function() { + panels.promise().done( function() { ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" ); ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; start(); - }); -}); + } ); +} ); asyncTest( "{ animate: { duration, easing, down } }, animate down", function() { expect( 7 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { active: 1, animate: { duration: 100, @@ -240,10 +245,11 @@ asyncTest( "{ animate: { duration, easing, down } }, animate down", function() { easing: "swing" } } - }), + } ), panels = element.find( ".ui-accordion-content" ), animate = $.fn.animate; - // called twice (both panels) + + // Called twice (both panels) $.fn.animate = function( props, options ) { equal( options.duration, 100, "correct duration" ); equal( options.easing, "swing", "correct easing" ); @@ -252,19 +258,19 @@ asyncTest( "{ animate: { duration, easing, down } }, animate down", function() { ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 0 ); - panels.promise().done(function() { + panels.promise().done( function() { ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" ); ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; start(); - }); -}); + } ); +} ); test( "{ collapsible: false }", function() { expect( 4 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { active: 1 - }); + } ); element.accordion( "option", "active", false ); equal( element.accordion( "option", "active" ), 1 ); state( element, 0, 1, 0 ); @@ -272,14 +278,14 @@ test( "{ collapsible: false }", function() { element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); equal( element.accordion( "option", "active" ), 1 ); state( element, 0, 1, 0 ); -}); +} ); test( "{ collapsible: true }", function() { expect( 6 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { active: 1, collapsible: true - }); + } ); element.accordion( "option", "active", false ); equal( element.accordion( "option", "active" ), false ); @@ -292,37 +298,37 @@ test( "{ collapsible: true }", function() { element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); equal( element.accordion( "option", "active" ), false ); state( element, 0, 0, 0 ); -}); +} ); test( "{ event: null }", function() { expect( 5 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { event: null - }); + } ); state( element, 1, 0, 0 ); element.accordion( "option", "active", 1 ); equal( element.accordion( "option", "active" ), 1 ); state( element, 0, 1, 0 ); - // ensure default click handler isn't bound + // Ensure default click handler isn't bound element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" ); equal( element.accordion( "option", "active" ), 1 ); state( element, 0, 1, 0 ); -}); +} ); test( "{ event: custom }", function() { expect( 11 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { event: "custom1 custom2" - }); + } ); state( element, 1, 0, 0 ); element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" ); equal( element.accordion( "option", "active" ), 1 ); state( element, 0, 1, 0 ); - // ensure default click handler isn't bound + // Ensure default click handler isn't bound element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" ); equal( element.accordion( "option", "active" ), 1 ); state( element, 0, 1, 0 ); @@ -333,7 +339,7 @@ test( "{ event: custom }", function() { element.accordion( "option", "event", "custom3" ); - // ensure old event handlers are unbound + // Ensure old event handlers are unbound element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" ); element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom2" ); equal( element.accordion( "option", "active" ), 2 ); @@ -342,126 +348,128 @@ test( "{ event: custom }", function() { element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" ); equal( element.accordion( "option", "active" ), 1 ); state( element, 0, 1, 0 ); -}); +} ); test( "{ header: default }", function() { expect( 2 ); - // default: > li > :first-child,> :not(li):even + + // Default: > li > :first-child,> :not(li):even // > :not(li):even - state( $( "#list1" ).accordion(), 1, 0, 0); + state( $( "#list1" ).accordion(), 1, 0, 0 ); + // > li > :first-child - state( $( "#navigation" ).accordion(), 1, 0, 0); -}); + state( $( "#navigation" ).accordion(), 1, 0, 0 ); +} ); test( "{ header: custom }", function( assert ) { expect( 6 ); - var element = $( "#navigationWrapper" ).accordion({ + var element = $( "#navigationWrapper" ).accordion( { header: "h2" - }); - element.find( "h2" ).each(function() { + } ); + element.find( "h2" ).each( function() { assert.hasClasses( this, "ui-accordion-header" ); - }); + } ); equal( element.find( ".ui-accordion-header" ).length, 3 ); state( element, 1, 0, 0 ); element.accordion( "option", "active", 2 ); state( element, 0, 0, 1 ); -}); +} ); test( "{ heightStyle: 'auto' }", function() { expect( 3 ); - var element = $( "#navigation" ).accordion({ heightStyle: "auto" }); + var element = $( "#navigation" ).accordion( { heightStyle: "auto" } ); equalHeight( element, 105 ); -}); +} ); test( "{ heightStyle: 'content' }", function() { expect( 3 ); - var element = $( "#navigation" ).accordion({ heightStyle: "content" }), - sizes = element.find( ".ui-accordion-content" ).map(function() { + var element = $( "#navigation" ).accordion( { heightStyle: "content" } ), + sizes = element.find( ".ui-accordion-content" ).map( function() { return $( this ).height(); - }).get(); + } ).get(); equal( sizes[ 0 ], 75 ); equal( sizes[ 1 ], 105 ); equal( sizes[ 2 ], 45 ); -}); +} ); test( "{ heightStyle: 'fill' }", function() { expect( 3 ); $( "#navigationWrapper" ).height( 500 ); - var element = $( "#navigation" ).accordion({ heightStyle: "fill" }); + var element = $( "#navigation" ).accordion( { heightStyle: "fill" } ); equalHeight( element, 455 ); -}); +} ); test( "{ heightStyle: 'fill' } with sibling", function() { expect( 3 ); $( "#navigationWrapper" ).height( 500 ); $( "

Lorem Ipsum

" ) - .css({ + .css( { height: 50, marginTop: 20, marginBottom: 30 - }) + } ) .prependTo( "#navigationWrapper" ); - var element = $( "#navigation" ).accordion({ heightStyle: "fill" }); - equalHeight( element , 355 ); -}); + var element = $( "#navigation" ).accordion( { heightStyle: "fill" } ); + equalHeight( element, 355 ); +} ); test( "{ heightStyle: 'fill' } with multiple siblings", function() { expect( 3 ); $( "#navigationWrapper" ).height( 500 ); $( "

Lorem Ipsum

" ) - .css({ + .css( { height: 50, marginTop: 20, marginBottom: 30 - }) + } ) .prependTo( "#navigationWrapper" ); $( "

Lorem Ipsum

" ) - .css({ + .css( { height: 50, marginTop: 20, marginBottom: 30, position: "absolute" - }) + } ) .prependTo( "#navigationWrapper" ); $( "

Lorem Ipsum

" ) - .css({ + .css( { height: 25, marginTop: 10, marginBottom: 15 - }) + } ) .prependTo( "#navigationWrapper" ); - var element = $( "#navigation" ).accordion({ heightStyle: "fill" }); + var element = $( "#navigation" ).accordion( { heightStyle: "fill" } ); equalHeight( element, 305 ); -}); +} ); test( "{ icons: false }", function() { expect( 8 ); var element = $( "#list1" ); function icons( on ) { - deepEqual( element.find( "span.ui-icon").length, on ? 3 : 0 ); + deepEqual( element.find( "span.ui-icon" ).length, on ? 3 : 0 ); deepEqual( element.find( ".ui-accordion-header.ui-accordion-icons" ).length, on ? 3 : 0 ); } element.accordion(); icons( true ); - element.accordion( "destroy" ).accordion({ + element.accordion( "destroy" ).accordion( { icons: false - }); + } ); icons( false ); element.accordion( "option", "icons", { header: "foo", activeHeader: "bar" } ); icons( true ); element.accordion( "option", "icons", false ); icons( false ); -}); +} ); test( "{ icons: hash }", function( assert ) { expect( 3 ); - var element = $( "#list1" ).accordion({ + var element = $( "#list1" ).accordion( { icons: { activeHeader: "a1", header: "h1" } - }); + } ); assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1" ); element.accordion( "option", "icons", { activeHeader: "a2", header: "h2" } ); - assert.lacksClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1"); + assert.lacksClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1" ); assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a2" ); -}); +} ); } ); diff --git a/tests/unit/autocomplete/common.js b/tests/unit/autocomplete/common.js index 94e98048dcf..a4d57f95db9 100644 --- a/tests/unit/autocomplete/common.js +++ b/tests/unit/autocomplete/common.js @@ -22,7 +22,7 @@ common.testWidget( "autocomplete", { }, source: null, - // callbacks + // Callbacks change: null, close: null, create: null, @@ -32,6 +32,6 @@ common.testWidget( "autocomplete", { search: null, select: null } -}); +} ); } ); diff --git a/tests/unit/autocomplete/core.js b/tests/unit/autocomplete/core.js index d57f2a980cf..41be5ae6a0a 100644 --- a/tests/unit/autocomplete/core.js +++ b/tests/unit/autocomplete/core.js @@ -12,15 +12,15 @@ test( "markup structure", function( assert ) { assert.hasClasses( element, "ui-autocomplete-input" ); assert.hasClasses( menu, "ui-autocomplete ui-widget ui-widget-content" ); -}); +} ); test( "prevent form submit on enter when menu is active", function() { expect( 2 ); var event, element = $( "#autocomplete" ) - .autocomplete({ + .autocomplete( { source: [ "java", "javascript" ] - }) + } ) .val( "ja" ) .autocomplete( "search" ), menu = element.autocomplete( "widget" ); @@ -35,16 +35,16 @@ test( "prevent form submit on enter when menu is active", function() { event.keyCode = $.ui.keyCode.ENTER; element.trigger( event ); ok( event.isDefaultPrevented(), "default action is prevented" ); -}); +} ); test( "allow form submit on enter when menu is not active", function() { expect( 1 ); var event, element = $( "#autocomplete" ) - .autocomplete({ + .autocomplete( { autoFocus: false, source: [ "java", "javascript" ] - }) + } ) .val( "ja" ) .autocomplete( "search" ); @@ -52,90 +52,90 @@ test( "allow form submit on enter when menu is not active", function() { event.keyCode = $.ui.keyCode.ENTER; element.trigger( event ); ok( !event.isDefaultPrevented(), "default action is prevented" ); -}); +} ); -(function() { +( function() { test( "up arrow invokes search - input", function() { arrowsInvokeSearch( "#autocomplete", true, true ); - }); + } ); test( "down arrow invokes search - input", function() { arrowsInvokeSearch( "#autocomplete", false, true ); - }); + } ); test( "up arrow invokes search - textarea", function() { arrowsInvokeSearch( "#autocomplete-textarea", true, false ); - }); + } ); test( "down arrow invokes search - textarea", function() { arrowsInvokeSearch( "#autocomplete-textarea", false, false ); - }); + } ); test( "up arrow invokes search - contenteditable", function() { arrowsInvokeSearch( "#autocomplete-contenteditable", true, false ); - }); + } ); test( "down arrow invokes search - contenteditable", function() { arrowsInvokeSearch( "#autocomplete-contenteditable", false, false ); - }); + } ); test( "up arrow moves focus - input", function() { arrowsMoveFocus( "#autocomplete", true ); - }); + } ); test( "down arrow moves focus - input", function() { arrowsMoveFocus( "#autocomplete", false ); - }); + } ); test( "up arrow moves focus - textarea", function() { arrowsMoveFocus( "#autocomplete-textarea", true ); - }); + } ); test( "down arrow moves focus - textarea", function() { arrowsMoveFocus( "#autocomplete-textarea", false ); - }); + } ); test( "up arrow moves focus - contenteditable", function() { arrowsMoveFocus( "#autocomplete-contenteditable", true ); - }); + } ); test( "down arrow moves focus - contenteditable", function() { arrowsMoveFocus( "#autocomplete-contenteditable", false ); - }); + } ); test( "up arrow moves cursor - input", function() { arrowsNavigateElement( "#autocomplete", true, false ); - }); + } ); test( "down arrow moves cursor - input", function() { arrowsNavigateElement( "#autocomplete", false, false ); - }); + } ); test( "up arrow moves cursor - textarea", function() { arrowsNavigateElement( "#autocomplete-textarea", true, true ); - }); + } ); test( "down arrow moves cursor - textarea", function() { arrowsNavigateElement( "#autocomplete-textarea", false, true ); - }); + } ); test( "up arrow moves cursor - contenteditable", function() { arrowsNavigateElement( "#autocomplete-contenteditable", true, true ); - }); + } ); test( "down arrow moves cursor - contenteditable", function() { arrowsNavigateElement( "#autocomplete-contenteditable", false, true ); - }); + } ); function arrowsInvokeSearch( id, isKeyUp, shouldMove ) { expect( 1 ); var didMove = false, - element = $( id ).autocomplete({ + element = $( id ).autocomplete( { source: [ "a" ], delay: 0, minLength: 0 - }); + } ); element.autocomplete( "instance" )._move = function() { didMove = true; }; @@ -146,11 +146,11 @@ test( "allow form submit on enter when menu is not active", function() { function arrowsMoveFocus( id, isKeyUp ) { expect( 1 ); - var element = $( id ).autocomplete({ + var element = $( id ).autocomplete( { source: [ "a" ], delay: 0, minLength: 0 - }); + } ); element.autocomplete( "instance" )._move = function() { ok( true, "repsond to arrow" ); }; @@ -162,25 +162,25 @@ test( "allow form submit on enter when menu is not active", function() { expect( 1 ); var didMove = false, - element = $( id ).autocomplete({ + element = $( id ).autocomplete( { source: [ "a" ], delay: 0, minLength: 0 - }); + } ); element.on( "keypress", function( e ) { didMove = !e.isDefaultPrevented(); - }); + } ); element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } ); element.simulate( "keypress" ); equal( didMove, shouldMove, "respond to arrow" ); } -})(); +} )(); asyncTest( "past end of menu in multiline autocomplete", function() { expect( 2 ); var customVal = "custom value", - element = $( "#autocomplete-contenteditable" ).autocomplete({ + element = $( "#autocomplete-contenteditable" ).autocomplete( { delay: 0, source: [ "javascript" ], focus: function( event, ui ) { @@ -188,25 +188,25 @@ asyncTest( "past end of menu in multiline autocomplete", function() { $( this ).text( customVal ); event.preventDefault(); } - }); + } ); element .simulate( "focus" ) .autocomplete( "search", "ja" ); - setTimeout(function() { + setTimeout( function() { element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); equal( element.text(), customVal ); start(); - }); -}); + } ); +} ); asyncTest( "ESCAPE in multiline autocomplete", function() { expect( 2 ); var customVal = "custom value", - element = $( "#autocomplete-contenteditable" ).autocomplete({ + element = $( "#autocomplete-contenteditable" ).autocomplete( { delay: 0, source: [ "javascript" ], focus: function( event, ui ) { @@ -214,38 +214,38 @@ asyncTest( "ESCAPE in multiline autocomplete", function() { $( this ).text( customVal ); event.preventDefault(); } - }); + } ); element .simulate( "focus" ) .autocomplete( "search", "ja" ); - setTimeout(function() { + setTimeout( function() { element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); equal( element.text(), customVal ); start(); - }); -}); + } ); +} ); asyncTest( "handle race condition", function() { expect( 3 ); var count = 0, - element = $( "#autocomplete" ).autocomplete({ + element = $( "#autocomplete" ).autocomplete( { source: function( request, response ) { count++; if ( request.term.length === 1 ) { equal( count, 1, "request with 1 character is first" ); - setTimeout(function() { - response([ "one" ]); + setTimeout( function() { + response( [ "one" ] ); setTimeout( checkResults ); - }); + } ); return; } equal( count, 2, "request with 2 characters is second" ); - response([ "two" ]); + response( [ "two" ] ); } - }); + } ); element.autocomplete( "search", "a" ); element.autocomplete( "search", "ab" ); @@ -255,41 +255,41 @@ asyncTest( "handle race condition", function() { "correct results displayed" ); start(); } -}); +} ); asyncTest( "simultaneous searches (#9334)", function() { expect( 2 ); - var element = $( "#autocomplete" ).autocomplete({ + var element = $( "#autocomplete" ).autocomplete( { source: function( request, response ) { - setTimeout(function() { - response([ request.term ]); - }); + setTimeout( function() { + response( [ request.term ] ); + } ); }, response: function() { ok( true, "response from first instance" ); } - }), - element2 = $( "#autocomplete-textarea" ).autocomplete({ + } ), + element2 = $( "#autocomplete-textarea" ).autocomplete( { source: function( request, response ) { - setTimeout(function() { - response([ request.term ]); - }); + setTimeout( function() { + response( [ request.term ] ); + } ); }, response: function() { ok( true, "response from second instance" ); start(); } - }); + } ); element.autocomplete( "search", "test" ); element2.autocomplete( "search", "test" ); -}); +} ); test( "ARIA", function() { expect( 13 ); - var element = $( "#autocomplete" ).autocomplete({ + var element = $( "#autocomplete" ).autocomplete( { source: [ "java", "javascript" ] - }), + } ), liveRegion = element.autocomplete( "instance" ).liveRegion; equal( liveRegion.children().length, 0, "Empty live region on create" ); @@ -311,7 +311,7 @@ test( "ARIA", function() { element.one( "autocompletefocus", function( event ) { event.preventDefault(); - }); + } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); equal( liveRegion.children().filter( ":visible" ).text(), "javascript", "Live region updated when default focus is prevented" ); @@ -335,7 +335,7 @@ test( "ARIA", function() { element.autocomplete( "destroy" ); equal( liveRegion.parent().length, 0, "The liveRegion should be detached after destroy" ); -}); +} ); test( "ARIA, aria-label announcement", function() { expect( 1 ); @@ -345,27 +345,27 @@ test( "ARIA, aria-label announcement", function() { $.each( items, function( index, item ) { that._renderItemData( ul, item ) .attr( "aria-label", item.category + " : " + item.label ); - }); + } ); } - }); - var element = $( "#autocomplete" ).catcomplete({ + } ); + var element = $( "#autocomplete" ).catcomplete( { source: [ { label: "anders andersson", category: "People" } ] - }), + } ), liveRegion = element.catcomplete( "instance" ).liveRegion; element.catcomplete( "search", "a" ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); equal( liveRegion.children().filter( ":visible" ).text(), "People : anders andersson", "Live region changed on keydown to announce the highlighted value's aria-label attribute" ); -}); +} ); test( "ARIA, init on detached input", function() { expect( 1 ); - var element = $( "" ).autocomplete({ + var element = $( "" ).autocomplete( { source: [ "java", "javascript" ] - }), + } ), liveRegion = element.autocomplete( "instance" ).liveRegion; equal( liveRegion.parent().length, 1, "liveRegion must have a parent" ); -}); +} ); test( ".replaceWith() (#9172)", function() { expect( 1 ); @@ -375,27 +375,27 @@ test( ".replaceWith() (#9172)", function() { parent = element.parent(); element.replaceWith( replacement ); equal( parent.html().toLowerCase(), replacement ); -}); +} ); asyncTest( "Search if the user retypes the same value (#7434)", function() { expect( 3 ); - var element = $( "#autocomplete" ).autocomplete({ + var element = $( "#autocomplete" ).autocomplete( { source: [ "java", "javascript" ], delay: 0 - }), + } ), menu = element.autocomplete( "instance" ).menu.element; element.val( "j" ).simulate( "keydown" ); - setTimeout(function() { + setTimeout( function() { ok( menu.is( ":visible" ), "menu displays initially" ); element.trigger( "blur" ); ok( !menu.is( ":visible" ), "menu hidden after blur" ); element.val( "j" ).simulate( "keydown" ); - setTimeout(function() { + setTimeout( function() { ok( menu.is( ":visible" ), "menu displays after typing the same value" ); start(); - }); - }); -}); + } ); + } ); +} ); } ); diff --git a/tests/unit/autocomplete/events.js b/tests/unit/autocomplete/events.js index 59d5dd5400f..688763f7e87 100644 --- a/tests/unit/autocomplete/events.js +++ b/tests/unit/autocomplete/events.js @@ -7,7 +7,7 @@ module( "autocomplete: events" ); var data = [ "Clojure", "COBOL", "ColdFusion", "Java", "JavaScript", "Scala", "Scheme" ]; -$.each([ +$.each( [ { type: "input", selector: "#autocomplete", @@ -27,7 +27,7 @@ $.each([ asyncTest( "all events - " + settings.type, function() { expect( 13 ); var element = $( settings.selector ) - .autocomplete({ + .autocomplete( { autoFocus: false, delay: 0, source: data, @@ -63,40 +63,41 @@ $.each([ ok( menu.is( ":hidden" ), "menu closed on change" ); start(); } - }), + } ), menu = element.autocomplete( "widget" ); element.simulate( "focus" )[ settings.valueMethod ]( "j" ).trigger( "keydown" ); - setTimeout(function() { + setTimeout( function() { ok( menu.is( ":visible" ), "menu is visible after delay" ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); - // blur must be async for IE to handle it properly - setTimeout(function() { + + // Blur must be async for IE to handle it properly + setTimeout( function() { element.simulate( "blur" ); - }); - }); - }); -}); + } ); + } ); + } ); +} ); asyncTest( "change without selection", function() { expect( 1 ); - var element = $( "#autocomplete" ).autocomplete({ + var element = $( "#autocomplete" ).autocomplete( { delay: 0, source: data, change: function( event, ui ) { strictEqual( ui.item, null ); start(); } - }); + } ); element.triggerHandler( "focus" ); element.val( "ja" ).triggerHandler( "blur" ); -}); +} ); asyncTest( "cancel search", function() { expect( 6 ); var first = true, - element = $( "#autocomplete" ).autocomplete({ + element = $( "#autocomplete" ).autocomplete( { delay: 0, source: data, search: function() { @@ -110,76 +111,76 @@ asyncTest( "cancel search", function() { open: function() { ok( true, "menu opened" ); } - }), + } ), menu = element.autocomplete( "widget" ); element.val( "ja" ).trigger( "keydown" ); - setTimeout(function() { + setTimeout( function() { ok( menu.is( ":hidden" ), "menu is hidden after first search" ); element.val( "java" ).trigger( "keydown" ); - setTimeout(function() { + setTimeout( function() { ok( menu.is( ":visible" ), "menu is visible after second search" ); equal( menu.find( ".ui-menu-item" ).length, 2, "# of menu items" ); start(); - }); - }); -}); + } ); + } ); +} ); asyncTest( "cancel focus", function() { expect( 1 ); var customVal = "custom value", - element = $( "#autocomplete" ).autocomplete({ + element = $( "#autocomplete" ).autocomplete( { delay: 0, source: data, focus: function() { $( this ).val( customVal ); return false; } - }); + } ); element.val( "ja" ).trigger( "keydown" ); - setTimeout(function() { + setTimeout( function() { element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); equal( element.val(), customVal ); start(); - }); -}); + } ); +} ); asyncTest( "cancel select", function() { expect( 1 ); var customVal = "custom value", - element = $( "#autocomplete" ).autocomplete({ + element = $( "#autocomplete" ).autocomplete( { delay: 0, source: data, select: function() { $( this ).val( customVal ); return false; } - }); + } ); element.val( "ja" ).trigger( "keydown" ); - setTimeout(function() { + setTimeout( function() { element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); equal( element.val(), customVal ); start(); - }); -}); + } ); +} ); asyncTest( "blur during remote search", function() { expect( 1 ); - var ac = $( "#autocomplete" ).autocomplete({ + var ac = $( "#autocomplete" ).autocomplete( { delay: 0, source: function( request, response ) { ok( true, "trigger request" ); ac.simulate( "blur" ); - setTimeout(function() { - response([ "result" ]); + setTimeout( function() { + response( [ "result" ] ); start(); - }, 25); + }, 25 ); }, open: function() { ok( false, "opened after a blur" ); } - }); + } ); ac.val( "ro" ).trigger( "keydown" ); -}); +} ); } ); diff --git a/tests/unit/autocomplete/methods.js b/tests/unit/autocomplete/methods.js index f614c13cd7a..0ebdc0d7e40 100644 --- a/tests/unit/autocomplete/methods.js +++ b/tests/unit/autocomplete/methods.js @@ -9,16 +9,16 @@ test( "destroy", function( assert ) { expect( 1 ); assert.domEqual( "#autocomplete", function() { $( "#autocomplete" ).autocomplete().autocomplete( "destroy" ); - }); -}); + } ); +} ); test( "search, close", function() { expect( 6 ); var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ], - element = $( "#autocomplete" ).autocomplete({ + element = $( "#autocomplete" ).autocomplete( { source: data, minLength: 0 - }), + } ), menu = element.autocomplete( "widget" ); ok( menu.is( ":hidden" ), "menu is hidden on init" ); @@ -35,7 +35,7 @@ test( "search, close", function() { element.autocomplete( "close" ); ok( menu.is( ":hidden" ), "menu is hidden after close" ); -}); +} ); test( "widget", function( assert ) { expect( 2 ); @@ -43,6 +43,6 @@ test( "widget", function( assert ) { widgetElement = element.autocomplete( "widget" ); equal( widgetElement.length, 1, "one element" ); assert.hasClasses( widgetElement, "ui-menu" ); -}); +} ); } ); diff --git a/tests/unit/autocomplete/options.js b/tests/unit/autocomplete/options.js index 7d281fb316c..76c13e754c8 100644 --- a/tests/unit/autocomplete/options.js +++ b/tests/unit/autocomplete/options.js @@ -14,16 +14,16 @@ test( "appendTo: null", function() { equal( element.autocomplete( "widget" ).parent()[ 0 ], document.body, "defaults to body" ); element.autocomplete( "destroy" ); -}); +} ); test( "appendTo: explicit", function() { expect( 6 ); var detached = $( "
" ), element = $( "#autocomplete" ); - element.autocomplete({ + element.autocomplete( { appendTo: ".autocomplete-wrap" - }); + } ); equal( element.autocomplete( "widget" ).parent()[ 0 ], $( "#autocomplete-wrap1" )[ 0 ], "first found element" ); equal( $( "#autocomplete-wrap2 .ui-autocomplete" ).length, 0, @@ -35,16 +35,16 @@ test( "appendTo: explicit", function() { $( "#autocomplete-wrap1" )[ 0 ], "modified after init" ); element.autocomplete( "destroy" ); - element.autocomplete({ + element.autocomplete( { appendTo: detached - }); + } ); equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ], "detached jQuery object" ); element.autocomplete( "destroy" ); - element.autocomplete({ + element.autocomplete( { appendTo: detached[ 0 ] - }); + } ); equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ], "detached DOM element" ); element.autocomplete( "destroy" ); @@ -53,7 +53,7 @@ test( "appendTo: explicit", function() { equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ], "detached DOM element via option()" ); element.autocomplete( "destroy" ); -}); +} ); test( "appendTo: ui-front", function() { expect( 2 ); @@ -65,15 +65,15 @@ test( "appendTo: ui-front", function() { $( "#autocomplete-wrap2" )[ 0 ], "null, inside .ui-front" ); element.autocomplete( "destroy" ); - element.autocomplete({ + element.autocomplete( { appendTo: $() - }); + } ); equal( element.autocomplete( "widget" ).parent()[ 0 ], $( "#autocomplete-wrap2" )[ 0 ], "empty jQuery object, inside .ui-front" ); -}); +} ); function autoFocusTest( afValue, focusedLength ) { - var element = $( "#autocomplete" ).autocomplete({ + var element = $( "#autocomplete" ).autocomplete( { autoFocus: afValue, delay: 0, source: data, @@ -83,10 +83,10 @@ function autoFocusTest( afValue, focusedLength ) { .find( ".ui-menu-item-wrapper.ui-state-active" ) .length, focusedLength, - "first item is " + (afValue ? "" : "not") + " auto focused" ); + "first item is " + ( afValue ? "" : "not" ) + " auto focused" ); start(); } - }); + } ); element.val( "ja" ).trigger( "keydown" ); stop(); } @@ -94,36 +94,36 @@ function autoFocusTest( afValue, focusedLength ) { test( "autoFocus: false", function() { expect( 1 ); autoFocusTest( false, 0 ); -}); +} ); test( "autoFocus: true", function() { expect( 1 ); autoFocusTest( true, 1 ); -}); +} ); asyncTest( "delay", function() { expect( 2 ); - var element = $( "#autocomplete" ).autocomplete({ + var element = $( "#autocomplete" ).autocomplete( { source: data, delay: 25 - }), + } ), menu = element.autocomplete( "widget" ); element.val( "ja" ).trigger( "keydown" ); ok( menu.is( ":hidden" ), "menu is closed immediately after search" ); - setTimeout(function() { + setTimeout( function() { ok( menu.is( ":visible" ), "menu is open after delay" ); start(); }, 50 ); -}); +} ); asyncTest( "disabled", function( assert ) { expect( 5 ); - var element = $( "#autocomplete" ).autocomplete({ + var element = $( "#autocomplete" ).autocomplete( { source: data, delay: 0 - }), + } ), menu = element.autocomplete( "disable" ).autocomplete( "widget" ); element.val( "ja" ).trigger( "keydown" ); @@ -133,17 +133,17 @@ asyncTest( "disabled", function( assert ) { assert.hasClasses( menu, "ui-autocomplete-disabled" ); ok( !element.attr( "aria-disabled" ), "element doesn't get aria-disabled" ); - setTimeout(function() { + setTimeout( function() { ok( menu.is( ":hidden" ) ); start(); - }); -}); + } ); +} ); test( "minLength", function() { expect( 2 ); - var element = $( "#autocomplete" ).autocomplete({ + var element = $( "#autocomplete" ).autocomplete( { source: data - }), + } ), menu = element.autocomplete( "widget" ); element.autocomplete( "search", "" ); ok( menu.is( ":hidden" ), "blank not enough for minLength: 1" ); @@ -151,19 +151,19 @@ test( "minLength", function() { element.autocomplete( "option", "minLength", 0 ); element.autocomplete( "search", "" ); ok( menu.is( ":visible" ), "blank enough for minLength: 0" ); -}); +} ); asyncTest( "minLength, exceed then drop below", function() { expect( 4 ); - var element = $( "#autocomplete" ).autocomplete({ + var element = $( "#autocomplete" ).autocomplete( { minLength: 2, source: function( req, res ) { equal( req.term, "12", "correct search term" ); - setTimeout(function() { - res([ "item" ]); - }); + setTimeout( function() { + res( [ "item" ] ); + } ); } - }), + } ), menu = element.autocomplete( "widget" ); ok( menu.is( ":hidden" ), "menu is hidden before first search" ); @@ -172,55 +172,57 @@ asyncTest( "minLength, exceed then drop below", function() { ok( menu.is( ":hidden" ), "menu is hidden before second search" ); element.autocomplete( "search", "1" ); - setTimeout(function() { + setTimeout( function() { ok( menu.is( ":hidden" ), "menu is hidden after searches" ); start(); - }); -}); + } ); +} ); test( "minLength, exceed then drop below then exceed", function() { expect( 3 ); var _res = [], - element = $( "#autocomplete" ).autocomplete({ + element = $( "#autocomplete" ).autocomplete( { minLength: 2, source: function( req, res ) { _res.push( res ); } - }), + } ), menu = element.autocomplete( "widget" ); - // trigger a valid search + // Trigger a valid search ok( menu.is( ":hidden" ), "menu is hidden before first search" ); element.autocomplete( "search", "12" ); - // trigger a search below the minLength, to turn on cancelSearch flag + // Trigger a search below the minLength, to turn on cancelSearch flag ok( menu.is( ":hidden" ), "menu is hidden before second search" ); element.autocomplete( "search", "1" ); - // trigger a valid search + // Trigger a valid search element.autocomplete( "search", "13" ); - // react as if the first search was cancelled (default ajax behavior) - _res[ 0 ]([]); - // react to second search - _res[ 1 ]([ "13" ]); + + // React as if the first search was cancelled (default ajax behavior) + _res[ 0 ]( [] ); + + // React to second search + _res[ 1 ]( [ "13" ] ); ok( menu.is( ":visible" ), "menu is visible after searches" ); -}); +} ); test( "source, local string array", function() { expect( 1 ); - var element = $( "#autocomplete" ).autocomplete({ + var element = $( "#autocomplete" ).autocomplete( { source: data - }), + } ), menu = element.autocomplete( "widget" ); element.val( "ja" ).autocomplete( "search" ); equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" ); -}); +} ); function sourceTest( source, async ) { - var element = $( "#autocomplete" ).autocomplete({ + var element = $( "#autocomplete" ).autocomplete( { source: source - }), + } ), menu = element.autocomplete( "widget" ); function result() { var items = menu.find( ".ui-menu-item" ); @@ -228,15 +230,15 @@ function sourceTest( source, async ) { deepEqual( items.eq( 0 ).data( "ui-autocomplete-item" ), { label: "java", value: "java" - }); + } ); deepEqual( items.eq( 1 ).data( "ui-autocomplete-item" ), { label: "javascript", value: "javascript" - }); + } ); deepEqual( items.eq( 2 ).data( "ui-autocomplete-item" ), { label: "clojure", value: "clojure" - }); + } ); element.autocomplete( "destroy" ); if ( async ) { start(); @@ -254,64 +256,64 @@ function sourceTest( source, async ) { test( "source, local object array, only labels", function() { expect( 4 ); - sourceTest([ + sourceTest( [ { label: "java", value: null }, { label: "php", value: null }, { label: "coldfusion", value: "" }, { label: "javascript", value: "" }, { label: "clojure" } - ]); -}); + ] ); +} ); test( "source, local object array, only values", function() { expect( 4 ); - sourceTest([ + sourceTest( [ { value: "java", label: null }, { value: "php", label: null }, { value: "coldfusion", label: "" }, { value: "javascript", label: "" }, { value: "clojure" } - ]); -}); + ] ); +} ); test( "source, url string with remote json string array", function() { expect( 4 ); sourceTest( "remote_string_array.txt", true ); -}); +} ); test( "source, url string with remote json object array, only value properties", function() { expect( 4 ); sourceTest( "remote_object_array_values.txt", true ); -}); +} ); test( "source, url string with remote json object array, only label properties", function() { expect( 4 ); sourceTest( "remote_object_array_labels.txt", true ); -}); +} ); test( "source, custom", function() { expect( 5 ); - sourceTest(function( request, response ) { + sourceTest( function( request, response ) { equal( request.term, "j" ); - response([ + response( [ "java", { label: "javascript", value: null }, { value: "clojure", label: null } - ]); - }); -}); + ] ); + } ); +} ); test( "source, update after init", function() { expect( 2 ); - var element = $( "#autocomplete" ).autocomplete({ + var element = $( "#autocomplete" ).autocomplete( { source: [ "java", "javascript", "haskell" ] - }), + } ), menu = element.autocomplete( "widget" ); element.val( "ja" ).autocomplete( "search" ); equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" ); element.autocomplete( "option", "source", [ "php", "asp" ] ); element.val( "ph" ).autocomplete( "search" ); equal( menu.find( ".ui-menu-item" ).text(), "php" ); -}); +} ); } ); diff --git a/tests/unit/button/common.js b/tests/unit/button/common.js index 0372cddbf1f..4ef136facc7 100644 --- a/tests/unit/button/common.js +++ b/tests/unit/button/common.js @@ -14,9 +14,9 @@ common.testWidget( "button", { label: null, text: true, - // callbacks + // Callbacks create: null } -}); +} ); } ); diff --git a/tests/unit/button/core.js b/tests/unit/button/core.js index f3ae2e58361..f4e5d35a783 100644 --- a/tests/unit/button/core.js +++ b/tests/unit/button/core.js @@ -3,58 +3,58 @@ define( [ "ui/widgets/button" ], function( $ ) { -module("button: core"); +module( "button: core" ); -test("checkbox", function( assert ) { +test( "checkbox", function( assert ) { expect( 4 ); - var input = $("#check"), - label = $("label[for=check]"); - ok( input.is(":visible") ); - ok( label.is(":not(.ui-button)") ); + var input = $( "#check" ), + label = $( "label[for=check]" ); + ok( input.is( ":visible" ) ); + ok( label.is( ":not(.ui-button)" ) ); input.button(); assert.hasClasses( input, "ui-helper-hidden-accessible" ); assert.hasClasses( label, "ui-button" ); -}); +} ); -test("radios", function( assert ) { +test( "radios", function( assert ) { expect( 8 ); - var inputs = $("#radio0 input"), - labels = $("#radio0 label"); - ok( inputs.is(":visible") ); - ok( labels.is(":not(.ui-button)") ); + var inputs = $( "#radio0 input" ), + labels = $( "#radio0 label" ); + ok( inputs.is( ":visible" ) ); + ok( labels.is( ":not(.ui-button)" ) ); inputs.button(); - inputs.each(function() { + inputs.each( function() { assert.hasClasses( this, "ui-helper-hidden-accessible" ); - }); - labels.each(function() { + } ); + labels.each( function() { assert.hasClasses( this, "ui-button" ); - }); -}); + } ); +} ); -test("radio groups", function( assert ) { +test( "radio groups", function( assert ) { expect( 12 ); - function assertClasses(noForm, form1, form2) { - assert.hasClasses( $("#radio0 .ui-button" + noForm ), "ui-state-active" ); - assert.hasClasses( $("#radio1 .ui-button" + form1 ), "ui-state-active" ); - assert.hasClasses( $("#radio2 .ui-button" + form2 ), "ui-state-active" ); + function assertClasses( noForm, form1, form2 ) { + assert.hasClasses( $( "#radio0 .ui-button" + noForm ), "ui-state-active" ); + assert.hasClasses( $( "#radio1 .ui-button" + form1 ), "ui-state-active" ); + assert.hasClasses( $( "#radio2 .ui-button" + form2 ), "ui-state-active" ); } - $("input[type=radio]").button(); - assertClasses(":eq(0)", ":eq(1)", ":eq(2)"); + $( "input[type=radio]" ).button(); + assertClasses( ":eq(0)", ":eq(1)", ":eq(2)" ); - // click outside of forms - $("#radio0 .ui-button:eq(1)").trigger( "click" ); - assertClasses(":eq(1)", ":eq(1)", ":eq(2)"); + // Click outside of forms + $( "#radio0 .ui-button:eq(1)" ).trigger( "click" ); + assertClasses( ":eq(1)", ":eq(1)", ":eq(2)" ); - // click in first form - $("#radio1 .ui-button:eq(0)").trigger( "click" ); - assertClasses(":eq(1)", ":eq(0)", ":eq(2)"); + // Click in first form + $( "#radio1 .ui-button:eq(0)" ).trigger( "click" ); + assertClasses( ":eq(1)", ":eq(0)", ":eq(2)" ); - // click in second form - $("#radio2 .ui-button:eq(0)").trigger( "click" ); - assertClasses(":eq(1)", ":eq(0)", ":eq(0)"); -}); + // Click in second form + $( "#radio2 .ui-button:eq(0)" ).trigger( "click" ); + assertClasses( ":eq(1)", ":eq(0)", ":eq(0)" ); +} ); test( "radio groups - ignore elements with same name", function() { expect( 1 ); @@ -63,47 +63,48 @@ test( "radio groups - ignore elements with same name", function() { checkbox = $( "", { type: "checkbox", name: radios.attr( "name" ) - }); + } ); form.append( checkbox ); radios.button( "refresh" ); ok( true, "no exception from accessing button instance of checkbox" ); -}); +} ); -test("input type submit, don't create child elements", function() { +test( "input type submit, don't create child elements", function() { expect( 2 ); - var input = $("#submit"); + var input = $( "#submit" ); deepEqual( input.children().length, 0 ); input.button(); deepEqual( input.children().length, 0 ); -}); +} ); -test("buttonset", function( assert ) { +test( "buttonset", function( assert ) { expect( 6 ); - var set = $("#radio1").buttonset(); + var set = $( "#radio1" ).buttonset(); assert.hasClasses( set, "ui-buttonset" ); - deepEqual( set.children(".ui-button").length, 3 ); - deepEqual( set.children("input[type=radio].ui-helper-hidden-accessible").length, 3 ); - ok( set.children("label:eq(0)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") ); - ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") ); - ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") ); -}); - -test("buttonset (rtl)", function( assert ) { + deepEqual( set.children( ".ui-button" ).length, 3 ); + deepEqual( set.children( "input[type=radio].ui-helper-hidden-accessible" ).length, 3 ); + ok( set.children( "label:eq(0)" ).is( ".ui-button.ui-corner-left:not(.ui-corner-all)" ) ); + ok( set.children( "label:eq(1)" ).is( ".ui-button:not(.ui-corner-all)" ) ); + ok( set.children( "label:eq(2)" ).is( ".ui-button.ui-corner-right:not(.ui-corner-all)" ) ); +} ); + +test( "buttonset (rtl)", function( assert ) { expect( 6 ); var set, - parent = $("#radio1").parent(); + parent = $( "#radio1" ).parent(); + // Set to rtl - parent.attr("dir", "rtl"); + parent.attr( "dir", "rtl" ); - set = $("#radio1").buttonset(); + set = $( "#radio1" ).buttonset(); assert.hasClasses( set, "ui-buttonset" ); - deepEqual( set.children(".ui-button").length, 3 ); - deepEqual( set.children("input[type=radio].ui-helper-hidden-accessible").length, 3 ); - ok( set.children("label:eq(0)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") ); - ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") ); - ok( set.children("label:eq(2)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") ); -}); + deepEqual( set.children( ".ui-button" ).length, 3 ); + deepEqual( set.children( "input[type=radio].ui-helper-hidden-accessible" ).length, 3 ); + ok( set.children( "label:eq(0)" ).is( ".ui-button.ui-corner-right:not(.ui-corner-all)" ) ); + ok( set.children( "label:eq(1)" ).is( ".ui-button:not(.ui-corner-all)" ) ); + ok( set.children( "label:eq(2)" ).is( ".ui-button.ui-corner-left:not(.ui-corner-all)" ) ); +} ); // TODO: simulated click events don't behave like real click events in IE // remove this when simulate properly simulates this @@ -112,22 +113,22 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) { asyncTest( "ensure checked and aria after single click on checkbox label button, see #5518", function( assert ) { expect( 3 ); - $("#check2").button().on( "change", function() { - var lbl = $( this ).button("widget"); + $( "#check2" ).button().on( "change", function() { + var lbl = $( this ).button( "widget" ); ok( this.checked, "checked ok" ); - ok( lbl.attr("aria-pressed") === "true", "aria ok" ); + ok( lbl.attr( "aria-pressed" ) === "true", "aria ok" ); assert.hasClasses( lbl, "ui-state-active" ); - }); + } ); - // support: Opera + // Support: Opera // Opera doesn't trigger a change event when this is done synchronously. // This seems to be a side effect of another test, but until that can be // tracked down, this delay will have to do. - setTimeout(function() { - $("#check2").button("widget").simulate("click"); + setTimeout( function() { + $( "#check2" ).button( "widget" ).simulate( "click" ); start(); }, 1 ); - }); + } ); } test( "#7092 - button creation that requires a matching label does not find label in all cases", function( assert ) { @@ -151,15 +152,15 @@ test( "#7092 - button creation that requires a matching label does not find labe group = $( "" ); group.filter( "input[type=checkbox]" ).button(); assert.hasClasses( group.find( "label" ), "ui-button" ); -}); +} ); test( "#5946 - buttonset should ignore buttons that are not :visible", function( assert ) { expect( 2 ); $( "#radio01" ).next().addBack().hide(); - var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" }); + var set = $( "#radio0" ).buttonset( { items: "input[type=radio]:visible" } ); ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) ); assert.hasClasses( set.find( "label:eq(1)" ), "ui-button ui-corner-left" ); -}); +} ); test( "#6262 - buttonset not applying ui-corner to invisible elements", function( assert ) { expect( 3 ); @@ -169,7 +170,7 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function assert.hasClasses( set.find( "label:eq(1)" ), "ui-button" ); assert.hasClasses( set.find( "label:eq(2)" ), "ui-button ui-corner-right" ); -}); +} ); asyncTest( "Resetting a button's form should refresh the visual state of the button widget to match.", function( assert ) { expect( 2 ); @@ -185,15 +186,15 @@ asyncTest( "Resetting a button's form should refresh the visual state of the but form.get( 0 ).reset(); - // #9213: If a button has been removed, refresh should not be called on it when + // If a button has been removed, refresh should not be called on it when // its corresponding form is reset. button.remove(); - setTimeout(function() { + setTimeout( function() { assert.hasClasses( checkbox.button( "widget" ), "ui-state-active" ); start(); }, 1 ); -}); +} ); asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function( assert ) { expect( 2 ); @@ -201,30 +202,30 @@ asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyb label = $( "label[for='check']" ); assert.lacksClasses( label, "ui-state-focus" ); check.trigger( "focus" ); - setTimeout(function() { + setTimeout( function() { assert.hasClasses( label, "ui-state-focus" ); start(); - }); -}); + } ); +} ); test( "#7534 - Button label selector works for ids with \":\"", function( assert ) { expect( 1 ); var group = $( "" ); group.find( "input" ).button(); - assert.hasClasses( group.find( "label" ), "ui-button" , "Found an id with a :" ); -}); + assert.hasClasses( group.find( "label" ), "ui-button", "Found an id with a :" ); +} ); asyncTest( "#9169 - Disabled button maintains ui-state-focus", function( assert ) { expect( 2 ); var element = $( "#button1" ).button(); element[ 0 ].focus(); - setTimeout(function() { + setTimeout( function() { assert.hasClasses( element, "ui-state-focus" ); element.button( "disable" ); assert.lacksClasses( element, "ui-state-focus", "button does not have ui-state-focus when disabled" ); start(); - }); -}); + } ); +} ); } ); diff --git a/tests/unit/button/events.js b/tests/unit/button/events.js index d778b4a2bf3..15a285046de 100644 --- a/tests/unit/button/events.js +++ b/tests/unit/button/events.js @@ -3,15 +3,15 @@ define( [ "ui/widgets/button" ], function( $ ) { -module("button: events"); +module( "button: events" ); -test("buttonset works with single-quote named elements (#7505)", function() { +test( "buttonset works with single-quote named elements (#7505)", function() { expect( 1 ); - $("#radio3").buttonset(); - $("#radio33").on( "click", function(){ + $( "#radio3" ).buttonset(); + $( "#radio33" ).on( "click", function() { ok( true, "button clicks work with single-quote named elements" ); - }).trigger( "click" ); -}); + } ).trigger( "click" ); +} ); asyncTest( "when button loses focus, ensure active state is removed (#8559)", function( assert ) { expect( 1 ); @@ -22,15 +22,15 @@ asyncTest( "when button loses focus, ensure active state is removed (#8559)", fu element.one( "blur", function() { assert.lacksClasses( element, "ui-state-active", "button loses active state appropriately" ); start(); - }).trigger( "blur" ); - }); + } ).trigger( "blur" ); + } ); element.trigger( "focus" ); - setTimeout(function() { + setTimeout( function() { element .simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ) .simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } ); - }); -}); + } ); +} ); } ); diff --git a/tests/unit/button/methods.js b/tests/unit/button/methods.js index 29e91702219..0bafd90f918 100644 --- a/tests/unit/button/methods.js +++ b/tests/unit/button/methods.js @@ -3,50 +3,50 @@ define( [ "ui/widgets/button" ], function( $ ) { -module("button: methods"); +module( "button: methods" ); -test("destroy", function( assert ) { +test( "destroy", function( assert ) { expect( 1 ); assert.domEqual( "#button", function() { $( "#button" ).button().button( "destroy" ); - }); -}); + } ); +} ); test( "refresh: Ensure disabled state is preserved correctly.", function() { expect( 8 ); var element = $( "" ); - element.button({ disabled: true }).button( "refresh" ); + element.button( { disabled: true } ).button( "refresh" ); ok( element.button( "option", "disabled" ), "Anchor button should remain disabled after refresh" ); //See #8237 element = $( "
" ); - element.button({ disabled: true }).button( "refresh" ); + element.button( { disabled: true } ).button( "refresh" ); ok( element.button( "option", "disabled" ), "
buttons should remain disabled after refresh" ); element = $( "" ); - element.button( { disabled: true} ).button( "refresh" ); - ok( element.button( "option", "disabled" ), "" ); - element.button( { disabled: true} ).prop( "disabled", false ).button( "refresh" ); - ok( !element.button( "option", "disabled" ), "Changing a " ) @@ -464,7 +464,7 @@ $.widget( "ui.dialog", { var that = this, buttons = this.options.buttons; - // if we already have a button pane, remove it + // If we already have a button pane, remove it this.uiDialogButtonPane.remove(); this.uiButtonSet.empty(); @@ -722,12 +722,12 @@ $.widget( "ui.dialog", { uiDialog.resizable( "destroy" ); } - // currently resizable, changing handles + // Currently resizable, changing handles if ( isResizable && typeof value === "string" ) { uiDialog.resizable( "option", "handles", value ); } - // currently non-resizable, becoming resizable + // Currently non-resizable, becoming resizable if ( !isResizable && value !== false ) { this._makeResizable(); } @@ -756,7 +756,7 @@ $.widget( "ui.dialog", { options.width = options.minWidth; } - // reset wrapper sizing + // Reset wrapper sizing // determine the height of all the non-content elements nonContentHeight = this.uiDialog.css( { height: "auto", diff --git a/ui/widgets/draggable.js b/ui/widgets/draggable.js index ab9d2466778..b2c56509fd5 100644 --- a/ui/widgets/draggable.js +++ b/ui/widgets/draggable.js @@ -65,7 +65,7 @@ $.widget("ui.draggable", $.ui.mouse, { stack: false, zIndex: false, - // callbacks + // Callbacks drag: null, start: null, stop: null @@ -108,7 +108,7 @@ $.widget("ui.draggable", $.ui.mouse, { this._blurActiveElement( event ); - // among others, prevent a drag on a resizable-handle + // Among others, prevent a drag on a resizable-handle if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) { return false; } @@ -362,7 +362,7 @@ $.widget("ui.draggable", $.ui.mouse, { helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo)); } - // http://bugs.jqueryui.com/ticket/9446 + // Http://bugs.jqueryui.com/ticket/9446 // a helper function can return the original element // which wouldn't have been set to relative in _create if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) { @@ -700,7 +700,7 @@ $.ui.plugin.add( "draggable", "connectToSortable", { if ( sortable && !sortable.options.disabled ) { draggable.sortables.push( sortable ); - // refreshPositions is called at drag start to refresh the containerCache + // RefreshPositions is called at drag start to refresh the containerCache // which is used in drag. This ensures it's initialized and synchronized // with any changes that might have happened on the page since initialization. sortable.refreshPositions(); @@ -825,7 +825,7 @@ $.ui.plugin.add( "draggable", "connectToSortable", { this.refreshPositions(); }); - // hack so receive/update callbacks work (mostly) + // Hack so receive/update callbacks work (mostly) draggable.currentItem = draggable.element; sortable.fromOutside = draggable; } @@ -854,7 +854,7 @@ $.ui.plugin.add( "draggable", "connectToSortable", { sortable._trigger( "out", event, sortable._uiHash( sortable ) ); sortable._mouseStop( event, true ); - // restore sortable behaviors that were modfied + // Restore sortable behaviors that were modfied // when the draggable entered the sortable area (#9481) sortable.options.revert = sortable.options._revert; sortable.options.helper = sortable.options._helper; diff --git a/ui/widgets/droppable.js b/ui/widgets/droppable.js index 3a8bd71094f..6ba8d8c8090 100644 --- a/ui/widgets/droppable.js +++ b/ui/widgets/droppable.js @@ -41,7 +41,7 @@ $.widget( "ui.droppable", { scope: "default", tolerance: "intersect", - // callbacks + // Callbacks activate: null, deactivate: null, drop: null, @@ -388,7 +388,7 @@ $.ui.ddmanager = { } } - // we just moved into a greedy child + // We just moved into a greedy child if ( parentInstance && c === "isover" ) { parentInstance.isover = false; parentInstance.isout = true; @@ -399,7 +399,7 @@ $.ui.ddmanager = { this[c === "isout" ? "isover" : "isout"] = false; this[c === "isover" ? "_over" : "_out"].call( this, event ); - // we just moved out of a greedy child + // We just moved out of a greedy child if ( parentInstance && c === "isout" ) { parentInstance.isout = false; parentInstance.isover = true; diff --git a/ui/widgets/menu.js b/ui/widgets/menu.js index 3e1f71a3bb1..48258e85e95 100644 --- a/ui/widgets/menu.js +++ b/ui/widgets/menu.js @@ -52,7 +52,7 @@ return $.widget( "ui.menu", { }, role: "menu", - // callbacks + // Callbacks blur: null, focus: null, select: null diff --git a/ui/widgets/mouse.js b/ui/widgets/mouse.js index 80242c0b73a..2114f187000 100644 --- a/ui/widgets/mouse.js +++ b/ui/widgets/mouse.js @@ -78,7 +78,7 @@ return $.widget("ui.mouse", { this._mouseMoved = false; - // we may have missed mouseup (out of window) + // We may have missed mouseup (out of window) (this._mouseStarted && this._mouseUp(event)); this._mouseDownEvent = event; @@ -112,7 +112,7 @@ return $.widget("ui.mouse", { $.removeData(event.target, this.widgetName + ".preventClickEvent"); } - // these delegates are required to keep context + // These delegates are required to keep context this._mouseMoveDelegate = function(event) { return that._mouseMove(event); }; diff --git a/ui/widgets/progressbar.js b/ui/widgets/progressbar.js index a52cbb71345..07ffaa97f8d 100644 --- a/ui/widgets/progressbar.js +++ b/ui/widgets/progressbar.js @@ -90,7 +90,7 @@ return $.widget( "ui.progressbar", { this.indeterminate = newValue === false; - // sanitize value + // Sanitize value if ( typeof newValue !== "number" ) { newValue = 0; } diff --git a/ui/widgets/resizable.js b/ui/widgets/resizable.js index 95cf918d941..cc6f9f186de 100644 --- a/ui/widgets/resizable.js +++ b/ui/widgets/resizable.js @@ -60,7 +60,7 @@ $.widget("ui.resizable", $.ui.mouse, { // See #7960 zIndex: 90, - // callbacks + // Callbacks resize: null, start: null, stop: null @@ -153,7 +153,7 @@ $.widget("ui.resizable", $.ui.mouse, { display: "block" }) ); - // support: IE9 + // Support: IE9 // avoid IE jump (hard set the margin) this.originalElement.css({ margin: this.originalElement.css("margin") }); @@ -796,7 +796,7 @@ $.ui.plugin.add("resizable", "animate", { $(pr[0]).css({ width: data.width, height: data.height }); } - // propagating resize, and updating values for each animation step + // Propagating resize, and updating values for each animation step that._updateCache(data); that._propagate("resize", event); diff --git a/ui/widgets/selectable.js b/ui/widgets/selectable.js index 4edf46ad68d..0dadac9627d 100644 --- a/ui/widgets/selectable.js +++ b/ui/widgets/selectable.js @@ -40,7 +40,7 @@ return $.widget("ui.selectable", $.ui.mouse, { filter: "*", tolerance: "touch", - // callbacks + // Callbacks selected: null, selecting: null, start: null, @@ -55,7 +55,7 @@ return $.widget("ui.selectable", $.ui.mouse, { this.dragged = false; - // cache selectee children based on filter + // Cache selectee children based on filter this.refresh = function() { that.selectees = $(that.options.filter, that.element[0]); that._addClass( that.selectees, "ui-selectee" ); diff --git a/ui/widgets/selectmenu.js b/ui/widgets/selectmenu.js index bf415a82629..273e68594c0 100644 --- a/ui/widgets/selectmenu.js +++ b/ui/widgets/selectmenu.js @@ -58,7 +58,7 @@ return $.widget( "ui.selectmenu", { }, width: false, - // callbacks + // Callbacks change: null, close: null, focus: null, @@ -169,7 +169,7 @@ return $.widget( "ui.selectmenu", { select: function( event, ui ) { event.preventDefault(); - // support: IE8 + // Support: IE8 // If the item was selected via a click, the text selection // will be destroyed in IE that._setSelection(); @@ -410,12 +410,12 @@ return $.widget( "ui.selectmenu", { selection.removeAllRanges(); selection.addRange( this.range ); - // support: IE8 + // Support: IE8 } else { this.range.select(); } - // support: IE + // Support: IE // Setting the text selection kills the button focus in IE, but // restoring the focus doesn't kill the selection. this.button.focus(); @@ -446,7 +446,7 @@ return $.widget( "ui.selectmenu", { this.range = selection.getRangeAt( 0 ); } - // support: IE8 + // Support: IE8 } else { this.range = document.selection.createRange(); } @@ -638,7 +638,7 @@ return $.widget( "ui.selectmenu", { this.menu.outerWidth( Math.max( this.button.outerWidth(), - // support: IE10 + // Support: IE10 // IE10 wraps long text (possibly a rounding bug) // so we add 1px to avoid the wrapping this.menu.width( "" ).outerWidth() + 1 diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index 1ab319ebbf7..792fa4da2da 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -57,14 +57,14 @@ return $.widget( "ui.slider", $.ui.mouse, { value: 0, values: null, - // callbacks + // Callbacks change: null, slide: null, start: null, stop: null }, - // number of pages in a slider + // Number of pages in a slider // (how many times can you page up/down to go through the whole range) numPages: 5, @@ -516,7 +516,7 @@ return $.widget( "ui.slider", $.ui.mouse, { } }, - // returns the step-aligned value that val is closest to, between (inclusive) min and max + // Returns the step-aligned value that val is closest to, between (inclusive) min and max _trimAlignValue: function( val ) { if ( val <= this._valueMin() ) { return this._valueMin(); diff --git a/ui/widgets/sortable.js b/ui/widgets/sortable.js index 1d384a80e6c..bea58defd86 100644 --- a/ui/widgets/sortable.js +++ b/ui/widgets/sortable.js @@ -62,7 +62,7 @@ return $.widget("ui.sortable", $.ui.mouse, { tolerance: "intersect", zIndex: 1000, - // callbacks + // Callbacks activate: null, beforeStop: null, change: null, @@ -258,7 +258,7 @@ return $.widget("ui.sortable", $.ui.mouse, { if( o.cursor && o.cursor !== "auto" ) { // cursor option body = this.document.find( "body" ); - // support: IE + // Support: IE this.storedCursor = body.css( "cursor" ); body.css( "cursor", o.cursor ); @@ -400,7 +400,7 @@ return $.widget("ui.sortable", $.ui.mouse, { continue; } - // cannot intersect with itself + // Cannot intersect with itself // no useless actions that have been done before // no action if the item moved is the parent of the item checked if (itemElement !== this.currentItem[0] && @@ -860,17 +860,17 @@ return $.widget("ui.sortable", $.ui.mouse, { innermostContainer = null, innermostIndex = null; - // get innermost container that intersects with item + // Get innermost container that intersects with item for (i = this.containers.length - 1; i >= 0; i--) { - // never consider a container that's located within the item itself + // Never consider a container that's located within the item itself if($.contains(this.currentItem[0], this.containers[i].element[0])) { continue; } if(this._intersectsWith(this.containers[i].containerCache)) { - // if we've already found a container and it's more "inner" than this, then continue + // If we've already found a container and it's more "inner" than this, then continue if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) { continue; } @@ -888,12 +888,12 @@ return $.widget("ui.sortable", $.ui.mouse, { } - // if no intersecting containers found, return + // If no intersecting containers found, return if(!innermostContainer) { return; } - // move the item into the container if it's not there already + // Move the item into the container if it's not there already if(this.containers.length === 1) { if (!this.containers[innermostIndex].containerCache.over) { this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); diff --git a/ui/widgets/spinner.js b/ui/widgets/spinner.js index bc0535700bd..712d99bad8c 100644 --- a/ui/widgets/spinner.js +++ b/ui/widgets/spinner.js @@ -91,7 +91,7 @@ $.widget( "ui.spinner", { this._on( this._events ); this._refresh(); - // turning off autocomplete prevents the browser from remembering the + // Turning off autocomplete prevents the browser from remembering the // value when navigating through history, so we re-enable autocomplete // if the page is unloaded before the widget is destroyed. #7790 this._on( this.window, { @@ -178,11 +178,11 @@ $.widget( "ui.spinner", { } } - // ensure focus is on (or stays on) the text field + // Ensure focus is on (or stays on) the text field event.preventDefault(); checkFocus.call( this ); - // support: IE + // Support: IE // IE doesn't prevent moving focus even with event.preventDefault() // so we set a flag to know when we should ignore the blur event // and check (again) if focus moved off of the input. @@ -242,7 +242,7 @@ $.widget( "ui.spinner", { this.element.attr( "role", "spinbutton" ); - // button bindings + // Button bindings this.buttons = this.uiSpinner.children( "a" ) .attr( "tabIndex", -1 ) .button(); @@ -264,7 +264,7 @@ $.widget( "ui.spinner", { this.uiSpinner.height( this.uiSpinner.height() ); } - // disable spinner if element was already disabled + // Disable spinner if element was already disabled if ( this.options.disabled ) { this.disable(); } @@ -360,7 +360,7 @@ $.widget( "ui.spinner", { var base, aboveMin, options = this.options; - // make sure we're at a valid step + // Make sure we're at a valid step // - find out where we are relative to the base (min or 0) base = options.min !== null ? options.min : 0; aboveMin = value - base; @@ -369,10 +369,10 @@ $.widget( "ui.spinner", { // - rounding is based on 0, so adjust back to our base value = base + aboveMin; - // fix precision from bad JS floating point math + // Fix precision from bad JS floating point math value = parseFloat( value.toFixed( this._precision() ) ); - // clamp the value + // Clamp the value if ( options.max !== null && value > options.max ) { return options.max; } @@ -461,16 +461,16 @@ $.widget( "ui.spinner", { isValid: function() { var value = this.value(); - // null is invalid + // Null is invalid if ( value === null ) { return false; } - // if value gets adjusted, it's invalid + // If value gets adjusted, it's invalid return value === this._adjustValue( value ); }, - // update the value without triggering change + // Update the value without triggering change _value: function( value, allowAny ) { var parsed; if ( value !== "" ) { diff --git a/ui/widgets/tabs.js b/ui/widgets/tabs.js index 0b7bf585087..034dcc3aa16 100644 --- a/ui/widgets/tabs.js +++ b/ui/widgets/tabs.js @@ -53,7 +53,7 @@ $.widget( "ui.tabs", { hide: null, show: null, - // callbacks + // Callbacks activate: null, beforeActivate: null, beforeLoad: null, @@ -69,7 +69,7 @@ $.widget( "ui.tabs", { anchorUrl = anchor.href.replace( rhash, "" ); locationUrl = location.href.replace( rhash, "" ); - // decoding may throw an error if the URL isn't UTF-8 (#9518) + // Decoding may throw an error if the URL isn't UTF-8 (#9518) try { anchorUrl = decodeURIComponent( anchorUrl ); } catch ( error ) {} @@ -103,7 +103,7 @@ $.widget( "ui.tabs", { ) ).sort(); } - // check for length avoids error when initializing empty list + // Check for length avoids error when initializing empty list if ( this.options.active !== false && this.anchors.length ) { this.active = this._findActive( options.active ); } else { @@ -133,18 +133,18 @@ $.widget( "ui.tabs", { } ); } - // check for a tab marked active via a class + // Check for a tab marked active via a class if ( active === null ) { active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) ); } - // no active tab, set to false + // No active tab, set to false if ( active === null || active === -1 ) { active = this.tabs.length ? 0 : false; } } - // handle numbers: negative, out of range + // Handle numbers: negative, out of range if ( active !== false ) { active = this.tabs.index( this.tabs.eq( active ) ); if ( active === -1 ) { @@ -152,7 +152,7 @@ $.widget( "ui.tabs", { } } - // don't allow collapsible: false and active: false + // Don't allow collapsible: false and active: false if ( !collapsible && active === false && this.anchors.length ) { active = 0; } @@ -320,7 +320,7 @@ $.widget( "ui.tabs", { var options = this.options, lis = this.tablist.children( ":has(a[href])" ); - // get disabled tabs from class attribute from HTML + // Get disabled tabs from class attribute from HTML // this will get converted to a boolean if needed in _refresh() options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) { return lis.index( tab ); @@ -328,7 +328,7 @@ $.widget( "ui.tabs", { this._processTabs(); - // was collapsed or no tabs + // Was collapsed or no tabs if ( options.active === false || !this.anchors.length ) { options.active = false; this.active = $(); @@ -404,7 +404,7 @@ $.widget( "ui.tabs", { } } ) - // support: IE <9 + // Support: IE <9 // Preventing the default action in mousedown doesn't prevent IE // from focusing the element, so if the anchor gets focused, blur. // We don't have to worry about focusing the previously focused @@ -440,7 +440,7 @@ $.widget( "ui.tabs", { tab = $( anchor ).closest( "li" ), originalAriaControls = tab.attr( "aria-controls" ); - // inline tab + // Inline tab if ( that._isLocal( anchor ) ) { selector = anchor.hash; panelId = selector.substring( 1 ); @@ -483,7 +483,7 @@ $.widget( "ui.tabs", { } }, - // allow overriding how to find the list for rare usage scenarios (#7715) + // Allow overriding how to find the list for rare usage scenarios (#7715) _getList: function() { return this.tablist || this.element.find( "ol, ul" ).eq( 0 ); }, @@ -505,7 +505,7 @@ $.widget( "ui.tabs", { } } - // disable tabs + // Disable tabs for ( i = 0; ( li = this.tabs[ i ] ); i++ ) { currentItem = $( li ); if ( disabled === true || $.inArray( i, disabled ) !== -1 ) { @@ -625,7 +625,7 @@ $.widget( "ui.tabs", { this._toggle( event, eventData ); }, - // handles show/hide for selecting tabs + // Handles show/hide for selecting tabs _toggle: function( event, eventData ) { var that = this, toShow = eventData.newPanel, @@ -649,7 +649,7 @@ $.widget( "ui.tabs", { } } - // start out by hiding, then showing, then completing + // Start out by hiding, then showing, then completing if ( toHide.length && this.options.hide ) { this._hide( toHide, this.options.hide, function() { that._removeClass( eventData.oldTab.closest( "li" ), @@ -692,12 +692,12 @@ $.widget( "ui.tabs", { var anchor, active = this._findActive( index ); - // trying to activate the already active panel + // Trying to activate the already active panel if ( active[ 0 ] === this.active[ 0 ] ) { return; } - // trying to collapse, simulate a click on the current active header + // Trying to collapse, simulate a click on the current active header if ( !active.length ) { active = this.active; } @@ -832,14 +832,14 @@ $.widget( "ui.tabs", { } }; - // not remote + // Not remote if ( this._isLocal( anchor[ 0 ] ) ) { return; } this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) ); - // support: jQuery <1.8 + // Support: jQuery <1.8 // jQuery <1.8 returns false if the request is canceled in beforeSend, // but as of 1.8, $.ajax() always returns a jqXHR object. if ( this.xhr && this.xhr.statusText !== "canceled" ) { diff --git a/ui/widgets/tooltip.js b/ui/widgets/tooltip.js index 1c919582efa..6c4493052d7 100644 --- a/ui/widgets/tooltip.js +++ b/ui/widgets/tooltip.js @@ -59,7 +59,7 @@ $.widget( "ui.tooltip", { show: true, track: false, - // callbacks + // Callbacks close: null, open: null }, @@ -139,14 +139,14 @@ $.widget( "ui.tooltip", { _disable: function() { var that = this; - // close open tooltips + // Close open tooltips $.each( this.tooltips, function( id, tooltipData ) { var event = $.Event( "blur" ); event.target = event.currentTarget = tooltipData.element[ 0 ]; that.close( event, true ); } ); - // remove title attributes to prevent native tooltips + // Remove title attributes to prevent native tooltips this.element.find( this.options.items ).addBack().each( function() { var element = $( this ); if ( element.is( "[title]" ) ) { @@ -185,7 +185,7 @@ $.widget( "ui.tooltip", { target.data( "ui-tooltip-open", true ); - // kill parent tooltips, custom or native, for hover + // Kill parent tooltips, custom or native, for hover if ( event && event.type === "mouseover" ) { target.parents().each( function() { var parent = $( this ), @@ -232,7 +232,7 @@ $.widget( "ui.tooltip", { return; } - // jQuery creates a special event for focusin when it doesn't + // JQuery creates a special event for focusin when it doesn't // exist natively. To improve performance, the native event // object is reused and the type is changed. Therefore, we can't // rely on the type being correct after the event finished @@ -264,7 +264,7 @@ $.widget( "ui.tooltip", { return; } - // if we have a title, clear it to prevent the native tooltip + // If we have a title, clear it to prevent the native tooltip // we have to check first to avoid defining a title if none exists // (we don't want to cause an element to start matching [title]) // @@ -377,7 +377,7 @@ $.widget( "ui.tooltip", { tooltip = tooltipData.tooltip; - // disabling closes the tooltip, so we need to track when we're closing + // Disabling closes the tooltip, so we need to track when we're closing // to avoid an infinite loop in case the tooltip becomes disabled on close if ( tooltipData.closing ) { return; @@ -386,7 +386,7 @@ $.widget( "ui.tooltip", { // Clear the interval for delayed tracking tooltips clearInterval( this.delayedShow ); - // only set title if we had one before (see comment in _open()) + // Only set title if we had one before (see comment in _open()) // If the title attribute has changed since open(), don't restore if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) { target.attr( "title", target.data( "ui-tooltip-title" ) ); @@ -462,7 +462,7 @@ $.widget( "ui.tooltip", { _destroy: function() { var that = this; - // close open tooltips + // Close open tooltips $.each( this.tooltips, function( id, tooltipData ) { // Delegate to close method to handle common cleanup var event = $.Event( "blur" ),