jquery-ui-middleman 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +2 -0
  5. data/Gemfile +3 -0
  6. data/History.md +115 -0
  7. data/License.txt +2 -0
  8. data/README.md +226 -0
  9. data/Rakefile +221 -0
  10. data/VERSIONS.md +27 -0
  11. data/app/assets/images/jquery-ui/animated-overlay.gif +0 -0
  12. data/app/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  13. data/app/assets/images/jquery-ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  14. data/app/assets/images/jquery-ui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  15. data/app/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  16. data/app/assets/images/jquery-ui/ui-bg_glass_75_dadada_1x400.png +0 -0
  17. data/app/assets/images/jquery-ui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  18. data/app/assets/images/jquery-ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  19. data/app/assets/images/jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  20. data/app/assets/images/jquery-ui/ui-icons_222222_256x240.png +0 -0
  21. data/app/assets/images/jquery-ui/ui-icons_2e83ff_256x240.png +0 -0
  22. data/app/assets/images/jquery-ui/ui-icons_454545_256x240.png +0 -0
  23. data/app/assets/images/jquery-ui/ui-icons_888888_256x240.png +0 -0
  24. data/app/assets/images/jquery-ui/ui-icons_cd0a0a_256x240.png +0 -0
  25. data/app/assets/javascripts/jquery.ui.accordion.js +575 -0
  26. data/app/assets/javascripts/jquery.ui.all.js +34 -0
  27. data/app/assets/javascripts/jquery.ui.autocomplete.js +615 -0
  28. data/app/assets/javascripts/jquery.ui.button.js +422 -0
  29. data/app/assets/javascripts/jquery.ui.core.js +320 -0
  30. data/app/assets/javascripts/jquery.ui.datepicker-af.js +23 -0
  31. data/app/assets/javascripts/jquery.ui.datepicker-ar-DZ.js +23 -0
  32. data/app/assets/javascripts/jquery.ui.datepicker-ar.js +23 -0
  33. data/app/assets/javascripts/jquery.ui.datepicker-az.js +23 -0
  34. data/app/assets/javascripts/jquery.ui.datepicker-be.js +23 -0
  35. data/app/assets/javascripts/jquery.ui.datepicker-bg.js +24 -0
  36. data/app/assets/javascripts/jquery.ui.datepicker-bs.js +23 -0
  37. data/app/assets/javascripts/jquery.ui.datepicker-ca.js +23 -0
  38. data/app/assets/javascripts/jquery.ui.datepicker-cs.js +23 -0
  39. data/app/assets/javascripts/jquery.ui.datepicker-cy-GB.js +23 -0
  40. data/app/assets/javascripts/jquery.ui.datepicker-da.js +23 -0
  41. data/app/assets/javascripts/jquery.ui.datepicker-de.js +23 -0
  42. data/app/assets/javascripts/jquery.ui.datepicker-el.js +23 -0
  43. data/app/assets/javascripts/jquery.ui.datepicker-en-AU.js +23 -0
  44. data/app/assets/javascripts/jquery.ui.datepicker-en-GB.js +23 -0
  45. data/app/assets/javascripts/jquery.ui.datepicker-en-NZ.js +23 -0
  46. data/app/assets/javascripts/jquery.ui.datepicker-eo.js +23 -0
  47. data/app/assets/javascripts/jquery.ui.datepicker-es.js +23 -0
  48. data/app/assets/javascripts/jquery.ui.datepicker-et.js +23 -0
  49. data/app/assets/javascripts/jquery.ui.datepicker-eu.js +23 -0
  50. data/app/assets/javascripts/jquery.ui.datepicker-fa.js +59 -0
  51. data/app/assets/javascripts/jquery.ui.datepicker-fi.js +23 -0
  52. data/app/assets/javascripts/jquery.ui.datepicker-fo.js +23 -0
  53. data/app/assets/javascripts/jquery.ui.datepicker-fr-CA.js +23 -0
  54. data/app/assets/javascripts/jquery.ui.datepicker-fr-CH.js +23 -0
  55. data/app/assets/javascripts/jquery.ui.datepicker-fr.js +25 -0
  56. data/app/assets/javascripts/jquery.ui.datepicker-gl.js +23 -0
  57. data/app/assets/javascripts/jquery.ui.datepicker-he.js +23 -0
  58. data/app/assets/javascripts/jquery.ui.datepicker-hi.js +23 -0
  59. data/app/assets/javascripts/jquery.ui.datepicker-hr.js +23 -0
  60. data/app/assets/javascripts/jquery.ui.datepicker-hu.js +23 -0
  61. data/app/assets/javascripts/jquery.ui.datepicker-hy.js +23 -0
  62. data/app/assets/javascripts/jquery.ui.datepicker-id.js +23 -0
  63. data/app/assets/javascripts/jquery.ui.datepicker-is.js +23 -0
  64. data/app/assets/javascripts/jquery.ui.datepicker-it.js +23 -0
  65. data/app/assets/javascripts/jquery.ui.datepicker-ja.js +23 -0
  66. data/app/assets/javascripts/jquery.ui.datepicker-ka.js +21 -0
  67. data/app/assets/javascripts/jquery.ui.datepicker-kk.js +23 -0
  68. data/app/assets/javascripts/jquery.ui.datepicker-km.js +23 -0
  69. data/app/assets/javascripts/jquery.ui.datepicker-ko.js +23 -0
  70. data/app/assets/javascripts/jquery.ui.datepicker-ky.js +24 -0
  71. data/app/assets/javascripts/jquery.ui.datepicker-lb.js +23 -0
  72. data/app/assets/javascripts/jquery.ui.datepicker-lt.js +23 -0
  73. data/app/assets/javascripts/jquery.ui.datepicker-lv.js +23 -0
  74. data/app/assets/javascripts/jquery.ui.datepicker-mk.js +23 -0
  75. data/app/assets/javascripts/jquery.ui.datepicker-ml.js +23 -0
  76. data/app/assets/javascripts/jquery.ui.datepicker-ms.js +23 -0
  77. data/app/assets/javascripts/jquery.ui.datepicker-nb.js +22 -0
  78. data/app/assets/javascripts/jquery.ui.datepicker-nl-BE.js +23 -0
  79. data/app/assets/javascripts/jquery.ui.datepicker-nl.js +23 -0
  80. data/app/assets/javascripts/jquery.ui.datepicker-nn.js +22 -0
  81. data/app/assets/javascripts/jquery.ui.datepicker-no.js +23 -0
  82. data/app/assets/javascripts/jquery.ui.datepicker-pl.js +23 -0
  83. data/app/assets/javascripts/jquery.ui.datepicker-pt-BR.js +23 -0
  84. data/app/assets/javascripts/jquery.ui.datepicker-pt.js +22 -0
  85. data/app/assets/javascripts/jquery.ui.datepicker-rm.js +21 -0
  86. data/app/assets/javascripts/jquery.ui.datepicker-ro.js +26 -0
  87. data/app/assets/javascripts/jquery.ui.datepicker-ru.js +23 -0
  88. data/app/assets/javascripts/jquery.ui.datepicker-sk.js +23 -0
  89. data/app/assets/javascripts/jquery.ui.datepicker-sl.js +24 -0
  90. data/app/assets/javascripts/jquery.ui.datepicker-sq.js +23 -0
  91. data/app/assets/javascripts/jquery.ui.datepicker-sr-SR.js +23 -0
  92. data/app/assets/javascripts/jquery.ui.datepicker-sr.js +23 -0
  93. data/app/assets/javascripts/jquery.ui.datepicker-sv.js +23 -0
  94. data/app/assets/javascripts/jquery.ui.datepicker-ta.js +23 -0
  95. data/app/assets/javascripts/jquery.ui.datepicker-th.js +23 -0
  96. data/app/assets/javascripts/jquery.ui.datepicker-tj.js +23 -0
  97. data/app/assets/javascripts/jquery.ui.datepicker-tr.js +23 -0
  98. data/app/assets/javascripts/jquery.ui.datepicker-uk.js +24 -0
  99. data/app/assets/javascripts/jquery.ui.datepicker-vi.js +23 -0
  100. data/app/assets/javascripts/jquery.ui.datepicker-zh-CN.js +23 -0
  101. data/app/assets/javascripts/jquery.ui.datepicker-zh-HK.js +23 -0
  102. data/app/assets/javascripts/jquery.ui.datepicker-zh-TW.js +23 -0
  103. data/app/assets/javascripts/jquery.ui.datepicker.js +2040 -0
  104. data/app/assets/javascripts/jquery.ui.dialog.js +815 -0
  105. data/app/assets/javascripts/jquery.ui.draggable.js +962 -0
  106. data/app/assets/javascripts/jquery.ui.droppable.js +377 -0
  107. data/app/assets/javascripts/jquery.ui.effect-blind.js +84 -0
  108. data/app/assets/javascripts/jquery.ui.effect-bounce.js +115 -0
  109. data/app/assets/javascripts/jquery.ui.effect-clip.js +69 -0
  110. data/app/assets/javascripts/jquery.ui.effect-drop.js +67 -0
  111. data/app/assets/javascripts/jquery.ui.effect-explode.js +99 -0
  112. data/app/assets/javascripts/jquery.ui.effect-fade.js +32 -0
  113. data/app/assets/javascripts/jquery.ui.effect-fold.js +78 -0
  114. data/app/assets/javascripts/jquery.ui.effect-highlight.js +52 -0
  115. data/app/assets/javascripts/jquery.ui.effect-pulsate.js +65 -0
  116. data/app/assets/javascripts/jquery.ui.effect-scale.js +320 -0
  117. data/app/assets/javascripts/jquery.ui.effect-shake.js +76 -0
  118. data/app/assets/javascripts/jquery.ui.effect-slide.js +66 -0
  119. data/app/assets/javascripts/jquery.ui.effect-transfer.js +49 -0
  120. data/app/assets/javascripts/jquery.ui.effect.all.js +14 -0
  121. data/app/assets/javascripts/jquery.ui.effect.js +1289 -0
  122. data/app/assets/javascripts/jquery.ui.menu.js +625 -0
  123. data/app/assets/javascripts/jquery.ui.mouse.js +172 -0
  124. data/app/assets/javascripts/jquery.ui.position.js +497 -0
  125. data/app/assets/javascripts/jquery.ui.progressbar.js +148 -0
  126. data/app/assets/javascripts/jquery.ui.resizable.js +972 -0
  127. data/app/assets/javascripts/jquery.ui.selectable.js +281 -0
  128. data/app/assets/javascripts/jquery.ui.slider.js +676 -0
  129. data/app/assets/javascripts/jquery.ui.sortable.js +1289 -0
  130. data/app/assets/javascripts/jquery.ui.spinner.js +497 -0
  131. data/app/assets/javascripts/jquery.ui.tabs.js +849 -0
  132. data/app/assets/javascripts/jquery.ui.tooltip.js +406 -0
  133. data/app/assets/javascripts/jquery.ui.widget.js +521 -0
  134. data/app/assets/stylesheets/jquery.ui.accordion.css.erb +42 -0
  135. data/app/assets/stylesheets/jquery.ui.all.css.erb +14 -0
  136. data/app/assets/stylesheets/jquery.ui.autocomplete.css.erb +21 -0
  137. data/app/assets/stylesheets/jquery.ui.base.css.erb +27 -0
  138. data/app/assets/stylesheets/jquery.ui.button.css.erb +118 -0
  139. data/app/assets/stylesheets/jquery.ui.core.css.erb +93 -0
  140. data/app/assets/stylesheets/jquery.ui.datepicker.css.erb +182 -0
  141. data/app/assets/stylesheets/jquery.ui.dialog.css.erb +75 -0
  142. data/app/assets/stylesheets/jquery.ui.menu.css.erb +83 -0
  143. data/app/assets/stylesheets/jquery.ui.progressbar.css.erb +32 -0
  144. data/app/assets/stylesheets/jquery.ui.resizable.css.erb +82 -0
  145. data/app/assets/stylesheets/jquery.ui.selectable.css.erb +19 -0
  146. data/app/assets/stylesheets/jquery.ui.slider.css.erb +77 -0
  147. data/app/assets/stylesheets/jquery.ui.spinner.css.erb +70 -0
  148. data/app/assets/stylesheets/jquery.ui.tabs.css.erb +56 -0
  149. data/app/assets/stylesheets/jquery.ui.theme.css.erb +409 -0
  150. data/app/assets/stylesheets/jquery.ui.tooltip.css.erb +23 -0
  151. data/lib/jquery-ui-middleman.rb +1 -0
  152. data/lib/jquery/ui/version.rb +6 -0
  153. metadata +209 -0
