jquery-ui-rails 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jquery-ui-rails might be problematic. Click here for more details.

Files changed (137) hide show
  1. data/.gitignore +0 -1
  2. data/History.md +6 -0
  3. data/README.md +1 -0
  4. data/Rakefile +13 -2
  5. data/lib/jquery/ui/rails/version.rb +1 -1
  6. data/vendor/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  7. data/vendor/assets/images/jquery-ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  8. data/vendor/assets/images/jquery-ui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  9. data/vendor/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  10. data/vendor/assets/images/jquery-ui/ui-bg_glass_75_dadada_1x400.png +0 -0
  11. data/vendor/assets/images/jquery-ui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  12. data/vendor/assets/images/jquery-ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  13. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  14. data/vendor/assets/images/jquery-ui/ui-icons_222222_256x240.png +0 -0
  15. data/vendor/assets/images/jquery-ui/ui-icons_2e83ff_256x240.png +0 -0
  16. data/vendor/assets/images/jquery-ui/ui-icons_454545_256x240.png +0 -0
  17. data/vendor/assets/images/jquery-ui/ui-icons_888888_256x240.png +0 -0
  18. data/vendor/assets/images/jquery-ui/ui-icons_cd0a0a_256x240.png +0 -0
  19. data/vendor/assets/javascripts/jquery.effects.all.js +14 -0
  20. data/vendor/assets/javascripts/jquery.effects.blind.js +51 -0
  21. data/vendor/assets/javascripts/jquery.effects.bounce.js +80 -0
  22. data/vendor/assets/javascripts/jquery.effects.clip.js +56 -0
  23. data/vendor/assets/javascripts/jquery.effects.core.js +763 -0
  24. data/vendor/assets/javascripts/jquery.effects.drop.js +52 -0
  25. data/vendor/assets/javascripts/jquery.effects.explode.js +81 -0
  26. data/vendor/assets/javascripts/jquery.effects.fade.js +34 -0
  27. data/vendor/assets/javascripts/jquery.effects.fold.js +58 -0
  28. data/vendor/assets/javascripts/jquery.effects.highlight.js +52 -0
  29. data/vendor/assets/javascripts/jquery.effects.pulsate.js +53 -0
  30. data/vendor/assets/javascripts/jquery.effects.scale.js +180 -0
  31. data/vendor/assets/javascripts/jquery.effects.shake.js +59 -0
  32. data/vendor/assets/javascripts/jquery.effects.slide.js +52 -0
  33. data/vendor/assets/javascripts/jquery.effects.transfer.js +47 -0
  34. data/vendor/assets/javascripts/jquery.ui.accordion.js +614 -0
  35. data/vendor/assets/javascripts/jquery.ui.all.js +31 -0
  36. data/vendor/assets/javascripts/jquery.ui.autocomplete.js +635 -0
  37. data/vendor/assets/javascripts/jquery.ui.button.js +417 -0
  38. data/vendor/assets/javascripts/jquery.ui.core.js +321 -0
  39. data/vendor/assets/javascripts/jquery.ui.datepicker-af.js +25 -0
  40. data/vendor/assets/javascripts/jquery.ui.datepicker-ar-DZ.js +25 -0
  41. data/vendor/assets/javascripts/jquery.ui.datepicker-ar.js +25 -0
  42. data/vendor/assets/javascripts/jquery.ui.datepicker-az.js +25 -0
  43. data/vendor/assets/javascripts/jquery.ui.datepicker-bg.js +26 -0
  44. data/vendor/assets/javascripts/jquery.ui.datepicker-bs.js +25 -0
  45. data/vendor/assets/javascripts/jquery.ui.datepicker-ca.js +25 -0
  46. data/vendor/assets/javascripts/jquery.ui.datepicker-cs.js +25 -0
  47. data/vendor/assets/javascripts/jquery.ui.datepicker-cy-GB.js +25 -0
  48. data/vendor/assets/javascripts/jquery.ui.datepicker-da.js +25 -0
  49. data/vendor/assets/javascripts/jquery.ui.datepicker-de.js +25 -0
  50. data/vendor/assets/javascripts/jquery.ui.datepicker-el.js +25 -0
  51. data/vendor/assets/javascripts/jquery.ui.datepicker-en-AU.js +25 -0
  52. data/vendor/assets/javascripts/jquery.ui.datepicker-en-GB.js +25 -0
  53. data/vendor/assets/javascripts/jquery.ui.datepicker-en-NZ.js +25 -0
  54. data/vendor/assets/javascripts/jquery.ui.datepicker-eo.js +25 -0
  55. data/vendor/assets/javascripts/jquery.ui.datepicker-es.js +25 -0
  56. data/vendor/assets/javascripts/jquery.ui.datepicker-et.js +25 -0
  57. data/vendor/assets/javascripts/jquery.ui.datepicker-eu.js +25 -0
  58. data/vendor/assets/javascripts/jquery.ui.datepicker-fa.js +61 -0
  59. data/vendor/assets/javascripts/jquery.ui.datepicker-fi.js +25 -0
  60. data/vendor/assets/javascripts/jquery.ui.datepicker-fo.js +25 -0
  61. data/vendor/assets/javascripts/jquery.ui.datepicker-fr-CH.js +25 -0
  62. data/vendor/assets/javascripts/jquery.ui.datepicker-fr.js +27 -0
  63. data/vendor/assets/javascripts/jquery.ui.datepicker-ge.js +23 -0
  64. data/vendor/assets/javascripts/jquery.ui.datepicker-gl.js +25 -0
  65. data/vendor/assets/javascripts/jquery.ui.datepicker-he.js +25 -0
  66. data/vendor/assets/javascripts/jquery.ui.datepicker-hi.js +25 -0
  67. data/vendor/assets/javascripts/jquery.ui.datepicker-hr.js +25 -0
  68. data/vendor/assets/javascripts/jquery.ui.datepicker-hu.js +25 -0
  69. data/vendor/assets/javascripts/jquery.ui.datepicker-hy.js +25 -0
  70. data/vendor/assets/javascripts/jquery.ui.datepicker-id.js +25 -0
  71. data/vendor/assets/javascripts/jquery.ui.datepicker-is.js +25 -0
  72. data/vendor/assets/javascripts/jquery.ui.datepicker-it.js +25 -0
  73. data/vendor/assets/javascripts/jquery.ui.datepicker-ja.js +25 -0
  74. data/vendor/assets/javascripts/jquery.ui.datepicker-kk.js +25 -0
  75. data/vendor/assets/javascripts/jquery.ui.datepicker-km.js +25 -0
  76. data/vendor/assets/javascripts/jquery.ui.datepicker-ko.js +25 -0
  77. data/vendor/assets/javascripts/jquery.ui.datepicker-lb.js +25 -0
  78. data/vendor/assets/javascripts/jquery.ui.datepicker-lt.js +25 -0
  79. data/vendor/assets/javascripts/jquery.ui.datepicker-lv.js +25 -0
  80. data/vendor/assets/javascripts/jquery.ui.datepicker-mk.js +25 -0
  81. data/vendor/assets/javascripts/jquery.ui.datepicker-ml.js +25 -0
  82. data/vendor/assets/javascripts/jquery.ui.datepicker-ms.js +25 -0
  83. data/vendor/assets/javascripts/jquery.ui.datepicker-nl-BE.js +25 -0
  84. data/vendor/assets/javascripts/jquery.ui.datepicker-nl.js +25 -0
  85. data/vendor/assets/javascripts/jquery.ui.datepicker-no.js +25 -0
  86. data/vendor/assets/javascripts/jquery.ui.datepicker-pl.js +25 -0
  87. data/vendor/assets/javascripts/jquery.ui.datepicker-pt-BR.js +25 -0
  88. data/vendor/assets/javascripts/jquery.ui.datepicker-pt.js +24 -0
  89. data/vendor/assets/javascripts/jquery.ui.datepicker-rm.js +23 -0
  90. data/vendor/assets/javascripts/jquery.ui.datepicker-ro.js +28 -0
  91. data/vendor/assets/javascripts/jquery.ui.datepicker-ru.js +25 -0
  92. data/vendor/assets/javascripts/jquery.ui.datepicker-sk.js +25 -0
  93. data/vendor/assets/javascripts/jquery.ui.datepicker-sl.js +26 -0
  94. data/vendor/assets/javascripts/jquery.ui.datepicker-sq.js +25 -0
  95. data/vendor/assets/javascripts/jquery.ui.datepicker-sr-SR.js +25 -0
  96. data/vendor/assets/javascripts/jquery.ui.datepicker-sr.js +25 -0
  97. data/vendor/assets/javascripts/jquery.ui.datepicker-sv.js +25 -0
  98. data/vendor/assets/javascripts/jquery.ui.datepicker-ta.js +25 -0
  99. data/vendor/assets/javascripts/jquery.ui.datepicker-th.js +25 -0
  100. data/vendor/assets/javascripts/jquery.ui.datepicker-tj.js +25 -0
  101. data/vendor/assets/javascripts/jquery.ui.datepicker-tr.js +25 -0
  102. data/vendor/assets/javascripts/jquery.ui.datepicker-uk.js +26 -0
  103. data/vendor/assets/javascripts/jquery.ui.datepicker-vi.js +25 -0
  104. data/vendor/assets/javascripts/jquery.ui.datepicker-zh-CN.js +25 -0
  105. data/vendor/assets/javascripts/jquery.ui.datepicker-zh-HK.js +25 -0
  106. data/vendor/assets/javascripts/jquery.ui.datepicker-zh-TW.js +25 -0
  107. data/vendor/assets/javascripts/jquery.ui.datepicker.js +1826 -0
  108. data/vendor/assets/javascripts/jquery.ui.dialog.js +882 -0
  109. data/vendor/assets/javascripts/jquery.ui.draggable.js +835 -0
  110. data/vendor/assets/javascripts/jquery.ui.droppable.js +301 -0
  111. data/vendor/assets/javascripts/jquery.ui.mouse.js +168 -0
  112. data/vendor/assets/javascripts/jquery.ui.position.js +298 -0
  113. data/vendor/assets/javascripts/jquery.ui.progressbar.js +112 -0
  114. data/vendor/assets/javascripts/jquery.ui.resizable.js +811 -0
  115. data/vendor/assets/javascripts/jquery.ui.selectable.js +271 -0
  116. data/vendor/assets/javascripts/jquery.ui.slider.js +666 -0
  117. data/vendor/assets/javascripts/jquery.ui.sortable.js +1085 -0
  118. data/vendor/assets/javascripts/jquery.ui.tabs.js +760 -0
  119. data/vendor/assets/javascripts/jquery.ui.widget.js +272 -0
  120. data/vendor/assets/stylesheets/jquery.ui.accordion.css.erb +23 -0
  121. data/vendor/assets/stylesheets/jquery.ui.all.css.erb +13 -0
  122. data/vendor/assets/stylesheets/jquery.ui.autocomplete.css.erb +57 -0
  123. data/vendor/assets/stylesheets/jquery.ui.base.css.erb +23 -0
  124. data/vendor/assets/stylesheets/jquery.ui.button.css.erb +42 -0
  125. data/vendor/assets/stylesheets/jquery.ui.core.css.erb +38 -0
  126. data/vendor/assets/stylesheets/jquery.ui.datepicker.css.erb +72 -0
  127. data/vendor/assets/stylesheets/jquery.ui.dialog.css.erb +25 -0
  128. data/vendor/assets/stylesheets/jquery.ui.progressbar.css.erb +15 -0
  129. data/vendor/assets/stylesheets/jquery.ui.resizable.css.erb +24 -0
  130. data/vendor/assets/stylesheets/jquery.ui.selectable.css.erb +14 -0
  131. data/vendor/assets/stylesheets/jquery.ui.slider.css.erb +28 -0
  132. data/vendor/assets/stylesheets/jquery.ui.tabs.css.erb +22 -0
  133. data/vendor/assets/stylesheets/jquery.ui.theme.css.erb +250 -0
  134. metadata +111 -113
  135. data/jquery-ui/GPL-LICENSE.txt +0 -278
  136. data/jquery-ui/MIT-LICENSE.txt +0 -25
  137. data/jquery-ui/package.json +0 -36
