Projet

Général

Profil

Révision 503b3f7b

Ajouté par Assos Assos il y a environ 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/jquery_update/replace/ui/ui/jquery.ui.tabs.js
1
/*
2
 * jQuery UI Tabs 1.8.11
1
/*!
2
 * jQuery UI Tabs 1.10.2
3
 * http://jqueryui.com
3 4
 *
4
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
 * Dual licensed under the MIT or GPL Version 2 licenses.
5
 * Copyright 2013 jQuery Foundation and other contributors
6
 * Released under the MIT license.
6 7
 * http://jquery.org/license
7 8
 *
8
 * http://docs.jquery.com/UI/Tabs
9
 * http://api.jqueryui.com/tabs/
9 10
 *
10 11
 * Depends:
11 12
 *	jquery.ui.core.js
......
14 15
(function( $, undefined ) {
15 16

  
16 17
var tabId = 0,
17
	listId = 0;
18
	rhash = /#.*$/;
18 19

  
19 20
function getNextTabId() {
20 21
	return ++tabId;
21 22
}
22 23

  
23
function getNextListId() {
24
	return ++listId;
24
function isLocal( anchor ) {
25
	return anchor.hash.length > 1 &&
26
		decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
27
			decodeURIComponent( location.href.replace( rhash, "" ) );
25 28
}
26 29

  
27 30
$.widget( "ui.tabs", {
31
	version: "1.10.2",
32
	delay: 300,
28 33
	options: {
29
		add: null,
30
		ajaxOptions: null,
31
		cache: false,
32
		cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
34
		active: null,
33 35
		collapsible: false,
34
		disable: null,
35
		disabled: [],
36
		enable: null,
37 36
		event: "click",
38
		fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
39
		idPrefix: "ui-tabs-",
40
		load: null,
41
		panelTemplate: "<div></div>",
42
		remove: null,
43
		select: null,
37
		heightStyle: "content",
38
		hide: null,
44 39
		show: null,
45
		spinner: "<em>Loading&#8230;</em>",
46
		tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
40

  
41
		// callbacks
42
		activate: null,
43
		beforeActivate: null,
44
		beforeLoad: null,
45
		load: null
47 46
	},
48 47

  
49 48
	_create: function() {
50
		this._tabify( true );
51
	},
49
		var that = this,
50
			options = this.options;
52 51

  
53
	_setOption: function( key, value ) {
54
		if ( key == "selected" ) {
55
			if (this.options.collapsible && value == this.options.selected ) {
56
				return;
57
			}
58
			this.select( value );
59
		} else {
60
			this.options[ key ] = value;
61
			this._tabify();
62
		}
63
	},
52
		this.running = false;
64 53

  
65
	_tabId: function( a ) {
66
		return a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) ||
67
			this.options.idPrefix + getNextTabId();
68
	},
54
		this.element
55
			.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
56
			.toggleClass( "ui-tabs-collapsible", options.collapsible )
57
			// Prevent users from focusing disabled tabs via click
58
			.delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
59
				if ( $( this ).is( ".ui-state-disabled" ) ) {
60
					event.preventDefault();
61
				}
62
			})
63
			// support: IE <9
64
			// Preventing the default action in mousedown doesn't prevent IE
65
			// from focusing the element, so if the anchor gets focused, blur.
66
			// We don't have to worry about focusing the previously focused
67
			// element since clicking on a non-focusable element should focus
68
			// the body anyway.
69
			.delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
70
				if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
71
					this.blur();
72
				}
73
			});
69 74

  
70
	_sanitizeSelector: function( hash ) {
71
		// we need this because an id may contain a ":"
72
		return hash.replace( /:/g, "\\:" );
73
	},
75
		this._processTabs();
76
		options.active = this._initialActive();
74 77

  
75
	_cookie: function() {
76
		var cookie = this.cookie ||
77
			( this.cookie = this.options.cookie.name || "ui-tabs-" + getNextListId() );
78
		return $.cookie.apply( null, [ cookie ].concat( $.makeArray( arguments ) ) );
79
	},
78
		// Take disabling tabs via class attribute from HTML
79
		// into account and update option properly.
80
		if ( $.isArray( options.disabled ) ) {
81
			options.disabled = $.unique( options.disabled.concat(
82
				$.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
83
					return that.tabs.index( li );
84
				})
85
			) ).sort();
86
		}
80 87

  
81
	_ui: function( tab, panel ) {
82
		return {
83
			tab: tab,
84
			panel: panel,
85
			index: this.anchors.index( tab )
86
		};
87
	},
88
		// check for length avoids error when initializing empty list
89
		if ( this.options.active !== false && this.anchors.length ) {
90
			this.active = this._findActive( options.active );
91
		} else {
92
			this.active = $();
93
		}
88 94

  
89
	_cleanup: function() {
90
		// restore all former loading tabs labels
91
		this.lis.filter( ".ui-state-processing" )
92
			.removeClass( "ui-state-processing" )
93
			.find( "span:data(label.tabs)" )
94
				.each(function() {
95
					var el = $( this );
96
					el.html( el.data( "label.tabs" ) ).removeData( "label.tabs" );
97
				});
95
		this._refresh();
96

  
97
		if ( this.active.length ) {
98
			this.load( options.active );
99
		}
98 100
	},
99 101

  
100
	_tabify: function( init ) {
101
		var self = this,
102
			o = this.options,
103
			fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
102
	_initialActive: function() {
103
		var active = this.options.active,
104
			collapsible = this.options.collapsible,
105
			locationHash = location.hash.substring( 1 );
106

  
107
		if ( active === null ) {
108
			// check the fragment identifier in the URL
109
			if ( locationHash ) {
110
				this.tabs.each(function( i, tab ) {
111
					if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
112
						active = i;
113
						return false;
114
					}
115
				});
116
			}
104 117

  
105
		this.list = this.element.find( "ol,ul" ).eq( 0 );
106
		this.lis = $( " > li:has(a[href])", this.list );
107
		this.anchors = this.lis.map(function() {
108
			return $( "a", this )[ 0 ];
109
		});
110
		this.panels = $( [] );
111

  
112
		this.anchors.each(function( i, a ) {
113
			var href = $( a ).attr( "href" );
114
			// For dynamically created HTML that contains a hash as href IE < 8 expands
115
			// such href to the full page url with hash and then misinterprets tab as ajax.
116
			// Same consideration applies for an added tab with a fragment identifier
117
			// since a[href=#fragment-identifier] does unexpectedly not match.
118
			// Thus normalize href attribute...
119
			var hrefBase = href.split( "#" )[ 0 ],
120
				baseEl;
121
			if ( hrefBase && ( hrefBase === location.toString().split( "#" )[ 0 ] ||
122
					( baseEl = $( "base" )[ 0 ]) && hrefBase === baseEl.href ) ) {
123
				href = a.hash;
124
				a.href = href;
118
			// check for a tab marked active via a class
119
			if ( active === null ) {
120
				active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
125 121
			}
126 122

  
127
			// inline tab
128
			if ( fragmentId.test( href ) ) {
129
				self.panels = self.panels.add( self.element.find( self._sanitizeSelector( href ) ) );
130
			// remote tab
131
			// prevent loading the page itself if href is just "#"
132
			} else if ( href && href !== "#" ) {
133
				// required for restore on destroy
134
				$.data( a, "href.tabs", href );
135

  
136
				// TODO until #3808 is fixed strip fragment identifier from url
137
				// (IE fails to load from such url)
138
				$.data( a, "load.tabs", href.replace( /#.*$/, "" ) );
139

  
140
				var id = self._tabId( a );
141
				a.href = "#" + id;
142
				var $panel = self.element.find( "#" + id );
143
				if ( !$panel.length ) {
144
					$panel = $( o.panelTemplate )
145
						.attr( "id", id )
146
						.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
147
						.insertAfter( self.panels[ i - 1 ] || self.list );
148
					$panel.data( "destroy.tabs", true );
149
				}
150
				self.panels = self.panels.add( $panel );
151
			// invalid tab href
152
			} else {
153
				o.disabled.push( i );
123
			// no active tab, set to false
124
			if ( active === null || active === -1 ) {
125
				active = this.tabs.length ? 0 : false;
154 126
			}
155
		});
127
		}
156 128

  
157
		// initialization from scratch
158
		if ( init ) {
159
			// attach necessary classes for styling
160
			this.element.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" );
161
			this.list.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
162
			this.lis.addClass( "ui-state-default ui-corner-top" );
163
			this.panels.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" );
164

  
165
			// Selected tab
166
			// use "selected" option or try to retrieve:
167
			// 1. from fragment identifier in url
168
			// 2. from cookie
169
			// 3. from selected class attribute on <li>
170
			if ( o.selected === undefined ) {
171
				if ( location.hash ) {
172
					this.anchors.each(function( i, a ) {
173
						if ( a.hash == location.hash ) {
174
							o.selected = i;
175
							return false;
176
						}
177
					});
178
				}
179
				if ( typeof o.selected !== "number" && o.cookie ) {
180
					o.selected = parseInt( self._cookie(), 10 );
181
				}
182
				if ( typeof o.selected !== "number" && this.lis.filter( ".ui-tabs-selected" ).length ) {
183
					o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
184
				}
185
				o.selected = o.selected || ( this.lis.length ? 0 : -1 );
186
			} else if ( o.selected === null ) { // usage of null is deprecated, TODO remove in next release
187
				o.selected = -1;
129
		// handle numbers: negative, out of range
130
		if ( active !== false ) {
131
			active = this.tabs.index( this.tabs.eq( active ) );
132
			if ( active === -1 ) {
133
				active = collapsible ? false : 0;
188 134
			}
135
		}
189 136

  
190
			// sanity check - default to first tab...
191
			o.selected = ( ( o.selected >= 0 && this.anchors[ o.selected ] ) || o.selected < 0 )
192
				? o.selected
193
				: 0;
194

  
195
			// Take disabling tabs via class attribute from HTML
196
			// into account and update option properly.
197
			// A selected tab cannot become disabled.
198
			o.disabled = $.unique( o.disabled.concat(
199
				$.map( this.lis.filter( ".ui-state-disabled" ), function( n, i ) {
200
					return self.lis.index( n );
201
				})
202
			) ).sort();
137
		// don't allow collapsible: false and active: false
138
		if ( !collapsible && active === false && this.anchors.length ) {
139
			active = 0;
140
		}
203 141

  
204
			if ( $.inArray( o.selected, o.disabled ) != -1 ) {
205
				o.disabled.splice( $.inArray( o.selected, o.disabled ), 1 );
206
			}
142
		return active;
143
	},
207 144

  
208
			// highlight selected tab
209
			this.panels.addClass( "ui-tabs-hide" );
210
			this.lis.removeClass( "ui-tabs-selected ui-state-active" );
211
			// check for length avoids error when initializing empty list
212
			if ( o.selected >= 0 && this.anchors.length ) {
213
				self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) ).removeClass( "ui-tabs-hide" );
214
				this.lis.eq( o.selected ).addClass( "ui-tabs-selected ui-state-active" );
215

  
216
				// seems to be expected behavior that the show callback is fired
217
				self.element.queue( "tabs", function() {
218
					self._trigger( "show", null,
219
						self._ui( self.anchors[ o.selected ], self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) )[ 0 ] ) );
220
				});
145
	_getCreateEventData: function() {
146
		return {
147
			tab: this.active,
148
			panel: !this.active.length ? $() : this._getPanelForTab( this.active )
149
		};
150
	},
221 151

  
222
				this.load( o.selected );
223
			}
152
	_tabKeydown: function( event ) {
153
		/*jshint maxcomplexity:15*/