@@ -0,0 +1,34 @@
1
+ //= require jquery.ui.accordion
2
+ //= require jquery.ui.autocomplete
3
+ //= require jquery.ui.button
4
+ //= require jquery.ui.core
5
+ //= require jquery.ui.datepicker
6
+ //= require jquery.ui.dialog
7
+ //= require jquery.ui.draggable
8
+ //= require jquery.ui.droppable
9
+ //= require jquery.ui.effect-blind
10
+ //= require jquery.ui.effect-bounce
11
+ //= require jquery.ui.effect-clip
12
+ //= require jquery.ui.effect-drop
13
+ //= require jquery.ui.effect-explode
14
+ //= require jquery.ui.effect-fade
15
+ //= require jquery.ui.effect-fold
16
+ //= require jquery.ui.effect-highlight
17
+ //= require jquery.ui.effect-pulsate
18
+ //= require jquery.ui.effect-scale
19
+ //= require jquery.ui.effect-shake
20
+ //= require jquery.ui.effect-slide
21
+ //= require jquery.ui.effect-transfer
22
+ //= require jquery.ui.effect
23
+ //= require jquery.ui.menu
24
+ //= require jquery.ui.mouse
25
+ //= require jquery.ui.position
26
+ //= require jquery.ui.progressbar
27
+ //= require jquery.ui.resizable
28
+ //= require jquery.ui.selectable
29
+ //= require jquery.ui.slider
30
+ //= require jquery.ui.sortable
31
+ //= require jquery.ui.spinner
32
+ //= require jquery.ui.tabs
33
+ //= require jquery.ui.tooltip
34
+ //= require jquery.ui.widget
@@ -0,0 +1,615 @@
1
+ //= require jquery.ui.core
2
+ //= require jquery.ui.widget
3
+ //= require jquery.ui.menu
4
+ //= require jquery.ui.position
5
+
6
+ /*!
7
+ * jQuery UI Autocomplete 1.10.3
8
+ * http://jqueryui.com
9
+ *
10
+ * Copyright 2013 jQuery Foundation and other contributors
11
+ * Released under the MIT license.
12
+ * http://jquery.org/license
13
+ *
14
+ * http://api.jqueryui.com/autocomplete/
15
+ *
16
+ * Depends:
17
+ * jquery.ui.core.js
18
+ * jquery.ui.widget.js
19
+ * jquery.ui.position.js
20
+ * jquery.ui.menu.js
21
+ */
22
+ (function( $, undefined ) {
23
+
24
+ // used to prevent race conditions with remote data sources
25
+ var requestIndex = 0;
26
+
27
+ $.widget( "ui.autocomplete", {
28
+ version: "1.10.3",
29
+ defaultElement: "<input>",
30
+ options: {
31
+ appendTo: null,
32
+ autoFocus: false,
33
+ delay: 300,
34
+ minLength: 1,
35
+ position: {
36
+ my: "left top",
37
+ at: "left bottom",
38
+ collision: "none"
39
+ },
40
+ source: null,
41
+
42
+ // callbacks
43
+ change: null,
44
+ close: null,
45
+ focus: null,
46
+ open: null,
47
+ response: null,
48
+ search: null,
49
+ select: null
50
+ },
51
+
52
+ pending: 0,
53
+
54
+ _create: function() {
55
+ // Some browsers only repeat keydown events, not keypress events,
56
+ // so we use the suppressKeyPress flag to determine if we've already
57
+ // handled the keydown event. #7269
58
+ // Unfortunately the code for & in keypress is the same as the up arrow,
59
+ // so we use the suppressKeyPressRepeat flag to avoid handling keypress
60
+ // events when we know the keydown event was used to modify the
61
+ // search term. #7799
62
+ var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
63
+ nodeName = this.element[0].nodeName.toLowerCase(),
64
+ isTextarea = nodeName === "textarea",
65
+ isInput = nodeName === "input";
66
+
67
+ this.isMultiLine =
68
+ // Textareas are always multi-line
69
+ isTextarea ? true :
70
+ // Inputs are always single-line, even if inside a contentEditable element
71
+ // IE also treats inputs as contentEditable
72
+ isInput ? false :
73
+ // All other element types are determined by whether or not they're contentEditable
74
+ this.element.prop( "isContentEditable" );
75
+
76
+ this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
77
+ this.isNewMenu = true;
78
+
79
+ this.element
80
+ .addClass( "ui-autocomplete-input" )
81
+ .attr( "autocomplete", "off" );
82
+
83
+ this._on( this.element, {
84
+ keydown: function( event ) {
85
+ /*jshint maxcomplexity:15*/
86
+ if ( this.element.prop( "readOnly" ) ) {
87
+ suppressKeyPress = true;
88
+ suppressInput = true;
89
+ suppressKeyPressRepeat = true;
90
+ return;
91
+ }
92
+
93
+ suppressKeyPress = false;
94
+ suppressInput = false;
95
+ suppressKeyPressRepeat = false;
96
+ var keyCode = $.ui.keyCode;
97
+ switch( event.keyCode ) {
98
+ case keyCode.PAGE_UP:
99
+ suppressKeyPress = true;
100
+ this._move( "previousPage", event );
101
+ break;
102
+ case keyCode.PAGE_DOWN:
103
+ suppressKeyPress = true;
104
+ this._move( "nextPage", event );
105
+ break;
106
+ case keyCode.UP:
107
+ suppressKeyPress = true;
108
+ this._keyEvent( "previous", event );
109
+ break;
110
+ case keyCode.DOWN:
111
+ suppressKeyPress = true;
112
+ this._keyEvent( "next", event );
113
+ break;
114
+ case keyCode.ENTER:
115
+ case keyCode.NUMPAD_ENTER:
116
+ // when menu is open and has focus
117
+ if ( this.menu.active ) {
118
+ // #6055 - Opera still allows the keypress to occur
119
+ // which causes forms to submit
120
+ suppressKeyPress = true;
121
+ event.preventDefault();
122
+ this.menu.select( event );
123
+ }
124
+ break;
125
+ case keyCode.TAB:
126
+ if ( this.menu.active ) {
127
+ this.menu.select( event );
128
+ }
129
+ break;
130
+ case keyCode.ESCAPE:
131
+ if ( this.menu.element.is( ":visible" ) ) {
132
+ this._value( this.term );
133
+ this.close( event );
134
+ // Different browsers have different default behavior for escape
135
+ // Single press can mean undo or clear
136
+ // Double press in IE means clear the whole form
137
+ event.preventDefault();
138
+ }
139
+ break;
140
+ default:
141
+ suppressKeyPressRepeat = true;
142
+ // search timeout should be triggered before the input value is changed
143
+ this._searchTimeout( event );
144
+ break;
145
+ }
146
+ },
147
+ keypress: function( event ) {
148
+ if ( suppressKeyPress ) {
149
+ suppressKeyPress = false;
150
+ if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
151
+ event.preventDefault();
152
+ }
153
+ return;
154
+ }
155
+ if ( suppressKeyPressRepeat ) {
156
+ return;
157
+ }
158
+
159
+ // replicate some key handlers to allow them to repeat in Firefox and Opera
160
+ var keyCode = $.ui.keyCode;
161
+ switch( event.keyCode ) {
162
+ case keyCode.PAGE_UP:
163
+ this._move( "previousPage", event );
164
+ break;
165
+ case keyCode.PAGE_DOWN:
166
+ this._move( "nextPage", event );
167
+ break;
168
+ case keyCode.UP:
169
+ this._keyEvent( "previous", event );
170
+ break;
171
+ case keyCode.DOWN:
172
+ this._keyEvent( "next", event );
173
+ break;
174
+ }
175
+ },
176
+ input: function( event ) {
177
+ if ( suppressInput ) {
178
+ suppressInput = false;
179
+ event.preventDefault();
180
+ return;
181
+ }
182
+ this._searchTimeout( event );
183
+ },
184
+ focus: function() {
185
+ this.selectedItem = null;
186
+ this.previous = this._value();
187
+ },
188
+ blur: function( event ) {
189
+ if ( this.cancelBlur ) {
190
+ delete this.cancelBlur;
191
+ return;
192
+ }
193
+
194
+ clearTimeout( this.searching );
195
+ this.close( event );
196
+ this._change( event );
197
+ }
198
+ });
199
+
200
+ this._initSource();
201
+ this.menu = $( "<ul>" )
202
+ .addClass( "ui-autocomplete ui-front" )
203
+ .appendTo( this._appendTo() )
204
+ .menu({
205
+ // disable ARIA support, the live region takes care of that
206
+ role: null
207
+ })
208
+ .hide()
209
+ .data( "ui-menu" );
210
+
211
+ this._on( this.menu.element, {
212
+ mousedown: function( event ) {
213
+ // prevent moving focus out of the text field
214
+ event.preventDefault();
215
+
216
+ // IE doesn't prevent moving focus even with event.preventDefault()
217
+ // so we set a flag to know when we should ignore the blur event
218
+ this.cancelBlur = true;
219
+ this._delay(function() {
220
+ delete this.cancelBlur;
221
+ });
222
+
223
+ // clicking on the scrollbar causes focus to shift to the body
224
+ // but we can't detect a mouseup or a click immediately afterward
225
+ // so we have to track the next mousedown and close the menu if
226
+ // the user clicks somewhere outside of the autocomplete
227
+ var menuElement = this.menu.element[ 0 ];
228
+ if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
229
+ this._delay(function() {
230
+ var that = this;
231
+ this.document.one( "mousedown", function( event ) {
232
+ if ( event.target !== that.element[ 0 ] &&
233
+ event.target !== menuElement &&
234
+ !$.contains( menuElement, event.target ) ) {
235
+ that.close();
236
+ }
237
+ });
238
+ });
239
+ }
240
+ },
241
+ menufocus: function( event, ui ) {
242
+ // support: Firefox
243
+ // Prevent accidental activation of menu items in Firefox (#7024 #9118)
244
+ if ( this.isNewMenu ) {
245
+ this.isNewMenu = false;
246
+ if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
247
+ this.menu.blur();
248
+
249
+ this.document.one( "mousemove", function() {
250
+ $( event.target ).trigger( event.originalEvent );
251
+ });
252
+
253
+ return;
254
+ }
255
+ }
256
+
257
+ var item = ui.item.data( "ui-autocomplete-item" );
258
+ if ( false !== this._trigger( "focus", event, { item: item } ) ) {
259
+ // use value to match what will end up in the input, if it was a key event
260
+ if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
261
+ this._value( item.value );
262
+ }
263
+ } else {
264
+ // Normally the input is populated with the item's value as the
265
+ // menu is navigated, causing screen readers to notice a change and
266
+ // announce the item. Since the focus event was canceled, this doesn't
267
+ // happen, so we update the live region so that screen readers can
268
+ // still notice the change and announce it.
269
+ this.liveRegion.text( item.value );
270
+ }
271
+ },
272
+ menuselect: function( event, ui ) {
273
+ var item = ui.item.data( "ui-autocomplete-item" ),
274
+ previous = this.previous;
275
+
276
+ // only trigger when focus was lost (click on menu)
277
+ if ( this.element[0] !== this.document[0].activeElement ) {
278
+ this.element.focus();
279
+ this.previous = previous;
280
+ // #6109 - IE triggers two focus events and the second
281
+ // is asynchronous, so we need to reset the previous
282
+ // term synchronously and asynchronously :-(
283
+ this._delay(function() {
284
+ this.previous = previous;
285
+ this.selectedItem = item;
286
+ });
287
+ }
288
+
289
+ if ( false !== this._trigger( "select", event, { item: item } ) ) {
290
+ this._value( item.value );
291
+ }
292
+ // reset the term after the select event
293
+ // this allows custom select handling to work properly
294
+ this.term = this._value();
295
+
296
+ this.close( event );
297
+ this.selectedItem = item;
298
+ }
299
+ });
300
+
301
+ this.liveRegion = $( "<span>", {
302
+ role: "status",
303
+ "aria-live": "polite"
304
+ })
305
+ .addClass( "ui-helper-hidden-accessible" )
306
+ .insertBefore( this.element );
307
+
308
+ // turning off autocomplete prevents the browser from remembering the
309
+ // value when navigating through history, so we re-enable autocomplete
310
+ // if the page is unloaded before the widget is destroyed. #7790
311
+ this._on( this.window, {
312
+ beforeunload: function() {
313
+ this.element.removeAttr( "autocomplete" );
314
+ }
315
+ });
316
+ },
317
+
318
+ _destroy: function() {
319
+ clearTimeout( this.searching );
320
+ this.element
321
+ .removeClass( "ui-autocomplete-input" )
322
+ .removeAttr( "autocomplete" );
323
+ this.menu.element.remove();
324
+ this.liveRegion.remove();
325
+ },
326
+
327
+ _setOption: function( key, value ) {
328
+ this._super( key, value );
329
+ if ( key === "source" ) {
330
+ this._initSource();
331
+ }
332
+ if ( key === "appendTo" ) {
333
+ this.menu.element.appendTo( this._appendTo() );
334
+ }
335
+ if ( key === "disabled" && value && this.xhr ) {
336
+ this.xhr.abort();
337
+ }
338
+ },
339
+
340
+ _appendTo: function() {
341
+ var element = this.options.appendTo;
342
+
343
+ if ( element ) {
344
+ element = element.jquery || element.nodeType ?
345
+ $( element ) :
346
+ this.document.find( element ).eq( 0 );
347
+ }
348
+
349
+ if ( !element ) {
350
+ element = this.element.closest( ".ui-front" );
351
+ }
352
+
353
+ if ( !element.length ) {
354
+ element = this.document[0].body;
355
+ }
356
+
357
+ return element;
358
+ },
359
+
360
+ _initSource: function() {
361
+ var array, url,
362
+ that = this;
363
+ if ( $.isArray(this.options.source) ) {
364
+ array = this.options.source;
365
+ this.source = function( request, response ) {
366
+ response( $.ui.autocomplete.filter( array, request.term ) );
367
+ };
368
+ } else if ( typeof this.options.source === "string" ) {
369
+ url = this.options.source;
370
+ this.source = function( request, response ) {
371
+ if ( that.xhr ) {
372
+ that.xhr.abort();
373
+ }
374
+ that.xhr = $.ajax({
375
+ url: url,
376
+ data: request,
377
+ dataType: "json",
378
+ success: function( data ) {
379
+ response( data );
380
+ },
381
+ error: function() {
382
+ response( [] );
383
+ }
384
+ });
385
+ };
386
+ } else {
387
+ this.source = this.options.source;
388
+ }
389
+ },
390
+
391
+ _searchTimeout: function( event ) {
392
+ clearTimeout( this.searching );
393
+ this.searching = this._delay(function() {
394
+ // only search if the value has changed
395
+ if ( this.term !== this._value() ) {
396
+ this.selectedItem = null;
397
+ this.search( null, event );
398
+ }
399
+ }, this.options.delay );
400
+ },
401
+
402
+ search: function( value, event ) {
403
+ value = value != null ? value : this._value();
404
+
405
+ // always save the actual value, not the one passed as an argument
406
+ this.term = this._value();
407
+
408
+ if ( value.length < this.options.minLength ) {
409
+ return this.close( event );
410
+ }
411
+
412
+ if ( this._trigger( "search", event ) === false ) {
413
+ return;
414
+ }
415
+
416
+ return this._search( value );
417
+ },
418
+
419
+ _search: function( value ) {
420
+ this.pending++;
421
+ this.element.addClass( "ui-autocomplete-loading" );
422
+ this.cancelSearch = false;
423
+
424
+ this.source( { term: value }, this._response() );
425
+ },
426
+
427
+ _response: function() {
428
+ var that = this,
429
+ index = ++requestIndex;
430
+
431
+ return function( content ) {
432
+ if ( index === requestIndex ) {
433
+ that.__response( content );
434
+ }
435
+
436
+ that.pending--;
437
+ if ( !that.pending ) {
438
+ that.element.removeClass( "ui-autocomplete-loading" );
439
+ }
440
+ };
441
+ },
442
+
443
+ __response: function( content ) {
444
+ if ( content ) {
445
+ content = this._normalize( content );
446
+ }
447
+ this._trigger( "response", null, { content: content } );
448
+ if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
449
+ this._suggest( content );
450
+ this._trigger( "open" );
451
+ } else {
452
+ // use ._close() instead of .close() so we don't cancel future searches
453
+ this._close();
454
+ }
455
+ },
456
+
457
+ close: function( event ) {
458
+ this.cancelSearch = true;
459
+ this._close( event );
460
+ },
461
+
462
+ _close: function( event ) {
463
+ if ( this.menu.element.is( ":visible" ) ) {
464
+ this.menu.element.hide();
465
+ this.menu.blur();
466
+ this.isNewMenu = true;
467
+ this._trigger( "close", event );
468
+ }
469
+ },
470
+
471
+ _change: function( event ) {
472
+ if ( this.previous !== this._value() ) {
473
+ this._trigger( "change", event, { item: this.selectedItem } );
474
+ }
475
+ },
476
+
477
+ _normalize: function( items ) {
478
+ // assume all items have the right format when the first item is complete
479
+ if ( items.length && items[0].label && items[0].value ) {
480
+ return items;
481
+ }
482
+ return $.map( items, function( item ) {
483
+ if ( typeof item === "string" ) {
484
+ return {
485
+ label: item,
486
+ value: item
487
+ };
488
+ }
489
+ return $.extend({
490
+ label: item.label || item.value,
491
+ value: item.value || item.label
492
+ }, item );
493
+ });
494
+ },
495
+
496
+ _suggest: function( items ) {
497
+ var ul = this.menu.element.empty();
498
+ this._renderMenu( ul, items );
499
+ this.isNewMenu = true;
500
+ this.menu.refresh();
501
+
502
+ // size and position menu
503
+ ul.show();
504
+ this._resizeMenu();
505
+ ul.position( $.extend({
506
+ of: this.element
507
+ }, this.options.position ));
508
+
509
+ if ( this.options.autoFocus ) {
510
+ this.menu.next();
511
+ }
512
+ },
513
+
514
+ _resizeMenu: function() {
515
+ var ul = this.menu.element;
516
+ ul.outerWidth( Math.max(
517
+ // Firefox wraps long text (possibly a rounding bug)
518
+ // so we add 1px to avoid the wrapping (#7513)
519
+ ul.width( "" ).outerWidth() + 1,
520
+ this.element.outerWidth()
521
+ ) );
522
+ },
523
+
524
+ _renderMenu: function( ul, items ) {
525
+ var that = this;
526
+ $.each( items, function( index, item ) {
527
+ that._renderItemData( ul, item );
528
+ });
529
+ },
530
+
531
+ _renderItemData: function( ul, item ) {
532
+ return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
533
+ },
534
+
535
+ _renderItem: function( ul, item ) {
536
+ return $( "<li>" )
537
+ .append( $( "<a>" ).text( item.label ) )
538
+ .appendTo( ul );
539
+ },
540
+
541
+ _move: function( direction, event ) {
542
+ if ( !this.menu.element.is( ":visible" ) ) {
543
+ this.search( null, event );
544
+ return;
545
+ }
546
+ if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
547
+ this.menu.isLastItem() && /^next/.test( direction ) ) {
548
+ this._value( this.term );
549
+ this.menu.blur();
550
+ return;
551
+ }
552
+ this.menu[ direction ]( event );
553
+ },
554
+
555
+ widget: function() {
556
+ return this.menu.element;
557
+ },
558
+
559
+ _value: function() {
560
+ return this.valueMethod.apply( this.element, arguments );
561
+ },
562
+
563
+ _keyEvent: function( keyEvent, event ) {
564
+ if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
565
+ this._move( keyEvent, event );
566
+
567
+ // prevents moving cursor to beginning/end of the text field in some browsers
568
+ event.preventDefault();
569
+ }
570
+ }
571
+ });
572
+
573
+ $.extend( $.ui.autocomplete, {
574
+ escapeRegex: function( value ) {
575
+ return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
576
+ },
577
+ filter: function(array, term) {
578
+ var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
579
+ return $.grep( array, function(value) {
580
+ return matcher.test( value.label || value.value || value );
581
+ });
582
+ }
583
+ });
584
+
585
+
586
+ // live region extension, adding a `messages` option
587
+ // NOTE: This is an experimental API. We are still investigating
588
+ // a full solution for string manipulation and internationalization.
589
+ $.widget( "ui.autocomplete", $.ui.autocomplete, {
590
+ options: {
591
+ messages: {
592
+ noResults: "No search results.",
593
+ results: function( amount ) {
594
+ return amount + ( amount > 1 ? " results are" : " result is" ) +
595
+ " available, use up and down arrow keys to navigate.";
596
+ }
597
+ }
598
+ },
599
+
600
+ __response: function( content ) {
601
+ var message;
602
+ this._superApply( arguments );
603
+ if ( this.options.disabled || this.cancelSearch ) {
604
+ return;
605
+ }
606
+ if ( content && content.length ) {
607
+ message = this.options.messages.results( content.length );
608
+ } else {
609
+ message = this.options.messages.noResults;
610
+ }
611
+ this.liveRegion.text( message );
612
+ }
613
+ });
614
+
615
+ }( jQuery ));