sn-jquery-ui-rails 6.0.2

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