From 913afd5c92fa624baa1bff8194c8a187b9f6e52f Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:04:13 -0400 Subject: [PATCH 01/26] Tooltip: Style updates --- tests/unit/tooltip/common-deprecated.js | 2 +- tests/unit/tooltip/common.js | 2 +- tests/unit/tooltip/methods.js | 2 +- tests/unit/tooltip/options.js | 2 +- tests/visual/tooltip/tooltip.html | 10 +++++----- ui/widgets/tooltip.js | 18 +++++++++--------- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/unit/tooltip/common-deprecated.js b/tests/unit/tooltip/common-deprecated.js index 9e3c5ef5930..75a688f0a0c 100644 --- a/tests/unit/tooltip/common-deprecated.js +++ b/tests/unit/tooltip/common-deprecated.js @@ -21,7 +21,7 @@ common.testWidget( "tooltip", { tooltipClass: null, track: false, - // callbacks + // Callbacks close: null, create: null, open: null diff --git a/tests/unit/tooltip/common.js b/tests/unit/tooltip/common.js index 77e3f02b8f0..15c9dfad833 100644 --- a/tests/unit/tooltip/common.js +++ b/tests/unit/tooltip/common.js @@ -20,7 +20,7 @@ common.testWidget( "tooltip", { show: true, track: false, - // callbacks + // Callbacks close: null, create: null, open: null diff --git a/tests/unit/tooltip/methods.js b/tests/unit/tooltip/methods.js index b5b6ca6e9f3..d4c56e1f3d1 100644 --- a/tests/unit/tooltip/methods.js +++ b/tests/unit/tooltip/methods.js @@ -13,7 +13,7 @@ test( "destroy", function( assert ) { element.tooltip().tooltip( "destroy" ); }); - // make sure that open tooltips are removed on destroy + // Make sure that open tooltips are removed on destroy assert.domEqual( "#tooltipped1", function() { element .tooltip() diff --git a/tests/unit/tooltip/options.js b/tests/unit/tooltip/options.js index 6aa576583bd..2833e68ddb6 100644 --- a/tests/unit/tooltip/options.js +++ b/tests/unit/tooltip/options.js @@ -161,7 +161,7 @@ test( "items", function() { element.tooltip( "open", event ); deepEqual( $( "#" + $( "#fixture-span" ).data( "ui-tooltip-id" ) ).text(), "title-text" ); - // make sure default [title] doesn't get used + // Make sure default [title] doesn't get used event.target = $( "#tooltipped1" )[ 0 ]; element.tooltip( "open", event ); deepEqual( $( "#tooltipped1" ).data( "ui-tooltip-id" ), undefined ); diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html index c0ba7a11cea..176af85d86c 100644 --- a/tests/visual/tooltip/tooltip.html +++ b/tests/visual/tooltip/tooltip.html @@ -20,7 +20,7 @@ // default $( "#context1, form, #childish, #nested-input" ).tooltip(); - // custom class, replaces ui-widget-content + // Custom class, replaces ui-widget-content $( "#context2" ).tooltip({ classes: { "ui-tooltip": "ui-corner-all ui-widget-header" @@ -32,7 +32,7 @@ } }); - // synchronous content + // Synchronous content $( "#footnotes" ).tooltip({ items: "[href^='#']", content: function() { @@ -40,7 +40,7 @@ } }); - // asynchronous content + // Asynchronous content $( "#async" ).tooltip({ content: function( response ) { setTimeout(function() { @@ -50,7 +50,7 @@ } }); - // asynchronous content with caching + // Asynchronous content with caching var content; $( "#async2" ).tooltip({ content: function( response ) { @@ -65,7 +65,7 @@ } }); - // custom position + // Custom position $( "#right2" ).tooltip({ classes: { "ui-tooltip": "ui-corner-all ui-state-highlight" 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" ), From 21400d1cb22c2d2385ea2cdeea1c6f5fe7f2e4ab Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:04:44 -0400 Subject: [PATCH 02/26] Tabs: Style updates --- demos/tabs/manipulation.html | 10 +++++----- tests/unit/tabs/common.js | 2 +- tests/unit/tabs/core.js | 24 +++++++++++------------ tests/unit/tabs/events.js | 22 ++++++++++----------- tests/unit/tabs/methods.js | 20 +++++++++---------- tests/unit/tabs/options.js | 16 +++++++-------- ui/widgets/tabs.js | 38 ++++++++++++++++++------------------ 7 files changed, 66 insertions(+), 66 deletions(-) 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/tests/unit/tabs/common.js b/tests/unit/tabs/common.js index 42dd0c2fc50..40c899847be 100644 --- a/tests/unit/tabs/common.js +++ b/tests/unit/tabs/common.js @@ -19,7 +19,7 @@ common.testWidget( "tabs", { hide: null, show: null, - // callbacks + // Callbacks activate: null, beforeActivate: null, beforeLoad: null, diff --git a/tests/unit/tabs/core.js b/tests/unit/tabs/core.js index b64f1d8f36f..9c62817eba4 100644 --- a/tests/unit/tabs/core.js +++ b/tests/unit/tabs/core.js @@ -191,7 +191,7 @@ asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER", equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" ); tabs.eq( 0 ).simulate( "focus" ); - // down, right, down (wrap), up (wrap) + // Down, right, down (wrap), up (wrap) function step1() { assert.hasClasses( tabs.eq( 0 ), "ui-state-focus", "first tab has focus" ); equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" ); @@ -242,7 +242,7 @@ asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER", setTimeout( step2, 25 ); } - // left, home, space + // Left, home, space function step2() { equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" ); equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" ); @@ -280,7 +280,7 @@ asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER", setTimeout( step3 ); } - // end, enter + // End, enter function step3() { equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" ); equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" ); @@ -307,7 +307,7 @@ asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER", setTimeout( step4 ); } - // enter (collapse) + // Enter (collapse) function step4() { equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" ); ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" ); @@ -347,7 +347,7 @@ $.each({ equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" ); tabs.eq( 0 ).simulate( "focus" ); - // down + // Down function step1() { var eventProperties = { keyCode: keyCode.DOWN }; eventProperties[ modifier + "Key" ] = true; @@ -371,7 +371,7 @@ $.each({ setTimeout( step2, 25 ); } - // right + // Right function step2() { var eventProperties = { keyCode: keyCode.RIGHT }; eventProperties[ modifier + "Key" ] = true; @@ -398,7 +398,7 @@ $.each({ setTimeout( step3, 25 ); } - // down (wrap) + // Down (wrap) function step3() { var eventProperties = { keyCode: keyCode.DOWN }; eventProperties[ modifier + "Key" ] = true; @@ -421,7 +421,7 @@ $.each({ setTimeout( step4, 25 ); } - // up (wrap) + // Up (wrap) function step4() { var eventProperties = { keyCode: keyCode.UP }; eventProperties[ modifier + "Key" ] = true; @@ -445,7 +445,7 @@ $.each({ setTimeout( step5, 25 ); } - // left + // Left function step5() { var eventProperties = { keyCode: keyCode.LEFT }; eventProperties[ modifier + "Key" ] = true; @@ -472,7 +472,7 @@ $.each({ setTimeout( step6, 25 ); } - // home + // Home function step6() { var eventProperties = { keyCode: keyCode.HOME }; eventProperties[ modifier + "Key" ] = true; @@ -499,7 +499,7 @@ $.each({ setTimeout( step7, 25 ); } - // end + // End function step7() { var eventProperties = { keyCode: keyCode.END }; eventProperties[ modifier + "Key" ] = true; @@ -523,7 +523,7 @@ $.each({ setTimeout( step8, 25 ); } - // space + // Space function step8() { equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" ); ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" ); diff --git a/tests/unit/tabs/events.js b/tests/unit/tabs/events.js index 7e3d27fdaed..307e110fdbe 100644 --- a/tests/unit/tabs/events.js +++ b/tests/unit/tabs/events.js @@ -58,7 +58,7 @@ test( "beforeActivate", function() { anchors = tabs.find( ".ui-tabs-anchor" ), panels = element.find( ".ui-tabs-panel" ); - // from collapsed + // From collapsed element.one( "tabsbeforeactivate", function( event, ui ) { ok( !( "originalEvent" in event ), "originalEvent" ); equal( ui.oldTab.length, 0, "oldTab length" ); @@ -72,7 +72,7 @@ test( "beforeActivate", function() { element.tabs( "option", "active", 0 ); state( element, 1, 0, 0 ); - // switching tabs + // Switching tabs element.one( "tabsbeforeactivate", function( event, ui ) { equal( event.originalEvent.type, "click", "originalEvent" ); equal( ui.oldTab.length, 1, "oldTab length" ); @@ -88,7 +88,7 @@ test( "beforeActivate", function() { anchors.eq( 1 ).trigger( "click" ); state( element, 0, 1, 0 ); - // collapsing + // Collapsing element.one( "tabsbeforeactivate", function( event, ui ) { ok( !( "originalEvent" in event ), "originalEvent" ); equal( ui.oldTab.length, 1, "oldTab length" ); @@ -102,7 +102,7 @@ test( "beforeActivate", function() { element.tabs( "option", "active", false ); state( element, 0, 0, 0 ); - // prevent activation + // Prevent activation element.one( "tabsbeforeactivate", function( event, ui ) { ok( !( "originalEvent" in event ), "originalEvent" ); equal( ui.oldTab.length, 0, "oldTab length" ); @@ -129,7 +129,7 @@ test( "activate", function() { anchors = element.find( ".ui-tabs-anchor" ), panels = element.find( ".ui-tabs-panel" ); - // from collapsed + // From collapsed element.one( "tabsactivate", function( event, ui ) { ok( !( "originalEvent" in event ), "originalEvent" ); equal( ui.oldTab.length, 0, "oldTab length" ); @@ -143,7 +143,7 @@ test( "activate", function() { element.tabs( "option", "active", 0 ); state( element, 1, 0, 0 ); - // switching tabs + // Switching tabs element.one( "tabsactivate", function( event, ui ) { equal( event.originalEvent.type, "click", "originalEvent" ); equal( ui.oldTab.length, 1, "oldTab length" ); @@ -159,7 +159,7 @@ test( "activate", function() { anchors.eq( 1 ).trigger( "click" ); state( element, 0, 1, 0 ); - // collapsing + // Collapsing element.one( "tabsactivate", function( event, ui ) { ok( !( "originalEvent" in event ), "originalEvent" ); equal( ui.oldTab.length, 1, "oldTab length" ); @@ -173,7 +173,7 @@ test( "activate", function() { element.tabs( "option", "active", false ); state( element, 0, 0, 0 ); - // prevent activation + // Prevent activation element.one( "tabsbeforeactivate", function( event ) { ok( true, "tabsbeforeactivate" ); event.preventDefault(); @@ -190,7 +190,7 @@ test( "beforeLoad", function() { var tab, panelId, panel, element = $( "#tabs2" ); - // init + // Init element.one( "tabsbeforeload", function( event, ui ) { tab = element.find( ".ui-tabs-nav li" ).eq( 2 ); panelId = tab.attr( "aria-controls" ); @@ -234,7 +234,7 @@ test( "beforeLoad", function() { state( element, 0, 0, 1, 0, 0 ); equal( panel.html(), "", "panel html after" ); - // click, change panel content + // Click, change panel content element.one( "tabsbeforeload", function( event, ui ) { tab = element.find( ".ui-tabs-nav li" ).eq( 3 ); panelId = tab.attr( "aria-controls" ); @@ -263,7 +263,7 @@ asyncTest( "load", function() { var tab, panelId, panel, element = $( "#tabs2" ); - // init + // Init element.one( "tabsload", function( event, ui ) { tab = element.find( ".ui-tabs-nav li" ).eq( 2 ); panelId = tab.attr( "aria-controls" ); diff --git a/tests/unit/tabs/methods.js b/tests/unit/tabs/methods.js index 3be31c5f8a1..d904ac53040 100644 --- a/tests/unit/tabs/methods.js +++ b/tests/unit/tabs/methods.js @@ -110,13 +110,13 @@ test( "refresh", function() { state( element, 1, 0, 0 ); disabled( element, false ); - // disable tab via markup + // Disable tab via markup element.find( ".ui-tabs-nav li" ).eq( 1 ).addClass( "ui-state-disabled" ); element.tabs( "refresh" ); state( element, 1, 0, 0 ); disabled( element, [ 1 ] ); - // add remote tab + // Add remote tab element.find( ".ui-tabs-nav" ).append( "
  • new
  • " ); element.tabs( "refresh" ); state( element, 1, 0, 0, 0 ); @@ -124,13 +124,13 @@ test( "refresh", function() { equal( element.find( "#" + $( "#newTab" ).attr( "aria-controls" ) ).length, 1, "panel added for remote tab" ); - // remove all tabs + // Remove all tabs element.find( ".ui-tabs-nav li, .ui-tabs-panel" ).remove(); element.tabs( "refresh" ); state( element ); equal( element.tabs( "option", "active" ), false, "no active tab" ); - // add tabs + // Add tabs element.find( ".ui-tabs-nav" ) .append( "
  • new 2
  • " ) .append( "
  • new 3
  • " ) @@ -145,26 +145,26 @@ test( "refresh", function() { state( element, 0, 0, 0, 0 ); disabled( element, [ 0 ] ); - // activate third tab + // Activate third tab element.tabs( "option", "active", 2 ); state( element, 0, 0, 1, 0 ); disabled( element, [ 0 ] ); - // remove fourth tab, third tab should stay active + // Remove fourth tab, third tab should stay active element.find( ".ui-tabs-nav li" ).eq( 3 ).remove(); element.find( ".ui-tabs-panel" ).eq( 3 ).remove(); element.tabs( "refresh" ); state( element, 0, 0, 1 ); disabled( element, [ 0 ] ); - // remove third (active) tab, second tab should become active + // Remove third (active) tab, second tab should become active element.find( ".ui-tabs-nav li" ).eq( 2 ).remove(); element.find( ".ui-tabs-panel" ).eq( 2 ).remove(); element.tabs( "refresh" ); state( element, 0, 1 ); disabled( element, [ 0 ] ); - // remove first tab, previously active tab (now first) should stay active + // Remove first tab, previously active tab (now first) should stay active element.find( ".ui-tabs-nav li" ).eq( 0 ).remove(); element.find( ".ui-tabs-panel" ).eq( 0 ).remove(); element.tabs( "refresh" ); @@ -182,7 +182,7 @@ test( "refresh - looping", function() { state( element, 0, 1, 0 ); disabled( element, [ 0 ] ); - // remove active, jump to previous + // Remove active, jump to previous // previous is disabled, just back one more // reached first tab, move to end // activate last tab @@ -197,7 +197,7 @@ asyncTest( "load", function() { var element = $( "#tabs2" ).tabs(); - // load content of inactive tab + // Load content of inactive tab // useful for preloading content with custom caching element.one( "tabsbeforeload", function( event, ui ) { var tab = element.find( ".ui-tabs-nav li" ).eq( 3 ), diff --git a/tests/unit/tabs/options.js b/tests/unit/tabs/options.js index 39771efe6ce..f615e165ee7 100644 --- a/tests/unit/tabs/options.js +++ b/tests/unit/tabs/options.js @@ -155,7 +155,7 @@ test( "collapsible", function( assert ) { test( "disabled", function( assert ) { expect( 23 ); - // fully enabled by default + // Fully enabled by default var event, element = $( "#tabs1" ).tabs(); disabled( element, false ); @@ -164,7 +164,7 @@ test( "disabled", function( assert ) { assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" ); ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); - // disable single tab + // Disable single tab element.tabs( "option", "disabled", [ 1 ] ); disabled( element, [ 1 ] ); @@ -172,7 +172,7 @@ test( "disabled", function( assert ) { assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" ); ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); - // disabled active tab + // Disabled active tab element.tabs( "option", "disabled", [ 0, 1 ] ); disabled( element, [ 0, 1 ] ); @@ -180,7 +180,7 @@ test( "disabled", function( assert ) { assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" ); ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); - // disable all tabs + // Disable all tabs element.tabs( "option", "disabled", [ 0, 1, 2 ] ); disabled( element, true ); @@ -192,7 +192,7 @@ test( "disabled", function( assert ) { element.find( ".ui-tabs-anchor" ).eq( 0 ).trigger( event ); ok( event.isDefaultPrevented(), "click is prevented for disabled tab" ); - // enable all tabs + // Enable all tabs element.tabs( "option", "disabled", [] ); disabled( element, false ); }); @@ -209,7 +209,7 @@ test( "{ event: null }", function() { equal( element.tabs( "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-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "click" ); equal( element.tabs( "option", "active" ), 1 ); state( element, 0, 1, 0 ); @@ -227,7 +227,7 @@ test( "{ event: custom }", function() { equal( element.tabs( "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-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "click" ); equal( element.tabs( "option", "active" ), 1 ); state( element, 0, 1, 0 ); @@ -238,7 +238,7 @@ test( "{ event: custom }", function() { element.tabs( "option", "event", "custom3" ); - // ensure old event handlers are unbound + // Ensure old event handlers are unbound element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom1" ); equal( element.tabs( "option", "active" ), 2 ); state( element, 0, 0, 1 ); 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" ) { From 0a08176066ad5ff38ac54017cb91a251def689e4 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:04:59 -0400 Subject: [PATCH 03/26] Spinner: Style updates --- tests/unit/spinner/common-deprecated.js | 2 +- tests/unit/spinner/common.js | 2 +- tests/unit/spinner/options.js | 2 +- ui/widgets/spinner.js | 22 +++++++++++----------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/unit/spinner/common-deprecated.js b/tests/unit/spinner/common-deprecated.js index 8ff50fa25bf..ece9adeace8 100644 --- a/tests/unit/spinner/common-deprecated.js +++ b/tests/unit/spinner/common-deprecated.js @@ -23,7 +23,7 @@ common.testWidget( "spinner", { page: 10, step: 1, - // callbacks + // Callbacks change: null, create: null, spin: null, diff --git a/tests/unit/spinner/common.js b/tests/unit/spinner/common.js index 8ff50fa25bf..ece9adeace8 100644 --- a/tests/unit/spinner/common.js +++ b/tests/unit/spinner/common.js @@ -23,7 +23,7 @@ common.testWidget( "spinner", { page: 10, step: 1, - // callbacks + // Callbacks change: null, create: null, spin: null, diff --git a/tests/unit/spinner/options.js b/tests/unit/spinner/options.js index d43c968cdb9..c3a9f74a288 100644 --- a/tests/unit/spinner/options.js +++ b/tests/unit/spinner/options.js @@ -147,7 +147,7 @@ test( "culture, null", function() { element.spinner( "stepUp" ); equal( element.val(), "¥1", "formatted after step" ); - // reset culture + // Reset culture Globalize.culture( "default" ); }); 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 !== "" ) { From c10130dc38957723a8517e2ef303cb5583076542 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:05:15 -0400 Subject: [PATCH 04/26] Sortable: Style updates --- tests/unit/sortable/common.js | 2 +- tests/unit/sortable/events.js | 2 +- tests/unit/sortable/options.js | 4 ++-- ui/widgets/sortable.js | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/unit/sortable/common.js b/tests/unit/sortable/common.js index aefb28b70c0..a28c2511aa3 100644 --- a/tests/unit/sortable/common.js +++ b/tests/unit/sortable/common.js @@ -33,7 +33,7 @@ common.testWidget( "sortable", { tolerance: "intersect", zIndex: 1000, - // callbacks + // Callbacks activate: null, beforeStop: null, change: null, diff --git a/tests/unit/sortable/events.js b/tests/unit/sortable/events.js index bf5579fde42..74f10dfebca 100644 --- a/tests/unit/sortable/events.js +++ b/tests/unit/sortable/events.js @@ -25,7 +25,7 @@ test("start", function() { ok(hash.item, "UI hash includes: item"); ok(!hash.sender, "UI hash does not include: sender"); - // todo: see if these events should actually have sane values in them + // Todo: see if these events should actually have sane values in them ok("position" in hash, "UI hash includes: position"); ok("offset" in hash, "UI hash includes: offset"); }); diff --git a/tests/unit/sortable/options.js b/tests/unit/sortable/options.js index 7448390965c..5d24a3606f1 100644 --- a/tests/unit/sortable/options.js +++ b/tests/unit/sortable/options.js @@ -136,7 +136,7 @@ test( "#8792: issues with floated items in connected lists", function() { element = $( "#qunit-fixture li:eq(0)" ); - // move the first li to the right of the second li in the first ul + // Move the first li to the right of the second li in the first ul element.simulate( "drag", { dx: 55, moves: 15 @@ -144,7 +144,7 @@ test( "#8792: issues with floated items in connected lists", function() { equal( changeCount, 1, "change fired only once (no jitters) when dragging a floated sortable in it's own container" ); - // move the first li ( which is now in the second spot ) + // Move the first li ( which is now in the second spot ) // through the first spot in the second ul to the second spot in the second ul element.simulate( "drag", { dx: 100, 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)); From 5367aa316f216192462707531acd6d974ce7e350 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:05:36 -0400 Subject: [PATCH 05/26] Slider: Style updates --- tests/unit/slider/common.js | 2 +- tests/unit/slider/methods.js | 2 +- tests/unit/slider/options.js | 12 ++++++------ ui/widgets/slider.js | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/unit/slider/common.js b/tests/unit/slider/common.js index e623a74029f..5cc3e66c596 100644 --- a/tests/unit/slider/common.js +++ b/tests/unit/slider/common.js @@ -23,7 +23,7 @@ common.testWidget( "slider", { value: 0, values: null, - // callbacks + // Callbacks create: null, change: null, slide: null, diff --git a/tests/unit/slider/methods.js b/tests/unit/slider/methods.js index 5a87edfda57..a4187bd7ffb 100644 --- a/tests/unit/slider/methods.js +++ b/tests/unit/slider/methods.js @@ -88,7 +88,7 @@ test( "value", function() { equal( element.slider( "value", 2 ), element, "value method is chainable" ); equal( element.slider( "option", "value" ), 1, "value method set respects max" ); - // set max value with step 0.01 + // Set max value with step 0.01 element.slider( "option", { min: 2, value: 2, diff --git a/tests/unit/slider/options.js b/tests/unit/slider/options.js index 3853c4c5d51..f6b61a2b362 100644 --- a/tests/unit/slider/options.js +++ b/tests/unit/slider/options.js @@ -20,7 +20,7 @@ test( "disabled", function( assert ){ count++; }); - // enabled + // Enabled assert.lacksClasses( element, "ui-slider-disabled" ); equal( element.slider( "option", "disabled" ), false , "is not disabled" ); @@ -30,7 +30,7 @@ test( "disabled", function( assert ){ handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); equal( count, 2, "slider moved" ); - // disabled + // Disabled element.slider( "option", "disabled", true ); assert.hasClasses( element, "ui-slider-disabled" ); equal( element.slider( "option", "disabled" ), true, "is disabled" ); @@ -240,7 +240,7 @@ test( "step", function() { test( "values", function() { expect( 2 ); - // testing multiple ranges on the same page, the object reference to the values + // Testing multiple ranges on the same page, the object reference to the values // property is preserved via multiple range elements, so updating options.values // of 1 slider updates options.values of all the others var ranges = $([ @@ -270,7 +270,7 @@ test( "range", function( assert ) { expect( 32 ); var range; - // min + // Min element = $( "
    " ).slider({ range: "min", min: 1, @@ -282,7 +282,7 @@ test( "range", function( assert ) { equal( element.find( ".ui-slider-range-min" ).length, 1, "range min" ); element.slider( "destroy" ); - // max + // Max element = $( "
    " ).slider({ range: "max", min: 1, @@ -294,7 +294,7 @@ test( "range", function( assert ) { equal( element.find( ".ui-slider-range-max" ).length, 1, "range max" ); element.slider( "destroy" ); - // true + // True element = $( "
    " ).slider({ range: true, min: 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(); From 1dd26f3ee426ebbd481be668ea14aded4f1e1492 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:06:35 -0400 Subject: [PATCH 06/26] Selectmenu: Style updates --- tests/unit/selectmenu/common.js | 2 +- ui/widgets/selectmenu.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/unit/selectmenu/common.js b/tests/unit/selectmenu/common.js index 758e004badb..8582247caf1 100644 --- a/tests/unit/selectmenu/common.js +++ b/tests/unit/selectmenu/common.js @@ -21,7 +21,7 @@ common.testWidget( "selectmenu", { }, width: false, - // callbacks + // Callbacks change: null, close: null, create: null, 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 From 7d345249a946b91d48340ffe21704d9deb577183 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:07:08 -0400 Subject: [PATCH 07/26] Selectable: Style updates --- tests/unit/selectable/common.js | 2 +- ui/widgets/selectable.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/selectable/common.js b/tests/unit/selectable/common.js index 317fde562bf..460ea0602a0 100644 --- a/tests/unit/selectable/common.js +++ b/tests/unit/selectable/common.js @@ -15,7 +15,7 @@ common.testWidget( "selectable", { filter: "*", tolerance: "touch", - // callbacks + // Callbacks create: null, selected: null, selecting: null, 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" ); From f1a5f533fc38c35b89f68afd061627a4745519f1 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:07:28 -0400 Subject: [PATCH 08/26] Resizable: Style updates --- tests/unit/resizable/common.js | 2 +- tests/unit/resizable/events.js | 6 +++--- tests/unit/resizable/options.js | 10 +++++----- ui/widgets/resizable.js | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/unit/resizable/common.js b/tests/unit/resizable/common.js index 6096446f324..3f1f82bced9 100644 --- a/tests/unit/resizable/common.js +++ b/tests/unit/resizable/common.js @@ -29,7 +29,7 @@ common.testWidget( "resizable", { minWidth: 10, zIndex: 90, - // callbacks + // Callbacks create: null, resize: null, start: null, diff --git a/tests/unit/resizable/events.js b/tests/unit/resizable/events.js index eb64400c668..b77130741f4 100644 --- a/tests/unit/resizable/events.js +++ b/tests/unit/resizable/events.js @@ -203,7 +203,7 @@ test( "resize (containment) works with parent with negative offset", function() fixedContainer = absoluteContainer.wrap( "
    " ).parent(), increaseWidthBy = 50; - // position fixed container in window top left + // Position fixed container in window top left fixedContainer.css({ width: 400, height: 100, @@ -212,7 +212,7 @@ test( "resize (containment) works with parent with negative offset", function() left: 0 }); - // position absolute container within fixed on slightly outside window + // Position absolute container within fixed on slightly outside window absoluteContainer.css({ width: 400, height: 100, @@ -221,7 +221,7 @@ test( "resize (containment) works with parent with negative offset", function() left: -50 }); - // set up resizable to be contained within absolute container + // Set up resizable to be contained within absolute container target.resizable({ handles: "all", containment: "parent" diff --git a/tests/unit/resizable/options.js b/tests/unit/resizable/options.js index 1e643a576bc..23434830979 100644 --- a/tests/unit/resizable/options.js +++ b/tests/unit/resizable/options.js @@ -126,7 +126,7 @@ test("aspectRatio: 'preserve' (ne)", function() { test( "aspectRatio: Resizing can move objects", function() { expect( 7 ); - // http://bugs.jqueryui.com/ticket/7018 - Resizing can move objects + // Http://bugs.jqueryui.com/ticket/7018 - Resizing can move objects var handleW = ".ui-resizable-w", handleNW = ".ui-resizable-nw", target = $( "#resizable1" ).resizable({ @@ -143,7 +143,7 @@ test( "aspectRatio: Resizing can move objects", function() { equal( target.height(), 100, "compare height - no size change" ); equal( target.position().left, 75, "compare left - no movement" ); - // http://bugs.jqueryui.com/ticket/9107 - aspectRatio and containment not handled correctly + // Http://bugs.jqueryui.com/ticket/9107 - aspectRatio and containment not handled correctly $( "#container" ).css({ width: 200, height: 300, position: "absolute", left: 100, top: 100 }); $( "#resizable1" ).css({ width: 100, height: 100, left: 0, top: 0 }); @@ -173,7 +173,7 @@ test( "containment", function() { test( "containment - not immediate parent", function() { expect( 4 ); - // http://bugs.jqueryui.com/ticket/7485 - Resizable: Containment calculation is wrong + // Http://bugs.jqueryui.com/ticket/7485 - Resizable: Containment calculation is wrong // when containment element is not the immediate parent var element = $( "#child" ).resizable({ containment: "#container2", @@ -205,7 +205,7 @@ test( "containment - not immediate parent", function() { test( "containment - immediate parent", function() { expect( 4 ); - // http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong when containment element is "position: relative" + // Http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong when containment element is "position: relative" // when containment element is immediate parent var element = $( "#child" ).resizable({ containment: "parent", @@ -302,7 +302,7 @@ test( "grid - Resizable: can be moved when grid option is set (#9611)", function test( "grid - maintains grid with padding and border when approaching no dimensions", function() { expect( 2 ); - // http://bugs.jqueryui.com/ticket/10437 - Resizable: border with grid option working wrong + // Http://bugs.jqueryui.com/ticket/10437 - Resizable: border with grid option working wrong var handle = ".ui-resizable-nw", target = $( "#resizable1" ).css({ padding: 5, 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); From 9f00a7378b61dfd9fe40261be3de86e439f0e899 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:07:48 -0400 Subject: [PATCH 09/26] Progressbar: Style updates --- ui/widgets/progressbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } From c4a5e4adf95254038394517905e27c94df4f4a5b Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:08:12 -0400 Subject: [PATCH 10/26] Mouse: Style updates --- ui/widgets/mouse.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); }; From 5093932387d4e8c4d2c3479d8028994146cc0900 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:08:28 -0400 Subject: [PATCH 11/26] Menu: Style updates --- tests/unit/menu/common.js | 2 +- tests/unit/menu/events.js | 4 ++-- ui/widgets/menu.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/menu/common.js b/tests/unit/menu/common.js index 81674be351c..adb74cf0a9a 100644 --- a/tests/unit/menu/common.js +++ b/tests/unit/menu/common.js @@ -18,7 +18,7 @@ common.testWidget( "menu", { }, role: "menu", - // callbacks + // Callbacks blur: null, create: null, focus: null, diff --git a/tests/unit/menu/events.js b/tests/unit/menu/events.js index 8a4b92fff97..790e5912c23 100644 --- a/tests/unit/menu/events.js +++ b/tests/unit/menu/events.js @@ -333,7 +333,7 @@ asyncTest( "handle keyboard navigation on menu without scroll and with submenus" element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); equal( logOutput(), "keydown,4", "Keydown LEFT (close submenu)" ); - // re-open submenu + // Re-open submenu element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); setTimeout( menukeyboard3 ); } @@ -525,7 +525,7 @@ asyncTest( "handle keyboard navigation on menu with scroll and with submenus", f element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); equal( logOutput(), "keydown,1", "Keydown LEFT (close submenu)" ); - // re-open submenu + // Re-open submenu element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); setTimeout( menukeyboard3, 50 ); } 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 From 666c48becf0056687bfdda341396f5115a3b0f73 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:10:45 -0400 Subject: [PATCH 12/26] Droppable: Style updates --- demos/droppable/photo-manager.html | 16 ++++++++-------- tests/unit/droppable/common-deprecated.js | 2 +- tests/unit/droppable/common.js | 2 +- tests/unit/droppable/options.js | 4 ++-- ui/widgets/droppable.js | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) 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/tests/unit/droppable/common-deprecated.js b/tests/unit/droppable/common-deprecated.js index e9fdc69cc8f..ecbc9b1a1b7 100644 --- a/tests/unit/droppable/common-deprecated.js +++ b/tests/unit/droppable/common-deprecated.js @@ -15,7 +15,7 @@ common.testWidget( "droppable", { scope: "default", tolerance: "intersect", - // callbacks + // Callbacks activate: null, create: null, deactivate: null, diff --git a/tests/unit/droppable/common.js b/tests/unit/droppable/common.js index d3bffc67b6a..5d0e55d6f7a 100644 --- a/tests/unit/droppable/common.js +++ b/tests/unit/droppable/common.js @@ -13,7 +13,7 @@ common.testWidget( "droppable", { scope: "default", tolerance: "intersect", - // callbacks + // Callbacks activate: null, create: null, deactivate: null, diff --git a/tests/unit/droppable/options.js b/tests/unit/droppable/options.js index 2fdf483d20a..c2035ce8cc4 100644 --- a/tests/unit/droppable/options.js +++ b/tests/unit/droppable/options.js @@ -114,7 +114,7 @@ test( "tolerance, intersect", function() { height: 10, position: "absolute", - // http://bugs.jqueryui.com/ticket/6876 + // Http://bugs.jqueryui.com/ticket/6876 // Droppable: droppable region is offset by draggables margin marginTop: 3, marginLeft: 3 @@ -183,7 +183,7 @@ test( "tolerance, pointer", function() { }); }); - // http://bugs.jqueryui.com/ticket/4977 - tolerance, pointer - bug when pointer outside draggable + // Http://bugs.jqueryui.com/ticket/4977 - tolerance, pointer - bug when pointer outside draggable draggable.css({ top: 0, left: 0 }).draggable( "option", "axis", "x" ); droppable.css({ top: 15, left: 15 }); 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; From e4c8b490582de10031b6af55425355801cf05be4 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:11:02 -0400 Subject: [PATCH 13/26] Draggable: Style updates --- tests/unit/draggable/common.js | 2 +- tests/unit/draggable/core.js | 12 ++++++------ tests/unit/draggable/options.js | 12 ++++++------ ui/widgets/draggable.js | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/unit/draggable/common.js b/tests/unit/draggable/common.js index d09e6b7b75e..c9a687ce3c7 100644 --- a/tests/unit/draggable/common.js +++ b/tests/unit/draggable/common.js @@ -37,7 +37,7 @@ common.testWidget( "draggable", { distance: 1, iframeFix: false, - // callbacks + // Callbacks create: null, drag: null, start: null, diff --git a/tests/unit/draggable/core.js b/tests/unit/draggable/core.js index 30563b622e9..d6eaeb2aaba 100644 --- a/tests/unit/draggable/core.js +++ b/tests/unit/draggable/core.js @@ -67,11 +67,11 @@ test( "resizable handle with complex markup (#8756 / #8757)", function() { var handle = $(".ui-resizable-w div"), target = $( "#draggable1" ).draggable().resizable({ handles: "all" }); - // todo: fix resizable so it doesn't require a mouseover + // Todo: fix resizable so it doesn't require a mouseover handle.simulate("mouseover").simulate( "drag", { dx: -50 } ); equal( target.width(), 250, "compare width" ); - // todo: fix resizable so it doesn't require a mouseover + // Todo: fix resizable so it doesn't require a mouseover handle.simulate("mouseover").simulate( "drag", { dx: 50 } ); equal( target.width(), 200, "compare width" ); }); @@ -215,7 +215,7 @@ test( "scroll offset with fixed ancestors", function() { $( [ "hidden", "auto", "scroll" ] ).each(function() { var overflow = this; - // http://bugs.jqueryui.com/ticket/9379 - position bug in scrollable div + // Http://bugs.jqueryui.com/ticket/9379 - position bug in scrollable div // http://bugs.jqueryui.com/ticket/10147 - Wrong position in a parent with "overflow: hidden" test( "position in scrollable parent with overflow: " + overflow, function() { expect( 2 ); @@ -230,7 +230,7 @@ $( [ "hidden", "auto", "scroll" ] ).each(function() { dragDelta = 20, delta = 100, - // we scroll after each drag event, so subtract 1 from number of moves for expected + // We scroll after each drag event, so subtract 1 from number of moves for expected expected = delta + ( ( moves - 1 ) * dragDelta ), element = $( "#dragged" ).draggable({ drag: function() { @@ -300,13 +300,13 @@ asyncTest( "blur behavior", function() { testHelper.move( focusElement, 1, 1 ); - // http://bugs.jqueryui.com/ticket/10527 + // Http://bugs.jqueryui.com/ticket/10527 // Draggable: Can't select option in modal dialog (IE8) strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused after mousing down on itself" ); testHelper.move( element, 50, 50 ); - // http://bugs.jqueryui.com/ticket/4261 + // Http://bugs.jqueryui.com/ticket/4261 // active element should blur when mousing down on a draggable notStrictEqual( document.activeElement, focusElement.get( 0 ), "test element is no longer focused after mousing down on a draggable" ); start(); diff --git a/tests/unit/draggable/options.js b/tests/unit/draggable/options.js index e1fd8288ab4..bc7370e8b5c 100644 --- a/tests/unit/draggable/options.js +++ b/tests/unit/draggable/options.js @@ -278,12 +278,12 @@ test( "connectToSortable, dragging out of a sortable", function() { // Position issue when connected to sortable deepEqual( ui.helper.offset(), offsetExpected, "draggable offset is correct" ); - // http://bugs.jqueryui.com/ticket/7734 + // Http://bugs.jqueryui.com/ticket/7734 // HTML IDs are removed when dragging to a Sortable equal( sortItem[ 0 ], dragHelper[ 0 ], "both have the same helper" ); equal( sortItem.attr( "id" ), dragHelper.attr( "id" ), "both have the same id" ); - // http://bugs.jqueryui.com/ticket/9481 + // Http://bugs.jqueryui.com/ticket/9481 // connectToSortable causes sortable revert to fail on second attempt equal( sortable.sortable( "option", "revert" ), 100, "sortable revert behavior is preserved" ); }); @@ -357,7 +357,7 @@ test( "connectToSortable, dragging multiple elements in and out of sortable", fu moves: 10 }); - // http://bugs.jqueryui.com/ticket/9675 + // Http://bugs.jqueryui.com/ticket/9675 // Animation issue with revert and connectToSortable sortable.one( "sortstop", function( event, ui ) { ok( !$.contains( document, ui.placeholder[ 0 ] ), "placeholder was removed" ); @@ -419,7 +419,7 @@ test( "connectToSortable, dragging through a sortable", function() { sortable = $( "#sortable2" ).sortable(), sortableOffset = sortable.offset(); - // http://bugs.jqueryui.com/ticket/10669 + // Http://bugs.jqueryui.com/ticket/10669 // Draggable: Position issue with connectToSortable draggable.one( "dragstop", function() { equal( draggable.parent().attr( "id" ), "sortable", "restored draggable to original parent" ); @@ -1022,7 +1022,7 @@ asyncTest( "revert and revertDuration", function() { } }); - // animation are async, so test for it asynchronously + // Animation are async, so test for it asynchronously testHelper.move( element, 50, 50 ); setTimeout( function() { ok( $( "#draggable2" ).is( ":animated" ), "revert: true with revertDuration should animate" ); @@ -1191,7 +1191,7 @@ test( "snap, snapMode, and snapTolerance", function( assert ) { }), element2 = $( "#draggable2" ).draggable(); - // http://bugs.jqueryui.com/ticket/9724 + // Http://bugs.jqueryui.com/ticket/9724 // Draggable: Snapping coordinates thrown off by margin on draggable element.css( "margin", "3px" ); 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; From 596ca8eab99db6c02c53ef64a13cd1fa853d6413 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:11:21 -0400 Subject: [PATCH 14/26] Dialog: Style updates --- tests/unit/dialog/common-deprecated.js | 2 +- tests/unit/dialog/common.js | 2 +- tests/unit/dialog/core.js | 2 +- tests/unit/dialog/events.js | 2 +- tests/unit/dialog/options.js | 6 +++--- ui/widgets/dialog.js | 14 +++++++------- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/unit/dialog/common-deprecated.js b/tests/unit/dialog/common-deprecated.js index 69153039ce4..26f7cb201bd 100644 --- a/tests/unit/dialog/common-deprecated.js +++ b/tests/unit/dialog/common-deprecated.js @@ -36,7 +36,7 @@ common.testWidget( "dialog", { title: null, width: 300, - // callbacks + // Callbacks beforeClose: null, close: null, create: null, diff --git a/tests/unit/dialog/common.js b/tests/unit/dialog/common.js index 8722d1753bf..b1884b8cc4c 100644 --- a/tests/unit/dialog/common.js +++ b/tests/unit/dialog/common.js @@ -35,7 +35,7 @@ common.testWidget( "dialog", { title: null, width: 300, - // callbacks + // Callbacks beforeClose: null, close: null, create: null, diff --git a/tests/unit/dialog/core.js b/tests/unit/dialog/core.js index 1560c34acdf..b351b0aeb0e 100644 --- a/tests/unit/dialog/core.js +++ b/tests/unit/dialog/core.js @@ -224,7 +224,7 @@ asyncTest( "Prevent tabbing out of dialogs", function() { function checkTab() { equal( document.activeElement, inputs[ 0 ], "Tab key event moved focus within the modal" ); - // check shift tab + // Check shift tab $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true }); setTimeout( checkShiftTab ); } diff --git a/tests/unit/dialog/events.js b/tests/unit/dialog/events.js index 13c4525011a..8a56699ab23 100644 --- a/tests/unit/dialog/events.js +++ b/tests/unit/dialog/events.js @@ -76,7 +76,7 @@ test( "focus", function() { other.dialog( "moveToTop" ); element.trigger( "mousedown" ); - // triggers just once when already on top + // Triggers just once when already on top element.dialog( "open" ); element.dialog( "moveToTop" ); element.trigger( "mousedown" ); diff --git a/tests/unit/dialog/options.js b/tests/unit/dialog/options.js index c4f1b3e15e7..aa659f04178 100644 --- a/tests/unit/dialog/options.js +++ b/tests/unit/dialog/options.js @@ -344,7 +344,7 @@ test("minWidth", function( assert ) { test( "position, default center on window", function( assert ) { expect( 2 ); - // dialogs alter the window width and height in Firefox + // Dialogs alter the window width and height in Firefox // so we collect that information before creating the dialog // Support: Firefox var winWidth = $( window ).width(), @@ -360,7 +360,7 @@ test( "position, default center on window", function( assert ) { test( "position, right bottom at right bottom via ui.position args", function( assert ) { expect( 2 ); - // dialogs alter the window width and height in Firefox + // Dialogs alter the window width and height in Firefox // so we collect that information before creating the dialog // Support: Firefox var winWidth = $( window ).width(), @@ -469,7 +469,7 @@ test( "title", function() { equal( titleText(), "foo", "title after init" ); element.remove(); - // make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement + // Make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement element = $( "
    " ).dialog(); // some browsers return a non-breaking space and some return " " // so we get the text to normalize to the actual non-breaking space diff --git a/ui/widgets/dialog.js b/ui/widgets/dialog.js index 40f6c614f58..abff0e535c6 100644 --- a/ui/widgets/dialog.js +++ b/ui/widgets/dialog.js @@ -81,7 +81,7 @@ $.widget( "ui.dialog", { title: null, width: 300, - // callbacks + // Callbacks beforeClose: null, close: null, drag: null, @@ -353,7 +353,7 @@ $.widget( "ui.dialog", { return; } - // prevent tabbing out of dialogs + // Prevent tabbing out of dialogs if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) { return; } @@ -408,7 +408,7 @@ $.widget( "ui.dialog", { } } ); - // support: IE + // Support: IE // Use type="button" to prevent enter keypresses in textboxes from closing the // dialog in IE (#9312) this.uiDialogTitlebarClose = $( "" ) @@ -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", From 1e8fdf06e7db00b7fc5f026829281692d372a9dc Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:11:33 -0400 Subject: [PATCH 15/26] Datepicker: Style updates --- tests/unit/datepicker/events.js | 238 +++++++++++++++++--------------- ui/i18n/datepicker-af.js | 38 ++--- ui/i18n/datepicker-ar-DZ.js | 36 ++--- ui/widgets/datepicker.js | 14 +- 4 files changed, 167 insertions(+), 159 deletions(-) diff --git a/tests/unit/datepicker/events.js b/tests/unit/datepicker/events.js index f33351b57a5..4a5654d09e9 100644 --- a/tests/unit/datepicker/events.js +++ b/tests/unit/datepicker/events.js @@ -4,151 +4,159 @@ define( [ "ui/widgets/datepicker" ], function( $, testHelper ) { -module("datepicker: events"); +module( "datepicker: events" ); var selectedThis = null, selectedDate = null, selectedInst = null; -function callback(date, inst) { +function callback( date, inst ) { selectedThis = this; selectedDate = date; selectedInst = inst; } -function callback2(year, month, inst) { +function callback2( year, month, inst ) { selectedThis = this; selectedDate = year + "/" + month; selectedInst = inst; } -test("events", function() { +test( "events", function() { expect( 26 ); var dateStr, newMonthYear, inp2, - inp = testHelper.init("#inp", {onSelect: callback}), + inp = testHelper.init( "#inp", { onSelect: callback } ), date = new Date(); + // onSelect - inp.val("").datepicker("show"). - simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - equal(selectedThis, inp[0], "Callback selected this"); - equal(selectedInst, $.data(inp[0], testHelper.PROP_NAME), "Callback selected inst"); - equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date), - "Callback selected date"); - inp.val("").datepicker("show"). - simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}). - simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - date.setDate(date.getDate() + 7); - equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date), - "Callback selected date - ctrl+down"); - inp.val("").datepicker("show"). - simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); - equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date), - "Callback selected date - esc"); + inp.val( "" ).datepicker( "show" ). + simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + equal( selectedThis, inp[ 0 ], "Callback selected this" ); + equal( selectedInst, $.data( inp[ 0 ], testHelper.PROP_NAME ), "Callback selected inst" ); + equal( selectedDate, $.datepicker.formatDate( "mm/dd/yy", date ), + "Callback selected date" ); + inp.val( "" ).datepicker( "show" ). + simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.DOWN } ). + simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + date.setDate( date.getDate() + 7 ); + equal( selectedDate, $.datepicker.formatDate( "mm/dd/yy", date ), + "Callback selected date - ctrl+down" ); + inp.val( "" ).datepicker( "show" ). + simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); + equal( selectedDate, $.datepicker.formatDate( "mm/dd/yy", date ), + "Callback selected date - esc" ); dateStr = "02/04/2008"; - inp.val(dateStr).datepicker("show"). - simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - equal(dateStr, selectedDate, - "onSelect is called after enter keydown"); + inp.val( dateStr ).datepicker( "show" ). + simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + equal( dateStr, selectedDate, + "onSelect is called after enter keydown" ); + // onChangeMonthYear - inp.datepicker("option", {onChangeMonthYear: callback2, onSelect: null}). - val("").datepicker("show"); - newMonthYear = function(date) { - return date.getFullYear() + "/" + (date.getMonth() + 1); + inp.datepicker( "option", { onChangeMonthYear: callback2, onSelect: null } ). + val( "" ).datepicker( "show" ); + newMonthYear = function( date ) { + return date.getFullYear() + "/" + ( date.getMonth() + 1 ); }; date = new Date(); - date.setDate(1); - inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}); - date.setMonth(date.getMonth() - 1); - equal(selectedThis, inp[0], "Callback change month/year this"); - equal(selectedInst, $.data(inp[0], testHelper.PROP_NAME), "Callback change month/year inst"); - equal(selectedDate, newMonthYear(date), - "Callback change month/year date - pgup"); - inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}); - date.setMonth(date.getMonth() + 1); - equal(selectedDate, newMonthYear(date), - "Callback change month/year date - pgdn"); - inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}); - date.setFullYear(date.getFullYear() - 1); - equal(selectedDate, newMonthYear(date), - "Callback change month/year date - ctrl+pgup"); - inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME}); - date.setFullYear(date.getFullYear() + 1); - equal(selectedDate, newMonthYear(date), - "Callback change month/year date - ctrl+home"); - inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}); - date.setFullYear(date.getFullYear() + 1); - equal(selectedDate, newMonthYear(date), - "Callback change month/year date - ctrl+pgdn"); - inp.datepicker("setDate", new Date(2007, 1 - 1, 26)); - equal(selectedDate, "2007/1", "Callback change month/year date - setDate"); + date.setDate( 1 ); + inp.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + date.setMonth( date.getMonth() - 1 ); + equal( selectedThis, inp[ 0 ], "Callback change month/year this" ); + equal( selectedInst, $.data( inp[ 0 ], testHelper.PROP_NAME ), "Callback change month/year inst" ); + equal( selectedDate, newMonthYear( date ), + "Callback change month/year date - pgup" ); + inp.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + date.setMonth( date.getMonth() + 1 ); + equal( selectedDate, newMonthYear( date ), + "Callback change month/year date - pgdn" ); + inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } ); + date.setFullYear( date.getFullYear() - 1 ); + equal( selectedDate, newMonthYear( date ), + "Callback change month/year date - ctrl+pgup" ); + inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.HOME } ); + date.setFullYear( date.getFullYear() + 1 ); + equal( selectedDate, newMonthYear( date ), + "Callback change month/year date - ctrl+home" ); + inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN } ); + date.setFullYear( date.getFullYear() + 1 ); + equal( selectedDate, newMonthYear( date ), + "Callback change month/year date - ctrl+pgdn" ); + inp.datepicker( "setDate", new Date( 2007, 1 - 1, 26 ) ); + equal( selectedDate, "2007/1", "Callback change month/year date - setDate" ); selectedDate = null; - inp.datepicker("setDate", new Date(2007, 1 - 1, 12)); - ok(selectedDate == null, "Callback change month/year date - setDate no change"); + inp.datepicker( "setDate", new Date( 2007, 1 - 1, 12 ) ); + ok( selectedDate == null, "Callback change month/year date - setDate no change" ); + // onChangeMonthYear step by 2 - inp.datepicker("option", {stepMonths: 2}). - datepicker("hide").val("").datepicker("show"). - simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}); - date.setMonth(date.getMonth() - 14); - equal(selectedDate, newMonthYear(date), - "Callback change month/year by 2 date - pgup"); - inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}); - date.setMonth(date.getMonth() - 12); - equal(selectedDate, newMonthYear(date), - "Callback change month/year by 2 date - ctrl+pgup"); - inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}); - date.setMonth(date.getMonth() + 2); - equal(selectedDate, newMonthYear(date), - "Callback change month/year by 2 date - pgdn"); - inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}); - date.setMonth(date.getMonth() + 12); - equal(selectedDate, newMonthYear(date), - "Callback change month/year by 2 date - ctrl+pgdn"); + inp.datepicker( "option", { stepMonths: 2 } ). + datepicker( "hide" ).val( "" ).datepicker( "show" ). + simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + date.setMonth( date.getMonth() - 14 ); + equal( selectedDate, newMonthYear( date ), + "Callback change month/year by 2 date - pgup" ); + inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } ); + date.setMonth( date.getMonth() - 12 ); + equal( selectedDate, newMonthYear( date ), + "Callback change month/year by 2 date - ctrl+pgup" ); + inp.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + date.setMonth( date.getMonth() + 2 ); + equal( selectedDate, newMonthYear( date ), + "Callback change month/year by 2 date - pgdn" ); + inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN } ); + date.setMonth( date.getMonth() + 12 ); + equal( selectedDate, newMonthYear( date ), + "Callback change month/year by 2 date - ctrl+pgdn" ); + // onClose - inp.datepicker("option", {onClose: callback, onChangeMonthYear: null, stepMonths: 1}). - val("").datepicker("show"). - simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); - equal(selectedThis, inp[0], "Callback close this"); - equal(selectedInst, $.data(inp[0], testHelper.PROP_NAME), "Callback close inst"); - equal(selectedDate, "", "Callback close date - esc"); - inp.val("").datepicker("show"). - simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", new Date()), - "Callback close date - enter"); - inp.val("02/04/2008").datepicker("show"). - simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); - equal(selectedDate, "02/04/2008", "Callback close date - preset"); - inp.val("02/04/2008").datepicker("show"). - simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END}); - equal(selectedDate, "", "Callback close date - ctrl+end"); - - inp2 = testHelper.init("#inp2"); - inp2.datepicker().datepicker("option", {onClose: callback}).datepicker("show"); - inp.datepicker("show"); - equal(selectedThis, inp2[0], "Callback close this"); -}); - -test("beforeShowDay-getDate", function() { + inp.datepicker( "option", { onClose: callback, onChangeMonthYear: null, stepMonths: 1 } ). + val( "" ).datepicker( "show" ). + simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); + equal( selectedThis, inp[ 0 ], "Callback close this" ); + equal( selectedInst, $.data( inp[ 0 ], testHelper.PROP_NAME ), "Callback close inst" ); + equal( selectedDate, "", "Callback close date - esc" ); + inp.val( "" ).datepicker( "show" ). + simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + equal( selectedDate, $.datepicker.formatDate( "mm/dd/yy", new Date() ), + "Callback close date - enter" ); + inp.val( "02/04/2008" ).datepicker( "show" ). + simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); + equal( selectedDate, "02/04/2008", "Callback close date - preset" ); + inp.val( "02/04/2008" ).datepicker( "show" ). + simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.END } ); + equal( selectedDate, "", "Callback close date - ctrl+end" ); + + inp2 = testHelper.init( "#inp2" ); + inp2.datepicker().datepicker( "option", { onClose: callback } ).datepicker( "show" ); + inp.datepicker( "show" ); + equal( selectedThis, inp2[ 0 ], "Callback close this" ); +} ); + +test( "beforeShowDay-getDate", function() { expect( 3 ); - var inp = testHelper.init("#inp", {beforeShowDay: function() { inp.datepicker("getDate"); return [true, ""]; }}), - dp = $("#ui-datepicker-div"); - inp.val("01/01/2010").datepicker("show"); + var inp = testHelper.init( "#inp", { beforeShowDay: function() { inp.datepicker( "getDate" ); return [ true, "" ]; } } ), + dp = $( "#ui-datepicker-div" ); + inp.val( "01/01/2010" ).datepicker( "show" ); + // contains non-breaking space - equal($("div.ui-datepicker-title").text(), - // support: IE <9, jQuery <1.8 + equal( $( "div.ui-datepicker-title" ).text(), + + // Support: IE <9, jQuery <1.8 // In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways - $( "January 2010" ).text(), "Initial month"); - $("a.ui-datepicker-next", dp).trigger( "click" ); - $("a.ui-datepicker-next", dp).trigger( "click" ); + $( "January 2010" ).text(), "Initial month" ); + $( "a.ui-datepicker-next", dp ).trigger( "click" ); + $( "a.ui-datepicker-next", dp ).trigger( "click" ); + // contains non-breaking space - equal($("div.ui-datepicker-title").text(), - $( "March 2010" ).text(), "After next clicks"); - inp.datepicker("hide").datepicker("show"); - $("a.ui-datepicker-prev", dp).trigger( "click" ); - $("a.ui-datepicker-prev", dp).trigger( "click" ); + equal( $( "div.ui-datepicker-title" ).text(), + $( "March 2010" ).text(), "After next clicks" ); + inp.datepicker( "hide" ).datepicker( "show" ); + $( "a.ui-datepicker-prev", dp ).trigger( "click" ); + $( "a.ui-datepicker-prev", dp ).trigger( "click" ); + // contains non-breaking space - equal($("div.ui-datepicker-title").text(), - $( "November 2009" ).text(), "After prev clicks"); - inp.datepicker("hide"); -}); + equal( $( "div.ui-datepicker-title" ).text(), + $( "November 2009" ).text(), "After prev clicks" ); + inp.datepicker( "hide" ); +} ); } ); diff --git a/ui/i18n/datepicker-af.js b/ui/i18n/datepicker-af.js index 6c535569677..f13315e1045 100644 --- a/ui/i18n/datepicker-af.js +++ b/ui/i18n/datepicker-af.js @@ -1,37 +1,37 @@ /* Afrikaans initialisation for the jQuery UI date picker plugin. */ /* Written by Renier Pretorius. */ -(function( factory ) { +( function( factory ) { if ( typeof define === "function" && define.amd ) { // AMD. Register as an anonymous module. - define([ "../widgets/datepicker" ], factory ); + define( [ "../widgets/datepicker" ], factory ); } else { // Browser globals factory( jQuery.datepicker ); } -}(function( datepicker ) { +}( function( datepicker ) { -datepicker.regional['af'] = { - closeText: 'Selekteer', - prevText: 'Vorige', - nextText: 'Volgende', - currentText: 'Vandag', - monthNames: ['Januarie','Februarie','Maart','April','Mei','Junie', - 'Julie','Augustus','September','Oktober','November','Desember'], - monthNamesShort: ['Jan', 'Feb', 'Mrt', 'Apr', 'Mei', 'Jun', - 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des'], - dayNames: ['Sondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrydag', 'Saterdag'], - dayNamesShort: ['Son', 'Maa', 'Din', 'Woe', 'Don', 'Vry', 'Sat'], - dayNamesMin: ['So','Ma','Di','Wo','Do','Vr','Sa'], +datepicker.regional[ "af" ] = { + closeText: "Selekteer", + prevText: "Vorige", + nextText: "Volgende", + currentText: "Vandag", + monthNames: [ "Januarie","Februarie","Maart","April","Mei","Junie", + "Julie","Augustus","September","Oktober","November","Desember" ], + monthNamesShort: [ "Jan", "Feb", "Mrt", "Apr", "Mei", "Jun", + "Jul", "Aug", "Sep", "Okt", "Nov", "Des" ], + dayNames: [ "Sondag", "Maandag", "Dinsdag", 'Woensdag', 'Donderdag', 'Vrydag', 'Saterdag' ], + dayNamesShort: [ 'Son', 'Maa', 'Din', 'Woe', 'Don', 'Vry', 'Sat' ], + dayNamesMin: [ 'So','Ma','Di','Wo','Do','Vr','Sa' ], weekHeader: 'Wk', dateFormat: 'dd/mm/yy', firstDay: 1, isRTL: false, showMonthAfterYear: false, - yearSuffix: ''}; -datepicker.setDefaults(datepicker.regional['af']); + yearSuffix: '' }; +datepicker.setDefaults( datepicker.regional[ 'af' ] ); -return datepicker.regional['af']; +return datepicker.regional[ 'af' ]; -})); +} ) ); diff --git a/ui/i18n/datepicker-ar-DZ.js b/ui/i18n/datepicker-ar-DZ.js index ff003c9986b..ab8c1f08b2e 100644 --- a/ui/i18n/datepicker-ar-DZ.js +++ b/ui/i18n/datepicker-ar-DZ.js @@ -1,37 +1,37 @@ /* Algerian Arabic Translation for jQuery UI date picker plugin. (can be used for Tunisia)*/ /* Mohamed Cherif BOUCHELAGHEM -- cherifbouchelaghem@yahoo.fr */ -(function( factory ) { +( function( factory ) { if ( typeof define === "function" && define.amd ) { // AMD. Register as an anonymous module. - define([ "../widgets/datepicker" ], factory ); + define( [ "../widgets/datepicker" ], factory ); } else { // Browser globals factory( jQuery.datepicker ); } -}(function( datepicker ) { +}( function( datepicker ) { -datepicker.regional['ar-DZ'] = { - closeText: 'إغلاق', - prevText: '<السابق', - nextText: 'التالي>', - currentText: 'اليوم', - monthNames: ['جانفي', 'فيفري', 'مارس', 'أفريل', 'ماي', 'جوان', - 'جويلية', 'أوت', 'سبتمبر','أكتوبر', 'نوفمبر', 'ديسمبر'], - monthNamesShort: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'], - dayNames: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'], - dayNamesShort: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'], - dayNamesMin: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'], +datepicker.regional[ "ar-DZ" ] = { + closeText: "إغلاق", + prevText: "<السابق", + nextText: "التالي>", + currentText: "اليوم", + monthNames: [ "جانفي", "فيفري", "مارس", "أفريل", "ماي", "جوان", + "جويلية", "أوت", "سبتمبر","أكتوبر", "نوفمبر", "ديسمبر" ], + monthNamesShort: [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", '12' ], + dayNames: [ 'الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت' ], + dayNamesShort: [ 'الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت' ], + dayNamesMin: [ 'الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت' ], weekHeader: 'أسبوع', dateFormat: 'dd/mm/yy', firstDay: 6, isRTL: true, showMonthAfterYear: false, - yearSuffix: ''}; -datepicker.setDefaults(datepicker.regional['ar-DZ']); + yearSuffix: '' }; +datepicker.setDefaults( datepicker.regional[ 'ar-DZ' ] ); -return datepicker.regional['ar-DZ']; +return datepicker.regional[ 'ar-DZ' ]; -})); +} ) ); diff --git a/ui/widgets/datepicker.js b/ui/widgets/datepicker.js index 85b658319bb..36e7ef327b9 100644 --- a/ui/widgets/datepicker.js +++ b/ui/widgets/datepicker.js @@ -360,7 +360,7 @@ $.extend(Datepicker.prototype, { [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY]; } - // move input on screen for focus, but hidden behind dialog + // Move input on screen for focus, but hidden behind dialog this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px"); inst.settings.onSelect = onSelect; this._inDialog = true; @@ -547,7 +547,7 @@ $.extend(Datepicker.prototype, { } }, - // change method deprecated + // Change method deprecated _changeDatepicker: function(target, name, value) { this._optionDatepicker(target, name, value); }, @@ -611,7 +611,7 @@ $.extend(Datepicker.prototype, { if (onSelect) { dateStr = $.datepicker._formatDate(inst); - // trigger custom callback + // Trigger custom callback onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); } else { $.datepicker._hideDatepicker(); @@ -836,7 +836,7 @@ $.extend(Datepicker.prototype, { inst.input.trigger( "focus" ); } - // deffered render of the years select (to avoid flashes on Firefox) + // Deffered render of the years select (to avoid flashes on Firefox) if( inst.yearshtml ){ origyearshtml = inst.yearshtml; setTimeout(function(){ @@ -869,7 +869,7 @@ $.extend(Datepicker.prototype, { offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0; offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0; - // now check if datepicker is showing outside window viewport - move to a better place if so. + // Now check if datepicker is showing outside window viewport - move to a better place if so. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? Math.abs(offset.left + dpWidth - viewWidth) : 0); offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ? @@ -1824,7 +1824,7 @@ $.extend(Datepicker.prototype, { html = "
    ", monthHtml = ""; - // month selection + // Month selection if (secondary || !changeMonth) { monthHtml += "" + monthNames[drawMonth] + ""; } else { @@ -1845,7 +1845,7 @@ $.extend(Datepicker.prototype, { html += monthHtml + (secondary || !(changeMonth && changeYear) ? " " : ""); } - // year selection + // Year selection if ( !inst.yearshtml ) { inst.yearshtml = ""; if (secondary || !changeYear) { From 069bee3dee33adc86a3a7f9bf9be72ca489259f0 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:11:54 -0400 Subject: [PATCH 16/26] Autocomplete: Style updates --- tests/unit/autocomplete/common.js | 4 +- tests/unit/autocomplete/core.js | 164 ++++++++++++++--------------- tests/unit/autocomplete/events.js | 73 ++++++------- tests/unit/autocomplete/methods.js | 12 +-- tests/unit/autocomplete/options.js | 144 ++++++++++++------------- ui/widgets/autocomplete.js | 18 ++-- 6 files changed, 209 insertions(+), 206 deletions(-) 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/ui/widgets/autocomplete.js b/ui/widgets/autocomplete.js index a36282dd56f..954258e23ca 100644 --- a/ui/widgets/autocomplete.js +++ b/ui/widgets/autocomplete.js @@ -51,7 +51,7 @@ $.widget( "ui.autocomplete", { }, source: null, - // callbacks + // Callbacks change: null, close: null, focus: null, @@ -165,7 +165,7 @@ $.widget( "ui.autocomplete", { return; } - // replicate some key handlers to allow them to repeat in Firefox and Opera + // Replicate some key handlers to allow them to repeat in Firefox and Opera var keyCode = $.ui.keyCode; switch ( event.keyCode ) { case keyCode.PAGE_UP: @@ -239,7 +239,7 @@ $.widget( "ui.autocomplete", { } } ); - // clicking on the scrollbar causes focus to shift to the body + // Clicking on the scrollbar causes focus to shift to the body // but we can't detect a mouseup or a click immediately afterward // so we have to track the next mousedown and close the menu if // the user clicks somewhere outside of the autocomplete @@ -293,7 +293,7 @@ $.widget( "ui.autocomplete", { var item = ui.item.data( "ui-autocomplete-item" ), previous = this.previous; - // only trigger when focus was lost (click on menu) + // Only trigger when focus was lost (click on menu) if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) { this.element.trigger( "focus" ); this.previous = previous; @@ -327,7 +327,7 @@ $.widget( "ui.autocomplete", { this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" ); - // 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, { @@ -427,7 +427,7 @@ $.widget( "ui.autocomplete", { search: function( value, event ) { value = value != null ? value : this._value(); - // always save the actual value, not the one passed as an argument + // Always save the actual value, not the one passed as an argument this.term = this._value(); if ( value.length < this.options.minLength ) { @@ -523,7 +523,7 @@ $.widget( "ui.autocomplete", { this.isNewMenu = true; this.menu.refresh(); - // size and position menu + // Size and position menu ul.show(); this._resizeMenu(); ul.position( $.extend( { @@ -592,7 +592,7 @@ $.widget( "ui.autocomplete", { if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) { this._move( keyEvent, event ); - // prevents moving cursor to beginning/end of the text field in some browsers + // Prevents moving cursor to beginning/end of the text field in some browsers event.preventDefault(); } } @@ -610,7 +610,7 @@ $.extend( $.ui.autocomplete, { } } ); -// live region extension, adding a `messages` option +// Live region extension, adding a `messages` option // NOTE: This is an experimental API. We are still investigating // a full solution for string manipulation and internationalization. $.widget( "ui.autocomplete", $.ui.autocomplete, { From 937ad64792404ba7e5117f261a43937a1949d4a9 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:12:07 -0400 Subject: [PATCH 17/26] Accordion: Style updates --- tests/unit/accordion/common.js | 4 +- tests/unit/accordion/core.js | 22 ++-- tests/unit/accordion/events.js | 46 +++---- tests/unit/accordion/helper.js | 10 +- tests/unit/accordion/methods.js | 61 ++++----- tests/unit/accordion/options.js | 222 +++++++++++++++++--------------- ui/widgets/accordion.js | 26 ++-- 7 files changed, 200 insertions(+), 191 deletions(-) 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/ui/widgets/accordion.js b/ui/widgets/accordion.js index 88e9bdb6f26..8c16df38f6d 100644 --- a/ui/widgets/accordion.js +++ b/ui/widgets/accordion.js @@ -53,7 +53,7 @@ return $.widget( "ui.accordion", { header: "ui-icon-triangle-1-e" }, - // callbacks + // Callbacks activate: null, beforeActivate: null }, @@ -81,7 +81,7 @@ return $.widget( "ui.accordion", { this._addClass( "ui-accordion", "ui-widget ui-helper-reset" ); this.element.attr( "role", "tablist" ); - // don't allow collapsible: false and active: false / null + // Don't allow collapsible: false and active: false / null if ( !options.collapsible && ( options.active === false || options.active == null ) ) { options.active = 0; } @@ -124,17 +124,17 @@ return $.widget( "ui.accordion", { _destroy: function() { var contents; - // clean up main element + // Clean up main element this.element.removeAttr( "role" ); - // clean up headers + // Clean up headers this.headers .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" ) .removeUniqueId(); this._destroyIcons(); - // clean up content panels + // Clean up content panels contents = this.headers.next() .css( "display", "" ) .removeAttr( "role aria-hidden aria-labelledby" ) @@ -161,7 +161,7 @@ return $.widget( "ui.accordion", { this._super( key, value ); - // setting collapsible: false while collapsed; open first panel + // Setting collapsible: false while collapsed; open first panel if ( key === "collapsible" && !value && this.options.active === false ) { this._activate( 0 ); } @@ -234,7 +234,7 @@ return $.widget( "ui.accordion", { var options = this.options; this._processPanels(); - // was collapsed or no panel + // Was collapsed or no panel if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) { options.active = false; this.active = $(); @@ -318,7 +318,7 @@ return $.widget( "ui.accordion", { } ) .hide(); - // make sure at least one header is in the tab order + // Make sure at least one header is in the tab order if ( !this.active.length ) { this.headers.eq( 0 ).attr( "tabIndex", 0 ); } else { @@ -372,12 +372,12 @@ return $.widget( "ui.accordion", { _activate: function( index ) { var active = this._findActive( index )[ 0 ]; - // trying to activate the already active panel + // Trying to activate the already active panel if ( active === this.active[ 0 ] ) { return; } - // trying to collapse, simulate a click on the currently active header + // Trying to collapse, simulate a click on the currently active header active = active || this.active[ 0 ]; this._eventHandler( { @@ -436,12 +436,12 @@ return $.widget( "ui.accordion", { options.active = collapsing ? false : this.headers.index( clicked ); - // when the call to ._toggle() comes after the class changes + // When the call to ._toggle() comes after the class changes // it causes a very odd bug in IE 8 (see #6720) this.active = clickedIsActive ? $() : clicked; this._toggle( eventData ); - // switch classes + // Switch classes // corner classes on the previously active header stay after the animation this._removeClass( active, "ui-accordion-header-active", "ui-state-active" ); if ( options.icons ) { @@ -467,7 +467,7 @@ return $.widget( "ui.accordion", { var toShow = data.newPanel, toHide = this.prevShow.length ? this.prevShow : data.oldPanel; - // handle activating a panel during the animation for another activation + // Handle activating a panel during the animation for another activation this.prevShow.add( this.prevHide ).stop( true, true ); this.prevShow = toShow; this.prevHide = toHide; From 2fa73b5d2800fe8512b4aa4f175fa0dde0f7f656 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:12:17 -0400 Subject: [PATCH 18/26] Effects: Style updates --- demos/effect/default.html | 8 +- demos/effect/easing.html | 10 +- demos/effect/hide.html | 8 +- demos/effect/show.html | 6 +- demos/effect/toggle.html | 6 +- tests/unit/effects/core.js | 10 +- ui/effect.js | 365 ++++++++++++++++++----------------- ui/effects/effect-bounce.js | 13 +- ui/effects/effect-explode.js | 10 +- 9 files changed, 227 insertions(+), 209 deletions(-) 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/tests/unit/effects/core.js b/tests/unit/effects/core.js index c8e7c26321d..5f634a78293 100644 --- a/tests/unit/effects/core.js +++ b/tests/unit/effects/core.js @@ -30,7 +30,7 @@ function notPresent( value, array, message ) { // minDuration is used for "short" animate tests where we are only concerned about the final var minDuration = 15, - // duration is used for "long" animates where we plan on testing properties during animation + // Duration is used for "long" animates where we plan on testing properties during animation duration = 200; module( "effects.core" ); @@ -115,11 +115,11 @@ asyncTest( "animateClass works with colors", function() { expect(2); - // we want to catch the first frame of animation + // We want to catch the first frame of animation jQuery.fx.step.backgroundColor = function( fx ) { oldStep.apply( this, arguments ); - // make sure it has animated somewhere we can detect + // Make sure it has animated somewhere we can detect if ( fx.pos > 255 / 2000 ) { jQuery.fx.step.backgroundColor = oldStep; notPresent( test.css("backgroundColor"), @@ -206,14 +206,14 @@ function( assert ) { expect( 2 ); var test = $( "div.ticket7106" ); - // ensure the class stays and that the css property stays + // Ensure the class stays and that the css property stays function animationComplete() { assert.hasClasses( test, "testClass", "class change during animateClass was not lost" ); equal( test.height(), 100, "css change during animateClass was not lost" ); start(); } - // add a class and change a style property after starting an animated class + // Add a class and change a style property after starting an animated class test.addClass( "animate", minDuration, animationComplete ) .addClass( "testClass" ) .height( 100 ); diff --git a/ui/effect.js b/ui/effect.js index 7fa45cfc0c6..322c31a981f 100644 --- a/ui/effect.js +++ b/ui/effect.js @@ -13,7 +13,7 @@ //>>docs: http://api.jqueryui.com/category/effects-core/ //>>demos: http://jqueryui.com/effect/ -(function( factory ) { +( function( factory ) { if ( typeof define === "function" && define.amd ) { // AMD. Register as an anonymous module. @@ -23,7 +23,7 @@ // Browser globals factory( jQuery ); } -}(function( $ ) { +}( function( $ ) { var dataSpace = "ui-effects-", dataSpaceStyle = "ui-effects-style", @@ -47,13 +47,14 @@ $.effects = { * * Date: Wed Jan 16 08:47:09 2013 -0600 */ -(function( jQuery, undefined ) { +( function( jQuery, undefined ) { var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor", - // plusequals test for += 100 -= 100 + // Plusequals test for += 100 -= 100 rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, - // a set of RE's that can match strings and generate color tuples. + + // A set of RE's that can match strings and generate color tuples. stringParsers = [ { re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, parse: function( execResult ) { @@ -75,7 +76,8 @@ $.effects = { ]; } }, { - // this regex ignores A-F because it's compared against an already lowercased string + + // This regex ignores A-F because it's compared against an already lowercased string re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, parse: function( execResult ) { return [ @@ -85,7 +87,8 @@ $.effects = { ]; } }, { - // this regex ignores A-F because it's compared against an already lowercased string + + // This regex ignores A-F because it's compared against an already lowercased string re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, parse: function( execResult ) { return [ @@ -107,7 +110,7 @@ $.effects = { } } ], - // jQuery.Color( ) + // JQuery.Color( ) color = jQuery.Color = function( color, green, blue, alpha ) { return new jQuery.Color.fn.parse( color, green, blue, alpha ); }, @@ -161,20 +164,20 @@ $.effects = { }, support = color.support = {}, - // element for support tests + // Element for support tests supportElem = jQuery( "

    " )[ 0 ], - // colors = jQuery.Color.names + // Colors = jQuery.Color.names colors, - // local aliases of functions called often + // Local aliases of functions called often each = jQuery.each; -// determine rgba support immediately +// Determine rgba support immediately supportElem.style.cssText = "background-color:rgba(1,1,1,.5)"; support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1; -// define cache name and alpha properties +// Define cache name and alpha properties // for rgba and hsla spaces each( spaces, function( spaceName, space ) { space.cache = "_" + spaceName; @@ -183,13 +186,13 @@ each( spaces, function( spaceName, space ) { type: "percent", def: 1 }; -}); +} ); function clamp( value, prop, allowEmpty ) { var type = propTypes[ prop.type ] || {}; if ( value == null ) { - return (allowEmpty || !prop.def) ? null : prop.def; + return ( allowEmpty || !prop.def ) ? null : prop.def; } // ~~ is an short way of doing floor for positive numbers @@ -202,12 +205,13 @@ function clamp( value, prop, allowEmpty ) { } if ( type.mod ) { - // we add mod before modding to make sure that negatives values + + // We add mod before modding to make sure that negatives values // get converted properly: -10 -> 350 - return (value + type.mod) % type.mod; + return ( value + type.mod ) % type.mod; } - // for now all property types without mod have min and max + // For now all property types without mod have min and max return 0 > value ? 0 : type.max < value ? type.max : value; } @@ -226,20 +230,20 @@ function stringParse( string ) { if ( values ) { parsed = inst[ spaceName ]( values ); - // if this was an rgba parse the assignment might happen twice + // If this was an rgba parse the assignment might happen twice // oh well.... inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; rgba = inst._rgba = parsed._rgba; - // exit each( stringParsers ) here because we matched + // Exit each( stringParsers ) here because we matched return false; } - }); + } ); // Found a stringParser that handled it if ( rgba.length ) { - // if this came from a parsed string, force "transparent" when alpha is 0 + // If this came from a parsed string, force "transparent" when alpha is 0 // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) if ( rgba.join() === "0,0,0,0" ) { jQuery.extend( rgba, colors.transparent ); @@ -247,7 +251,7 @@ function stringParse( string ) { return inst; } - // named colors + // Named colors return colors[ string ]; } @@ -266,7 +270,7 @@ color.fn = jQuery.extend( color.prototype, { type = jQuery.type( red ), rgba = this._rgba = []; - // more than 1 argument specified - assume ( red, green, blue, alpha ) + // More than 1 argument specified - assume ( red, green, blue, alpha ) if ( green !== undefined ) { red = [ red, green, blue, alpha ]; type = "array"; @@ -279,7 +283,7 @@ color.fn = jQuery.extend( color.prototype, { if ( type === "array" ) { each( spaces.rgba.props, function( key, prop ) { rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); - }); + } ); return this; } @@ -289,16 +293,16 @@ color.fn = jQuery.extend( color.prototype, { if ( red[ space.cache ] ) { inst[ space.cache ] = red[ space.cache ].slice(); } - }); + } ); } else { each( spaces, function( spaceName, space ) { var cache = space.cache; each( space.props, function( key, prop ) { - // if the cache doesn't exist, and we know how to convert + // If the cache doesn't exist, and we know how to convert if ( !inst[ cache ] && space.to ) { - // if the value was null, we don't need to copy it + // If the value was null, we don't need to copy it // if the key was alpha, we don't need to copy it either if ( key === "alpha" || red[ key ] == null ) { return; @@ -306,20 +310,21 @@ color.fn = jQuery.extend( color.prototype, { inst[ cache ] = space.to( inst._rgba ); } - // this is the only case where we allow nulls for ALL properties. + // This is the only case where we allow nulls for ALL properties. // call clamp with alwaysAllowEmpty inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); - }); + } ); - // everything defined but alpha? + // Everything defined but alpha? if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { - // use the default of 1 + + // Use the default of 1 inst[ cache ][ 3 ] = 1; if ( space.from ) { inst._rgba = space.from( inst[ cache ] ); } } - }); + } ); } return this; } @@ -332,17 +337,17 @@ color.fn = jQuery.extend( color.prototype, { each( spaces, function( _, space ) { var localCache, isCache = is[ space.cache ]; - if (isCache) { + if ( isCache ) { localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; each( space.props, function( _, prop ) { if ( isCache[ prop.idx ] != null ) { same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); return same; } - }); + } ); } return same; - }); + } ); return same; }, _space: function() { @@ -352,7 +357,7 @@ color.fn = jQuery.extend( color.prototype, { if ( inst[ space.cache ] ) { used.push( spaceName ); } - }); + } ); return used.pop(); }, transition: function( other, distance ) { @@ -370,11 +375,12 @@ color.fn = jQuery.extend( color.prototype, { endValue = end[ index ], type = propTypes[ prop.type ] || {}; - // if null, don't override start value + // If null, don't override start value if ( endValue === null ) { return; } - // if null - use end + + // If null - use end if ( startValue === null ) { result[ index ] = endValue; } else { @@ -387,11 +393,12 @@ color.fn = jQuery.extend( color.prototype, { } result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); } - }); + } ); return this[ spaceName ]( result ); }, blend: function( opaque ) { - // if we are already opaque - return ourself + + // If we are already opaque - return ourself if ( this._rgba[ 3 ] === 1 ) { return this; } @@ -402,13 +409,13 @@ color.fn = jQuery.extend( color.prototype, { return color( jQuery.map( rgb, function( v, i ) { return ( 1 - a ) * blend[ i ] + a * v; - })); + } ) ); }, toRgbaString: function() { var prefix = "rgba(", rgba = jQuery.map( this._rgba, function( v, i ) { return v == null ? ( i > 2 ? 1 : 0 ) : v; - }); + } ); if ( rgba[ 3 ] === 1 ) { rgba.pop(); @@ -424,12 +431,12 @@ color.fn = jQuery.extend( color.prototype, { v = i > 2 ? 1 : 0; } - // catch 1 and 2 + // Catch 1 and 2 if ( i && i < 3 ) { v = Math.round( v * 100 ) + "%"; } return v; - }); + } ); if ( hsla[ 3 ] === 1 ) { hsla.pop(); @@ -447,18 +454,18 @@ color.fn = jQuery.extend( color.prototype, { return "#" + jQuery.map( rgba, function( v ) { - // default to 0 when nulls exist + // Default to 0 when nulls exist v = ( v || 0 ).toString( 16 ); return v.length === 1 ? "0" + v : v; - }).join(""); + } ).join( "" ); }, toString: function() { return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); } -}); +} ); color.fn.parse.prototype = color.fn; -// hsla conversions adapted from: +// Hsla conversions adapted from: // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 function hue2rgb( p, q, h ) { @@ -466,7 +473,7 @@ function hue2rgb( p, q, h ) { if ( h * 6 < 1 ) { return p + ( q - p ) * h * 6; } - if ( h * 2 < 1) { + if ( h * 2 < 1 ) { return q; } if ( h * 3 < 2 ) { @@ -500,7 +507,7 @@ spaces.hsla.to = function( rgba ) { h = ( 60 * ( r - g ) / diff ) + 240; } - // chroma (diff) == 0 means greyscale which, by definition, saturation = 0% + // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0% // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add) if ( diff === 0 ) { s = 0; @@ -509,7 +516,7 @@ spaces.hsla.to = function( rgba ) { } else { s = diff / ( 2 - add ); } - return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; + return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ]; }; spaces.hsla.from = function( hsla ) { @@ -537,10 +544,10 @@ each( spaces, function( spaceName, space ) { to = space.to, from = space.from; - // makes rgba() and hsla() + // Makes rgba() and hsla() color.fn[ spaceName ] = function( value ) { - // generate a cache for this space if it doesn't exist + // Generate a cache for this space if it doesn't exist if ( to && !this[ cache ] ) { this[ cache ] = to( this._rgba ); } @@ -559,7 +566,7 @@ each( spaces, function( spaceName, space ) { val = local[ prop.idx ]; } local[ prop.idx ] = clamp( val, prop ); - }); + } ); if ( from ) { ret = color( from( local ) ); @@ -570,9 +577,10 @@ each( spaces, function( spaceName, space ) { } }; - // makes red() green() blue() alpha() hue() saturation() lightness() + // Makes red() green() blue() alpha() hue() saturation() lightness() each( props, function( key, prop ) { - // alpha is included in more than one space + + // Alpha is included in more than one space if ( color.fn[ key ] ) { return; } @@ -603,10 +611,10 @@ each( spaces, function( spaceName, space ) { local[ prop.idx ] = value; return this[ fn ]( local ); }; - }); -}); + } ); +} ); -// add cssHook and .fx.step function for each named hook. +// Add cssHook and .fx.step function for each named hook. // accept a space separated string of properties color.hook = function( hook ) { var hooks = hook.split( " " ); @@ -621,7 +629,7 @@ color.hook = function( hook ) { if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { curElem = hook === "backgroundColor" ? elem.parentNode : elem; while ( - (backgroundColor === "" || backgroundColor === "transparent") && + ( backgroundColor === "" || backgroundColor === "transparent" ) && curElem && curElem.style ) { try { @@ -641,7 +649,8 @@ color.hook = function( hook ) { try { elem.style[ hook ] = value; } catch ( e ) { - // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit' + + // Wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit' } } }; @@ -653,7 +662,7 @@ color.hook = function( hook ) { } jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); }; - }); + } ); }; @@ -665,7 +674,7 @@ jQuery.cssHooks.borderColor = { each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) { expanded[ "border" + part + "Color" ] = value; - }); + } ); return expanded; } }; @@ -674,6 +683,7 @@ jQuery.cssHooks.borderColor = { // Usage of any of the other color names requires adding yourself or including // jquery.color.svg-names.js. colors = jQuery.Color.names = { + // 4.1. Basic color keywords aqua: "#00ffff", black: "#000000", @@ -698,12 +708,12 @@ colors = jQuery.Color.names = { _default: "#ffffff" }; -})( jQuery ); +} )( jQuery ); /******************************************************************************/ /****************************** CLASS ANIMATIONS ******************************/ /******************************************************************************/ -(function() { +( function() { var classAnimationActions = [ "add", "remove", "toggle" ], shorthandStyles = { @@ -718,14 +728,14 @@ var classAnimationActions = [ "add", "remove", "toggle" ], padding: 1 }; -$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { +$.each( [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { $.fx.step[ prop ] = function( fx ) { if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { jQuery.style( fx.elem, prop, fx.end ); fx.setAttr = true; } }; -}); +} ); function getElementStyles( elem ) { var key, len, @@ -742,7 +752,8 @@ function getElementStyles( elem ) { styles[ $.camelCase( key ) ] = style[ key ]; } } - // support: Opera, IE <9 + + // Support: Opera, IE <9 } else { for ( key in style ) { if ( typeof style[ key ] === "string" ) { @@ -772,7 +783,7 @@ function styleDifference( oldStyle, newStyle ) { return diff; } -// support: jQuery <1.8 +// Support: jQuery <1.8 if ( !$.fn.addBack ) { $.fn.addBack = function( selector ) { return this.add( selector == null ? @@ -790,136 +801,139 @@ $.effects.animateClass = function( value, duration, easing, callback ) { applyClassChange, allAnimations = o.children ? animated.find( "*" ).addBack() : animated; - // map the animated objects to store the original styles. - allAnimations = allAnimations.map(function() { + // Map the animated objects to store the original styles. + allAnimations = allAnimations.map( function() { var el = $( this ); return { el: el, start: getElementStyles( this ) }; - }); + } ); - // apply class change + // Apply class change applyClassChange = function() { - $.each( classAnimationActions, function(i, action) { + $.each( classAnimationActions, function( i, action ) { if ( value[ action ] ) { animated[ action + "Class" ]( value[ action ] ); } - }); + } ); }; applyClassChange(); - // map all animated objects again - calculate new styles and diff - allAnimations = allAnimations.map(function() { + // Map all animated objects again - calculate new styles and diff + allAnimations = allAnimations.map( function() { this.end = getElementStyles( this.el[ 0 ] ); this.diff = styleDifference( this.start, this.end ); return this; - }); + } ); - // apply original class + // Apply original class animated.attr( "class", baseClass ); - // map all animated objects again - this time collecting a promise - allAnimations = allAnimations.map(function() { + // Map all animated objects again - this time collecting a promise + allAnimations = allAnimations.map( function() { var styleInfo = this, dfd = $.Deferred(), - opts = $.extend({}, o, { + opts = $.extend( {}, o, { queue: false, complete: function() { dfd.resolve( styleInfo ); } - }); + } ); this.el.animate( this.diff, opts ); return dfd.promise(); - }); + } ); - // once all animations have completed: - $.when.apply( $, allAnimations.get() ).done(function() { + // Once all animations have completed: + $.when.apply( $, allAnimations.get() ).done( function() { - // set the final class + // Set the final class applyClassChange(); - // for each animated element, + // For each animated element, // clear all css properties that were animated $.each( arguments, function() { var el = this.el; - $.each( this.diff, function(key) { + $.each( this.diff, function( key ) { el.css( key, "" ); - }); - }); + } ); + } ); - // this is guarnteed to be there if you use jQuery.speed() + // This is guarnteed to be there if you use jQuery.speed() // it also handles dequeuing the next anim... o.complete.call( animated[ 0 ] ); - }); - }); + } ); + } ); }; -$.fn.extend({ - addClass: (function( orig ) { +$.fn.extend( { + addClass: ( function( orig ) { return function( classNames, speed, easing, callback ) { return speed ? $.effects.animateClass.call( this, { add: classNames }, speed, easing, callback ) : orig.apply( this, arguments ); }; - })( $.fn.addClass ), + } )( $.fn.addClass ), - removeClass: (function( orig ) { + removeClass: ( function( orig ) { return function( classNames, speed, easing, callback ) { return arguments.length > 1 ? $.effects.animateClass.call( this, { remove: classNames }, speed, easing, callback ) : orig.apply( this, arguments ); }; - })( $.fn.removeClass ), + } )( $.fn.removeClass ), - toggleClass: (function( orig ) { + toggleClass: ( function( orig ) { return function( classNames, force, speed, easing, callback ) { if ( typeof force === "boolean" || force === undefined ) { if ( !speed ) { - // without speed parameter + + // Without speed parameter return orig.apply( this, arguments ); } else { return $.effects.animateClass.call( this, - (force ? { add: classNames } : { remove: classNames }), + ( force ? { add: classNames } : { remove: classNames } ), speed, easing, callback ); } } else { - // without force parameter + + // Without force parameter return $.effects.animateClass.call( this, { toggle: classNames }, force, speed, easing ); } }; - })( $.fn.toggleClass ), + } )( $.fn.toggleClass ), - switchClass: function( remove, add, speed, easing, callback) { + switchClass: function( remove, add, speed, easing, callback ) { return $.effects.animateClass.call( this, { add: add, remove: remove }, speed, easing, callback ); } -}); +} ); -})(); +} )(); /******************************************************************************/ /*********************************** EFFECTS **********************************/ /******************************************************************************/ -(function() { +( function() { if ( $.expr && $.expr.filters && $.expr.filters.animated ) { - $.expr.filters.animated = (function( orig ) { + $.expr.filters.animated = ( function( orig ) { return function( elem ) { return !!$( elem ).data( dataSpaceAnimated ) || orig( elem ); }; - })( $.expr.filters.animated ); + } )( $.expr.filters.animated ); } if ( $.uiBackCompat !== false ) { $.extend( $.effects, { + // Saves a set of properties in a data storage save: function( element, set ) { var i = 0, length = set.length; @@ -951,12 +965,12 @@ if ( $.uiBackCompat !== false ) { // Wraps the element around a wrapper that copies position properties createWrapper: function( element ) { - // if the element is already wrapped, return it + // If the element is already wrapped, return it if ( element.parent().is( ".ui-effects-wrapper" ) ) { return element.parent(); } - // wrap the element + // Wrap the element var props = { width: element.outerWidth( true ), height: element.outerHeight( true ), @@ -964,13 +978,14 @@ if ( $.uiBackCompat !== false ) { }, wrapper = $( "

    " ) .addClass( "ui-effects-wrapper" ) - .css({ + .css( { fontSize: "100%", background: "transparent", border: "none", margin: 0, padding: 0 - }), + } ), + // Store the size in case width/height are defined in % - Fixes #5245 size = { width: element.width(), @@ -978,7 +993,7 @@ if ( $.uiBackCompat !== false ) { }, active = document.activeElement; - // support: Firefox + // Support: Firefox // Firefox incorrectly exposes anonymous content // https://bugzilla.mozilla.org/show_bug.cgi?id=561664 try { @@ -996,30 +1011,30 @@ if ( $.uiBackCompat !== false ) { wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element - // transfer positioning properties to the wrapper + // Transfer positioning properties to the wrapper if ( element.css( "position" ) === "static" ) { - wrapper.css({ position: "relative" }); - element.css({ position: "relative" }); + wrapper.css( { position: "relative" } ); + element.css( { position: "relative" } ); } else { $.extend( props, { position: element.css( "position" ), zIndex: element.css( "z-index" ) - }); - $.each([ "top", "left", "bottom", "right" ], function(i, pos) { + } ); + $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) { props[ pos ] = element.css( pos ); if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { props[ pos ] = "auto"; } - }); - element.css({ + } ); + element.css( { position: "relative", top: 0, left: 0, right: "auto", bottom: "auto" - }); + } ); } - element.css(size); + element.css( size ); return wrapper.css( props ).show(); }, @@ -1038,7 +1053,7 @@ if ( $.uiBackCompat !== false ) { return element; } - }); + } ); } $.extend( $.effects, { @@ -1167,19 +1182,19 @@ $.extend( $.effects, { // will change margin if you explicitly set height // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380 // Support: Safari - element.css({ + element.css( { marginTop: element.css( "marginTop" ), marginBottom: element.css( "marginBottom" ), marginLeft: element.css( "marginLeft" ), marginRight: element.css( "marginRight" ) - }) + } ) .outerWidth( element.outerWidth() ) .outerHeight( element.outerHeight() ); if ( /^(static|relative)/.test( cssPosition ) ) { cssPosition = "absolute"; - placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css({ + placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( { // Convert inline to inline block to account for inline elements // that turn to inline block based on content (like img) @@ -1192,7 +1207,7 @@ $.extend( $.effects, { marginLeft: element.css( "marginLeft" ), marginRight: element.css( "marginRight" ), "float": element.css( "float" ) - }) + } ) .outerWidth( element.outerWidth() ) .outerHeight( element.outerHeight() ) .addClass( "ui-effects-placeholder" ); @@ -1200,11 +1215,11 @@ $.extend( $.effects, { element.data( dataSpace + "placeholder", placeholder ); } - element.css({ + element.css( { position: cssPosition, left: position.left, top: position.top - }); + } ); return placeholder; }, @@ -1233,49 +1248,49 @@ $.extend( $.effects, { if ( unit[ 0 ] > 0 ) { value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; } - }); + } ); return value; } -}); +} ); -// return an effect options object for the given parameters: +// Return an effect options object for the given parameters: function _normalizeArguments( effect, options, speed, callback ) { - // allow passing all options as the first parameter + // Allow passing all options as the first parameter if ( $.isPlainObject( effect ) ) { options = effect; effect = effect.effect; } - // convert to an object + // Convert to an object effect = { effect: effect }; - // catch (effect, null, ...) + // Catch (effect, null, ...) if ( options == null ) { options = {}; } - // catch (effect, callback) + // Catch (effect, callback) if ( $.isFunction( options ) ) { callback = options; speed = null; options = {}; } - // catch (effect, speed, ?) + // Catch (effect, speed, ?) if ( typeof options === "number" || $.fx.speeds[ options ] ) { callback = speed; speed = options; options = {}; } - // catch (effect, options, callback) + // Catch (effect, options, callback) if ( $.isFunction( speed ) ) { callback = speed; speed = null; } - // add options to effect + // Add options to effect if ( options ) { $.extend( effect, options ); } @@ -1292,6 +1307,7 @@ function _normalizeArguments( effect, options, speed, callback ) { } function standardAnimationOption( option ) { + // Valid standard speeds (nothing, number, named speed) if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) { return true; @@ -1316,8 +1332,8 @@ function standardAnimationOption( option ) { return false; } -$.fn.extend({ - effect: function( /* effect, options, speed, callback */ ) { +$.fn.extend( { + effect: function( /* Effect, options, speed, callback */ ) { var args = _normalizeArguments.apply( this, arguments ), effectMethod = $.effects.effect[ args.effect ], defaultMode = effectMethod.mode, @@ -1354,7 +1370,8 @@ $.fn.extend({ }; if ( $.fx.off || !effectMethod ) { - // delegate to the original method (e.g., .show()) if possible + + // Delegate to the original method (e.g., .show()) if possible if ( mode ) { return this[ mode ]( args.duration, complete ); } else { @@ -1362,7 +1379,7 @@ $.fn.extend({ if ( complete ) { complete.call( this ); } - }); + } ); } } @@ -1424,7 +1441,7 @@ $.fn.extend({ this.queue( queueName, prefilter ).queue( queueName, run ); }, - show: (function( orig ) { + show: ( function( orig ) { return function( option ) { if ( standardAnimationOption( option ) ) { return orig.apply( this, arguments ); @@ -1434,9 +1451,9 @@ $.fn.extend({ return this.effect.call( this, args ); } }; - })( $.fn.show ), + } )( $.fn.show ), - hide: (function( orig ) { + hide: ( function( orig ) { return function( option ) { if ( standardAnimationOption( option ) ) { return orig.apply( this, arguments ); @@ -1446,9 +1463,9 @@ $.fn.extend({ return this.effect.call( this, args ); } }; - })( $.fn.hide ), + } )( $.fn.hide ), - toggle: (function( orig ) { + toggle: ( function( orig ) { return function( option ) { if ( standardAnimationOption( option ) || typeof option === "boolean" ) { return orig.apply( this, arguments ); @@ -1458,9 +1475,9 @@ $.fn.extend({ return this.effect.call( this, args ); } }; - })( $.fn.toggle ), + } )( $.fn.toggle ), - cssUnit: function(key) { + cssUnit: function( key ) { var style = this.css( key ), val = []; @@ -1468,14 +1485,14 @@ $.fn.extend({ if ( style.indexOf( unit ) > 0 ) { val = [ parseFloat( style ), unit ]; } - }); + } ); return val; }, cssClip: function( clipObj ) { return clipObj ? this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " + clipObj.bottom + "px " + clipObj.left + "px)" ) : - parseClip( this.css("clip"), this ); + parseClip( this.css( "clip" ), this ); }, transfer: function( options, done ) { @@ -1496,21 +1513,21 @@ $.fn.extend({ transfer = $( "
    " ) .appendTo( "body" ) .addClass( options.className ) - .css({ + .css( { top: startPosition.top - fixTop, left: startPosition.left - fixLeft, height: element.innerHeight(), width: element.innerWidth(), position: targetFixed ? "fixed" : "absolute" - }) + } ) .animate( animation, options.duration, options.easing, function() { transfer.remove(); if ( $.isFunction( done ) ) { done(); } - }); + } ); } -}); +} ); function parseClip( str, element ) { var outerWidth = element.outerWidth(), @@ -1535,23 +1552,23 @@ $.fx.step.clip = function( fx ) { fx.clipInit = true; } - $( fx.elem ).cssClip({ - top: fx.pos * (fx.end.top - fx.start.top) + fx.start.top, - right: fx.pos * (fx.end.right - fx.start.right) + fx.start.right, - bottom: fx.pos * (fx.end.bottom - fx.start.bottom) + fx.start.bottom, - left: fx.pos * (fx.end.left - fx.start.left) + fx.start.left - }); + $( fx.elem ).cssClip( { + top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top, + right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right, + bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom, + left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left + } ); }; -})(); +} )(); /******************************************************************************/ /*********************************** EASING ***********************************/ /******************************************************************************/ -(function() { +( function() { -// based on easing equations from Robert Penner (http://www.robertpenner.com/easing) +// Based on easing equations from Robert Penner (http://www.robertpenner.com/easing) var baseEasings = {}; @@ -1559,7 +1576,7 @@ $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { baseEasings[ name ] = function( p ) { return Math.pow( p, i + 2 ); }; -}); +} ); $.extend( baseEasings, { Sine: function( p ) { @@ -1570,7 +1587,7 @@ $.extend( baseEasings, { }, Elastic: function( p ) { return p === 0 || p === 1 ? p : - -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 ); + -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 ); }, Back: function( p ) { return p * p * ( 3 * p - 2 ); @@ -1582,7 +1599,7 @@ $.extend( baseEasings, { while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); } -}); +} ); $.each( baseEasings, function( name, easeIn ) { $.easing[ "easeIn" + name ] = easeIn; @@ -1594,10 +1611,10 @@ $.each( baseEasings, function( name, easeIn ) { easeIn( p * 2 ) / 2 : 1 - easeIn( p * -2 + 2 ) / 2; }; -}); +} ); -})(); +} )(); return $.effects; -})); +} ) ); diff --git a/ui/effects/effect-bounce.js b/ui/effects/effect-bounce.js index 06bc84426dd..1743ef50398 100644 --- a/ui/effects/effect-bounce.js +++ b/ui/effects/effect-bounce.js @@ -33,7 +33,7 @@ return $.effects.define( "bounce", function( options, done ) { var upAnim, downAnim, refValue, element = $( this ), - // defaults: + // Defaults: mode = options.mode, hide = mode === "hide", show = mode === "show", @@ -41,12 +41,12 @@ return $.effects.define( "bounce", function( options, done ) { distance = options.distance, times = options.times || 5, - // number of internal animations + // Number of internal animations anims = times * 2 + ( show || hide ? 1 : 0 ), speed = options.duration / anims, easing = options.easing, - // utility: + // Utility: ref = ( direction === "up" || direction === "down" ) ? "top" : "left", motion = ( direction === "up" || direction === "left" ), i = 0, @@ -57,7 +57,7 @@ return $.effects.define( "bounce", function( options, done ) { refValue = element.css( ref ); - // default distance for the BIGGEST bounce is the outer Distance / 3 + // Default distance for the BIGGEST bounce is the outer Distance / 3 if ( !distance ) { distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3; } @@ -66,7 +66,7 @@ return $.effects.define( "bounce", function( options, done ) { downAnim = { opacity: 1 }; downAnim[ ref ] = refValue; - // if we are showing, force opacity 0 and set the initial position + // If we are showing, force opacity 0 and set the initial position // then do the "first" animation element .css( "opacity", 0 ) @@ -74,13 +74,14 @@ return $.effects.define( "bounce", function( options, done ) { .animate( downAnim, speed, easing ); } - // start at the smallest distance if we are hiding + // Start at the smallest distance if we are hiding if ( hide ) { distance = distance / Math.pow( 2, times - 1 ); } downAnim = {}; downAnim[ ref ] = refValue; + // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here for ( ; i < times; i++ ) { upAnim = {}; diff --git a/ui/effects/effect-explode.js b/ui/effects/effect-explode.js index 55c247d3e89..92b83f5452f 100644 --- a/ui/effects/effect-explode.js +++ b/ui/effects/effect-explode.js @@ -38,15 +38,15 @@ return $.effects.define( "explode", "hide", function( options, done ) { mode = options.mode, show = mode === "show", - // show and then visibility:hidden the element before calculating offset + // Show and then visibility:hidden the element before calculating offset offset = element.show().css( "visibility", "hidden" ).offset(), - // width and height of a piece + // Width and height of a piece width = Math.ceil( element.outerWidth() / cells ), height = Math.ceil( element.outerHeight() / rows ), pieces = []; - // children animate complete: + // Children animate complete: function childComplete() { pieces.push( this ); if ( pieces.length === rows * cells ) { @@ -54,7 +54,7 @@ return $.effects.define( "explode", "hide", function( options, done ) { } } - // clone the element for each row and cell. + // Clone the element for each row and cell. for ( i = 0; i < rows; i++ ) { // ===> top = offset.top + i * height; my = i - ( rows - 1 ) / 2; @@ -76,7 +76,7 @@ return $.effects.define( "explode", "hide", function( options, done ) { top: -i * height } ) - // select the wrapper - make it overflow: hidden and absolute positioned based on + // Select the wrapper - make it overflow: hidden and absolute positioned based on // where the original was located +left and +top equal to the size of pieces .parent() .addClass( "ui-effects-explode" ) From 90169ebd178ffc69359ec7346be3dffe14966361 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 21 Aug 2015 00:12:35 -0400 Subject: [PATCH 19/26] Button: Style updates --- tests/unit/button/common.js | 4 +- tests/unit/button/core.js | 163 ++++++++++++++++++----------------- tests/unit/button/events.js | 22 ++--- tests/unit/button/methods.js | 40 ++++----- tests/unit/button/options.js | 120 +++++++++++++------------- 5 files changed, 175 insertions(+), 174 deletions(-) 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