jqueryui-requirejs-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/LICENSE +22 -0
  2. data/README.md +3 -0
  3. data/Rakefile +27 -0
  4. data/app/assets/javascripts/jqueryui/accordion.js +575 -0
  5. data/app/assets/javascripts/jqueryui/autocomplete.js +613 -0
  6. data/app/assets/javascripts/jqueryui/button.js +422 -0
  7. data/app/assets/javascripts/jqueryui/core.js +323 -0
  8. data/app/assets/javascripts/jqueryui/datepicker-af.js +26 -0
  9. data/app/assets/javascripts/jqueryui/datepicker-ar-DZ.js +26 -0
  10. data/app/assets/javascripts/jqueryui/datepicker-ar.js +26 -0
  11. data/app/assets/javascripts/jqueryui/datepicker-az.js +26 -0
  12. data/app/assets/javascripts/jqueryui/datepicker-be.js +26 -0
  13. data/app/assets/javascripts/jqueryui/datepicker-bg.js +27 -0
  14. data/app/assets/javascripts/jqueryui/datepicker-bs.js +26 -0
  15. data/app/assets/javascripts/jqueryui/datepicker-ca.js +26 -0
  16. data/app/assets/javascripts/jqueryui/datepicker-cs.js +26 -0
  17. data/app/assets/javascripts/jqueryui/datepicker-cy-GB.js +26 -0
  18. data/app/assets/javascripts/jqueryui/datepicker-da.js +26 -0
  19. data/app/assets/javascripts/jqueryui/datepicker-de.js +26 -0
  20. data/app/assets/javascripts/jqueryui/datepicker-el.js +26 -0
  21. data/app/assets/javascripts/jqueryui/datepicker-en-AU.js +26 -0
  22. data/app/assets/javascripts/jqueryui/datepicker-en-GB.js +26 -0
  23. data/app/assets/javascripts/jqueryui/datepicker-en-NZ.js +26 -0
  24. data/app/assets/javascripts/jqueryui/datepicker-eo.js +26 -0
  25. data/app/assets/javascripts/jqueryui/datepicker-es.js +26 -0
  26. data/app/assets/javascripts/jqueryui/datepicker-et.js +26 -0
  27. data/app/assets/javascripts/jqueryui/datepicker-eu.js +26 -0
  28. data/app/assets/javascripts/jqueryui/datepicker-fa.js +62 -0
  29. data/app/assets/javascripts/jqueryui/datepicker-fi.js +26 -0
  30. data/app/assets/javascripts/jqueryui/datepicker-fo.js +26 -0
  31. data/app/assets/javascripts/jqueryui/datepicker-fr-CA.js +26 -0
  32. data/app/assets/javascripts/jqueryui/datepicker-fr-CH.js +26 -0
  33. data/app/assets/javascripts/jqueryui/datepicker-fr.js +28 -0
  34. data/app/assets/javascripts/jqueryui/datepicker-gl.js +26 -0
  35. data/app/assets/javascripts/jqueryui/datepicker-he.js +26 -0
  36. data/app/assets/javascripts/jqueryui/datepicker-hi.js +26 -0
  37. data/app/assets/javascripts/jqueryui/datepicker-hr.js +26 -0
  38. data/app/assets/javascripts/jqueryui/datepicker-hu.js +26 -0
  39. data/app/assets/javascripts/jqueryui/datepicker-hy.js +26 -0
  40. data/app/assets/javascripts/jqueryui/datepicker-id.js +26 -0
  41. data/app/assets/javascripts/jqueryui/datepicker-is.js +26 -0
  42. data/app/assets/javascripts/jqueryui/datepicker-it.js +26 -0
  43. data/app/assets/javascripts/jqueryui/datepicker-ja.js +26 -0
  44. data/app/assets/javascripts/jqueryui/datepicker-ka.js +24 -0
  45. data/app/assets/javascripts/jqueryui/datepicker-kk.js +26 -0
  46. data/app/assets/javascripts/jqueryui/datepicker-km.js +26 -0
  47. data/app/assets/javascripts/jqueryui/datepicker-ko.js +26 -0
  48. data/app/assets/javascripts/jqueryui/datepicker-ky.js +27 -0
  49. data/app/assets/javascripts/jqueryui/datepicker-lb.js +26 -0
  50. data/app/assets/javascripts/jqueryui/datepicker-lt.js +26 -0
  51. data/app/assets/javascripts/jqueryui/datepicker-lv.js +26 -0
  52. data/app/assets/javascripts/jqueryui/datepicker-mk.js +26 -0
  53. data/app/assets/javascripts/jqueryui/datepicker-ml.js +26 -0
  54. data/app/assets/javascripts/jqueryui/datepicker-ms.js +26 -0
  55. data/app/assets/javascripts/jqueryui/datepicker-nb.js +25 -0
  56. data/app/assets/javascripts/jqueryui/datepicker-nl-BE.js +26 -0
  57. data/app/assets/javascripts/jqueryui/datepicker-nl.js +26 -0
  58. data/app/assets/javascripts/jqueryui/datepicker-nn.js +25 -0
  59. data/app/assets/javascripts/jqueryui/datepicker-no.js +26 -0
  60. data/app/assets/javascripts/jqueryui/datepicker-pl.js +26 -0
  61. data/app/assets/javascripts/jqueryui/datepicker-pt-BR.js +26 -0
  62. data/app/assets/javascripts/jqueryui/datepicker-pt.js +25 -0
  63. data/app/assets/javascripts/jqueryui/datepicker-rm.js +24 -0
  64. data/app/assets/javascripts/jqueryui/datepicker-ro.js +29 -0
  65. data/app/assets/javascripts/jqueryui/datepicker-ru.js +26 -0
  66. data/app/assets/javascripts/jqueryui/datepicker-sk.js +26 -0
  67. data/app/assets/javascripts/jqueryui/datepicker-sl.js +27 -0
  68. data/app/assets/javascripts/jqueryui/datepicker-sq.js +26 -0
  69. data/app/assets/javascripts/jqueryui/datepicker-sr-SR.js +26 -0
  70. data/app/assets/javascripts/jqueryui/datepicker-sr.js +26 -0
  71. data/app/assets/javascripts/jqueryui/datepicker-sv.js +26 -0
  72. data/app/assets/javascripts/jqueryui/datepicker-ta.js +26 -0
  73. data/app/assets/javascripts/jqueryui/datepicker-th.js +26 -0
  74. data/app/assets/javascripts/jqueryui/datepicker-tj.js +26 -0
  75. data/app/assets/javascripts/jqueryui/datepicker-tr.js +26 -0
  76. data/app/assets/javascripts/jqueryui/datepicker-uk.js +27 -0
  77. data/app/assets/javascripts/jqueryui/datepicker-vi.js +26 -0
  78. data/app/assets/javascripts/jqueryui/datepicker-zh-CN.js +26 -0
  79. data/app/assets/javascripts/jqueryui/datepicker-zh-HK.js +26 -0
  80. data/app/assets/javascripts/jqueryui/datepicker-zh-TW.js +26 -0
  81. data/app/assets/javascripts/jqueryui/datepicker.js +2053 -0
  82. data/app/assets/javascripts/jqueryui/dialog.js +811 -0
  83. data/app/assets/javascripts/jqueryui/draggable.js +936 -0
  84. data/app/assets/javascripts/jqueryui/droppable.js +375 -0
  85. data/app/assets/javascripts/jqueryui/effect-blind.js +85 -0
  86. data/app/assets/javascripts/jqueryui/effect-bounce.js +116 -0
  87. data/app/assets/javascripts/jqueryui/effect-clip.js +70 -0
  88. data/app/assets/javascripts/jqueryui/effect-drop.js +68 -0
  89. data/app/assets/javascripts/jqueryui/effect-explode.js +100 -0
  90. data/app/assets/javascripts/jqueryui/effect-fade.js +33 -0
  91. data/app/assets/javascripts/jqueryui/effect-fold.js +79 -0
  92. data/app/assets/javascripts/jqueryui/effect-highlight.js +53 -0
  93. data/app/assets/javascripts/jqueryui/effect-pulsate.js +66 -0
  94. data/app/assets/javascripts/jqueryui/effect-scale.js +321 -0
  95. data/app/assets/javascripts/jqueryui/effect-shake.js +77 -0
  96. data/app/assets/javascripts/jqueryui/effect-slide.js +67 -0
  97. data/app/assets/javascripts/jqueryui/effect-transfer.js +50 -0
  98. data/app/assets/javascripts/jqueryui/effect.js +1292 -0
  99. data/app/assets/javascripts/jqueryui/menu.js +624 -0
  100. data/app/assets/javascripts/jqueryui/mouse.js +172 -0
  101. data/app/assets/javascripts/jqueryui/position.js +500 -0
  102. data/app/assets/javascripts/jqueryui/progressbar.js +148 -0
  103. data/app/assets/javascripts/jqueryui/resizable.js +971 -0
  104. data/app/assets/javascripts/jqueryui/selectable.js +280 -0
  105. data/app/assets/javascripts/jqueryui/slider.js +675 -0
  106. data/app/assets/javascripts/jqueryui/sortable.js +1285 -0
  107. data/app/assets/javascripts/jqueryui/spinner.js +496 -0
  108. data/app/assets/javascripts/jqueryui/tabs.js +849 -0
  109. data/app/assets/javascripts/jqueryui/tooltip.js +405 -0
  110. data/app/assets/javascripts/jqueryui/widget.js +524 -0
  111. data/lib/jqueryui-requirejs-rails.rb +4 -0
  112. data/lib/jqueryui-requirejs-rails/engine.rb +4 -0
  113. data/lib/jqueryui-requirejs-rails/version.rb +3 -0
  114. metadata +196 -0