154
		var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
155
			selectedIndex = this.tabs.index( focusedTab ),
156
			goingForward = true;
224 157

  
225
			// clean up to avoid memory leaks in certain versions of IE 6
226
			// TODO: namespace this event
227
			$( window ).bind( "unload", function() {
228
				self.lis.add( self.anchors ).unbind( ".tabs" );
229
				self.lis = self.anchors = self.panels = null;
230
			});
231
		// update selected after add/remove
232
		} else {
233
			o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
158
		if ( this._handlePageNav( event ) ) {
159
			return;
234 160
		}
235 161

  
236
		// update collapsible
237
		// TODO: use .toggleClass()
238
		this.element[ o.collapsible ? "addClass" : "removeClass" ]( "ui-tabs-collapsible" );
239

  
240
		// set or update cookie after init and add/remove respectively
241
		if ( o.cookie ) {
242
			this._cookie( o.selected, o.cookie );
162
		switch ( event.keyCode ) {
163
			case $.ui.keyCode.RIGHT:
164
			case $.ui.keyCode.DOWN:
165
				selectedIndex++;
166
				break;
167
			case $.ui.keyCode.UP:
168
			case $.ui.keyCode.LEFT:
169
				goingForward = false;
170
				selectedIndex--;
171
				break;
172
			case $.ui.keyCode.END:
173
				selectedIndex = this.anchors.length - 1;
174
				break;
175
			case $.ui.keyCode.HOME:
176
				selectedIndex = 0;
177
				break;
178
			case $.ui.keyCode.SPACE:
179
				// Activate only, no collapsing
180
				event.preventDefault();
181
				clearTimeout( this.activating );
182
				this._activate( selectedIndex );
183
				return;
184
			case $.ui.keyCode.ENTER:
185
				// Toggle (cancel delayed activation, allow collapsing)
186
				event.preventDefault();
187
				clearTimeout( this.activating );
188
				// Determine if we should collapse or activate
189
				this._activate( selectedIndex === this.options.active ? false : selectedIndex );
190
				return;
191
			default:
192
				return;
243 193
		}
244 194

  
245
		// disable tabs
246
		for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
247
			$( li )[ $.inArray( i, o.disabled ) != -1 &&
248
				// TODO: use .toggleClass()
249
				!$( li ).hasClass( "ui-tabs-selected" ) ? "addClass" : "removeClass" ]( "ui-state-disabled" );
195
		// Focus the appropriate tab, based on which key was pressed
196
		event.preventDefault();
197
		clearTimeout( this.activating );
198
		selectedIndex = this._focusNextTab( selectedIndex, goingForward );
199

  
200
		// Navigating with control key will prevent automatic activation
201
		if ( !event.ctrlKey ) {
202
			// Update aria-selected immediately so that AT think the tab is already selected.
203
			// Otherwise AT may confuse the user by stating that they need to activate the tab,
204
			// but the tab will already be activated by the time the announcement finishes.
205
			focusedTab.attr( "aria-selected", "false" );
206
			this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
207

  
208
			this.activating = this._delay(function() {
209
				this.option( "active", selectedIndex );
210
			}, this.delay );
250 211
		}
212
	},
251 213

  
252
		// reset cache if switching from cached to not cached
253
		if ( o.cache === false ) {
254
			this.anchors.removeData( "cache.tabs" );
214
	_panelKeydown: function( event ) {
215
		if ( this._handlePageNav( event ) ) {
216
			return;
255 217
		}
256 218

  
257
		// remove all handlers before, tabify may run on existing tabs after add or option change
258
		this.lis.add( this.anchors ).unbind( ".tabs" );
219
		// Ctrl+up moves focus to the current tab
220
		if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
221
			event.preventDefault();
222
			this.active.focus();
223
		}
224
	},
259 225

  
260
		if ( o.event !== "mouseover" ) {
261
			var addState = function( state, el ) {
262
				if ( el.is( ":not(.ui-state-disabled)" ) ) {
263
					el.addClass( "ui-state-" + state );
264
				}
265
			};
266
			var removeState = function( state, el ) {
267
				el.removeClass( "ui-state-" + state );
268
			};
269
			this.lis.bind( "mouseover.tabs" , function() {
270
				addState( "hover", $( this ) );
271
			});
272
			this.lis.bind( "mouseout.tabs", function() {
273
				removeState( "hover", $( this ) );
274
			});
275
			this.anchors.bind( "focus.tabs", function() {
276
				addState( "focus", $( this ).closest( "li" ) );
277
			});
278
			this.anchors.bind( "blur.tabs", function() {
279
				removeState( "focus", $( this ).closest( "li" ) );
280
			});
226
	// Alt+page up/down moves focus to the previous/next tab (and activates)
227
	_handlePageNav: function( event ) {
228
		if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
229
			this._activate( this._focusNextTab( this.options.active - 1, false ) );
230
			return true;
281 231
		}
232
		if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
233
			this._activate( this._focusNextTab( this.options.active + 1, true ) );
234
			return true;
235
		}
236
	},
