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,697 @@
1
+ //= require jquery-ui/widgets/menu
2
+ //= require jquery-ui/escape-selector
3
+ //= require jquery-ui/form-reset-mixin
4
+ //= require jquery-ui/keycode
5
+ //= require jquery-ui/labels
6
+ //= require jquery-ui/position
7
+ //= require jquery-ui/unique-id
8
+ //= require jquery-ui/version
9
+ //= require jquery-ui/widget
10
+
11
+ /*!
12
+ * jQuery UI Selectmenu 1.12.1
13
+ * http://jqueryui.com
14
+ *
15
+ * Copyright jQuery Foundation and other contributors
16
+ * Released under the MIT license.
17
+ * http://jquery.org/license
18
+ */
19
+
20
+ //>>label: Selectmenu
21
+ //>>group: Widgets
22
+ // jscs:disable maximumLineLength
23
+ //>>description: Duplicates and extends the functionality of a native HTML select element, allowing it to be customizable in behavior and appearance far beyond the limitations of a native select.
24
+ // jscs:enable maximumLineLength
25
+ //>>docs: http://api.jqueryui.com/selectmenu/
26
+ //>>demos: http://jqueryui.com/selectmenu/
27
+ //>>css.structure: ../../themes/base/core.css
28
+ //>>css.structure: ../../themes/base/selectmenu.css, ../../themes/base/button.css
29
+ //>>css.theme: ../../themes/base/theme.css
30
+
31
+ ( function( factory ) {
32
+ if ( typeof define === "function" && define.amd ) {
33
+
34
+ // AMD. Register as an anonymous module.
35
+ define( [
36
+ "jquery",
37
+ "./menu",
38
+ "../escape-selector",
39
+ "../form-reset-mixin",
40
+ "../keycode",
41
+ "../labels",
42
+ "../position",
43
+ "../unique-id",
44
+ "../version",
45
+ "../widget"
46
+ ], factory );
47
+ } else {
48
+
49
+ // Browser globals
50
+ factory( jQuery );
51
+ }
52
+ }( function( $ ) {
53
+
54
+ return $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
55
+ version: "1.12.1",
56
+ defaultElement: "<select>",
57
+ options: {
58
+ appendTo: null,
59
+ classes: {
60
+ "ui-selectmenu-button-open": "ui-corner-top",
61
+ "ui-selectmenu-button-closed": "ui-corner-all"
62
+ },
63
+ disabled: null,
64
+ icons: {
65
+ button: "ui-icon-triangle-1-s"
66
+ },
67
+ position: {
68
+ my: "left top",
69
+ at: "left bottom",
70
+ collision: "none"
71
+ },
72
+ width: false,
73
+
74
+ // Callbacks
75
+ change: null,
76
+ close: null,
77
+ focus: null,
78
+ open: null,
79
+ select: null
80
+ },
81
+
82
+ _create: function() {
83
+ var selectmenuId = this.element.uniqueId().attr( "id" );
84
+ this.ids = {
85
+ element: selectmenuId,
86
+ button: selectmenuId + "-button",
87
+ menu: selectmenuId + "-menu"
88
+ };
89
+
90
+ this._drawButton();
91
+ this._drawMenu();
92
+ this._bindFormResetHandler();
93
+
94
+ this._rendered = false;
95
+ this.menuItems = $();
96
+ },
97
+
98
+ _drawButton: function() {
99
+ var icon,
100
+ that = this,
101
+ item = this._parseOption(
102
+ this.element.find( "option:selected" ),
103
+ this.element[ 0 ].selectedIndex
104
+ );
105
+
106
+ // Associate existing label with the new button
107
+ this.labels = this.element.labels().attr( "for", this.ids.button );
108
+ this._on( this.labels, {
109
+ click: function( event ) {
110
+ this.button.focus();
111
+ event.preventDefault();
112
+ }
113
+ } );
114
+
115
+ // Hide original select element
116
+ this.element.hide();
117
+
118
+ // Create button
119
+ this.button = $( "<span>", {
120
+ tabindex: this.options.disabled ? -1 : 0,
121
+ id: this.ids.button,
122
+ role: "combobox",
123
+ "aria-expanded": "false",
124
+ "aria-autocomplete": "list",
125
+ "aria-owns": this.ids.menu,
126
+ "aria-haspopup": "true",
127
+ title: this.element.attr( "title" )
128
+ } )
129
+ .insertAfter( this.element );
130
+
131
+ this._addClass( this.button, "ui-selectmenu-button ui-selectmenu-button-closed",
132
+ "ui-button ui-widget" );
133
+
134
+ icon = $( "<span>" ).appendTo( this.button );
135
+ this._addClass( icon, "ui-selectmenu-icon", "ui-icon " + this.options.icons.button );
136
+ this.buttonItem = this._renderButtonItem( item )
137
+ .appendTo( this.button );
138
+
139
+ if ( this.options.width !== false ) {
140
+ this._resizeButton();
141
+ }
142
+
143
+ this._on( this.button, this._buttonEvents );
144
+ this.button.one( "focusin", function() {
145
+
146
+ // Delay rendering the menu items until the button receives focus.
147
+ // The menu may have already been rendered via a programmatic open.
148
+ if ( !that._rendered ) {
149
+ that._refreshMenu();
150
+ }
151
+ } );
152
+ },
153
+
154
+ _drawMenu: function() {
155
+ var that = this;
156
+
157
+ // Create menu
158
+ this.menu = $( "<ul>", {
159
+ "aria-hidden": "true",
160
+ "aria-labelledby": this.ids.button,
161
+ id: this.ids.menu
162
+ } );
163
+
164
+ // Wrap menu
165
+ this.menuWrap = $( "<div>" ).append( this.menu );
166
+ this._addClass( this.menuWrap, "ui-selectmenu-menu", "ui-front" );
167
+ this.menuWrap.appendTo( this._appendTo() );
168
+
169
+ // Initialize menu widget
170
+ this.menuInstance = this.menu
171
+ .menu( {
172
+ classes: {
173
+ "ui-menu": "ui-corner-bottom"
174
+ },
175
+ role: "listbox",
176
+ select: function( event, ui ) {
177
+ event.preventDefault();
178
+
179
+ // Support: IE8
180
+ // If the item was selected via a click, the text selection
181
+ // will be destroyed in IE
182
+ that._setSelection();
183
+
184
+ that._select( ui.item.data( "ui-selectmenu-item" ), event );
185
+ },
186
+ focus: function( event, ui ) {
187
+ var item = ui.item.data( "ui-selectmenu-item" );
188
+
189
+ // Prevent inital focus from firing and check if its a newly focused item
190
+ if ( that.focusIndex != null && item.index !== that.focusIndex ) {
191
+ that._trigger( "focus", event, { item: item } );
192
+ if ( !that.isOpen ) {
193
+ that._select( item, event );
194
+ }
195
+ }
196
+ that.focusIndex = item.index;
197
+
198
+ that.button.attr( "aria-activedescendant",
199
+ that.menuItems.eq( item.index ).attr( "id" ) );
200
+ }
201
+ } )
202
+ .menu( "instance" );
203
+
204
+ // Don't close the menu on mouseleave
205
+ this.menuInstance._off( this.menu, "mouseleave" );
206
+
207
+ // Cancel the menu's collapseAll on document click
208
+ this.menuInstance._closeOnDocumentClick = function() {
209
+ return false;
210
+ };
211
+
212
+ // Selects often contain empty items, but never contain dividers
213
+ this.menuInstance._isDivider = function() {
214
+ return false;
215
+ };
216
+ },
217
+
218
+ refresh: function() {
219
+ this._refreshMenu();
220
+ this.buttonItem.replaceWith(
221
+ this.buttonItem = this._renderButtonItem(
222
+
223
+ // Fall back to an empty object in case there are no options
224
+ this._getSelectedItem().data( "ui-selectmenu-item" ) || {}
225
+ )
226
+ );
227
+ if ( this.options.width === null ) {
228
+ this._resizeButton();
229
+ }
230
+ },
231
+
232
+ _refreshMenu: function() {
233
+ var item,
234
+ options = this.element.find( "option" );
235
+
236
+ this.menu.empty();
237
+
238
+ this._parseOptions( options );
239
+ this._renderMenu( this.menu, this.items );
240
+
241
+ this.menuInstance.refresh();
242
+ this.menuItems = this.menu.find( "li" )
243
+ .not( ".ui-selectmenu-optgroup" )
244
+ .find( ".ui-menu-item-wrapper" );
245
+
246
+ this._rendered = true;
247
+
248
+ if ( !options.length ) {
249
+ return;
250
+ }
251
+
252
+ item = this._getSelectedItem();
253
+
254
+ // Update the menu to have the correct item focused
255
+ this.menuInstance.focus( null, item );
256
+ this._setAria( item.data( "ui-selectmenu-item" ) );
257
+
258
+ // Set disabled state
259
+ this._setOption( "disabled", this.element.prop( "disabled" ) );
260
+ },
261
+
262
+ open: function( event ) {
263
+ if ( this.options.disabled ) {
264
+ return;
265
+ }
266
+
267
+ // If this is the first time the menu is being opened, render the items
268
+ if ( !this._rendered ) {
269
+ this._refreshMenu();
270
+ } else {
271
+
272
+ // Menu clears focus on close, reset focus to selected item
273
+ this._removeClass( this.menu.find( ".ui-state-active" ), null, "ui-state-active" );
274
+ this.menuInstance.focus( null, this._getSelectedItem() );
275
+ }
276
+
277
+ // If there are no options, don't open the menu
278
+ if ( !this.menuItems.length ) {
279
+ return;
280
+ }
281
+
282
+ this.isOpen = true;
283
+ this._toggleAttr();
284
+ this._resizeMenu();
285
+ this._position();
286
+
287
+ this._on( this.document, this._documentClick );
288
+
289
+ this._trigger( "open", event );
290
+ },
291
+
292
+ _position: function() {
293
+ this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
294
+ },
295
+
296
+ close: function( event ) {
297
+ if ( !this.isOpen ) {
298
+ return;
299
+ }
300
+
301
+ this.isOpen = false;
302
+ this._toggleAttr();
303
+
304
+ this.range = null;
305
+ this._off( this.document );
306
+
307
+ this._trigger( "close", event );
308
+ },
309
+
310
+ widget: function() {
311
+ return this.button;
312
+ },
313
+
314
+ menuWidget: function() {
315
+ return this.menu;
316
+ },
317
+
318
+ _renderButtonItem: function( item ) {
319
+ var buttonItem = $( "<span>" );
320
+
321
+ this._setText( buttonItem, item.label );
322
+ this._addClass( buttonItem, "ui-selectmenu-text" );
323
+
324
+ return buttonItem;
325
+ },
326
+
327
+ _renderMenu: function( ul, items ) {
328
+ var that = this,
329
+ currentOptgroup = "";
330
+
331
+ $.each( items, function( index, item ) {
332
+ var li;
333
+
334
+ if ( item.optgroup !== currentOptgroup ) {
335
+ li = $( "<li>", {
336
+ text: item.optgroup
337
+ } );
338
+ that._addClass( li, "ui-selectmenu-optgroup", "ui-menu-divider" +
339
+ ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
340
+ " ui-state-disabled" :
341
+ "" ) );
342
+
343
+ li.appendTo( ul );
344
+
345
+ currentOptgroup = item.optgroup;
346
+ }
347
+
348
+ that._renderItemData( ul, item );
349
+ } );
350
+ },
351
+
352
+ _renderItemData: function( ul, item ) {
353
+ return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
354
+ },
355
+
356
+ _renderItem: function( ul, item ) {
357
+ var li = $( "<li>" ),
358
+ wrapper = $( "<div>", {
359
+ title: item.element.attr( "title" )
360
+ } );
361
+
362
+ if ( item.disabled ) {
363
+ this._addClass( li, null, "ui-state-disabled" );
364
+ }
365
+ this._setText( wrapper, item.label );
366
+
367
+ return li.append( wrapper ).appendTo( ul );
368
+ },
369
+
370
+ _setText: function( element, value ) {
371
+ if ( value ) {
372
+ element.text( value );
373
+ } else {
374
+ element.html( "&#160;" );
375
+ }
376
+ },
377
+
378
+ _move: function( direction, event ) {
379
+ var item, next,
380
+ filter = ".ui-menu-item";
381
+
382
+ if ( this.isOpen ) {
383
+ item = this.menuItems.eq( this.focusIndex ).parent( "li" );
384
+ } else {
385
+ item = this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
386
+ filter += ":not(.ui-state-disabled)";
387
+ }
388
+
389
+ if ( direction === "first" || direction === "last" ) {
390
+ next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
391
+ } else {
392
+ next = item[ direction + "All" ]( filter ).eq( 0 );
393
+ }
394
+
395
+ if ( next.length ) {
396
+ this.menuInstance.focus( event, next );
397
+ }
398
+ },
399
+
400
+ _getSelectedItem: function() {
401
+ return this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
402
+ },
403
+
404
+ _toggle: function( event ) {
405
+ this[ this.isOpen ? "close" : "open" ]( event );
406
+ },
407
+
408
+ _setSelection: function() {
409
+ var selection;
410
+
411
+ if ( !this.range ) {
412
+ return;
413
+ }
414
+
415
+ if ( window.getSelection ) {
416
+ selection = window.getSelection();
417
+ selection.removeAllRanges();
418
+ selection.addRange( this.range );
419
+
420
+ // Support: IE8
421
+ } else {
422
+ this.range.select();
423
+ }
424
+
425
+ // Support: IE
426
+ // Setting the text selection kills the button focus in IE, but
427
+ // restoring the focus doesn't kill the selection.
428
+ this.button.focus();
429
+ },
430
+
431
+ _documentClick: {
432
+ mousedown: function( event ) {
433
+ if ( !this.isOpen ) {
434
+ return;
435
+ }
436
+
437
+ if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" +
438
+ $.ui.escapeSelector( this.ids.button ) ).length ) {
439
+ this.close( event );
440
+ }
441
+ }
442
+ },
443
+
444
+ _buttonEvents: {
445
+
446
+ // Prevent text selection from being reset when interacting with the selectmenu (#10144)
447
+ mousedown: function() {
448
+ var selection;
449
+
450
+ if ( window.getSelection ) {
451
+ selection = window.getSelection();
452
+ if ( selection.rangeCount ) {
453
+ this.range = selection.getRangeAt( 0 );
454
+ }
455
+
456
+ // Support: IE8
457
+ } else {
458
+ this.range = document.selection.createRange();
459
+ }
460
+ },
461
+
462
+ click: function( event ) {
463
+ this._setSelection();
464
+ this._toggle( event );
465
+ },
466
+
467
+ keydown: function( event ) {
468
+ var preventDefault = true;
469
+ switch ( event.keyCode ) {
470
+ case $.ui.keyCode.TAB:
471
+ case $.ui.keyCode.ESCAPE:
472
+ this.close( event );
473
+ preventDefault = false;
474
+ break;
475
+ case $.ui.keyCode.ENTER:
476
+ if ( this.isOpen ) {
477
+ this._selectFocusedItem( event );
478
+ }
479
+ break;
480
+ case $.ui.keyCode.UP:
481
+ if ( event.altKey ) {
482
+ this._toggle( event );
483
+ } else {
484
+ this._move( "prev", event );
485
+ }
486
+ break;
487
+ case $.ui.keyCode.DOWN:
488
+ if ( event.altKey ) {
489
+ this._toggle( event );
490
+ } else {
491
+ this._move( "next", event );
492
+ }
493
+ break;
494
+ case $.ui.keyCode.SPACE:
495
+ if ( this.isOpen ) {
496
+ this._selectFocusedItem( event );
497
+ } else {
498
+ this._toggle( event );
499
+ }
500
+ break;
501
+ case $.ui.keyCode.LEFT:
502
+ this._move( "prev", event );
503
+ break;
504
+ case $.ui.keyCode.RIGHT:
505
+ this._move( "next", event );
506
+ break;
507
+ case $.ui.keyCode.HOME:
508
+ case $.ui.keyCode.PAGE_UP:
509
+ this._move( "first", event );
510
+ break;
511
+ case $.ui.keyCode.END:
512
+ case $.ui.keyCode.PAGE_DOWN:
513
+ this._move( "last", event );
514
+ break;
515
+ default:
516
+ this.menu.trigger( event );
517
+ preventDefault = false;
518
+ }
519
+
520
+ if ( preventDefault ) {
521
+ event.preventDefault();
522
+ }
523
+ }
524
+ },
525
+
526
+ _selectFocusedItem: function( event ) {
527
+ var item = this.menuItems.eq( this.focusIndex ).parent( "li" );
528
+ if ( !item.hasClass( "ui-state-disabled" ) ) {
529
+ this._select( item.data( "ui-selectmenu-item" ), event );
530
+ }
531
+ },
532
+
533
+ _select: function( item, event ) {
534
+ var oldIndex = this.element[ 0 ].selectedIndex;
535
+
536
+ // Change native select element
537
+ this.element[ 0 ].selectedIndex = item.index;
538
+ this.buttonItem.replaceWith( this.buttonItem = this._renderButtonItem( item ) );
539
+ this._setAria( item );
540
+ this._trigger( "select", event, { item: item } );
541
+
542
+ if ( item.index !== oldIndex ) {
543
+ this._trigger( "change", event, { item: item } );
544
+ }
545
+
546
+ this.close( event );
547
+ },
548
+
549
+ _setAria: function( item ) {
550
+ var id = this.menuItems.eq( item.index ).attr( "id" );
551
+
552
+ this.button.attr( {
553
+ "aria-labelledby": id,
554
+ "aria-activedescendant": id
555
+ } );
556
+ this.menu.attr( "aria-activedescendant", id );
557
+ },
558
+
559
+ _setOption: function( key, value ) {
560
+ if ( key === "icons" ) {
561
+ var icon = this.button.find( "span.ui-icon" );
562
+ this._removeClass( icon, null, this.options.icons.button )
563
+ ._addClass( icon, null, value.button );
564
+ }
565
+
566
+ this._super( key, value );
567
+
568
+ if ( key === "appendTo" ) {
569
+ this.menuWrap.appendTo( this._appendTo() );
570
+ }
571
+
572
+ if ( key === "width" ) {
573
+ this._resizeButton();
574
+ }
575
+ },
576
+
577
+ _setOptionDisabled: function( value ) {
578
+ this._super( value );
579
+
580
+ this.menuInstance.option( "disabled", value );
581
+ this.button.attr( "aria-disabled", value );
582
+ this._toggleClass( this.button, null, "ui-state-disabled", value );
583
+
584
+ this.element.prop( "disabled", value );
585
+ if ( value ) {
586
+ this.button.attr( "tabindex", -1 );
587
+ this.close();
588
+ } else {
589
+ this.button.attr( "tabindex", 0 );
590
+ }
591
+ },
592
+
593
+ _appendTo: function() {
594
+ var element = this.options.appendTo;
595
+
596
+ if ( element ) {
597
+ element = element.jquery || element.nodeType ?
598
+ $( element ) :
599
+ this.document.find( element ).eq( 0 );
600
+ }
601
+
602
+ if ( !element || !element[ 0 ] ) {
603
+ element = this.element.closest( ".ui-front, dialog" );
604
+ }
605
+
606
+ if ( !element.length ) {
607
+ element = this.document[ 0 ].body;
608
+ }
609
+
610
+ return element;
611
+ },
612
+
613
+ _toggleAttr: function() {
614
+ this.button.attr( "aria-expanded", this.isOpen );
615
+
616
+ // We can't use two _toggleClass() calls here, because we need to make sure
617
+ // we always remove classes first and add them second, otherwise if both classes have the
618
+ // same theme class, it will be removed after we add it.
619
+ this._removeClass( this.button, "ui-selectmenu-button-" +
620
+ ( this.isOpen ? "closed" : "open" ) )
621
+ ._addClass( this.button, "ui-selectmenu-button-" +
622
+ ( this.isOpen ? "open" : "closed" ) )
623
+ ._toggleClass( this.menuWrap, "ui-selectmenu-open", null, this.isOpen );
624
+
625
+ this.menu.attr( "aria-hidden", !this.isOpen );
626
+ },
627
+
628
+ _resizeButton: function() {
629
+ var width = this.options.width;
630
+
631
+ // For `width: false`, just remove inline style and stop
632
+ if ( width === false ) {
633
+ this.button.css( "width", "" );
634
+ return;
635
+ }
636
+
637
+ // For `width: null`, match the width of the original element
638
+ if ( width === null ) {
639
+ width = this.element.show().outerWidth();
640
+ this.element.hide();
641
+ }
642
+
643
+ this.button.outerWidth( width );
644
+ },
645
+
646
+ _resizeMenu: function() {
647
+ this.menu.outerWidth( Math.max(
648
+ this.button.outerWidth(),
649
+
650
+ // Support: IE10
651
+ // IE10 wraps long text (possibly a rounding bug)
652
+ // so we add 1px to avoid the wrapping
653
+ this.menu.width( "" ).outerWidth() + 1
654
+ ) );
655
+ },
656
+
657
+ _getCreateOptions: function() {
658
+ var options = this._super();
659
+
660
+ options.disabled = this.element.prop( "disabled" );
661
+
662
+ return options;
663
+ },
664
+
665
+ _parseOptions: function( options ) {
666
+ var that = this,
667
+ data = [];
668
+ options.each( function( index, item ) {
669
+ data.push( that._parseOption( $( item ), index ) );
670
+ } );
671
+ this.items = data;
672
+ },
673
+
674
+ _parseOption: function( option, index ) {
675
+ var optgroup = option.parent( "optgroup" );
676
+
677
+ return {
678
+ element: option,
679
+ index: index,
680
+ value: option.val(),
681
+ label: option.text(),
682
+ optgroup: optgroup.attr( "label" ) || "",
683
+ disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
684
+ };
685
+ },
686
+
687
+ _destroy: function() {
688
+ this._unbindFormResetHandler();
689
+ this.menuWrap.remove();
690
+ this.button.remove();
691
+ this.element.show();
692
+ this.element.removeUniqueId();
693
+ this.labels.attr( "for", this.ids.element );
694
+ }
695
+ } ] );
696
+
697
+ } ) );