@@ -0,0 +1,849 @@
1
+ define(['jquery','./core','./widget'], function (jQuery) {
2
+ /*!
3
+ * jQuery UI Tabs 1.10.2
4
+ * http://jqueryui.com
5
+ *
6
+ * Copyright 2013 jQuery Foundation and other contributors
7
+ * Released under the MIT license.
8
+ * http://jquery.org/license
9
+ *
10
+ * http://api.jqueryui.com/tabs/
11
+ *
12
+ * Depends:
13
+ * jquery.ui.core.js
14
+ * jquery.ui.widget.js
15
+ */
16
+ (function( $, undefined ) {
17
+
18
+ var tabId = 0,
19
+ rhash = /#.*$/;
20
+
21
+ function getNextTabId() {
22
+ return ++tabId;
23
+ }
24
+
25
+ function isLocal( anchor ) {
26
+ return anchor.hash.length > 1 &&
27
+ decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
28
+ decodeURIComponent( location.href.replace( rhash, "" ) );
29
+ }
30
+
31
+ $.widget( "ui.tabs", {
32
+ version: "1.10.2",
33
+ delay: 300,
34
+ options: {
35
+ active: null,
36
+ collapsible: false,
37
+ event: "click",
38
+ heightStyle: "content",
39
+ hide: null,
40
+ show: null,
41
+
42
+ // callbacks
43
+ activate: null,
44
+ beforeActivate: null,
45
+ beforeLoad: null,
46
+ load: null
47
+ },
48
+
49
+ _create: function() {
50
+ var that = this,
51
+ options = this.options;
52
+
53
+ this.running = false;
54
+
55
+ this.element
56
+ .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
57
+ .toggleClass( "ui-tabs-collapsible", options.collapsible )
58
+ // Prevent users from focusing disabled tabs via click
59
+ .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
60
+ if ( $( this ).is( ".ui-state-disabled" ) ) {
61
+ event.preventDefault();
62
+ }
63
+ })
64
+ // support: IE <9
65
+ // Preventing the default action in mousedown doesn't prevent IE
66
+ // from focusing the element, so if the anchor gets focused, blur.
67
+ // We don't have to worry about focusing the previously focused
68
+ // element since clicking on a non-focusable element should focus
69
+ // the body anyway.
70
+ .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
71
+ if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
72
+ this.blur();
73
+ }
74
+ });
75
+
76
+ this._processTabs();
77
+ options.active = this._initialActive();
78
+
79
+ // Take disabling tabs via class attribute from HTML
80
+ // into account and update option properly.
81
+ if ( $.isArray( options.disabled ) ) {
82
+ options.disabled = $.unique( options.disabled.concat(
83
+ $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
84
+ return that.tabs.index( li );
85
+ })
86
+ ) ).sort();
87
+ }
88
+
89
+ // check for length avoids error when initializing empty list
90
+ if ( this.options.active !== false && this.anchors.length ) {
91
+ this.active = this._findActive( options.active );
92
+ } else {
93
+ this.active = $();
94
+ }
95
+
96
+ this._refresh();
97
+
98
+ if ( this.active.length ) {
99
+ this.load( options.active );
100
+ }
101
+ },
102
+
103
+ _initialActive: function() {
104
+ var active = this.options.active,
105
+ collapsible = this.options.collapsible,
106
+ locationHash = location.hash.substring( 1 );
107
+
108
+ if ( active === null ) {
109
+ // check the fragment identifier in the URL
110
+ if ( locationHash ) {
111
+ this.tabs.each(function( i, tab ) {
112
+ if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
113
+ active = i;
114
+ return false;
115
+ }
116
+ });
117
+ }
118
+
119
+ // check for a tab marked active via a class
120
+ if ( active === null ) {
121
+ active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
122
+ }
123
+
124
+ // no active tab, set to false
125
+ if ( active === null || active === -1 ) {
126
+ active = this.tabs.length ? 0 : false;
127
+ }
128
+ }
129
+
130
+ // handle numbers: negative, out of range
131
+ if ( active !== false ) {
132
+ active = this.tabs.index( this.tabs.eq( active ) );
133
+ if ( active === -1 ) {
134
+ active = collapsible ? false : 0;
135
+ }
136
+ }
137
+
138
+ // don't allow collapsible: false and active: false
139
+ if ( !collapsible && active === false && this.anchors.length ) {
140
+ active = 0;
141
+ }
142
+
143
+ return active;
144
+ },
145
+
146
+ _getCreateEventData: function() {
147
+ return {
148
+ tab: this.active,
149
+ panel: !this.active.length ? $() : this._getPanelForTab( this.active )
150
+ };
151
+ },
152
+
153
+ _tabKeydown: function( event ) {
154
+ /*jshint maxcomplexity:15*/
155
+ var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
156
+ selectedIndex = this.tabs.index( focusedTab ),
157
+ goingForward = true;
158
+
159
+ if ( this._handlePageNav( event ) ) {
160
+ return;
161
+ }
162
+
163
+ switch ( event.keyCode ) {
164
+ case $.ui.keyCode.RIGHT:
165
+ case $.ui.keyCode.DOWN:
166
+ selectedIndex++;
167
+ break;
168
+ case $.ui.keyCode.UP:
169
+ case $.ui.keyCode.LEFT:
170
+ goingForward = false;
171
+ selectedIndex--;
172
+ break;
173
+ case $.ui.keyCode.END:
174
+ selectedIndex = this.anchors.length - 1;
175
+ break;
176
+ case $.ui.keyCode.HOME:
177
+ selectedIndex = 0;
178
+ break;
179
+ case $.ui.keyCode.SPACE:
180
+ // Activate only, no collapsing
181
+ event.preventDefault();
182
+ clearTimeout( this.activating );
183
+ this._activate( selectedIndex );
184
+ return;
185
+ case $.ui.keyCode.ENTER:
186
+ // Toggle (cancel delayed activation, allow collapsing)
187
+ event.preventDefault();
188
+ clearTimeout( this.activating );
189
+ // Determine if we should collapse or activate
190
+ this._activate( selectedIndex === this.options.active ? false : selectedIndex );
191
+ return;
192
+ default:
193
+ return;
194
+ }
195
+
196
+ // Focus the appropriate tab, based on which key was pressed
197
+ event.preventDefault();
198
+ clearTimeout( this.activating );
199
+ selectedIndex = this._focusNextTab( selectedIndex, goingForward );
200
+
201
+ // Navigating with control key will prevent automatic activation
202
+ if ( !event.ctrlKey ) {
203
+ // Update aria-selected immediately so that AT think the tab is already selected.
204
+ // Otherwise AT may confuse the user by stating that they need to activate the tab,
205
+ // but the tab will already be activated by the time the announcement finishes.
206
+ focusedTab.attr( "aria-selected", "false" );
207
+ this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
208
+
209
+ this.activating = this._delay(function() {
210
+ this.option( "active", selectedIndex );
211
+ }, this.delay );
212
+ }
213
+ },
214
+
215
+ _panelKeydown: function( event ) {
216
+ if ( this._handlePageNav( event ) ) {
217
+ return;
218
+ }
219
+
220
+ // Ctrl+up moves focus to the current tab
221
+ if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
222
+ event.preventDefault();
223
+ this.active.focus();
224
+ }
225
+ },
226
+
227
+ // Alt+page up/down moves focus to the previous/next tab (and activates)
228
+ _handlePageNav: function( event ) {
229
+ if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
230
+ this._activate( this._focusNextTab( this.options.active - 1, false ) );
231
+ return true;
232
+ }
233
+ if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
234
+ this._activate( this._focusNextTab( this.options.active + 1, true ) );
235
+ return true;
236
+ }
237
+ },
238
+
239
+ _findNextTab: function( index, goingForward ) {
240
+ var lastTabIndex = this.tabs.length - 1;
241
+
242
+ function constrain() {
243
+ if ( index > lastTabIndex ) {
244
+ index = 0;
245
+ }
246
+ if ( index < 0 ) {
247
+ index = lastTabIndex;
248
+ }
249
+ return index;
250
+ }
251
+
252
+ while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
253
+ index = goingForward ? index + 1 : index - 1;
254
+ }
255
+
256
+ return index;
257
+ },
258
+
259
+ _focusNextTab: function( index, goingForward ) {
260
+ index = this._findNextTab( index, goingForward );
261
+ this.tabs.eq( index ).focus();
262
+ return index;
263
+ },
264
+
265
+ _setOption: function( key, value ) {
266
+ if ( key === "active" ) {
267
+ // _activate() will handle invalid values and update this.options
268
+ this._activate( value );
269
+ return;
270
+ }
271
+
272
+ if ( key === "disabled" ) {
273
+ // don't use the widget factory's disabled handling
274
+ this._setupDisabled( value );
275
+ return;
276
+ }
277
+
278
+ this._super( key, value);
279
+
280
+ if ( key === "collapsible" ) {
281
+ this.element.toggleClass( "ui-tabs-collapsible", value );
282
+ // Setting collapsible: false while collapsed; open first panel
283
+ if ( !value && this.options.active === false ) {
284
+ this._activate( 0 );
285
+ }
286
+ }
287
+
288
+ if ( key === "event" ) {
289
+ this._setupEvents( value );
290
+ }
291
+
292
+ if ( key === "heightStyle" ) {
293
+ this._setupHeightStyle( value );
294
+ }
295
+ },
296
+
297
+ _tabId: function( tab ) {
298
+ return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
299
+ },
300
+
301
+ _sanitizeSelector: function( hash ) {
302
+ return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
303
+ },
304
+
305
+ refresh: function() {
306
+ var options = this.options,
307
+ lis = this.tablist.children( ":has(a[href])" );
308
+
309
+ // get disabled tabs from class attribute from HTML
310
+ // this will get converted to a boolean if needed in _refresh()
311
+ options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
312
+ return lis.index( tab );
313
+ });
314
+
315
+ this._processTabs();
316
+
317
+ // was collapsed or no tabs
318
+ if ( options.active === false || !this.anchors.length ) {
319
+ options.active = false;
320
+ this.active = $();
321
+ // was active, but active tab is gone
322
+ } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
323
+ // all remaining tabs are disabled
324
+ if ( this.tabs.length === options.disabled.length ) {
325
+ options.active = false;
326
+ this.active = $();
327
+ // activate previous tab
328
+ } else {
329
+ this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
330
+ }
331
+ // was active, active tab still exists
332
+ } else {
333
+ // make sure active index is correct
334
+ options.active = this.tabs.index( this.active );
335
+ }
336
+
337
+ this._refresh();
338
+ },
339
+
340
+ _refresh: function() {
341
+ this._setupDisabled( this.options.disabled );
342
+ this._setupEvents( this.options.event );
343
+ this._setupHeightStyle( this.options.heightStyle );
344
+
345
+ this.tabs.not( this.active ).attr({
346
+ "aria-selected": "false",
347
+ tabIndex: -1
348
+ });
349
+ this.panels.not( this._getPanelForTab( this.active ) )
350
+ .hide()
351
+ .attr({
352
+ "aria-expanded": "false",
353
+ "aria-hidden": "true"
354
+ });
355
+
356
+ // Make sure one tab is in the tab order
357
+ if ( !this.active.length ) {
358
+ this.tabs.eq( 0 ).attr( "tabIndex", 0 );
359
+ } else {
360
+ this.active
361
+ .addClass( "ui-tabs-active ui-state-active" )
362
+ .attr({
363
+ "aria-selected": "true",
364
+ tabIndex: 0
365
+ });
366
+ this._getPanelForTab( this.active )
367
+ .show()
368
+ .attr({
369
+ "aria-expanded": "true",
370
+ "aria-hidden": "false"
371
+ });
372
+ }
373
+ },
374
+
375
+ _processTabs: function() {
376
+ var that = this;
377
+
378
+ this.tablist = this._getList()
379
+ .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
380
+ .attr( "role", "tablist" );
381
+
382
+ this.tabs = this.tablist.find( "> li:has(a[href])" )
383
+ .addClass( "ui-state-default ui-corner-top" )
384
+ .attr({
385
+ role: "tab",
386
+ tabIndex: -1
387
+ });
388
+
389
+ this.anchors = this.tabs.map(function() {
390
+ return $( "a", this )[ 0 ];
391
+ })
392
+ .addClass( "ui-tabs-anchor" )
393
+ .attr({
394
+ role: "presentation",
395
+ tabIndex: -1
396
+ });
397
+
398
+ this.panels = $();
399
+
400
+ this.anchors.each(function( i, anchor ) {
401
+ var selector, panel, panelId,
402
+ anchorId = $( anchor ).uniqueId().attr( "id" ),
403
+ tab = $( anchor ).closest( "li" ),
404
+ originalAriaControls = tab.attr( "aria-controls" );
405
+
406
+ // inline tab
407
+ if ( isLocal( anchor ) ) {
408
+ selector = anchor.hash;
409
+ panel = that.element.find( that._sanitizeSelector( selector ) );
410
+ // remote tab
411
+ } else {
412
+ panelId = that._tabId( tab );
413
+ selector = "#" + panelId;
414
+ panel = that.element.find( selector );
415
+ if ( !panel.length ) {
416
+ panel = that._createPanel( panelId );
417
+ panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
418
+ }
419
+ panel.attr( "aria-live", "polite" );
420
+ }
421
+
422
+ if ( panel.length) {
423
+ that.panels = that.panels.add( panel );
424
+ }
425
+ if ( originalAriaControls ) {
426
+ tab.data( "ui-tabs-aria-controls", originalAriaControls );
427
+ }
428
+ tab.attr({
429
+ "aria-controls": selector.substring( 1 ),
430
+ "aria-labelledby": anchorId
431
+ });
432
+ panel.attr( "aria-labelledby", anchorId );
433
+ });
434
+
435
+ this.panels
436
+ .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
437
+ .attr( "role", "tabpanel" );
438
+ },
439
+
440
+ // allow overriding how to find the list for rare usage scenarios (#7715)
441
+ _getList: function() {
442
+ return this.element.find( "ol,ul" ).eq( 0 );
443
+ },
444
+
445
+ _createPanel: function( id ) {
446
+ return $( "<div>" )
447
+ .attr( "id", id )
448
+ .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
449
+ .data( "ui-tabs-destroy", true );
450
+ },
451
+
452
+ _setupDisabled: function( disabled ) {
453
+ if ( $.isArray( disabled ) ) {
454
+ if ( !disabled.length ) {
455
+ disabled = false;
456
+ } else if ( disabled.length === this.anchors.length ) {
457
+ disabled = true;
458
+ }
459
+ }
460
+
461
+ // disable tabs
462
+ for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
463
+ if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
464
+ $( li )
465
+ .addClass( "ui-state-disabled" )
466
+ .attr( "aria-disabled", "true" );
467
+ } else {
468
+ $( li )
469
+ .removeClass( "ui-state-disabled" )
470
+ .removeAttr( "aria-disabled" );
471
+ }
472
+ }
473
+
474
+ this.options.disabled = disabled;
475
+ },
476
+
477
+ _setupEvents: function( event ) {
478
+ var events = {
479
+ click: function( event ) {
480
+ event.preventDefault();
481
+ }
482
+ };
483
+ if ( event ) {
484
+ $.each( event.split(" "), function( index, eventName ) {
485
+ events[ eventName ] = "_eventHandler";
486
+ });
487
+ }
488
+
489
+ this._off( this.anchors.add( this.tabs ).add( this.panels ) );
490
+ this._on( this.anchors, events );
491
+ this._on( this.tabs, { keydown: "_tabKeydown" } );
492
+ this._on( this.panels, { keydown: "_panelKeydown" } );
493
+
494
+ this._focusable( this.tabs );
495
+ this._hoverable( this.tabs );
496
+ },
497
+
498
+ _setupHeightStyle: function( heightStyle ) {
499
+ var maxHeight,
500
+ parent = this.element.parent();
501
+
502
+ if ( heightStyle === "fill" ) {
503
+ maxHeight = parent.height();
504
+ maxHeight -= this.element.outerHeight() - this.element.height();
505
+
506
+ this.element.siblings( ":visible" ).each(function() {
507
+ var elem = $( this ),
508
+ position = elem.css( "position" );
509
+
510
+ if ( position === "absolute" || position === "fixed" ) {
511
+ return;
512
+ }
513
+ maxHeight -= elem.outerHeight( true );
514
+ });
515
+
516
+ this.element.children().not( this.panels ).each(function() {
517
+ maxHeight -= $( this ).outerHeight( true );
518
+ });
519
+
520
+ this.panels.each(function() {
521
+ $( this ).height( Math.max( 0, maxHeight -
522
+ $( this ).innerHeight() + $( this ).height() ) );
523
+ })
524
+ .css( "overflow", "auto" );
525
+ } else if ( heightStyle === "auto" ) {
526
+ maxHeight = 0;
527
+ this.panels.each(function() {
528
+ maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
529
+ }).height( maxHeight );
530
+ }
531
+ },
532
+
533
+ _eventHandler: function( event ) {
534
+ var options = this.options,
535
+ active = this.active,
536
+ anchor = $( event.currentTarget ),
537
+ tab = anchor.closest( "li" ),
538
+ clickedIsActive = tab[ 0 ] === active[ 0 ],
539
+ collapsing = clickedIsActive && options.collapsible,
540
+ toShow = collapsing ? $() : this._getPanelForTab( tab ),
541
+ toHide = !active.length ? $() : this._getPanelForTab( active ),
542
+ eventData = {
543
+ oldTab: active,
544
+ oldPanel: toHide,
545
+ newTab: collapsing ? $() : tab,
546
+ newPanel: toShow
547
+ };
548
+
549
+ event.preventDefault();
550
+
551
+ if ( tab.hasClass( "ui-state-disabled" ) ||
552
+ // tab is already loading
553
+ tab.hasClass( "ui-tabs-loading" ) ||
554
+ // can't switch durning an animation
555
+ this.running ||
556
+ // click on active header, but not collapsible
557
+ ( clickedIsActive && !options.collapsible ) ||
558
+ // allow canceling activation
559
+ ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
560
+ return;
561
+ }
562
+
563
+ options.active = collapsing ? false : this.tabs.index( tab );
564
+
565
+ this.active = clickedIsActive ? $() : tab;
566
+ if ( this.xhr ) {
567
+ this.xhr.abort();
568
+ }
569
+
570
+ if ( !toHide.length && !toShow.length ) {
571
+ $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
572
+ }
573
+
574
+ if ( toShow.length ) {
575
+ this.load( this.tabs.index( tab ), event );
576
+ }
577
+ this._toggle( event, eventData );
578
+ },
579
+
580
+ // handles show/hide for selecting tabs
581
+ _toggle: function( event, eventData ) {
582
+ var that = this,
583
+ toShow = eventData.newPanel,
584
+ toHide = eventData.oldPanel;
585
+
586
+ this.running = true;
587
+
588
+ function complete() {
589
+ that.running = false;
590
+ that._trigger( "activate", event, eventData );
591
+ }
592
+
593
+ function show() {
594
+ eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
595
+
596
+ if ( toShow.length && that.options.show ) {
597
+ that._show( toShow, that.options.show, complete );
598
+ } else {
599
+ toShow.show();
600
+ complete();
601
+ }
602
+ }
603
+
604
+ // start out by hiding, then showing, then completing
605
+ if ( toHide.length && this.options.hide ) {
606
+ this._hide( toHide, this.options.hide, function() {
607
+ eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
608
+ show();
609
+ });
610
+ } else {
611
+ eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
612
+ toHide.hide();
613
+ show();
614
+ }
615
+
616
+ toHide.attr({
617
+ "aria-expanded": "false",
618
+ "aria-hidden": "true"
619
+ });
620
+ eventData.oldTab.attr( "aria-selected", "false" );
621
+ // If we're switching tabs, remove the old tab from the tab order.
622
+ // If we're opening from collapsed state, remove the previous tab from the tab order.
623
+ // If we're collapsing, then keep the collapsing tab in the tab order.
624
+ if ( toShow.length && toHide.length ) {
625
+ eventData.oldTab.attr( "tabIndex", -1 );
626
+ } else if ( toShow.length ) {
627
+ this.tabs.filter(function() {
628
+ return $( this ).attr( "tabIndex" ) === 0;
629
+ })
630
+ .attr( "tabIndex", -1 );
631
+ }
632
+
633
+ toShow.attr({
634
+ "aria-expanded": "true",
635
+ "aria-hidden": "false"
636
+ });
637
+ eventData.newTab.attr({
638
+ "aria-selected": "true",
639
+ tabIndex: 0
640
+ });
641
+ },
642
+
643
+ _activate: function( index ) {
644
+ var anchor,
645
+ active = this._findActive( index );
646
+
647
+ // trying to activate the already active panel
648
+ if ( active[ 0 ] === this.active[ 0 ] ) {
649
+ return;
650
+ }
651
+
652
+ // trying to collapse, simulate a click on the current active header
653
+ if ( !active.length ) {
654
+ active = this.active;
655
+ }
656
+
657
+ anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
658
+ this._eventHandler({
659
+ target: anchor,
660
+ currentTarget: anchor,
661
+ preventDefault: $.noop
662
+ });
663
+ },
664
+
665
+ _findActive: function( index ) {
666
+ return index === false ? $() : this.tabs.eq( index );
667
+ },
668
+
669
+ _getIndex: function( index ) {
670
+ // meta-function to give users option to provide a href string instead of a numerical index.
671
+ if ( typeof index === "string" ) {
672
+ index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
673
+ }
674
+
675
+ return index;
676
+ },
677
+
678
+ _destroy: function() {
679
+ if ( this.xhr ) {
680
+ this.xhr.abort();
681
+ }
682
+
683
+ this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
684
+
685
+ this.tablist
686
+ .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
687
+ .removeAttr( "role" );
688
+
689
+ this.anchors
690
+ .removeClass( "ui-tabs-anchor" )
691
+ .removeAttr( "role" )
692
+ .removeAttr( "tabIndex" )
693
+ .removeUniqueId();
694
+
695
+ this.tabs.add( this.panels ).each(function() {
696
+ if ( $.data( this, "ui-tabs-destroy" ) ) {
697
+ $( this ).remove();
698
+ } else {
699
+ $( this )
700
+ .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
701
+ "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
702
+ .removeAttr( "tabIndex" )
703
+ .removeAttr( "aria-live" )
704
+ .removeAttr( "aria-busy" )
705
+ .removeAttr( "aria-selected" )
706
+ .removeAttr( "aria-labelledby" )
707
+ .removeAttr( "aria-hidden" )
708
+ .removeAttr( "aria-expanded" )
709
+ .removeAttr( "role" );
710
+ }
711
+ });
712
+
713
+ this.tabs.each(function() {
714
+ var li = $( this ),
715
+ prev = li.data( "ui-tabs-aria-controls" );
716
+ if ( prev ) {
717
+ li
718
+ .attr( "aria-controls", prev )
719
+ .removeData( "ui-tabs-aria-controls" );
720
+ } else {
721
+ li.removeAttr( "aria-controls" );
722
+ }
723
+ });
724
+
725
+ this.panels.show();
726
+
727
+ if ( this.options.heightStyle !== "content" ) {
728
+ this.panels.css( "height", "" );
729
+ }
730
+ },
731
+
732
+ enable: function( index ) {
733
+ var disabled = this.options.disabled;
734
+ if ( disabled === false ) {
735
+ return;
736
+ }
737
+
738
+ if ( index === undefined ) {
739
+ disabled = false;
740
+ } else {
741
+ index = this._getIndex( index );
742
+ if ( $.isArray( disabled ) ) {
743
+ disabled = $.map( disabled, function( num ) {
744
+ return num !== index ? num : null;
745
+ });
746
+ } else {
747
+ disabled = $.map( this.tabs, function( li, num ) {
748
+ return num !== index ? num : null;
749
+ });
750
+ }
751
+ }
752
+ this._setupDisabled( disabled );
753
+ },
754
+
755
+ disable: function( index ) {
756
+ var disabled = this.options.disabled;
757
+ if ( disabled === true ) {
758
+ return;
759
+ }
760
+
761
+ if ( index === undefined ) {
762
+ disabled = true;
763
+ } else {
764
+ index = this._getIndex( index );
765
+ if ( $.inArray( index, disabled ) !== -1 ) {
766
+ return;
767
+ }
768
+ if ( $.isArray( disabled ) ) {
769
+ disabled = $.merge( [ index ], disabled ).sort();
770
+ } else {
771
+ disabled = [ index ];
772
+ }
773
+ }
774
+ this._setupDisabled( disabled );
775
+ },
776
+
777
+ load: function( index, event ) {
778
+ index = this._getIndex( index );
779
+ var that = this,
780
+ tab = this.tabs.eq( index ),
781
+ anchor = tab.find( ".ui-tabs-anchor" ),
782
+ panel = this._getPanelForTab( tab ),
783
+ eventData = {
784
+ tab: tab,
785
+ panel: panel
786
+ };
787
+
788
+ // not remote
789
+ if ( isLocal( anchor[ 0 ] ) ) {
790
+ return;
791
+ }
792
+
793
+ this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
794
+
795
+ // support: jQuery <1.8
796
+ // jQuery <1.8 returns false if the request is canceled in beforeSend,
797
+ // but as of 1.8, $.ajax() always returns a jqXHR object.
798
+ if ( this.xhr && this.xhr.statusText !== "canceled" ) {
799
+ tab.addClass( "ui-tabs-loading" );
800
+ panel.attr( "aria-busy", "true" );
801
+
802
+ this.xhr
803
+ .success(function( response ) {
804
+ // support: jQuery <1.8
805
+ // http://bugs.jquery.com/ticket/11778
806
+ setTimeout(function() {
807
+ panel.html( response );
808
+ that._trigger( "load", event, eventData );
809
+ }, 1 );
810
+ })
811
+ .complete(function( jqXHR, status ) {
812
+ // support: jQuery <1.8
813
+ // http://bugs.jquery.com/ticket/11778
814
+ setTimeout(function() {
815
+ if ( status === "abort" ) {
816
+ that.panels.stop( false, true );
817
+ }
818
+
819
+ tab.removeClass( "ui-tabs-loading" );
820
+ panel.removeAttr( "aria-busy" );
821
+
822
+ if ( jqXHR === that.xhr ) {
823
+ delete that.xhr;
824
+ }
825
+ }, 1 );
826
+ });
827
+ }
828
+ },
829
+
830
+ _ajaxSettings: function( anchor, event, eventData ) {
831
+ var that = this;
832
+ return {
833
+ url: anchor.attr( "href" ),
834
+ beforeSend: function( jqXHR, settings ) {
835
+ return that._trigger( "beforeLoad", event,
836
+ $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
837
+ }
838
+ };
839
+ },
840
+
841
+ _getPanelForTab: function( tab ) {
842
+ var id = $( tab ).attr( "aria-controls" );
843
+ return this.element.find( this._sanitizeSelector( "#" + id ) );
844
+ }
845
+ });
846
+
847
+ })( jQuery );
848
+
849
+ });