@@ -315,185 +315,3 @@ $.extend( $.ui.autocomplete, {
315
315
} ) ;
316
316
317
317
} ( jQuery ) ) ;
318
-
319
- /*
320
- * jQuery UI Menu (not officially released)
321
- *
322
- * This widget isn't yet finished and the API is subject to change. We plan to finish
323
- * it for the next release. You're welcome to give it a try anyway and give us feedback,
324
- * as long as you're okay with migrating your code later on. We can help with that, too.
325
- *
326
- * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
327
- * Dual licensed under the MIT (MIT-LICENSE.txt)
328
- * and GPL (GPL-LICENSE.txt) licenses.
329
- *
330
- * http://docs.jquery.com/UI/Menu
331
- *
332
- * Depends:
333
- * jquery.ui.core.js
334
- * jquery.ui.widget.js
335
- */
336
- ( function ( $ ) {
337
-
338
- $ . widget ( "ui.menu" , {
339
- _create : function ( ) {
340
- var self = this ;
341
- this . element
342
- . addClass ( "ui-menu ui-widget ui-widget-content ui-corner-all" )
343
- . attr ( {
344
- role : "listbox" ,
345
- "aria-activedescendant" : "ui-active-menuitem"
346
- } )
347
- . click ( function ( event ) {
348
- if ( ! $ ( event . target ) . closest ( ".ui-menu-item a" ) . length ) {
349
- return ;
350
- }
351
- // temporary
352
- event . preventDefault ( ) ;
353
- self . select ( event ) ;
354
- } ) ;
355
- this . refresh ( ) ;
356
- } ,
357
-
358
- refresh : function ( ) {
359
- var self = this ;
360
-
361
- // don't refresh list items that are already adapted
362
- var items = this . element . children ( "li:not(.ui-menu-item):has(a)" )
363
- . addClass ( "ui-menu-item" )
364
- . attr ( "role" , "menuitem" ) ;
365
-
366
- items . children ( "a" )
367
- . addClass ( "ui-corner-all" )
368
- . attr ( "tabindex" , - 1 )
369
- // mouseenter doesn't work with event delegation
370
- . mouseenter ( function ( event ) {
371
- self . activate ( event , $ ( this ) . parent ( ) ) ;
372
- } )
373
- . mouseleave ( function ( ) {
374
- self . deactivate ( ) ;
375
- } ) ;
376
- } ,
377
-
378
- activate : function ( event , item ) {
379
- this . deactivate ( ) ;
380
- if ( this . hasScroll ( ) ) {
381
- var offset = item . offset ( ) . top - this . element . offset ( ) . top ,
382
- scroll = this . element . attr ( "scrollTop" ) ,
383
- elementHeight = this . element . height ( ) ;
384
- if ( offset < 0 ) {
385
- this . element . attr ( "scrollTop" , scroll + offset ) ;
386
- } else if ( offset > elementHeight ) {
387
- this . element . attr ( "scrollTop" , scroll + offset - elementHeight + item . height ( ) ) ;
388
- }
389
- }
390
- this . active = item . eq ( 0 )
391
- . children ( "a" )
392
- . addClass ( "ui-state-hover" )
393
- . attr ( "id" , "ui-active-menuitem" )
394
- . end ( ) ;
395
- this . _trigger ( "focus" , event , { item : item } ) ;
396
- } ,
397
-
398
- deactivate : function ( ) {
399
- if ( ! this . active ) { return ; }
400
-
401
- this . active . children ( "a" )
402
- . removeClass ( "ui-state-hover" )
403
- . removeAttr ( "id" ) ;
404
- this . _trigger ( "blur" ) ;
405
- this . active = null ;
406
- } ,
407
-
408
- next : function ( event ) {
409
- this . move ( "next" , ".ui-menu-item:first" , event ) ;
410
- } ,
411
-
412
- previous : function ( event ) {
413
- this . move ( "prev" , ".ui-menu-item:last" , event ) ;
414
- } ,
415
-
416
- first : function ( ) {
417
- return this . active && ! this . active . prev ( ) . length ;
418
- } ,
419
-
420
- last : function ( ) {
421
- return this . active && ! this . active . next ( ) . length ;
422
- } ,
423
-
424
- move : function ( direction , edge , event ) {
425
- if ( ! this . active ) {
426
- this . activate ( event , this . element . children ( edge ) ) ;
427
- return ;
428
- }
429
- var next = this . active [ direction + "All" ] ( ".ui-menu-item" ) . eq ( 0 ) ;
430
- if ( next . length ) {
431
- this . activate ( event , next ) ;
432
- } else {
433
- this . activate ( event , this . element . children ( edge ) ) ;
434
- }
435
- } ,
436
-
437
- // TODO merge with previousPage
438
- nextPage : function ( event ) {
439
- if ( this . hasScroll ( ) ) {
440
- // TODO merge with no-scroll-else
441
- if ( ! this . active || this . last ( ) ) {
442
- this . activate ( event , this . element . children ( ":first" ) ) ;
443
- return ;
444
- }
445
- var base = this . active . offset ( ) . top ,
446
- height = this . element . height ( ) ,
447
- result = this . element . children ( "li" ) . filter ( function ( ) {
448
- var close = $ ( this ) . offset ( ) . top - base - height + $ ( this ) . height ( ) ;
449
- // TODO improve approximation
450
- return close < 10 && close > - 10 ;
451
- } ) ;
452
-
453
- // TODO try to catch this earlier when scrollTop indicates the last page anyway
454
- if ( ! result . length ) {
455
- result = this . element . children ( ":last" ) ;
456
- }
457
- this . activate ( event , result ) ;
458
- } else {
459
- this . activate ( event , this . element . children ( ! this . active || this . last ( ) ? ":first" : ":last" ) ) ;
460
- }
461
- } ,
462
-
463
- // TODO merge with nextPage
464
- previousPage : function ( event ) {
465
- if ( this . hasScroll ( ) ) {
466
- // TODO merge with no-scroll-else
467
- if ( ! this . active || this . first ( ) ) {
468
- this . activate ( event , this . element . children ( ":last" ) ) ;
469
- return ;
470
- }
471
-
472
- var base = this . active . offset ( ) . top ,
473
- height = this . element . height ( ) ;
474
- result = this . element . children ( "li" ) . filter ( function ( ) {
475
- var close = $ ( this ) . offset ( ) . top - base + height - $ ( this ) . height ( ) ;
476
- // TODO improve approximation
477
- return close < 10 && close > - 10 ;
478
- } ) ;
479
-
480
- // TODO try to catch this earlier when scrollTop indicates the last page anyway
481
- if ( ! result . length ) {
482
- result = this . element . children ( ":first" ) ;
483
- }
484
- this . activate ( event , result ) ;
485
- } else {
486
- this . activate ( event , this . element . children ( ! this . active || this . first ( ) ? ":last" : ":first" ) ) ;
487
- }
488
- } ,
489
-
490
- hasScroll : function ( ) {
491
- return this . element . height ( ) < this . element . attr ( "scrollHeight" ) ;
492
- } ,
493
-
494
- select : function ( event ) {
495
- this . _trigger ( "selected" , event , { item : this . active } ) ;
496
- }
497
- } ) ;
498
-
499
- } ( jQuery ) ) ;
0 commit comments