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