jqueryui-requirejs-rails 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,405 @@
1
+ define(['jquery','./core','./widget','./position'], function (jQuery) {
2
+ /*!
3
+ * jQuery UI Tooltip 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/tooltip/
11
+ *
12
+ * Depends:
13
+ * jquery.ui.core.js
14
+ * jquery.ui.widget.js
15
+ * jquery.ui.position.js
16
+ */
17
+ (function( $ ) {
18
+
19
+ var increments = 0;
20
+
21
+ function addDescribedBy( elem, id ) {
22
+ var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
23
+ describedby.push( id );
24
+ elem
25
+ .data( "ui-tooltip-id", id )
26
+ .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
27
+ }
28
+
29
+ function removeDescribedBy( elem ) {
30
+ var id = elem.data( "ui-tooltip-id" ),
31
+ describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
32
+ index = $.inArray( id, describedby );
33
+ if ( index !== -1 ) {
34
+ describedby.splice( index, 1 );
35
+ }
36
+
37
+ elem.removeData( "ui-tooltip-id" );
38
+ describedby = $.trim( describedby.join( " " ) );
39
+ if ( describedby ) {
40
+ elem.attr( "aria-describedby", describedby );
41
+ } else {
42
+ elem.removeAttr( "aria-describedby" );
43
+ }
44
+ }
45
+
46
+ $.widget( "ui.tooltip", {
47
+ version: "1.10.2",
48
+ options: {
49
+ content: function() {
50
+ // support: IE<9, Opera in jQuery <1.7
51
+ // .text() can't accept undefined, so coerce to a string
52
+ var title = $( this ).attr( "title" ) || "";
53
+ // Escape title, since we're going from an attribute to raw HTML
54
+ return $( "<a>" ).text( title ).html();
55
+ },
56
+ hide: true,
57
+ // Disabled elements have inconsistent behavior across browsers (#8661)
58
+ items: "[title]:not([disabled])",
59
+ position: {
60
+ my: "left top+15",
61
+ at: "left bottom",
62
+ collision: "flipfit flip"
63
+ },
64
+ show: true,
65
+ tooltipClass: null,
66
+ track: false,
67
+
68
+ // callbacks
69
+ close: null,
70
+ open: null
71
+ },
72
+
73
+ _create: function() {
74
+ this._on({
75
+ mouseover: "open",
76
+ focusin: "open"
77
+ });
78
+
79
+ // IDs of generated tooltips, needed for destroy
80
+ this.tooltips = {};
81
+ // IDs of parent tooltips where we removed the title attribute
82
+ this.parents = {};
83
+
84
+ if ( this.options.disabled ) {
85
+ this._disable();
86
+ }
87
+ },
88
+
89
+ _setOption: function( key, value ) {
90
+ var that = this;
91
+
92
+ if ( key === "disabled" ) {
93
+ this[ value ? "_disable" : "_enable" ]();
94
+ this.options[ key ] = value;
95
+ // disable element style changes
96
+ return;
97
+ }
98
+
99
+ this._super( key, value );
100
+
101
+ if ( key === "content" ) {
102
+ $.each( this.tooltips, function( id, element ) {
103
+ that._updateContent( element );
104
+ });
105
+ }
106
+ },
107
+
108
+ _disable: function() {
109
+ var that = this;
110
+
111
+ // close open tooltips
112
+ $.each( this.tooltips, function( id, element ) {
113
+ var event = $.Event( "blur" );
114
+ event.target = event.currentTarget = element[0];
115
+ that.close( event, true );
116
+ });
117
+
118
+ // remove title attributes to prevent native tooltips
119
+ this.element.find( this.options.items ).addBack().each(function() {
120
+ var element = $( this );
121
+ if ( element.is( "[title]" ) ) {
122
+ element
123
+ .data( "ui-tooltip-title", element.attr( "title" ) )
124
+ .attr( "title", "" );
125
+ }
126
+ });
127
+ },
128
+
129
+ _enable: function() {
130
+ // restore title attributes
131
+ this.element.find( this.options.items ).addBack().each(function() {
132
+ var element = $( this );
133
+ if ( element.data( "ui-tooltip-title" ) ) {
134
+ element.attr( "title", element.data( "ui-tooltip-title" ) );
135
+ }
136
+ });
137
+ },
138
+
139
+ open: function( event ) {
140
+ var that = this,
141
+ target = $( event ? event.target : this.element )
142
+ // we need closest here due to mouseover bubbling,
143
+ // but always pointing at the same event target
144
+ .closest( this.options.items );
145
+
146
+ // No element to show a tooltip for or the tooltip is already open
147
+ if ( !target.length || target.data( "ui-tooltip-id" ) ) {
148
+ return;
149
+ }
150
+
151
+ if ( target.attr( "title" ) ) {
152
+ target.data( "ui-tooltip-title", target.attr( "title" ) );
153
+ }
154
+
155
+ target.data( "ui-tooltip-open", true );
156
+
157
+ // kill parent tooltips, custom or native, for hover
158
+ if ( event && event.type === "mouseover" ) {
159
+ target.parents().each(function() {
160
+ var parent = $( this ),
161
+ blurEvent;
162
+ if ( parent.data( "ui-tooltip-open" ) ) {
163
+ blurEvent = $.Event( "blur" );
164
+ blurEvent.target = blurEvent.currentTarget = this;
165
+ that.close( blurEvent, true );
166
+ }
167
+ if ( parent.attr( "title" ) ) {
168
+ parent.uniqueId();
169
+ that.parents[ this.id ] = {
170
+ element: this,
171
+ title: parent.attr( "title" )
172
+ };
173
+ parent.attr( "title", "" );
174
+ }
175
+ });
176
+ }
177
+
178
+ this._updateContent( target, event );
179
+ },
180
+
181
+ _updateContent: function( target, event ) {
182
+ var content,
183
+ contentOption = this.options.content,
184
+ that = this,
185
+ eventType = event ? event.type : null;
186
+
187
+ if ( typeof contentOption === "string" ) {
188
+ return this._open( event, target, contentOption );
189
+ }
190
+
191
+ content = contentOption.call( target[0], function( response ) {
192
+ // ignore async response if tooltip was closed already
193
+ if ( !target.data( "ui-tooltip-open" ) ) {
194
+ return;
195
+ }
196
+ // IE may instantly serve a cached response for ajax requests
197
+ // delay this call to _open so the other call to _open runs first
198
+ that._delay(function() {
199
+ // jQuery creates a special event for focusin when it doesn't
200
+ // exist natively. To improve performance, the native event
201
+ // object is reused and the type is changed. Therefore, we can't
202
+ // rely on the type being correct after the event finished
203
+ // bubbling, so we set it back to the previous value. (#8740)
204
+ if ( event ) {
205
+ event.type = eventType;
206
+ }
207
+ this._open( event, target, response );
208
+ });
209
+ });
210
+ if ( content ) {
211
+ this._open( event, target, content );
212
+ }
213
+ },
214
+
215
+ _open: function( event, target, content ) {
216
+ var tooltip, events, delayedShow,
217
+ positionOption = $.extend( {}, this.options.position );
218
+
219
+ if ( !content ) {
220
+ return;
221
+ }
222
+
223
+ // Content can be updated multiple times. If the tooltip already
224
+ // exists, then just update the content and bail.
225
+ tooltip = this._find( target );
226
+ if ( tooltip.length ) {
227
+ tooltip.find( ".ui-tooltip-content" ).html( content );
228
+ return;
229
+ }
230
+
231
+ // if we have a title, clear it to prevent the native tooltip
232
+ // we have to check first to avoid defining a title if none exists
233
+ // (we don't want to cause an element to start matching [title])
234
+ //
235
+ // We use removeAttr only for key events, to allow IE to export the correct
236
+ // accessible attributes. For mouse events, set to empty string to avoid
237
+ // native tooltip showing up (happens only when removing inside mouseover).
238
+ if ( target.is( "[title]" ) ) {
239
+ if ( event && event.type === "mouseover" ) {
240
+ target.attr( "title", "" );
241
+ } else {
242
+ target.removeAttr( "title" );
243
+ }
244
+ }
245
+
246
+ tooltip = this._tooltip( target );
247
+ addDescribedBy( target, tooltip.attr( "id" ) );
248
+ tooltip.find( ".ui-tooltip-content" ).html( content );
249
+
250
+ function position( event ) {
251
+ positionOption.of = event;
252
+ if ( tooltip.is( ":hidden" ) ) {
253
+ return;
254
+ }
255
+ tooltip.position( positionOption );
256
+ }
257
+ if ( this.options.track && event && /^mouse/.test( event.type ) ) {
258
+ this._on( this.document, {
259
+ mousemove: position
260
+ });
261
+ // trigger once to override element-relative positioning
262
+ position( event );
263
+ } else {
264
+ tooltip.position( $.extend({
265
+ of: target
266
+ }, this.options.position ) );
267
+ }
268
+
269
+ tooltip.hide();
270
+
271
+ this._show( tooltip, this.options.show );
272
+ // Handle tracking tooltips that are shown with a delay (#8644). As soon
273
+ // as the tooltip is visible, position the tooltip using the most recent
274
+ // event.
275
+ if ( this.options.show && this.options.show.delay ) {
276
+ delayedShow = this.delayedShow = setInterval(function() {
277
+ if ( tooltip.is( ":visible" ) ) {
278
+ position( positionOption.of );
279
+ clearInterval( delayedShow );
280
+ }
281
+ }, $.fx.interval );
282
+ }
283
+
284
+ this._trigger( "open", event, { tooltip: tooltip } );
285
+
286
+ events = {
287
+ keyup: function( event ) {
288
+ if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
289
+ var fakeEvent = $.Event(event);
290
+ fakeEvent.currentTarget = target[0];
291
+ this.close( fakeEvent, true );
292
+ }
293
+ },
294
+ remove: function() {
295
+ this._removeTooltip( tooltip );
296
+ }
297
+ };
298
+ if ( !event || event.type === "mouseover" ) {
299
+ events.mouseleave = "close";
300
+ }
301
+ if ( !event || event.type === "focusin" ) {
302
+ events.focusout = "close";
303
+ }
304
+ this._on( true, target, events );
305
+ },
306
+
307
+ close: function( event ) {
308
+ var that = this,
309
+ target = $( event ? event.currentTarget : this.element ),
310
+ tooltip = this._find( target );
311
+
312
+ // disabling closes the tooltip, so we need to track when we're closing
313
+ // to avoid an infinite loop in case the tooltip becomes disabled on close
314
+ if ( this.closing ) {
315
+ return;
316
+ }
317
+
318
+ // Clear the interval for delayed tracking tooltips
319
+ clearInterval( this.delayedShow );
320
+
321
+ // only set title if we had one before (see comment in _open())
322
+ if ( target.data( "ui-tooltip-title" ) ) {
323
+ target.attr( "title", target.data( "ui-tooltip-title" ) );
324
+ }
325
+
326
+ removeDescribedBy( target );
327
+
328
+ tooltip.stop( true );
329
+ this._hide( tooltip, this.options.hide, function() {
330
+ that._removeTooltip( $( this ) );
331
+ });
332
+
333
+ target.removeData( "ui-tooltip-open" );
334
+ this._off( target, "mouseleave focusout keyup" );
335
+ // Remove 'remove' binding only on delegated targets
336
+ if ( target[0] !== this.element[0] ) {
337
+ this._off( target, "remove" );
338
+ }
339
+ this._off( this.document, "mousemove" );
340
+
341
+ if ( event && event.type === "mouseleave" ) {
342
+ $.each( this.parents, function( id, parent ) {
343
+ $( parent.element ).attr( "title", parent.title );
344
+ delete that.parents[ id ];
345
+ });
346
+ }
347
+
348
+ this.closing = true;
349
+ this._trigger( "close", event, { tooltip: tooltip } );
350
+ this.closing = false;
351
+ },
352
+
353
+ _tooltip: function( element ) {
354
+ var id = "ui-tooltip-" + increments++,
355
+ tooltip = $( "<div>" )
356
+ .attr({
357
+ id: id,
358
+ role: "tooltip"
359
+ })
360
+ .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
361
+ ( this.options.tooltipClass || "" ) );
362
+ $( "<div>" )
363
+ .addClass( "ui-tooltip-content" )
364
+ .appendTo( tooltip );
365
+ tooltip.appendTo( this.document[0].body );
366
+ this.tooltips[ id ] = element;
367
+ return tooltip;
368
+ },
369
+
370
+ _find: function( target ) {
371
+ var id = target.data( "ui-tooltip-id" );
372
+ return id ? $( "#" + id ) : $();
373
+ },
374
+
375
+ _removeTooltip: function( tooltip ) {
376
+ tooltip.remove();
377
+ delete this.tooltips[ tooltip.attr( "id" ) ];
378
+ },
379
+
380
+ _destroy: function() {
381
+ var that = this;
382
+
383
+ // close open tooltips
384
+ $.each( this.tooltips, function( id, element ) {
385
+ // Delegate to close method to handle common cleanup
386
+ var event = $.Event( "blur" );
387
+ event.target = event.currentTarget = element[0];
388
+ that.close( event, true );
389
+
390
+ // Remove immediately; destroying an open tooltip doesn't use the
391
+ // hide animation
392
+ $( "#" + id ).remove();
393
+
394
+ // Restore the title
395
+ if ( element.data( "ui-tooltip-title" ) ) {
396
+ element.attr( "title", element.data( "ui-tooltip-title" ) );
397
+ element.removeData( "ui-tooltip-title" );
398
+ }
399
+ });
400
+ }
401
+ });
402
+
403
+ }( jQuery ) );
404
+
405
+ });
@@ -0,0 +1,524 @@
1
+ define(['jquery'], function (jQuery) {
2
+ /*!
3
+ * jQuery UI Widget 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/jQuery.widget/
11
+ */
12
+ (function( $, undefined ) {
13
+
14
+ var uuid = 0,
15
+ slice = Array.prototype.slice,
16
+ _cleanData = $.cleanData;
17
+ $.cleanData = function( elems ) {
18
+ for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
19
+ try {
20
+ $( elem ).triggerHandler( "remove" );
21
+ // http://bugs.jquery.com/ticket/8235
22
+ } catch( e ) {}
23
+ }
24
+ _cleanData( elems );
25
+ };
26
+
27
+ $.widget = function( name, base, prototype ) {
28
+ var fullName, existingConstructor, constructor, basePrototype,
29
+ // proxiedPrototype allows the provided prototype to remain unmodified
30
+ // so that it can be used as a mixin for multiple widgets (#8876)
31
+ proxiedPrototype = {},
32
+ namespace = name.split( "." )[ 0 ];
33
+
34
+ name = name.split( "." )[ 1 ];
35
+ fullName = namespace + "-" + name;
36
+
37
+ if ( !prototype ) {
38
+ prototype = base;
39
+ base = $.Widget;
40
+ }
41
+
42
+ // create selector for plugin
43
+ $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
44
+ return !!$.data( elem, fullName );
45
+ };
46
+
47
+ $[ namespace ] = $[ namespace ] || {};
48
+ existingConstructor = $[ namespace ][ name ];
49
+ constructor = $[ namespace ][ name ] = function( options, element ) {
50
+ // allow instantiation without "new" keyword
51
+ if ( !this._createWidget ) {
52
+ return new constructor( options, element );
53
+ }
54
+
55
+ // allow instantiation without initializing for simple inheritance
56
+ // must use "new" keyword (the code above always passes args)
57
+ if ( arguments.length ) {
58
+ this._createWidget( options, element );
59
+ }
60
+ };
61
+ // extend with the existing constructor to carry over any static properties
62
+ $.extend( constructor, existingConstructor, {
63
+ version: prototype.version,
64
+ // copy the object used to create the prototype in case we need to
65
+ // redefine the widget later
66
+ _proto: $.extend( {}, prototype ),
67
+ // track widgets that inherit from this widget in case this widget is
68
+ // redefined after a widget inherits from it
69
+ _childConstructors: []
70
+ });
71
+
72
+ basePrototype = new base();
73
+ // we need to make the options hash a property directly on the new instance
74
+ // otherwise we'll modify the options hash on the prototype that we're
75
+ // inheriting from
76
+ basePrototype.options = $.widget.extend( {}, basePrototype.options );
77
+ $.each( prototype, function( prop, value ) {
78
+ if ( !$.isFunction( value ) ) {
79
+ proxiedPrototype[ prop ] = value;
80
+ return;
81
+ }
82
+ proxiedPrototype[ prop ] = (function() {
83
+ var _super = function() {
84
+ return base.prototype[ prop ].apply( this, arguments );
85
+ },
86
+ _superApply = function( args ) {
87
+ return base.prototype[ prop ].apply( this, args );
88
+ };
89
+ return function() {
90
+ var __super = this._super,
91
+ __superApply = this._superApply,
92
+ returnValue;
93
+
94
+ this._super = _super;
95
+ this._superApply = _superApply;
96
+
97
+ returnValue = value.apply( this, arguments );
98
+
99
+ this._super = __super;
100
+ this._superApply = __superApply;
101
+
102
+ return returnValue;
103
+ };
104
+ })();
105
+ });
106
+ constructor.prototype = $.widget.extend( basePrototype, {
107
+ // TODO: remove support for widgetEventPrefix
108
+ // always use the name + a colon as the prefix, e.g., draggable:start
109
+ // don't prefix for widgets that aren't DOM-based
110
+ widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
111
+ }, proxiedPrototype, {
112
+ constructor: constructor,
113
+ namespace: namespace,
114
+ widgetName: name,
115
+ widgetFullName: fullName
116
+ });
117
+
118
+ // If this widget is being redefined then we need to find all widgets that
119
+ // are inheriting from it and redefine all of them so that they inherit from
120
+ // the new version of this widget. We're essentially trying to replace one
121
+ // level in the prototype chain.
122
+ if ( existingConstructor ) {
123
+ $.each( existingConstructor._childConstructors, function( i, child ) {
124
+ var childPrototype = child.prototype;
125
+
126
+ // redefine the child widget using the same prototype that was
127
+ // originally used, but inherit from the new version of the base
128
+ $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
129
+ });
130
+ // remove the list of existing child constructors from the old constructor
131
+ // so the old child constructors can be garbage collected
132
+ delete existingConstructor._childConstructors;
133
+ } else {
134
+ base._childConstructors.push( constructor );
135
+ }
136
+
137
+ $.widget.bridge( name, constructor );
138
+ };
139
+
140
+ $.widget.extend = function( target ) {
141
+ var input = slice.call( arguments, 1 ),
142
+ inputIndex = 0,
143
+ inputLength = input.length,
144
+ key,
145
+ value;
146
+ for ( ; inputIndex < inputLength; inputIndex++ ) {
147
+ for ( key in input[ inputIndex ] ) {
148
+ value = input[ inputIndex ][ key ];
149
+ if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
150
+ // Clone objects
151
+ if ( $.isPlainObject( value ) ) {
152
+ target[ key ] = $.isPlainObject( target[ key ] ) ?
153
+ $.widget.extend( {}, target[ key ], value ) :
154
+ // Don't extend strings, arrays, etc. with objects
155
+ $.widget.extend( {}, value );
156
+ // Copy everything else by reference
157
+ } else {
158
+ target[ key ] = value;
159
+ }
160
+ }
161
+ }
162
+ }
163
+ return target;
164
+ };
165
+
166
+ $.widget.bridge = function( name, object ) {
167
+ var fullName = object.prototype.widgetFullName || name;
168
+ $.fn[ name ] = function( options ) {
169
+ var isMethodCall = typeof options === "string",
170
+ args = slice.call( arguments, 1 ),
171
+ returnValue = this;
172
+
173
+ // allow multiple hashes to be passed on init
174
+ options = !isMethodCall && args.length ?
175
+ $.widget.extend.apply( null, [ options ].concat(args) ) :
176
+ options;
177
+
178
+ if ( isMethodCall ) {
179
+ this.each(function() {
180
+ var methodValue,
181
+ instance = $.data( this, fullName );
182
+ if ( !instance ) {
183
+ return $.error( "cannot call methods on " + name + " prior to initialization; " +
184
+ "attempted to call method '" + options + "'" );
185
+ }
186
+ if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
187
+ return $.error( "no such method '" + options + "' for " + name + " widget instance" );
188
+ }
189
+ methodValue = instance[ options ].apply( instance, args );
190
+ if ( methodValue !== instance && methodValue !== undefined ) {
191
+ returnValue = methodValue && methodValue.jquery ?
192
+ returnValue.pushStack( methodValue.get() ) :
193
+ methodValue;
194
+ return false;
195
+ }
196
+ });
197
+ } else {
198
+ this.each(function() {
199
+ var instance = $.data( this, fullName );
200
+ if ( instance ) {
201
+ instance.option( options || {} )._init();
202
+ } else {
203
+ $.data( this, fullName, new object( options, this ) );
204
+ }
205
+ });
206
+ }
207
+
208
+ return returnValue;
209
+ };
210
+ };
211
+
212
+ $.Widget = function( /* options, element */ ) {};
213
+ $.Widget._childConstructors = [];
214
+
215
+ $.Widget.prototype = {
216
+ widgetName: "widget",
217
+ widgetEventPrefix: "",
218
+ defaultElement: "<div>",
219
+ options: {
220
+ disabled: false,
221
+
222
+ // callbacks
223
+ create: null
224
+ },
225
+ _createWidget: function( options, element ) {
226
+ element = $( element || this.defaultElement || this )[ 0 ];
227
+ this.element = $( element );
228
+ this.uuid = uuid++;
229
+ this.eventNamespace = "." + this.widgetName + this.uuid;
230
+ this.options = $.widget.extend( {},
231
+ this.options,
232
+ this._getCreateOptions(),
233
+ options );
234
+
235
+ this.bindings = $();
236
+ this.hoverable = $();
237
+ this.focusable = $();
238
+
239
+ if ( element !== this ) {
240
+ $.data( element, this.widgetFullName, this );
241
+ this._on( true, this.element, {
242
+ remove: function( event ) {
243
+ if ( event.target === element ) {
244
+ this.destroy();
245
+ }
246
+ }
247
+ });
248
+ this.document = $( element.style ?
249
+ // element within the document
250
+ element.ownerDocument :
251
+ // element is window or document
252
+ element.document || element );
253
+ this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
254
+ }
255
+
256
+ this._create();
257
+ this._trigger( "create", null, this._getCreateEventData() );
258
+ this._init();
259
+ },
260
+ _getCreateOptions: $.noop,
261
+ _getCreateEventData: $.noop,
262
+ _create: $.noop,
263
+ _init: $.noop,
264
+
265
+ destroy: function() {
266
+ this._destroy();
267
+ // we can probably remove the unbind calls in 2.0
268
+ // all event bindings should go through this._on()
269
+ this.element
270
+ .unbind( this.eventNamespace )
271
+ // 1.9 BC for #7810
272
+ // TODO remove dual storage
273
+ .removeData( this.widgetName )
274
+ .removeData( this.widgetFullName )
275
+ // support: jquery <1.6.3
276
+ // http://bugs.jquery.com/ticket/9413
277
+ .removeData( $.camelCase( this.widgetFullName ) );
278
+ this.widget()
279
+ .unbind( this.eventNamespace )
280
+ .removeAttr( "aria-disabled" )
281
+ .removeClass(
282
+ this.widgetFullName + "-disabled " +
283
+ "ui-state-disabled" );
284
+
285
+ // clean up events and states
286
+ this.bindings.unbind( this.eventNamespace );
287
+ this.hoverable.removeClass( "ui-state-hover" );
288
+ this.focusable.removeClass( "ui-state-focus" );
289
+ },
290
+ _destroy: $.noop,
291
+
292
+ widget: function() {
293
+ return this.element;
294
+ },
295
+
296
+ option: function( key, value ) {
297
+ var options = key,
298
+ parts,
299
+ curOption,
300
+ i;
301
+
302
+ if ( arguments.length === 0 ) {
303
+ // don't return a reference to the internal hash
304
+ return $.widget.extend( {}, this.options );
305
+ }
306
+
307
+ if ( typeof key === "string" ) {
308
+ // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
309
+ options = {};
310
+ parts = key.split( "." );
311
+ key = parts.shift();
312
+ if ( parts.length ) {
313
+ curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
314
+ for ( i = 0; i < parts.length - 1; i++ ) {
315
+ curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
316
+ curOption = curOption[ parts[ i ] ];
317
+ }
318
+ key = parts.pop();
319
+ if ( value === undefined ) {
320
+ return curOption[ key ] === undefined ? null : curOption[ key ];
321
+ }
322
+ curOption[ key ] = value;
323
+ } else {
324
+ if ( value === undefined ) {
325
+ return this.options[ key ] === undefined ? null : this.options[ key ];
326
+ }
327
+ options[ key ] = value;
328
+ }
329
+ }
330
+
331
+ this._setOptions( options );
332
+
333
+ return this;
334
+ },
335
+ _setOptions: function( options ) {
336
+ var key;
337
+
338
+ for ( key in options ) {
339
+ this._setOption( key, options[ key ] );
340
+ }
341
+
342
+ return this;
343
+ },
344
+ _setOption: function( key, value ) {
345
+ this.options[ key ] = value;
346
+
347
+ if ( key === "disabled" ) {
348
+ this.widget()
349
+ .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
350
+ .attr( "aria-disabled", value );
351
+ this.hoverable.removeClass( "ui-state-hover" );
352
+ this.focusable.removeClass( "ui-state-focus" );
353
+ }
354
+
355
+ return this;
356
+ },
357
+
358
+ enable: function() {
359
+ return this._setOption( "disabled", false );
360
+ },
361
+ disable: function() {
362
+ return this._setOption( "disabled", true );
363
+ },
364
+
365
+ _on: function( suppressDisabledCheck, element, handlers ) {
366
+ var delegateElement,
367
+ instance = this;
368
+
369
+ // no suppressDisabledCheck flag, shuffle arguments
370
+ if ( typeof suppressDisabledCheck !== "boolean" ) {
371
+ handlers = element;
372
+ element = suppressDisabledCheck;
373
+ suppressDisabledCheck = false;
374
+ }
375
+
376
+ // no element argument, shuffle and use this.element
377
+ if ( !handlers ) {
378
+ handlers = element;
379
+ element = this.element;
380
+ delegateElement = this.widget();
381
+ } else {
382
+ // accept selectors, DOM elements
383
+ element = delegateElement = $( element );
384
+ this.bindings = this.bindings.add( element );
385
+ }
386
+
387
+ $.each( handlers, function( event, handler ) {
388
+ function handlerProxy() {
389
+ // allow widgets to customize the disabled handling
390
+ // - disabled as an array instead of boolean
391
+ // - disabled class as method for disabling individual parts
392
+ if ( !suppressDisabledCheck &&
393
+ ( instance.options.disabled === true ||
394
+ $( this ).hasClass( "ui-state-disabled" ) ) ) {
395
+ return;
396
+ }
397
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
398
+ .apply( instance, arguments );
399
+ }
400
+
401
+ // copy the guid so direct unbinding works
402
+ if ( typeof handler !== "string" ) {
403
+ handlerProxy.guid = handler.guid =
404
+ handler.guid || handlerProxy.guid || $.guid++;
405
+ }
406
+
407
+ var match = event.match( /^(\w+)\s*(.*)$/ ),
408
+ eventName = match[1] + instance.eventNamespace,
409
+ selector = match[2];
410
+ if ( selector ) {
411
+ delegateElement.delegate( selector, eventName, handlerProxy );
412
+ } else {
413
+ element.bind( eventName, handlerProxy );
414
+ }
415
+ });
416
+ },
417
+
418
+ _off: function( element, eventName ) {
419
+ eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
420
+ element.unbind( eventName ).undelegate( eventName );
421
+ },
422
+
423
+ _delay: function( handler, delay ) {
424
+ function handlerProxy() {
425
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
426
+ .apply( instance, arguments );
427
+ }
428
+ var instance = this;
429
+ return setTimeout( handlerProxy, delay || 0 );
430
+ },
431
+
432
+ _hoverable: function( element ) {
433
+ this.hoverable = this.hoverable.add( element );
434
+ this._on( element, {
435
+ mouseenter: function( event ) {
436
+ $( event.currentTarget ).addClass( "ui-state-hover" );
437
+ },
438
+ mouseleave: function( event ) {
439
+ $( event.currentTarget ).removeClass( "ui-state-hover" );
440
+ }
441
+ });
442
+ },
443
+
444
+ _focusable: function( element ) {
445
+ this.focusable = this.focusable.add( element );
446
+ this._on( element, {
447
+ focusin: function( event ) {
448
+ $( event.currentTarget ).addClass( "ui-state-focus" );
449
+ },
450
+ focusout: function( event ) {
451
+ $( event.currentTarget ).removeClass( "ui-state-focus" );
452
+ }
453
+ });
454
+ },
455
+
456
+ _trigger: function( type, event, data ) {
457
+ var prop, orig,
458
+ callback = this.options[ type ];
459
+
460
+ data = data || {};
461
+ event = $.Event( event );
462
+ event.type = ( type === this.widgetEventPrefix ?
463
+ type :
464
+ this.widgetEventPrefix + type ).toLowerCase();
465
+ // the original event may come from any element
466
+ // so we need to reset the target on the new event
467
+ event.target = this.element[ 0 ];
468
+
469
+ // copy original event properties over to the new event
470
+ orig = event.originalEvent;
471
+ if ( orig ) {
472
+ for ( prop in orig ) {
473
+ if ( !( prop in event ) ) {
474
+ event[ prop ] = orig[ prop ];
475
+ }
476
+ }
477
+ }
478
+
479
+ this.element.trigger( event, data );
480
+ return !( $.isFunction( callback ) &&
481
+ callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
482
+ event.isDefaultPrevented() );
483
+ }
484
+ };
485
+
486
+ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
487
+ $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
488
+ if ( typeof options === "string" ) {
489
+ options = { effect: options };
490
+ }
491
+ var hasOptions,
492
+ effectName = !options ?
493
+ method :
494
+ options === true || typeof options === "number" ?
495
+ defaultEffect :
496
+ options.effect || defaultEffect;
497
+ options = options || {};
498
+ if ( typeof options === "number" ) {
499
+ options = { duration: options };
500
+ }
501
+ hasOptions = !$.isEmptyObject( options );
502
+ options.complete = callback;
503
+ if ( options.delay ) {
504
+ element.delay( options.delay );
505
+ }
506
+ if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
507
+ element[ method ]( options );
508
+ } else if ( effectName !== method && element[ effectName ] ) {
509
+ element[ effectName ]( options.duration, options.easing, callback );
510
+ } else {
511
+ element.queue(function( next ) {
512
+ $( this )[ method ]();
513
+ if ( callback ) {
514
+ callback.call( element[ 0 ] );
515
+ }
516
+ next();
517
+ });
518
+ }
519
+ };
520
+ });
521
+
522
+ })( jQuery );
523
+
524
+ });