@@ -17,12 +17,12 @@ $.widget("ui.menu", {
1717 _create : function ( ) {
1818 var self = this ;
1919 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" )
2121 . attr ( {
2222 role : "listbox" ,
2323 "aria-activedescendant" : "ui-active-menuitem"
2424 } )
25- . bind ( "click.menu" , function ( event ) {
25+ . bind ( "click.menu" , function ( event ) {
2626 if ( self . options . disabled ) {
2727 return false ;
2828 }
@@ -33,7 +33,7 @@ $.widget("ui.menu", {
3333 event . preventDefault ( ) ;
3434 self . select ( event ) ;
3535 } )
36- . bind ( "mouseover.menu" , function ( event ) {
36+ . bind ( "mouseover.menu" , function ( event ) {
3737 if ( self . options . disabled ) {
3838 return ;
3939 }
@@ -50,17 +50,17 @@ $.widget("ui.menu", {
5050 if ( target . length && target . parent ( ) [ 0 ] === self . element [ 0 ] ) {
5151 self . deactivate ( event ) ;
5252 }
53- } ) ; ;
53+ } ) ;
5454 this . refresh ( ) ;
5555
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 ) ;
5858 }
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 ) {
6161 return ;
6262 }
63- switch ( event . keyCode ) {
63+ switch ( event . keyCode ) {
6464 case $ . ui . keyCode . PAGE_UP :
6565 self . previousPage ( ) ;
6666 event . preventDefault ( ) ;
@@ -91,153 +91,153 @@ $.widget("ui.menu", {
9191 } ,
9292
9393 destroy : function ( ) {
94- $ . Widget . prototype . destroy . apply ( this , arguments ) ;
94+ $ . Widget . prototype . destroy . apply ( this , arguments ) ;
9595
9696 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" ) ;
101101
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" ) ;
109109 } ,
110110
111111 refresh : function ( ) {
112112 // 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" ) ;
116116
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 ) ;
120120 } ,
121121
122122 activate : function ( event , item ) {
123123 this . deactivate ( ) ;
124- if ( this . _hasScroll ( ) ) {
124+ if ( this . _hasScroll ( ) ) {
125125 var offset = item . offset ( ) . top - this . element . offset ( ) . top ,
126- scroll = this . element . attr ( "scrollTop" ) ,
126+ scroll = this . element . attr ( "scrollTop" ) ,
127127 elementHeight = this . element . height ( ) ;
128128 if ( offset < 0 ) {
129- this . element . attr ( "scrollTop" , scroll + offset ) ;
129+ this . element . attr ( "scrollTop" , scroll + offset ) ;
130130 } else if ( offset > elementHeight ) {
131- this . element . attr ( "scrollTop" , scroll + offset - elementHeight + item . height ( ) ) ;
131+ this . element . attr ( "scrollTop" , scroll + offset - elementHeight + item . height ( ) ) ;
132132 }
133133 }
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" )
138138 . end ( ) ;
139- this . _trigger ( "focus" , event , { item : item } ) ;
139+ this . _trigger ( "focus" , event , { item : item } ) ;
140140 } ,
141141
142142 deactivate : function ( event ) {
143143 if ( ! this . active ) { return ; }
144144
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 ) ;
149149 this . active = null ;
150150 } ,
151151
152152 next : function ( event ) {
153- this . _move ( "next" , ".ui-menu-item:first" , event ) ;
153+ this . _move ( "next" , ".ui-menu-item:first" , event ) ;
154154 } ,
155155
156156 previous : function ( event ) {
157- this . _move ( "prev" , ".ui-menu-item:last" , event ) ;
157+ this . _move ( "prev" , ".ui-menu-item:last" , event ) ;
158158 } ,
159159
160160 first : function ( ) {
161- return this . active && ! this . active . prevAll ( ".ui-menu-item" ) . length ;
161+ return this . active && ! this . active . prevAll ( ".ui-menu-item" ) . length ;
162162 } ,
163163
164164 last : function ( ) {
165- return this . active && ! this . active . nextAll ( ".ui-menu-item" ) . length ;
165+ return this . active && ! this . active . nextAll ( ".ui-menu-item" ) . length ;
166166 } ,
167167
168168 _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 ) ) ;
171171 return ;
172172 }
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 ) ;
176176 } else {
177- this . activate ( event , this . element . children ( edge ) ) ;
177+ this . activate ( event , this . element . children ( edge ) ) ;
178178 }
179179 } ,
180180
181181 // TODO merge with previousPage
182- nextPage : function ( event ) {
183- if ( this . _hasScroll ( ) ) {
182+ nextPage : function ( event ) {
183+ if ( this . _hasScroll ( ) ) {
184184 // 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" ) ) ;
187187 return ;
188188 }
189189 var base = this . active . offset ( ) . top ,
190190 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 ( ) ;
193193 // TODO improve approximation
194194 return close < 10 && close > - 10 ;
195195 } ) ;
196196
197197 // 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" ) ;
200200 }
201- this . activate ( event , result ) ;
201+ this . activate ( event , result ) ;
202202 } 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" ) ) ;
204204 }
205205 } ,
206206
207207 // TODO merge with nextPage
208- previousPage : function ( event ) {
209- if ( this . _hasScroll ( ) ) {
208+ previousPage : function ( event ) {
209+ if ( this . _hasScroll ( ) ) {
210210 // 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" ) ) ;
213213 return ;
214214 }
215215
216216 var base = this . active . offset ( ) . top ,
217217 height = this . element . height ( ) ;
218- result = this . element . children ( "li" ) . filter ( function ( ) {
218+ result = this . element . children ( "li" ) . filter ( function ( ) {
219219 var close = $ ( this ) . offset ( ) . top - base + height - $ ( this ) . height ( ) ;
220220 // TODO improve approximation
221221 return close < 10 && close > - 10 ;
222222 } ) ;
223223
224224 // TODO try to catch this earlier when scrollTop indicates the last page anyway
225225 if ( ! result . length ) {
226- result = this . element . children ( ":first" ) ;
226+ result = this . element . children ( ":first" ) ;
227227 }
228- this . activate ( event , result ) ;
228+ this . activate ( event , result ) ;
229229 } 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" ) ) ;
231231 }
232232 } ,
233233
234234 _hasScroll : function ( ) {
235- return this . element . height ( ) < this . element . attr ( "scrollHeight" ) ;
235+ return this . element . height ( ) < this . element . attr ( "scrollHeight" ) ;
236236 } ,
237237
238238 select : function ( event ) {
239- this . _trigger ( "select" , event , { item : this . active } ) ;
239+ this . _trigger ( "select" , event , { item : this . active } ) ;
240240 }
241241} ) ;
242242
243- } ( jQuery ) ) ;
243+ } ( jQuery ) ) ;
0 commit comments