@@ -17,12 +17,12 @@ $.widget("ui.menu", {
17
17
_create : function ( ) {
18
18
var self = this ;
19
19
this . element
20
- . addClass ( "ui-menu ui-widget ui-widget-content ui-corner-all" )
20
+ . addClass ( "ui-menu ui-widget ui-widget-content ui-corner-all" )
21
21
. attr ( {
22
22
role : "listbox" ,
23
23
"aria-activedescendant" : "ui-active-menuitem"
24
24
} )
25
- . bind ( "click.menu" , function ( event ) {
25
+ . bind ( "click.menu" , function ( event ) {
26
26
if ( self . options . disabled ) {
27
27
return false ;
28
28
}
@@ -33,7 +33,7 @@ $.widget("ui.menu", {
33
33
event . preventDefault ( ) ;
34
34
self . select ( event ) ;
35
35
} )
36
- . bind ( "mouseover.menu" , function ( event ) {
36
+ . bind ( "mouseover.menu" , function ( event ) {
37
37
if ( self . options . disabled ) {
38
38
return ;
39
39
}
@@ -50,17 +50,17 @@ $.widget("ui.menu", {
50
50
if ( target . length && target . parent ( ) [ 0 ] === self . element [ 0 ] ) {
51
51
self . deactivate ( event ) ;
52
52
}
53
- } ) ; ;
53
+ } ) ;
54
54
this . refresh ( ) ;
55
55
56
- if ( ! this . options . input ) {
57
- this . options . input = this . element . attr ( "tabIndex" , 0 ) ;
56
+ if ( ! this . options . input ) {
57
+ this . options . input = this . element . attr ( "tabIndex" , 0 ) ;
58
58
}
59
- this . options . input . bind ( "keydown.menu" , function ( event ) {
60
- if ( self . options . disabled ) {
59
+ this . options . input . bind ( "keydown.menu" , function ( event ) {
60
+ if ( self . options . disabled ) {
61
61
return ;
62
62
}
63
- switch ( event . keyCode ) {
63
+ switch ( event . keyCode ) {
64
64
case $ . ui . keyCode . PAGE_UP :
65
65
self . previousPage ( ) ;
66
66
event . preventDefault ( ) ;
@@ -91,153 +91,153 @@ $.widget("ui.menu", {
91
91
} ,
92
92
93
93
destroy : function ( ) {
94
- $ . Widget . prototype . destroy . apply ( this , arguments ) ;
94
+ $ . Widget . prototype . destroy . apply ( this , arguments ) ;
95
95
96
96
this . element
97
- . removeClass ( "ui-menu ui-widget ui-widget-content ui-corner-all" )
98
- . removeAttr ( "tabIndex" )
99
- . removeAttr ( "role" )
100
- . removeAttr ( "aria-activedescendant" ) ;
97
+ . removeClass ( "ui-menu ui-widget ui-widget-content ui-corner-all" )
98
+ . removeAttr ( "tabIndex" )
99
+ . removeAttr ( "role" )
100
+ . removeAttr ( "aria-activedescendant" ) ;
101
101
102
- this . element . children ( ".ui-menu-item" )
103
- . removeClass ( "ui-menu-item" )
104
- . removeAttr ( "role" )
105
- . children ( "a" )
106
- . removeClass ( "ui-corner-all" )
107
- . removeAttr ( "tabIndex" )
108
- . unbind ( ".menu" ) ;
102
+ this . element . children ( ".ui-menu-item" )
103
+ . removeClass ( "ui-menu-item" )
104
+ . removeAttr ( "role" )
105
+ . children ( "a" )
106
+ . removeClass ( "ui-corner-all" )
107
+ . removeAttr ( "tabIndex" )
108
+ . unbind ( ".menu" ) ;
109
109
} ,
110
110
111
111
refresh : function ( ) {
112
112
// don't refresh list items that are already adapted
113
- var items = this . element . children ( "li:not(.ui-menu-item):has(a)" )
114
- . addClass ( "ui-menu-item" )
115
- . attr ( "role" , "menuitem" ) ;
113
+ var items = this . element . children ( "li:not(.ui-menu-item):has(a)" )
114
+ . addClass ( "ui-menu-item" )
115
+ . attr ( "role" , "menuitem" ) ;
116
116
117
- items . children ( "a" )
118
- . addClass ( "ui-corner-all" )
119
- . attr ( "tabIndex" , - 1 ) ;
117
+ items . children ( "a" )
118
+ . addClass ( "ui-corner-all" )
119
+ . attr ( "tabIndex" , - 1 ) ;
120
120
} ,
121
121
122
122
activate : function ( event , item ) {
123
123
this . deactivate ( ) ;
124
- if ( this . _hasScroll ( ) ) {
124
+ if ( this . _hasScroll ( ) ) {
125
125
var offset = item . offset ( ) . top - this . element . offset ( ) . top ,
126
- scroll = this . element . attr ( "scrollTop" ) ,
126
+ scroll = this . element . attr ( "scrollTop" ) ,
127
127
elementHeight = this . element . height ( ) ;
128
128
if ( offset < 0 ) {
129
- this . element . attr ( "scrollTop" , scroll + offset ) ;
129
+ this . element . attr ( "scrollTop" , scroll + offset ) ;
130
130
} else if ( offset > elementHeight ) {
131
- this . element . attr ( "scrollTop" , scroll + offset - elementHeight + item . height ( ) ) ;
131
+ this . element . attr ( "scrollTop" , scroll + offset - elementHeight + item . height ( ) ) ;
132
132
}
133
133
}
134
- this . active = item . eq ( 0 )
135
- . children ( "a" )
136
- . addClass ( "ui-state-hover" )
137
- . attr ( "id" , "ui-active-menuitem" )
134
+ this . active = item . eq ( 0 )
135
+ . children ( "a" )
136
+ . addClass ( "ui-state-hover" )
137
+ . attr ( "id" , "ui-active-menuitem" )
138
138
. end ( ) ;
139
- this . _trigger ( "focus" , event , { item : item } ) ;
139
+ this . _trigger ( "focus" , event , { item : item } ) ;
140
140
} ,
141
141
142
142
deactivate : function ( event ) {
143
143
if ( ! this . active ) { return ; }
144
144
145
- this . active . children ( "a" )
146
- . removeClass ( "ui-state-hover" )
147
- . removeAttr ( "id" ) ;
148
- this . _trigger ( "blur" , event ) ;
145
+ this . active . children ( "a" )
146
+ . removeClass ( "ui-state-hover" )
147
+ . removeAttr ( "id" ) ;
148
+ this . _trigger ( "blur" , event ) ;
149
149
this . active = null ;
150
150
} ,
151
151
152
152
next : function ( event ) {
153
- this . _move ( "next" , ".ui-menu-item:first" , event ) ;
153
+ this . _move ( "next" , ".ui-menu-item:first" , event ) ;
154
154
} ,
155
155
156
156
previous : function ( event ) {
157
- this . _move ( "prev" , ".ui-menu-item:last" , event ) ;
157
+ this . _move ( "prev" , ".ui-menu-item:last" , event ) ;
158
158
} ,
159
159
160
160
first : function ( ) {
161
- return this . active && ! this . active . prevAll ( ".ui-menu-item" ) . length ;
161
+ return this . active && ! this . active . prevAll ( ".ui-menu-item" ) . length ;
162
162
} ,
163
163
164
164
last : function ( ) {
165
- return this . active && ! this . active . nextAll ( ".ui-menu-item" ) . length ;
165
+ return this . active && ! this . active . nextAll ( ".ui-menu-item" ) . length ;
166
166
} ,
167
167
168
168
_move : function ( direction , edge , event ) {
169
- if ( ! this . active ) {
170
- this . activate ( event , this . element . children ( edge ) ) ;
169
+ if ( ! this . active ) {
170
+ this . activate ( event , this . element . children ( edge ) ) ;
171
171
return ;
172
172
}
173
- var next = this . active [ direction + "All" ] ( ".ui-menu-item" ) . eq ( 0 ) ;
174
- if ( next . length ) {
175
- this . activate ( event , next ) ;
173
+ var next = this . active [ direction + "All" ] ( ".ui-menu-item" ) . eq ( 0 ) ;
174
+ if ( next . length ) {
175
+ this . activate ( event , next ) ;
176
176
} else {
177
- this . activate ( event , this . element . children ( edge ) ) ;
177
+ this . activate ( event , this . element . children ( edge ) ) ;
178
178
}
179
179
} ,
180
180
181
181
// TODO merge with previousPage
182
- nextPage : function ( event ) {
183
- if ( this . _hasScroll ( ) ) {
182
+ nextPage : function ( event ) {
183
+ if ( this . _hasScroll ( ) ) {
184
184
// TODO merge with no-scroll-else
185
- if ( ! this . active || this . last ( ) ) {
186
- this . activate ( event , this . element . children ( ":first" ) ) ;
185
+ if ( ! this . active || this . last ( ) ) {
186
+ this . activate ( event , this . element . children ( ":first" ) ) ;
187
187
return ;
188
188
}
189
189
var base = this . active . offset ( ) . top ,
190
190
height = this . element . height ( ) ,
191
- result = this . element . children ( "li" ) . filter ( function ( ) {
192
- var close = $ ( this ) . offset ( ) . top - base - height + $ ( this ) . height ( ) ;
191
+ result = this . element . children ( "li" ) . filter ( function ( ) {
192
+ var close = $ ( this ) . offset ( ) . top - base - height + $ ( this ) . height ( ) ;
193
193
// TODO improve approximation
194
194
return close < 10 && close > - 10 ;
195
195
} ) ;
196
196
197
197
// TODO try to catch this earlier when scrollTop indicates the last page anyway
198
- if ( ! result . length ) {
199
- result = this . element . children ( ":last" ) ;
198
+ if ( ! result . length ) {
199
+ result = this . element . children ( ":last" ) ;
200
200
}
201
- this . activate ( event , result ) ;
201
+ this . activate ( event , result ) ;
202
202
} else {
203
- this . activate ( event , this . element . children ( ! this . active || this . last ( ) ? ":first" : ":last" ) ) ;
203
+ this . activate ( event , this . element . children ( ! this . active || this . last ( ) ? ":first" : ":last" ) ) ;
204
204
}
205
205
} ,
206
206
207
207
// TODO merge with nextPage
208
- previousPage : function ( event ) {
209
- if ( this . _hasScroll ( ) ) {
208
+ previousPage : function ( event ) {
209
+ if ( this . _hasScroll ( ) ) {
210
210
// TODO merge with no-scroll-else
211
- if ( ! this . active || this . first ( ) ) {
212
- this . activate ( event , this . element . children ( ":last" ) ) ;
211
+ if ( ! this . active || this . first ( ) ) {
212
+ this . activate ( event , this . element . children ( ":last" ) ) ;
213
213
return ;
214
214
}
215
215
216
216
var base = this . active . offset ( ) . top ,
217
217
height = this . element . height ( ) ;
218
- result = this . element . children ( "li" ) . filter ( function ( ) {
218
+ result = this . element . children ( "li" ) . filter ( function ( ) {
219
219
var close = $ ( this ) . offset ( ) . top - base + height - $ ( this ) . height ( ) ;
220
220
// TODO improve approximation
221
221
return close < 10 && close > - 10 ;
222
222
} ) ;
223
223
224
224
// TODO try to catch this earlier when scrollTop indicates the last page anyway
225
225
if ( ! result . length ) {
226
- result = this . element . children ( ":first" ) ;
226
+ result = this . element . children ( ":first" ) ;
227
227
}
228
- this . activate ( event , result ) ;
228
+ this . activate ( event , result ) ;
229
229
} else {
230
- this . activate ( event , this . element . children ( ! this . active || this . first ( ) ? ":last" : ":first" ) ) ;
230
+ this . activate ( event , this . element . children ( ! this . active || this . first ( ) ? ":last" : ":first" ) ) ;
231
231
}
232
232
} ,
233
233
234
234
_hasScroll : function ( ) {
235
- return this . element . height ( ) < this . element . attr ( "scrollHeight" ) ;
235
+ return this . element . height ( ) < this . element . attr ( "scrollHeight" ) ;
236
236
} ,
237
237
238
238
select : function ( event ) {
239
- this . _trigger ( "select" , event , { item : this . active } ) ;
239
+ this . _trigger ( "select" , event , { item : this . active } ) ;
240
240
}
241
241
} ) ;
242
242
243
- } ( jQuery ) ) ;
243
+ } ( jQuery ) ) ;
0 commit comments