1 /*! |
1 /*! |
2 * jQuery UI Tabs 1.13.1 |
2 * jQuery UI Tabs 1.13.3 |
3 * http://jqueryui.com |
3 * https://jqueryui.com |
4 * |
4 * |
5 * Copyright jQuery Foundation and other contributors |
5 * Copyright OpenJS Foundation and other contributors |
6 * Released under the MIT license. |
6 * Released under the MIT license. |
7 * http://jquery.org/license |
7 * https://jquery.org/license |
8 */ |
8 */ |
9 |
9 |
10 //>>label: Tabs |
10 //>>label: Tabs |
11 //>>group: Widgets |
11 //>>group: Widgets |
12 //>>description: Transforms a set of container elements into a tab structure. |
12 //>>description: Transforms a set of container elements into a tab structure. |
13 //>>docs: http://api.jqueryui.com/tabs/ |
13 //>>docs: https://api.jqueryui.com/tabs/ |
14 //>>demos: http://jqueryui.com/tabs/ |
14 //>>demos: https://jqueryui.com/tabs/ |
15 //>>css.structure: ../../themes/base/core.css |
15 //>>css.structure: ../../themes/base/core.css |
16 //>>css.structure: ../../themes/base/tabs.css |
16 //>>css.structure: ../../themes/base/tabs.css |
17 //>>css.theme: ../../themes/base/theme.css |
17 //>>css.theme: ../../themes/base/theme.css |
18 |
18 |
19 ( function( factory ) { |
19 ( function( factory ) { |
22 if ( typeof define === "function" && define.amd ) { |
22 if ( typeof define === "function" && define.amd ) { |
23 |
23 |
24 // AMD. Register as an anonymous module. |
24 // AMD. Register as an anonymous module. |
25 define( [ |
25 define( [ |
26 "jquery", |
26 "jquery", |
27 "./core" |
27 "../keycode", |
|
28 "../safe-active-element", |
|
29 "../unique-id", |
|
30 "../version", |
|
31 "../widget" |
28 ], factory ); |
32 ], factory ); |
29 } else { |
33 } else { |
30 |
34 |
31 // Browser globals |
35 // Browser globals |
32 factory( jQuery ); |
36 factory( jQuery ); |
33 } |
37 } |
34 } )( function( $ ) { |
38 } )( function( $ ) { |
35 "use strict"; |
39 "use strict"; |
36 |
40 |
37 $.widget( "ui.tabs", { |
41 $.widget( "ui.tabs", { |
38 version: "1.13.1", |
42 version: "1.13.3", |
39 delay: 300, |
43 delay: 300, |
40 options: { |
44 options: { |
41 active: null, |
45 active: null, |
42 classes: { |
46 classes: { |
43 "ui-tabs": "ui-corner-all", |
47 "ui-tabs": "ui-corner-all", |
174 if ( this._handlePageNav( event ) ) { |
178 if ( this._handlePageNav( event ) ) { |
175 return; |
179 return; |
176 } |
180 } |
177 |
181 |
178 switch ( event.keyCode ) { |
182 switch ( event.keyCode ) { |
179 case $.ui.keyCode.RIGHT: |
183 case $.ui.keyCode.RIGHT: |
180 case $.ui.keyCode.DOWN: |
184 case $.ui.keyCode.DOWN: |
181 selectedIndex++; |
185 selectedIndex++; |
182 break; |
186 break; |
183 case $.ui.keyCode.UP: |
187 case $.ui.keyCode.UP: |
184 case $.ui.keyCode.LEFT: |
188 case $.ui.keyCode.LEFT: |
185 goingForward = false; |
189 goingForward = false; |
186 selectedIndex--; |
190 selectedIndex--; |
187 break; |
191 break; |
188 case $.ui.keyCode.END: |
192 case $.ui.keyCode.END: |
189 selectedIndex = this.anchors.length - 1; |
193 selectedIndex = this.anchors.length - 1; |
190 break; |
194 break; |
191 case $.ui.keyCode.HOME: |
195 case $.ui.keyCode.HOME: |
192 selectedIndex = 0; |
196 selectedIndex = 0; |
193 break; |
197 break; |
194 case $.ui.keyCode.SPACE: |
198 case $.ui.keyCode.SPACE: |
195 |
199 |
196 // Activate only, no collapsing |
200 // Activate only, no collapsing |
197 event.preventDefault(); |
201 event.preventDefault(); |
198 clearTimeout( this.activating ); |
202 clearTimeout( this.activating ); |
199 this._activate( selectedIndex ); |
203 this._activate( selectedIndex ); |
200 return; |
204 return; |
201 case $.ui.keyCode.ENTER: |
205 case $.ui.keyCode.ENTER: |
202 |
206 |
203 // Toggle (cancel delayed activation, allow collapsing) |
207 // Toggle (cancel delayed activation, allow collapsing) |
204 event.preventDefault(); |
208 event.preventDefault(); |
205 clearTimeout( this.activating ); |
209 clearTimeout( this.activating ); |
206 |
210 |
207 // Determine if we should collapse or activate |
211 // Determine if we should collapse or activate |
208 this._activate( selectedIndex === this.options.active ? false : selectedIndex ); |
212 this._activate( selectedIndex === this.options.active ? false : selectedIndex ); |
209 return; |
213 return; |
210 default: |
214 default: |
211 return; |
215 return; |
212 } |
216 } |
213 |
217 |
214 // Focus the appropriate tab, based on which key was pressed |
218 // Focus the appropriate tab, based on which key was pressed |
215 event.preventDefault(); |
219 event.preventDefault(); |
216 clearTimeout( this.activating ); |
220 clearTimeout( this.activating ); |
328 // Was collapsed or no tabs |
332 // Was collapsed or no tabs |
329 if ( options.active === false || !this.anchors.length ) { |
333 if ( options.active === false || !this.anchors.length ) { |
330 options.active = false; |
334 options.active = false; |
331 this.active = $(); |
335 this.active = $(); |
332 |
336 |
333 // was active, but active tab is gone |
337 // was active, but active tab is gone |
334 } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) { |
338 } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) { |
335 |
339 |
336 // all remaining tabs are disabled |
340 // all remaining tabs are disabled |
337 if ( this.tabs.length === options.disabled.length ) { |
341 if ( this.tabs.length === options.disabled.length ) { |
338 options.active = false; |
342 options.active = false; |
339 this.active = $(); |
343 this.active = $(); |
340 |
344 |
341 // activate previous tab |
345 // activate previous tab |
342 } else { |
346 } else { |
343 this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) ); |
347 this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) ); |
344 } |
348 } |
345 |
349 |
346 // was active, active tab still exists |
350 // was active, active tab still exists |
347 } else { |
351 } else { |
348 |
352 |
349 // make sure active index is correct |
353 // make sure active index is correct |
350 options.active = this.tabs.index( this.active ); |
354 options.active = this.tabs.index( this.active ); |
351 } |
355 } |
445 if ( that._isLocal( anchor ) ) { |
449 if ( that._isLocal( anchor ) ) { |
446 selector = anchor.hash; |
450 selector = anchor.hash; |
447 panelId = selector.substring( 1 ); |
451 panelId = selector.substring( 1 ); |
448 panel = that.element.find( that._sanitizeSelector( selector ) ); |
452 panel = that.element.find( that._sanitizeSelector( selector ) ); |
449 |
453 |
450 // remote tab |
454 // remote tab |
451 } else { |
455 } else { |
452 |
456 |
453 // If the tab doesn't already have aria-controls, |
457 // If the tab doesn't already have aria-controls, |
454 // generate an id by using a throw-away element |
458 // generate an id by using a throw-away element |
455 panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id; |
459 panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id; |
603 |
607 |
604 event.preventDefault(); |
608 event.preventDefault(); |
605 |
609 |
606 if ( tab.hasClass( "ui-state-disabled" ) || |
610 if ( tab.hasClass( "ui-state-disabled" ) || |
607 |
611 |
608 // tab is already loading |
612 // tab is already loading |
609 tab.hasClass( "ui-tabs-loading" ) || |
613 tab.hasClass( "ui-tabs-loading" ) || |
610 |
614 |
611 // can't switch durning an animation |
615 // can't switch durning an animation |
612 this.running || |
616 this.running || |
613 |
617 |
614 // click on active header, but not collapsible |
618 // click on active header, but not collapsible |
615 ( clickedIsActive && !options.collapsible ) || |
619 ( clickedIsActive && !options.collapsible ) || |
616 |
620 |
617 // allow canceling activation |
621 // allow canceling activation |
618 ( this._trigger( "beforeActivate", event, eventData ) === false ) ) { |
622 ( this._trigger( "beforeActivate", event, eventData ) === false ) ) { |
619 return; |
623 return; |
620 } |
624 } |
621 |
625 |
622 options.active = collapsing ? false : this.tabs.index( tab ); |
626 options.active = collapsing ? false : this.tabs.index( tab ); |
623 |
627 |
862 |
866 |
863 this.xhr |
867 this.xhr |
864 .done( function( response, status, jqXHR ) { |
868 .done( function( response, status, jqXHR ) { |
865 |
869 |
866 // support: jQuery <1.8 |
870 // support: jQuery <1.8 |
867 // http://bugs.jquery.com/ticket/11778 |
871 // https://bugs.jquery.com/ticket/11778 |
868 setTimeout( function() { |
872 setTimeout( function() { |
869 panel.html( response ); |
873 panel.html( response ); |
870 that._trigger( "load", event, eventData ); |
874 that._trigger( "load", event, eventData ); |
871 |
875 |
872 complete( jqXHR, status ); |
876 complete( jqXHR, status ); |
873 }, 1 ); |
877 }, 1 ); |
874 } ) |
878 } ) |
875 .fail( function( jqXHR, status ) { |
879 .fail( function( jqXHR, status ) { |
876 |
880 |
877 // support: jQuery <1.8 |
881 // support: jQuery <1.8 |
878 // http://bugs.jquery.com/ticket/11778 |
882 // https://bugs.jquery.com/ticket/11778 |
879 setTimeout( function() { |
883 setTimeout( function() { |
880 complete( jqXHR, status ); |
884 complete( jqXHR, status ); |
881 }, 1 ); |
885 }, 1 ); |
882 } ); |
886 } ); |
883 } |
887 } |