@@ -0,0 +1,31 @@
1
+ //= require jquery.effects.blind
2
+ //= require jquery.effects.bounce
3
+ //= require jquery.effects.clip
4
+ //= require jquery.effects.core
5
+ //= require jquery.effects.drop
6
+ //= require jquery.effects.explode
7
+ //= require jquery.effects.fade
8
+ //= require jquery.effects.fold
9
+ //= require jquery.effects.highlight
10
+ //= require jquery.effects.pulsate
11
+ //= require jquery.effects.scale
12
+ //= require jquery.effects.shake
13
+ //= require jquery.effects.slide
14
+ //= require jquery.effects.transfer
15
+ //= require jquery.ui.accordion
16
+ //= require jquery.ui.autocomplete
17
+ //= require jquery.ui.button
18
+ //= require jquery.ui.core
19
+ //= require jquery.ui.datepicker
20
+ //= require jquery.ui.dialog
21
+ //= require jquery.ui.draggable
22
+ //= require jquery.ui.droppable
23
+ //= require jquery.ui.mouse
24
+ //= require jquery.ui.position
25
+ //= require jquery.ui.progressbar
26
+ //= require jquery.ui.resizable
27
+ //= require jquery.ui.selectable
28
+ //= require jquery.ui.slider
29
+ //= require jquery.ui.sortable
30
+ //= require jquery.ui.tabs
31
+ //= require jquery.ui.widget
@@ -0,0 +1,635 @@
1
+ //= require jquery.ui.core
2
+ //= require jquery.ui.widget
3
+ //= require jquery.ui.position
4
+
5
+ /*!
6
+ * jQuery UI Autocomplete 1.8.20
7
+ *
8
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
9
+ * Dual licensed under the MIT or GPL Version 2 licenses.
10
+ * http://jquery.org/license
11
+ *
12
+ * http://docs.jquery.com/UI/Autocomplete
13
+ *
14
+ * Depends:
15
+ * jquery.ui.core.js
16
+ * jquery.ui.widget.js
17
+ * jquery.ui.position.js
18
+ */
19
+ (function( $, undefined ) {
20
+
21
+ // used to prevent race conditions with remote data sources
22
+ var requestIndex = 0;
23
+
24
+ $.widget( "ui.autocomplete", {
25
+ options: {
26
+ appendTo: "body",
27
+ autoFocus: false,
28
+ delay: 300,
29
+ minLength: 1,
30
+ position: {
31
+ my: "left top",
32
+ at: "left bottom",
33
+ collision: "none"
34
+ },
35
+ source: null
36
+ },
37
+
38
+ pending: 0,
39
+
40
+ _create: function() {
41
+ var self = this,
42
+ doc = this.element[ 0 ].ownerDocument,
43
+ suppressKeyPress;
44
+ this.isMultiLine = this.element.is( "textarea" );
45
+
46
+ this.element
47
+ .addClass( "ui-autocomplete-input" )
48
+ .attr( "autocomplete", "off" )
49
+ // TODO verify these actually work as intended
50
+ .attr({
51
+ role: "textbox",
52
+ "aria-autocomplete": "list",
53
+ "aria-haspopup": "true"
54
+ })
55
+ .bind( "keydown.autocomplete", function( event ) {
56
+ if ( self.options.disabled || self.element.propAttr( "readOnly" ) ) {
57
+ return;
58
+ }
59
+
60
+ suppressKeyPress = false;
61
+ var keyCode = $.ui.keyCode;
62
+ switch( event.keyCode ) {
63
+ case keyCode.PAGE_UP:
64
+ self._move( "previousPage", event );
65
+ break;
66
+ case keyCode.PAGE_DOWN:
67
+ self._move( "nextPage", event );
68
+ break;
69
+ case keyCode.UP:
70
+ self._keyEvent( "previous", event );
71
+ break;
72
+ case keyCode.DOWN:
73
+ self._keyEvent( "next", event );
74
+ break;
75
+ case keyCode.ENTER:
76
+ case keyCode.NUMPAD_ENTER:
77
+ // when menu is open and has focus
78
+ if ( self.menu.active ) {
79
+ // #6055 - Opera still allows the keypress to occur
80
+ // which causes forms to submit
81
+ suppressKeyPress = true;
82
+ event.preventDefault();
83
+ }
84
+ //passthrough - ENTER and TAB both select the current element
85
+ case keyCode.TAB:
86
+ if ( !self.menu.active ) {
87
+ return;
88
+ }
89
+ self.menu.select( event );
90
+ break;
91
+ case keyCode.ESCAPE:
92
+ self.element.val( self.term );
93
+ self.close( event );
94
+ break;
95
+ default:
96
+ // keypress is triggered before the input value is changed
97
+ clearTimeout( self.searching );
98
+ self.searching = setTimeout(function() {
99
+ // only search if the value has changed
100
+ if ( self.term != self.element.val() ) {
101
+ self.selectedItem = null;
102
+ self.search( null, event );
103
+ }
104
+ }, self.options.delay );
105
+ break;
106
+ }
107
+ })
108
+ .bind( "keypress.autocomplete", function( event ) {
109
+ if ( suppressKeyPress ) {
110
+ suppressKeyPress = false;
111
+ event.preventDefault();
112
+ }
113
+ })
114
+ .bind( "focus.autocomplete", function() {
115
+ if ( self.options.disabled ) {
116
+ return;
117
+ }
118
+
119
+ self.selectedItem = null;
120
+ self.previous = self.element.val();
121
+ })
122
+ .bind( "blur.autocomplete", function( event ) {
123
+ if ( self.options.disabled ) {
124
+ return;
125
+ }
126
+
127
+ clearTimeout( self.searching );
128
+ // clicks on the menu (or a button to trigger a search) will cause a blur event
129
+ self.closing = setTimeout(function() {
130
+ self.close( event );
131
+ self._change( event );
132
+ }, 150 );
133
+ });
134
+ this._initSource();
135
+ this.menu = $( "<ul></ul>" )
136
+ .addClass( "ui-autocomplete" )
137
+ .appendTo( $( this.options.appendTo || "body", doc )[0] )
138
+ // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
139
+ .mousedown(function( event ) {
140
+ // clicking on the scrollbar causes focus to shift to the body
141
+ // but we can't detect a mouseup or a click immediately afterward
142
+ // so we have to track the next mousedown and close the menu if
143
+ // the user clicks somewhere outside of the autocomplete
144
+ var menuElement = self.menu.element[ 0 ];
145
+ if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
146
+ setTimeout(function() {
147
+ $( document ).one( 'mousedown', function( event ) {
148
+ if ( event.target !== self.element[ 0 ] &&
149
+ event.target !== menuElement &&
150
+ !$.ui.contains( menuElement, event.target ) ) {
151
+ self.close();
152
+ }
153
+ });
154
+ }, 1 );
155
+ }
156
+
157
+ // use another timeout to make sure the blur-event-handler on the input was already triggered
158
+ setTimeout(function() {
159
+ clearTimeout( self.closing );
160
+ }, 13);
161
+ })
162
+ .menu({
163
+ focus: function( event, ui ) {
164
+ var item = ui.item.data( "item.autocomplete" );
165
+ if ( false !== self._trigger( "focus", event, { item: item } ) ) {
166
+ // use value to match what will end up in the input, if it was a key event
167
+ if ( /^key/.test(event.originalEvent.type) ) {
168
+ self.element.val( item.value );
169
+ }
170
+ }
171
+ },
172
+ selected: function( event, ui ) {
173
+ var item = ui.item.data( "item.autocomplete" ),
174
+ previous = self.previous;
175
+
176
+ // only trigger when focus was lost (click on menu)
177
+ if ( self.element[0] !== doc.activeElement ) {
178
+ self.element.focus();
179
+ self.previous = previous;
180
+ // #6109 - IE triggers two focus events and the second
181
+ // is asynchronous, so we need to reset the previous
182
+ // term synchronously and asynchronously :-(
183
+ setTimeout(function() {
184
+ self.previous = previous;
185
+ self.selectedItem = item;
186
+ }, 1);
187
+ }
188
+
189
+ if ( false !== self._trigger( "select", event, { item: item } ) ) {
190
+ self.element.val( item.value );
191
+ }
192
+ // reset the term after the select event
193
+ // this allows custom select handling to work properly
194
+ self.term = self.element.val();
195
+
196
+ self.close( event );
197
+ self.selectedItem = item;
198
+ },
199
+ blur: function( event, ui ) {
200
+ // don't set the value of the text field if it's already correct
201
+ // this prevents moving the cursor unnecessarily
202
+ if ( self.menu.element.is(":visible") &&
203
+ ( self.element.val() !== self.term ) ) {
204
+ self.element.val( self.term );
205
+ }
206
+ }
207
+ })
208
+ .zIndex( this.element.zIndex() + 1 )
209
+ // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
210
+ .css({ top: 0, left: 0 })
211
+ .hide()
212
+ .data( "menu" );
213
+ if ( $.fn.bgiframe ) {
214
+ this.menu.element.bgiframe();
215
+ }
216
+ // turning off autocomplete prevents the browser from remembering the
217
+ // value when navigating through history, so we re-enable autocomplete
218
+ // if the page is unloaded before the widget is destroyed. #7790
219
+ self.beforeunloadHandler = function() {
220
+ self.element.removeAttr( "autocomplete" );
221
+ };
222
+ $( window ).bind( "beforeunload", self.beforeunloadHandler );
223
+ },
224
+
225
+ destroy: function() {
226
+ this.element
227
+ .removeClass( "ui-autocomplete-input" )
228
+ .removeAttr( "autocomplete" )
229
+ .removeAttr( "role" )
230
+ .removeAttr( "aria-autocomplete" )
231
+ .removeAttr( "aria-haspopup" );
232
+ this.menu.element.remove();
233
+ $( window ).unbind( "beforeunload", this.beforeunloadHandler );
234
+ $.Widget.prototype.destroy.call( this );
235
+ },
236
+
237
+ _setOption: function( key, value ) {
238
+ $.Widget.prototype._setOption.apply( this, arguments );
239
+ if ( key === "source" ) {
240
+ this._initSource();
241
+ }
242
+ if ( key === "appendTo" ) {
243
+ this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
244
+ }
245
+ if ( key === "disabled" && value && this.xhr ) {
246
+ this.xhr.abort();
247
+ }
248
+ },
249
+
250
+ _initSource: function() {
251
+ var self = this,
252
+ array,
253
+ url;
254
+ if ( $.isArray(this.options.source) ) {
255
+ array = this.options.source;
256
+ this.source = function( request, response ) {
257
+ response( $.ui.autocomplete.filter(array, request.term) );
258
+ };
259
+ } else if ( typeof this.options.source === "string" ) {
260
+ url = this.options.source;
261
+ this.source = function( request, response ) {
262
+ if ( self.xhr ) {
263
+ self.xhr.abort();
264
+ }
265
+ self.xhr = $.ajax({
266
+ url: url,
267
+ data: request,
268
+ dataType: "json",
269
+ success: function( data, status ) {
270
+ response( data );
271
+ },
272
+ error: function() {
273
+ response( [] );
274
+ }
275
+ });
276
+ };
277
+ } else {
278
+ this.source = this.options.source;
279
+ }
280
+ },
281
+
282
+ search: function( value, event ) {
283
+ value = value != null ? value : this.element.val();
284
+
285
+ // always save the actual value, not the one passed as an argument
286
+ this.term = this.element.val();
287
+
288
+ if ( value.length < this.options.minLength ) {
289
+ return this.close( event );
290
+ }
291
+
292
+ clearTimeout( this.closing );
293
+ if ( this._trigger( "search", event ) === false ) {
294
+ return;
295
+ }
296
+
297
+ return this._search( value );
298
+ },
299
+
300
+ _search: function( value ) {
301
+ this.pending++;
302
+ this.element.addClass( "ui-autocomplete-loading" );
303
+
304
+ this.source( { term: value }, this._response() );
305
+ },
306
+
307
+ _response: function() {
308
+ var that = this,
309
+ index = ++requestIndex;
310
+
311
+ return function( content ) {
312
+ if ( index === requestIndex ) {
313
+ that.__response( content );
314
+ }
315
+
316
+ that.pending--;
317
+ if ( !that.pending ) {
318
+ that.element.removeClass( "ui-autocomplete-loading" );
319
+ }
320
+ };
321
+ },
322
+
323
+ __response: function( content ) {
324
+ if ( !this.options.disabled && content && content.length ) {
325
+ content = this._normalize( content );
326
+ this._suggest( content );
327
+ this._trigger( "open" );
328
+ } else {
329
+ this.close();
330
+ }
331
+ },
332
+
333
+ close: function( event ) {
334
+ clearTimeout( this.closing );
335
+ if ( this.menu.element.is(":visible") ) {
336
+ this.menu.element.hide();
337
+ this.menu.deactivate();
338
+ this._trigger( "close", event );
339
+ }
340
+ },
341
+
342
+ _change: function( event ) {
343
+ if ( this.previous !== this.element.val() ) {
344
+ this._trigger( "change", event, { item: this.selectedItem } );
345
+ }
346
+ },
347
+
348
+ _normalize: function( items ) {
349
+ // assume all items have the right format when the first item is complete
350
+ if ( items.length && items[0].label && items[0].value ) {
351
+ return items;
352
+ }
353
+ return $.map( items, function(item) {
354
+ if ( typeof item === "string" ) {
355
+ return {
356
+ label: item,
357
+ value: item
358
+ };
359
+ }
360
+ return $.extend({
361
+ label: item.label || item.value,
362
+ value: item.value || item.label
363
+ }, item );
364
+ });
365
+ },
366
+
367
+ _suggest: function( items ) {
368
+ var ul = this.menu.element
369
+ .empty()
370
+ .zIndex( this.element.zIndex() + 1 );
371
+ this._renderMenu( ul, items );
372
+ // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
373
+ this.menu.deactivate();
374
+ this.menu.refresh();
375
+
376
+ // size and position menu
377
+ ul.show();
378
+ this._resizeMenu();
379
+ ul.position( $.extend({
380
+ of: this.element
381
+ }, this.options.position ));
382
+
383
+ if ( this.options.autoFocus ) {
384
+ this.menu.next( new $.Event("mouseover") );
385
+ }
386
+ },
387
+
388
+ _resizeMenu: function() {
389
+ var ul = this.menu.element;
390
+ ul.outerWidth( Math.max(
391
+ // Firefox wraps long text (possibly a rounding bug)
392
+ // so we add 1px to avoid the wrapping (#7513)
393
+ ul.width( "" ).outerWidth() + 1,
394
+ this.element.outerWidth()
395
+ ) );
396
+ },
397
+
398
+ _renderMenu: function( ul, items ) {
399
+ var self = this;
400
+ $.each( items, function( index, item ) {
401
+ self._renderItem( ul, item );
402
+ });
403
+ },
404
+
405
+ _renderItem: function( ul, item) {
406
+ return $( "<li></li>" )
407
+ .data( "item.autocomplete", item )
408
+ .append( $( "<a></a>" ).text( item.label ) )
409
+ .appendTo( ul );
410
+ },
411
+
412
+ _move: function( direction, event ) {
413
+ if ( !this.menu.element.is(":visible") ) {
414
+ this.search( null, event );
415
+ return;
416
+ }
417
+ if ( this.menu.first() && /^previous/.test(direction) ||
418
+ this.menu.last() && /^next/.test(direction) ) {
419
+ this.element.val( this.term );
420
+ this.menu.deactivate();
421
+ return;
422
+ }
423
+ this.menu[ direction ]( event );
424
+ },
425
+
426
+ widget: function() {
427
+ return this.menu.element;
428
+ },
429
+ _keyEvent: function( keyEvent, event ) {
430
+ if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
431
+ this._move( keyEvent, event );
432
+
433
+ // prevents moving cursor to beginning/end of the text field in some browsers
434
+ event.preventDefault();
435
+ }
436
+ }
437
+ });
438
+
439
+ $.extend( $.ui.autocomplete, {
440
+ escapeRegex: function( value ) {
441
+ return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
442
+ },
443
+ filter: function(array, term) {
444
+ var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
445
+ return $.grep( array, function(value) {
446
+ return matcher.test( value.label || value.value || value );
447
+ });
448
+ }
449
+ });
450
+
451
+ }( jQuery ));
452
+
453
+ /*
454
+ * jQuery UI Menu (not officially released)
455
+ *
456
+ * This widget isn't yet finished and the API is subject to change. We plan to finish
457
+ * it for the next release. You're welcome to give it a try anyway and give us feedback,
458
+ * as long as you're okay with migrating your code later on. We can help with that, too.
459
+ *
460
+ * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
461
+ * Dual licensed under the MIT or GPL Version 2 licenses.
462
+ * http://jquery.org/license
463
+ *
464
+ * http://docs.jquery.com/UI/Menu
465
+ *
466
+ * Depends:
467
+ * jquery.ui.core.js
468
+ * jquery.ui.widget.js
469
+ */
470
+ (function($) {
471
+
472
+ $.widget("ui.menu", {
473
+ _create: function() {
474
+ var self = this;
475
+ this.element
476
+ .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
477
+ .attr({
478
+ role: "listbox",
479
+ "aria-activedescendant": "ui-active-menuitem"
480
+ })
481
+ .click(function( event ) {
482
+ if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) {
483
+ return;
484
+ }
485
+ // temporary
486
+ event.preventDefault();
487
+ self.select( event );
488
+ });
489
+ this.refresh();
490
+ },
491
+
492
+ refresh: function() {
493
+ var self = this;
494
+
495
+ // don't refresh list items that are already adapted
496
+ var items = this.element.children("li:not(.ui-menu-item):has(a)")
497
+ .addClass("ui-menu-item")
498
+ .attr("role", "menuitem");
499
+
500
+ items.children("a")
501
+ .addClass("ui-corner-all")
502
+ .attr("tabindex", -1)
503
+ // mouseenter doesn't work with event delegation
504
+ .mouseenter(function( event ) {
505
+ self.activate( event, $(this).parent() );
506
+ })
507
+ .mouseleave(function() {
508
+ self.deactivate();
509
+ });
510
+ },
511
+
512
+ activate: function( event, item ) {
513
+ this.deactivate();
514
+ if (this.hasScroll()) {
515
+ var offset = item.offset().top - this.element.offset().top,
516
+ scroll = this.element.scrollTop(),
517
+ elementHeight = this.element.height();
518
+ if (offset < 0) {
519
+ this.element.scrollTop( scroll + offset);
520
+ } else if (offset >= elementHeight) {
521
+ this.element.scrollTop( scroll + offset - elementHeight + item.height());
522
+ }
523
+ }
524
+ this.active = item.eq(0)
525
+ .children("a")
526
+ .addClass("ui-state-hover")
527
+ .attr("id", "ui-active-menuitem")
528
+ .end();
529
+ this._trigger("focus", event, { item: item });
530
+ },
531
+
532
+ deactivate: function() {
533
+ if (!this.active) { return; }
534
+
535
+ this.active.children("a")
536
+ .removeClass("ui-state-hover")
537
+ .removeAttr("id");
538
+ this._trigger("blur");
539
+ this.active = null;
540
+ },
541
+
542
+ next: function(event) {
543
+ this.move("next", ".ui-menu-item:first", event);
544
+ },
545
+
546
+ previous: function(event) {
547
+ this.move("prev", ".ui-menu-item:last", event);
548
+ },
549
+
550
+ first: function() {
551
+ return this.active && !this.active.prevAll(".ui-menu-item").length;
552
+ },
553
+
554
+ last: function() {
555
+ return this.active && !this.active.nextAll(".ui-menu-item").length;
556
+ },
557
+
558
+ move: function(direction, edge, event) {
559
+ if (!this.active) {
560
+ this.activate(event, this.element.children(edge));
561
+ return;
562
+ }
563
+ var next = this.active[direction + "All"](".ui-menu-item").eq(0);
564
+ if (next.length) {
565
+ this.activate(event, next);
566
+ } else {
567
+ this.activate(event, this.element.children(edge));
568
+ }
569
+ },
570
+
571
+ // TODO merge with previousPage
572
+ nextPage: function(event) {
573
+ if (this.hasScroll()) {
574
+ // TODO merge with no-scroll-else
575
+ if (!this.active || this.last()) {
576
+ this.activate(event, this.element.children(".ui-menu-item:first"));
577
+ return;
578
+ }
579
+ var base = this.active.offset().top,
580
+ height = this.element.height(),
581
+ result = this.element.children(".ui-menu-item").filter(function() {
582
+ var close = $(this).offset().top - base - height + $(this).height();
583
+ // TODO improve approximation
584
+ return close < 10 && close > -10;
585
+ });
586
+
587
+ // TODO try to catch this earlier when scrollTop indicates the last page anyway
588
+ if (!result.length) {
589
+ result = this.element.children(".ui-menu-item:last");
590
+ }
591
+ this.activate(event, result);
592
+ } else {
593
+ this.activate(event, this.element.children(".ui-menu-item")
594
+ .filter(!this.active || this.last() ? ":first" : ":last"));
595
+ }
596
+ },
597
+
598
+ // TODO merge with nextPage
599
+ previousPage: function(event) {
600
+ if (this.hasScroll()) {
601
+ // TODO merge with no-scroll-else
602
+ if (!this.active || this.first()) {
603
+ this.activate(event, this.element.children(".ui-menu-item:last"));
604
+ return;
605
+ }
606
+
607
+ var base = this.active.offset().top,
608
+ height = this.element.height(),
609
+ result = this.element.children(".ui-menu-item").filter(function() {
610
+ var close = $(this).offset().top - base + height - $(this).height();
611
+ // TODO improve approximation
612
+ return close < 10 && close > -10;
613
+ });
614
+
615
+ // TODO try to catch this earlier when scrollTop indicates the last page anyway
616
+ if (!result.length) {
617
+ result = this.element.children(".ui-menu-item:first");
618
+ }
619
+ this.activate(event, result);
620
+ } else {
621
+ this.activate(event, this.element.children(".ui-menu-item")
622
+ .filter(!this.active || this.first() ? ":last" : ":first"));
623
+ }
624
+ },
625
+
626
+ hasScroll: function() {
627
+ return this.element.height() < this.element[ $.fn.prop ? "prop" : "attr" ]("scrollHeight");
628
+ },
629
+
630
+ select: function( event ) {
631
+ this._trigger("selected", event, { item: this.active });
632
+ }
633
+ });
634
+
635
+ }(jQuery));