282 237

  
283
		// set up animations
284
		var hideFx, showFx;
285
		if ( o.fx ) {
286
			if ( $.isArray( o.fx ) ) {
287
				hideFx = o.fx[ 0 ];
288
				showFx = o.fx[ 1 ];
289
			} else {
290
				hideFx = showFx = o.fx;
238
	_findNextTab: function( index, goingForward ) {
239
		var lastTabIndex = this.tabs.length - 1;
240

  
241
		function constrain() {
242
			if ( index > lastTabIndex ) {
243
				index = 0;
291 244
			}
245
			if ( index < 0 ) {
246
				index = lastTabIndex;
247
			}
248
			return index;
292 249
		}
293 250

  
294
		// Reset certain styles left over from animation
295
		// and prevent IE's ClearType bug...
296
		function resetStyle( $el, fx ) {
297
			$el.css( "display", "" );
298
			if ( !$.support.opacity && fx.opacity ) {
299
				$el[ 0 ].style.removeAttribute( "filter" );
300
			}
251
		while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
252
			index = goingForward ? index + 1 : index - 1;
301 253
		}
302 254

  
303
		// Show a tab...
304
		var showTab = showFx
305
			? function( clicked, $show ) {
306
				$( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
307
				$show.hide().removeClass( "ui-tabs-hide" ) // avoid flicker that way
308
					.animate( showFx, showFx.duration || "normal", function() {
309
						resetStyle( $show, showFx );
310
						self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
311
					});
312
			}
313
			: function( clicked, $show ) {
314
				$( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
315
				$show.removeClass( "ui-tabs-hide" );
316
				self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
317
			};
255
		return index;
256
	},
318 257

  
319
		// Hide a tab, $show is optional...
320
		var hideTab = hideFx
321
			? function( clicked, $hide ) {
322
				$hide.animate( hideFx, hideFx.duration || "normal", function() {
323
					self.lis.removeClass( "ui-tabs-selected ui-state-active" );
324
					$hide.addClass( "ui-tabs-hide" );
325
					resetStyle( $hide, hideFx );
326
					self.element.dequeue( "tabs" );
327
				});
328
			}
329
			: function( clicked, $hide, $show ) {
330
				self.lis.removeClass( "ui-tabs-selected ui-state-active" );
331
				$hide.addClass( "ui-tabs-hide" );
332
				self.element.dequeue( "tabs" );
333
			};
258
	_focusNextTab: function( index, goingForward ) {
259
		index = this._findNextTab( index, goingForward );
260
		this.tabs.eq( index ).focus();
261
		return index;
262
	},
334 263

  
335
		// attach tab event handler, unbind to avoid duplicates from former tabifying...
336
		this.anchors.bind( o.event + ".tabs", function() {
337
			var el = this,
338
				$li = $(el).closest( "li" ),
339
				$hide = self.panels.filter( ":not(.ui-tabs-hide)" ),
340
				$show = self.element.find( self._sanitizeSelector( el.hash ) );
341

  
342
			// If tab is already selected and not collapsible or tab disabled or
343
			// or is already loading or click callback returns false stop here.
344
			// Check if click handler returns false last so that it is not executed
345
			// for a disabled or loading tab!
346
			if ( ( $li.hasClass( "ui-tabs-selected" ) && !o.collapsible) ||
347
				$li.hasClass( "ui-state-disabled" ) ||
348
				$li.hasClass( "ui-state-processing" ) ||
349
				self.panels.filter( ":animated" ).length ||
350
				self._trigger( "select", null, self._ui( this, $show[ 0 ] ) ) === false ) {
351
				this.blur();
352
				return false;
353
			}
264
	_setOption: function( key, value ) {
265
		if ( key === "active" ) {
266
			// _activate() will handle invalid values and update this.options
267
			this._activate( value );
268
			return;
269
		}
354 270

  
355
			o.selected = self.anchors.index( this );
271
		if ( key === "disabled" ) {
272
			// don't use the widget factory's disabled handling
273
			this._setupDisabled( value );
274
			return;
275
		}
356 276

  
357
			self.abort();
277
		this._super( key, value);
358 278

  
359
			// if tab may be closed
360
			if ( o.collapsible ) {
361
				if ( $li.hasClass( "ui-tabs-selected" ) ) {
362
					o.selected = -1;
279
		if ( key === "collapsible" ) {
280
			this.element.toggleClass( "ui-tabs-collapsible", value );
281
			// Setting collapsible: false while collapsed; open first panel
282
			if ( !value && this.options.active === false ) {
283
				this._activate( 0 );
284
			}
285
		}
363 286

  
364
					if ( o.cookie ) {
365
						self._cookie( o.selected, o.cookie );
366
					}
287
		if ( key === "event" ) {
288
			this._setupEvents( value );
289
		}
367 290

  
368
					self.element.queue( "tabs", function() {
369
						hideTab( el, $hide );
370
					}).dequeue( "tabs" );
291
		if ( key === "heightStyle" ) {
292
			this._setupHeightStyle( value );
293
		}
294
	},
371 295

  
372
					this.blur();
373
					return false;
374
				} else if ( !$hide.length ) {
375
					if ( o.cookie ) {
376
						self._cookie( o.selected, o.cookie );
377
					}
296
	_tabId: function( tab ) {
297
		return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
298
	},
378 299

  
379
					self.element.queue( "tabs", function() {
380
						showTab( el, $show );
381
					});
300
	_sanitizeSelector: function( hash ) {
301
		return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
302
	},
382 303

  
383
					// TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
384
					self.load( self.anchors.index( this ) );
304
	refresh: function() {
305
		var options = this.options,
306
			lis = this.tablist.children( ":has(a[href])" );
385 307

  
386
					this.blur();
387
					return false;
388
				}
389
			}
308
		// get disabled tabs from class attribute from HTML
309
		// this will get converted to a boolean if needed in _refresh()
310
		options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
311
			return lis.index( tab );
312
		});
390 313

  
391
			if ( o.cookie ) {
392
				self._cookie( o.selected, o.cookie );
314
		this._processTabs();
315

  
316
		// was collapsed or no tabs
317
		if ( options.active === false || !this.anchors.length ) {
318
			options.active = false;
319
			this.active = $();
320
		// was active, but active tab is gone
321
		} else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
322
			// all remaining tabs are disabled
323
			if ( this.tabs.length === options.disabled.length ) {
324
				options.active = false;
325
				this.active = $();
326
			// activate previous tab
327
			} else {
328
				this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
393 329
			}
330
		// was active, active tab still exists
331
		} else {
332
			// make sure active index is correct
333
			options.active = this.tabs.index( this.active );
334
		}
394 335

  
395
			// show new tab
396
			if ( $show.length ) {
397
				if ( $hide.length ) {
398
					self.element.queue( "tabs", function() {
399
						hideTab( el, $hide );
400
					});
401
				}
402
				self.element.queue( "tabs", function() {
403
					showTab( el, $show );
404
				});
336
		this._refresh();
337
	},
405 338

  
406
				self.load( self.anchors.index( this ) );
407
			} else {
408
				throw "jQuery UI Tabs: Mismatching fragment identifier.";
409
			}
339
	_refresh: function() {
340
		this._setupDisabled( this.options.disabled );
341
		this._setupEvents( this.options.event );
342
		this._setupHeightStyle( this.options.heightStyle );
410 343

  
411
			// Prevent IE from keeping other link focussed when using the back button
412
			// and remove dotted border from clicked link. This is controlled via CSS
413
			// in modern browsers; blur() removes focus from address bar in Firefox
414
			// which can become a usability and annoying problem with tabs('rotate').
415
			if ( $.browser.msie ) {
416
				this.blur();
417
			}
344
		this.tabs.not( this.active ).attr({
345
			"aria-selected": "false",
346
			tabIndex: -1
418 347
		});
348
		this.panels.not( this._getPanelForTab( this.active ) )
349
			.hide()
350
			.attr({
351
				"aria-expanded": "false",
352
				"aria-hidden": "true"
353
			});
419 354

  
420
		// disable click in any case
421
		this.anchors.bind( "click.tabs", function(){
422
			return false;
423
		});
355
		// Make sure one tab is in the tab order
356
		if ( !this.active.length ) {
357
			this.tabs.eq( 0 ).attr( "tabIndex", 0 );
358
		} else {
359
			this.active
360
				.addClass( "ui-tabs-active ui-state-active" )
361
				.attr({
362
					"aria-selected": "true",
363
					tabIndex: 0
364
				});
365
			this._getPanelForTab( this.active )
366
				.show()
367
				.attr({
368
					"aria-expanded": "true",
369
					"aria-hidden": "false"
370
				});
371
		}
424 372
	},
425 373

  
426
    _getIndex: function( index ) {
427
		// meta-function to give users option to provide a href string instead of a numerical index.
428
		// also sanitizes numerical indexes to valid values.
429
		if ( typeof index == "string" ) {
430
			index = this.anchors.index( this.anchors.filter( "[href$=" + index + "]" ) );
431
		}
374
	_processTabs: function() {
375
		var that = this;
432 376

  
433
		return index;
434
	},
377
		this.tablist = this._getList()
378
			.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
379
			.attr( "role", "tablist" );
435 380

  
436
	destroy: function() {
437
		var o = this.options;
381
		this.tabs = this.tablist.find( "> li:has(a[href])" )
382
			.addClass( "ui-state-default ui-corner-top" )
383
			.attr({
384
				role: "tab",
385
				tabIndex: -1
386
			});
438 387

  
439
		this.abort();
388
		this.anchors = this.tabs.map(function() {
389
				return $( "a", this )[ 0 ];
390
			})
391
			.addClass( "ui-tabs-anchor" )
392
			.attr({
393
				role: "presentation",
394
				tabIndex: -1
395
			});
440 396

  
441
		this.element
442
			.unbind( ".tabs" )
443
			.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" )
444
			.removeData( "tabs" );
397
		this.panels = $();
445 398

  
446
		this.list.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
399
		this.anchors.each(function( i, anchor ) {
400
			var selector, panel, panelId,
401
				anchorId = $( anchor ).uniqueId().attr( "id" ),
402
				tab = $( anchor ).closest( "li" ),
403
				originalAriaControls = tab.attr( "aria-controls" );
447 404

  
448
		this.anchors.each(function() {
449
			var href = $.data( this, "href.tabs" );
450
			if ( href ) {
451
				this.href = href;
405
			// inline tab
406
			if ( isLocal( anchor ) ) {
407
				selector = anchor.hash;
408
				panel = that.element.find( that._sanitizeSelector( selector ) );
409
			// remote tab
410
			} else {
411
				panelId = that._tabId( tab );
412
				selector = "#" + panelId;
413
				panel = that.element.find( selector );
414
				if ( !panel.length ) {
415
					panel = that._createPanel( panelId );
416
					panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
417
				}
418
				panel.attr( "aria-live", "polite" );
419
			}
420

  
421
			if ( panel.length) {
422
				that.panels = that.panels.add( panel );
452 423
			}
453
			var $this = $( this ).unbind( ".tabs" );
454
			$.each( [ "href", "load", "cache" ], function( i, prefix ) {
455
				$this.removeData( prefix + ".tabs" );
424
			if ( originalAriaControls ) {
425
				tab.data( "ui-tabs-aria-controls", originalAriaControls );
426
			}
427
			tab.attr({
428
				"aria-controls": selector.substring( 1 ),
429
				"aria-labelledby": anchorId
456 430
			});
431
			panel.attr( "aria-labelledby", anchorId );
457 432
		});
458 433

  
459
		this.lis.unbind( ".tabs" ).add( this.panels ).each(function() {
460
			if ( $.data( this, "destroy.tabs" ) ) {
461
				$( this ).remove();
462
			} else {
463
				$( this ).removeClass([
464
					"ui-state-default",
465
					"ui-corner-top",
466
					"ui-tabs-selected",
467
					"ui-state-active",
468
					"ui-state-hover",
469
					"ui-state-focus",
470
					"ui-state-disabled",
471
					"ui-tabs-panel",
472
					"ui-widget-content",
473
					"ui-corner-bottom",
474
					"ui-tabs-hide"
475
				].join( " " ) );
434
		this.panels
435
			.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
436
			.attr( "role", "tabpanel" );
437
	},
438

  
439
	// allow overriding how to find the list for rare usage scenarios (#7715)
440
	_getList: function() {
441
		return this.element.find( "ol,ul" ).eq( 0 );
442
	},
443

  
444
	_createPanel: function( id ) {
445
		return $( "<div>" )
446
			.attr( "id", id )
447
			.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
448
			.data( "ui-tabs-destroy", true );
449
	},
450

  
451
	_setupDisabled: function( disabled ) {
452
		if ( $.isArray( disabled ) ) {
453
			if ( !disabled.length ) {
454
				disabled = false;
455
			} else if ( disabled.length === this.anchors.length ) {
456
				disabled = true;
476 457
			}
477
		});
458
		}
478 459

  
479
		if ( o.cookie ) {
480
			this._cookie( null, o.cookie );
460
		// disable tabs
461
		for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
462
			if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
463
				$( li )
464
					.addClass( "ui-state-disabled" )
465
					.attr( "aria-disabled", "true" );
466
			} else {
467
				$( li )
468
					.removeClass( "ui-state-disabled" )
469
					.removeAttr( "aria-disabled" );
470
			}
481 471
		}
482 472

  
483
		return this;
473
		this.options.disabled = disabled;
484 474
	},
485 475

  
486
	add: function( url, label, index ) {
487
		if ( index === undefined ) {
488
			index = this.anchors.length;
476
	_setupEvents: function( event ) {
477
		var events = {
478
			click: function( event ) {
479
				event.preventDefault();
480
			}
481
		};
482
		if ( event ) {
483
			$.each( event.split(" "), function( index, eventName ) {
484
				events[ eventName ] = "_eventHandler";
485
			});
489 486
		}
490 487

  
491
		var self = this,
492
			o = this.options,
493
			$li = $( o.tabTemplate.replace( /#\{href\}/g, url ).replace( /#\{label\}/g, label ) ),
494
			id = !url.indexOf( "#" ) ? url.replace( "#", "" ) : this._tabId( $( "a", $li )[ 0 ] );
488
		this._off( this.anchors.add( this.tabs ).add( this.panels ) );
489
		this._on( this.anchors, events );
490
		this._on( this.tabs, { keydown: "_tabKeydown" } );
491
		this._on( this.panels, { keydown: "_panelKeydown" } );
495 492

  
496
		$li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
493
		this._focusable( this.tabs );
494
		this._hoverable( this.tabs );
495
	},
497 496

  
498
		// try to find an existing element before creating a new one
499
		var $panel = self.element.find( "#" + id );
500
		if ( !$panel.length ) {
501
			$panel = $( o.panelTemplate )
502
				.attr( "id", id )
503
				.data( "destroy.tabs", true );
504
		}
505
		$panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" );
497
	_setupHeightStyle: function( heightStyle ) {
498
		var maxHeight,
499
			parent = this.element.parent();
506 500

  
507
		if ( index >= this.lis.length ) {
508
			$li.appendTo( this.list );
509
			$panel.appendTo( this.list[ 0 ].parentNode );
510
		} else {
511
			$li.insertBefore( this.lis[ index ] );
512
			$panel.insertBefore( this.panels[ index ] );
513
		}
501
		if ( heightStyle === "fill" ) {
502
			maxHeight = parent.height();
503
			maxHeight -= this.element.outerHeight() - this.element.height();
514 504

  
515
		o.disabled = $.map( o.disabled, function( n, i ) {
516
			return n >= index ? ++n : n;
517
		});
505
			this.element.siblings( ":visible" ).each(function() {
506
				var elem = $( this ),
507
					position = elem.css( "position" );
518 508

  
519
		this._tabify();
509
				if ( position === "absolute" || position === "fixed" ) {
510
					return;
511
				}
512
				maxHeight -= elem.outerHeight( true );
513
			});
520 514

  
521
		if ( this.anchors.length == 1 ) {
522
			o.selected = 0;
523
			$li.addClass( "ui-tabs-selected ui-state-active" );
524
			$panel.removeClass( "ui-tabs-hide" );
525
			this.element.queue( "tabs", function() {
526
				self._trigger( "show", null, self._ui( self.anchors[ 0 ], self.panels[ 0 ] ) );
515
			this.element.children().not( this.panels ).each(function() {
516
				maxHeight -= $( this ).outerHeight( true );
527 517
			});
528 518

  
529
			this.load( 0 );
519
			this.panels.each(function() {
520
				$( this ).height( Math.max( 0, maxHeight -
521
					$( this ).innerHeight() + $( this ).height() ) );
522
			})
523
			.css( "overflow", "auto" );
524
		} else if ( heightStyle === "auto" ) {
525
			maxHeight = 0;
526
			this.panels.each(function() {
527
				maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
528
			}).height( maxHeight );
530 529
		}
531

  
532
		this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
533
		return this;
534 530
	},
535 531

  
536
	remove: function( index ) {
537
		index = this._getIndex( index );
538
		var o = this.options,
539
			$li = this.lis.eq( index ).remove(),
540
			$panel = this.panels.eq( index ).remove();
541

  
542
		// If selected tab was removed focus tab to the right or
543
		// in case the last tab was removed the tab to the left.
544
		if ( $li.hasClass( "ui-tabs-selected" ) && this.anchors.length > 1) {
545
			this.select( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
546
		}
547

  
548
		o.disabled = $.map(
549
			$.grep( o.disabled, function(n, i) {
550
				return n != index;
551
			}),
552
			function( n, i ) {
553
				return n >= index ? --n : n;
554
			});
532
	_eventHandler: function( event ) {
533
		var options = this.options,
534
			active = this.active,
535
			anchor = $( event.currentTarget ),
536
			tab = anchor.closest( "li" ),
537
			clickedIsActive = tab[ 0 ] === active[ 0 ],
538
			collapsing = clickedIsActive && options.collapsible,
539
			toShow = collapsing ? $() : this._getPanelForTab( tab ),
540
			toHide = !active.length ? $() : this._getPanelForTab( active ),
541
			eventData = {
542
				oldTab: active,
543
				oldPanel: toHide,
544
				newTab: collapsing ? $() : tab,
545
				newPanel: toShow
546
			};
555 547

  
556
		this._tabify();
548
		event.preventDefault();
549

  
550
		if ( tab.hasClass( "ui-state-disabled" ) ||
551
				// tab is already loading
552
				tab.hasClass( "ui-tabs-loading" ) ||
553
				// can't switch durning an animation
554
				this.running ||
555
				// click on active header, but not collapsible
556
				( clickedIsActive && !options.collapsible ) ||
557
				// allow canceling activation
558
				( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
559
			return;
560
		}
557 561

  
558
		this._trigger( "remove", null, this._ui( $li.find( "a" )[ 0 ], $panel[ 0 ] ) );
559
		return this;
560
	},
562
		options.active = collapsing ? false : this.tabs.index( tab );
561 563

  
562
	enable: function( index ) {
563
		index = this._getIndex( index );
564
		var o = this.options;
565
		if ( $.inArray( index, o.disabled ) == -1 ) {
566
			return;
564
		this.active = clickedIsActive ? $() : tab;
565
		if ( this.xhr ) {
566
			this.xhr.abort();
567 567
		}
568 568

  
569
		this.lis.eq( index ).removeClass( "ui-state-disabled" );
570
		o.disabled = $.grep( o.disabled, function( n, i ) {
571
			return n != index;
572
		});
569
		if ( !toHide.length && !toShow.length ) {
570
			$.error( "jQuery UI Tabs: Mismatching fragment identifier." );
571
		}
573 572

  
574
		this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
575
		return this;
573
		if ( toShow.length ) {
574
			this.load( this.tabs.index( tab ), event );
575
		}
576
		this._toggle( event, eventData );
576 577
	},
577 578

  
578
	disable: function( index ) {
579
		index = this._getIndex( index );
580
		var self = this, o = this.options;
581
		// cannot disable already selected tab
582
		if ( index != o.selected ) {
583
			this.lis.eq( index ).addClass( "ui-state-disabled" );
579
	// handles show/hide for selecting tabs
580
	_toggle: function( event, eventData ) {
581
		var that = this,
582
			toShow = eventData.newPanel,
583
			toHide = eventData.oldPanel;
584 584

  
585
			o.disabled.push( index );
586
			o.disabled.sort();
585
		this.running = true;
587 586

  
588
			this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
587
		function complete() {
588
			that.running = false;
589
			that._trigger( "activate", event, eventData );
589 590
		}
590 591

  
591
		return this;
592
	},
592
		function show() {
593
			eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
593 594

  
594
	select: function( index ) {
595
		index = this._getIndex( index );
596
		if ( index == -1 ) {
597
			if ( this.options.collapsible && this.options.selected != -1 ) {
598
				index = this.options.selected;
595
			if ( toShow.length && that.options.show ) {
596
				that._show( toShow, that.options.show, complete );
599 597
			} else {
600
				return this;
598
				toShow.show();
599
				complete();
601 600
			}
602 601
		}
603
		this.anchors.eq( index ).trigger( this.options.event + ".tabs" );
604
		return this;
605
	},
606

  
607
	load: function( index ) {
608
		index = this._getIndex( index );
609
		var self = this,
610
			o = this.options,
611
			a = this.anchors.eq( index )[ 0 ],
612
			url = $.data( a, "load.tabs" );
613 602

  
614
		this.abort();
615

  
616
		// not remote or from cache
617
		if ( !url || this.element.queue( "tabs" ).length !== 0 && $.data( a, "cache.tabs" ) ) {
618
			this.element.dequeue( "tabs" );
619
			return;
603
		// start out by hiding, then showing, then completing
604
		if ( toHide.length && this.options.hide ) {
605
			this._hide( toHide, this.options.hide, function() {
606
				eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
607
				show();
608
			});
609
		} else {
610
			eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
611
			toHide.hide();
612
			show();
620 613
		}
621 614

  
622
		// load remote from here on
623
		this.lis.eq( index ).addClass( "ui-state-processing" );
624

  
625
		if ( o.spinner ) {
626
			var span = $( "span", a );
627
			span.data( "label.tabs", span.html() ).html( o.spinner );
615
		toHide.attr({
616
			"aria-expanded": "false",
617
			"aria-hidden": "true"
618
		});
619
		eventData.oldTab.attr( "aria-selected", "false" );
620
		// If we're switching tabs, remove the old tab from the tab order.
621
		// If we're opening from collapsed state, remove the previous tab from the tab order.
622
		// If we're collapsing, then keep the collapsing tab in the tab order.
623
		if ( toShow.length && toHide.length ) {
624
			eventData.oldTab.attr( "tabIndex", -1 );
625
		} else if ( toShow.length ) {
626
			this.tabs.filter(function() {
627
				return $( this ).attr( "tabIndex" ) === 0;
628
			})
629
			.attr( "tabIndex", -1 );
628 630
		}
629 631

  
630
		this.xhr = $.ajax( $.extend( {}, o.ajaxOptions, {
631
			url: url,
632
			success: function( r, s ) {
633
				self.element.find( self._sanitizeSelector( a.hash ) ).html( r );
632
		toShow.attr({
633
			"aria-expanded": "true",
634
			"aria-hidden": "false"
635
		});
636
		eventData.newTab.attr({
637
			"aria-selected": "true",
638
			tabIndex: 0
639
		});
640
	},
634 641

  
635
				// take care of tab labels
636
				self._cleanup();
642
	_activate: function( index ) {
643
		var anchor,
644
			active = this._findActive( index );
637 645

  
638
				if ( o.cache ) {
639
					$.data( a, "cache.tabs", true );
640
				}
646
		// trying to activate the already active panel
647
		if ( active[ 0 ] === this.active[ 0 ] ) {
648
			return;
649
		}
641 650

  
642
				self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
643
				try {
644
					o.ajaxOptions.success( r, s );
645
				}
646
				catch ( e ) {}
647
			},
648
			error: function( xhr, s, e ) {
649
				// take care of tab labels
650
				self._cleanup();
651

  
652
				self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
653
				try {
654
					// Passing index avoid a race condition when this method is
655
					// called after the user has selected another tab.
656
					// Pass the anchor that initiated this request allows
657
					// loadError to manipulate the tab content panel via $(a.hash)
658
					o.ajaxOptions.error( xhr, s, index, a );
659
				}
660
				catch ( e ) {}
661
			}
662
		} ) );
651
		// trying to collapse, simulate a click on the current active header
652
		if ( !active.length ) {
653
			active = this.active;
654
		}
663 655

  
664
		// last, so that load event is fired before show...
665
		self.element.dequeue( "tabs" );
656
		anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
657
		this._eventHandler({
658
			target: anchor,
659
			currentTarget: anchor,
660
			preventDefault: $.noop
661
		});
662
	},
666 663

  
667
		return this;
664
	_findActive: function( index ) {
665
		return index === false ? $() : this.tabs.eq( index );
668 666
	},
669 667

  
670
	abort: function() {
671
		// stop possibly running animations
672
		this.element.queue( [] );
673
		this.panels.stop( false, true );
668
	_getIndex: function( index ) {
669
		// meta-function to give users option to provide a href string instead of a numerical index.
670
		if ( typeof index === "string" ) {
671
			index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
672
		}
674 673

  
675
		// "tabs" queue must not contain more than two elements,
676
		// which are the callbacks for the latest clicked tab...
677
		this.element.queue( "tabs", this.element.queue( "tabs" ).splice( -2, 2 ) );
674
		return index;
675
	},
678 676

  
679
		// terminate pending requests from other tabs
677
	_destroy: function() {
680 678
		if ( this.xhr ) {
681 679
			this.xhr.abort();
682
			delete this.xhr;
683 680
		}
684 681

  
685
		// take care of tab labels
686
		this._cleanup();
687
		return this;
688
	},
682
		this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
689 683

  
690
	url: function( index, url ) {
691
		this.anchors.eq( index ).removeData( "cache.tabs" ).data( "load.tabs", url );
692
		return this;
693
	},
684
		this.tablist
685
			.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
686
			.removeAttr( "role" );
694 687

  
695
	length: function() {
696
		return this.anchors.length;
697
	}
698
});
699

  
700
$.extend( $.ui.tabs, {
701
	version: "1.8.11"
702
});
688
		this.anchors
689
			.removeClass( "ui-tabs-anchor" )
690
			.removeAttr( "role" )
691
			.removeAttr( "tabIndex" )
692
			.removeUniqueId();
703 693

  
704
/*
705
 * Tabs Extensions
706
 */
694
		this.tabs.add( this.panels ).each(function() {
695
			if ( $.data( this, "ui-tabs-destroy" ) ) {
696
				$( this ).remove();
697
			} else {
698
				$( this )
699
					.removeClass( "ui-state-default ui-state-active ui-state-disabled " +
700
						"ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
701
					.removeAttr( "tabIndex" )
702
					.removeAttr( "aria-live" )
703
					.removeAttr( "aria-busy" )
704
					.removeAttr( "aria-selected" )
705
					.removeAttr( "aria-labelledby" )
706
					.removeAttr( "aria-hidden" )
707
					.removeAttr( "aria-expanded" )
708
					.removeAttr( "role" );
709
			}
710
		});
707 711

  
708
/*
709
 * Rotate
710
 */
711
$.extend( $.ui.tabs.prototype, {
712
	rotation: null,
713
	rotate: function( ms, continuing ) {
714
		var self = this,
715
			o = this.options;
716

  
717
		var rotate = self._rotate || ( self._rotate = function( e ) {
718
			clearTimeout( self.rotation );
719
			self.rotation = setTimeout(function() {
720
				var t = o.selected;
721
				self.select( ++t < self.anchors.length ? t : 0 );
722
			}, ms );
723
			
724
			if ( e ) {
725
				e.stopPropagation();
712
		this.tabs.each(function() {
713
			var li = $( this ),
714
				prev = li.data( "ui-tabs-aria-controls" );
715
			if ( prev ) {
716
				li
717
					.attr( "aria-controls", prev )
718
					.removeData( "ui-tabs-aria-controls" );
719
			} else {
720
				li.removeAttr( "aria-controls" );
726 721
			}
727 722
		});
728 723

  
729
		var stop = self._unrotate || ( self._unrotate = !continuing
730
			? function(e) {
731
				if (e.clientX) { // in case of a true click
732
					self.rotate(null);
733
				}
724
		this.panels.show();
725

  
726
		if ( this.options.heightStyle !== "content" ) {
727
			this.panels.css( "height", "" );
728
		}
729
	},
730

  
731
	enable: function( index ) {
732
		var disabled = this.options.disabled;
733
		if ( disabled === false ) {
734
			return;
735
		}
736

  
737
		if ( index === undefined ) {
738
			disabled = false;
739
		} else {
740
			index = this._getIndex( index );
741
			if ( $.isArray( disabled ) ) {
742
				disabled = $.map( disabled, function( num ) {
743
					return num !== index ? num : null;
744
				});
745
			} else {
746
				disabled = $.map( this.tabs, function( li, num ) {
747
					return num !== index ? num : null;
748
				});
734 749
			}
735
			: function( e ) {
736
				t = o.selected;
737
				rotate();
738
			});
750
		}
751
		this._setupDisabled( disabled );
752
	},
739 753

  
740
		// start rotation
741
		if ( ms ) {
742
			this.element.bind( "tabsshow", rotate );
743
			this.anchors.bind( o.event + ".tabs", stop );
744
			rotate();
745
		// stop rotation
754
	disable: function( index ) {
755
		var disabled = this.options.disabled;
756
		if ( disabled === true ) {
757
			return;
758
		}
759

  
760
		if ( index === undefined ) {
761
			disabled = true;
746 762
		} else {
747
			clearTimeout( self.rotation );
748
			this.element.unbind( "tabsshow", rotate );
749
			this.anchors.unbind( o.event + ".tabs", stop );
750
			delete this._rotate;
751
			delete this._unrotate;
763
			index = this._getIndex( index );
764
			if ( $.inArray( index, disabled ) !== -1 ) {
765
				return;
766
			}
767
			if ( $.isArray( disabled ) ) {
768
				disabled = $.merge( [ index ], disabled ).sort();
769
			} else {
770
				disabled = [ index ];
771
			}
752 772
		}
773
		this._setupDisabled( disabled );
774
	},
775

  
776
	load: function( index, event ) {
777
		index = this._getIndex( index );
778
		var that = this,
779
			tab = this.tabs.eq( index ),
780
			anchor = tab.find( ".ui-tabs-anchor" ),
781
			panel = this._getPanelForTab( tab ),
782
			eventData = {
783
				tab: tab,
784
				panel: panel
785
			};
786

  
787
		// not remote
788
		if ( isLocal( anchor[ 0 ] ) ) {
789
			return;
790
		}
791

  
792
		this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
793

  
794
		// support: jQuery <1.8
795
		// jQuery <1.8 returns false if the request is canceled in beforeSend,
796
		// but as of 1.8, $.ajax() always returns a jqXHR object.
797
		if ( this.xhr && this.xhr.statusText !== "canceled" ) {
798
			tab.addClass( "ui-tabs-loading" );
799
			panel.attr( "aria-busy", "true" );
800

  
801
			this.xhr
802
				.success(function( response ) {
803
					// support: jQuery <1.8
804
					// http://bugs.jquery.com/ticket/11778
805
					setTimeout(function() {
806
						panel.html( response );
807
						that._trigger( "load", event, eventData );
808
					}, 1 );
809
				})
810
				.complete(function( jqXHR, status ) {
811
					// support: jQuery <1.8
812
					// http://bugs.jquery.com/ticket/11778
813
					setTimeout(function() {
814
						if ( status === "abort" ) {
815
							that.panels.stop( false, true );
816
						}
817

  
818
						tab.removeClass( "ui-tabs-loading" );
819
						panel.removeAttr( "aria-busy" );
820

  
821
						if ( jqXHR === that.xhr ) {
822
							delete that.xhr;
823
						}
824
					}, 1 );
825
				});
826
		}
827
	},
828

  
829
	_ajaxSettings: function( anchor, event, eventData ) {
830
		var that = this;
831
		return {
832
			url: anchor.attr( "href" ),
833
			beforeSend: function( jqXHR, settings ) {
834
				return that._trigger( "beforeLoad", event,
835
					$.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
836
			}
837
		};
838
	},
753 839

  
754
		return this;
840
	_getPanelForTab: function( tab ) {
841
		var id = $( tab ).attr( "aria-controls" );
842
		return this.element.find( this._sanitizeSelector( "#" + id ) );
755 843
	}
756 844
});
757 845

  

Formats disponibles : Unified diff