jquery-ui-rails-dox-fork 7.0.2

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