diff options
author | Alexander Schmitz <arschmitz@gmail.com> | 2015-08-21 00:04:44 -0400 |
---|---|---|
committer | Alexander Schmitz <arschmitz@gmail.com> | 2015-08-21 08:06:22 -0400 |
commit | 063885f592e6558d377968006ef7fe8ce192362c (patch) | |
tree | c506037207f99171d3ab0f1b700b30e7ad0e9ceb | |
parent | b7278a3968d9ac6332958811317865a412a9f39b (diff) | |
download | jquery-ui-063885f592e6558d377968006ef7fe8ce192362c.tar.gz jquery-ui-063885f592e6558d377968006ef7fe8ce192362c.zip |
Tabs: Style updates
Ref #14246
Ref gh-1588
-rw-r--r-- | demos/tabs/manipulation.html | 10 | ||||
-rw-r--r-- | tests/unit/tabs/common.js | 2 | ||||
-rw-r--r-- | tests/unit/tabs/core.js | 24 | ||||
-rw-r--r-- | tests/unit/tabs/events.js | 22 | ||||
-rw-r--r-- | tests/unit/tabs/methods.js | 20 | ||||
-rw-r--r-- | tests/unit/tabs/options.js | 16 | ||||
-rw-r--r-- | 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 bb4bb34c7..e10621bf3 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 42dd0c2fc..40c899847 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 b64f1d8f3..9c62817eb 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 7e3d27fda..307e110fd 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 3be31c5f8..d904ac530 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( "<li id='newTab'><a href='data/test.html'>new</a></li>" ); 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( "<li class='ui-state-disabled'><a href='#newTab2'>new 2</a></li>" ) .append( "<li><a href='#newTab3'>new 3</a></li>" ) @@ -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 39771efe6..f615e165e 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 0b7bf5850..034dcc3aa 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" ) { |