11// J2SMenu.js from JSmolMenu.js
22// author: Bob Hanson, hansonr@stolaf.edu
3+ // last edited 12/20/2018
34
45/*! jQuery UI - v1.9.2 - 2012-12-17
56* http://jqueryui.com
@@ -63,7 +64,16 @@ var r=e(t.target).closest(".ui-menu-item");
6364
6465
6566} ,
66- "mouseenter .ui-menu-item" :function ( t ) { var n = e ( t . currentTarget ) ; n . siblings ( ) . children ( ".ui-state-active" ) . removeClass ( "ui-state-active" ) , this . focus ( t , n ) } ,
67+ "mouseover .ui-menu-item" :function ( t ) {
68+ // BH 2018
69+ // -- added stopPropagation
70+ // -- changed to mouseover from mouseenter, since we have children
71+ t . stopPropagation ( ) ;
72+ var n = e ( t . currentTarget ) ;
73+ n . siblings ( ) . children ( ".ui-state-active" ) . removeClass ( "ui-state-active" ) ,
74+ this . focus ( t , n )
75+
76+ } ,
6777 mouseleave :"collapseAll" ,
6878 "mouseleave .ui-menu" : "collapseAll" ,
6979 focus :function ( e , t ) { var n = this . active || this . element . children ( ".ui-menu-item" ) . eq ( 0 ) ; t || this . focus ( e , n ) } ,
@@ -75,7 +85,15 @@ var r=e(t.target).closest(".ui-menu-item");
7585 click :function ( t ) { e ( t . target ) . closest ( ".ui-menu" ) . length || this . collapseAll ( t ) , n = ! 1 } } )
7686 } ,
7787
78- _destroy :function ( ) { this . element . removeAttr ( "aria-activedescendant" ) . find ( ".ui-menu" ) . andSelf ( ) . removeClass ( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" ) . removeAttr ( "role" ) . removeAttr ( "tabIndex" ) . removeAttr ( "aria-labelledby" ) . removeAttr ( "aria-expanded" ) . removeAttr ( "aria-hidden" ) . removeAttr ( "aria-disabled" ) . removeUniqueId ( ) . show ( ) , this . element . find ( ".ui-menu-item" ) . removeClass ( "ui-menu-item" ) . removeAttr ( "role" ) . removeAttr ( "aria-disabled" ) . children ( "a" ) . removeUniqueId ( ) . removeClass ( "ui-corner-all ui-state-hover" ) . removeAttr ( "tabIndex" ) . removeAttr ( "role" ) . removeAttr ( "aria-haspopup" ) . children ( ) . each ( function ( ) { var t = e ( this ) ; t . data ( "ui-menu-submenu-carat" ) && t . remove ( ) } ) , this . element . find ( ".ui-menu-divider" ) . removeClass ( "ui-menu-divider ui-widget-content" ) } ,
88+ _destroy :function ( ) { this . element . removeAttr ( "aria-activedescendant" ) . find ( ".ui-menu" ) . andSelf ( )
89+ . removeClass ( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
90+ . removeAttr ( "role" ) . removeAttr ( "tabIndex" ) . removeAttr ( "aria-labelledby" ) . removeAttr ( "aria-expanded" )
91+ . removeAttr ( "aria-hidden" ) . removeAttr ( "aria-disabled" ) . removeUniqueId ( ) . show ( ) ,
92+ this . element . find ( ".ui-menu-item" ) . removeClass ( "ui-menu-item" )
93+ . removeAttr ( "role" ) . removeAttr ( "aria-disabled" )
94+ . children ( "a" ) . removeUniqueId ( ) . removeClass ( "ui-corner-all ui-state-hover" )
95+ . removeAttr ( "tabIndex" ) . removeAttr ( "role" ) . removeAttr ( "aria-haspopup" ) . children ( ) . each ( function ( ) { var t = e ( this ) ; t . data ( "ui-menu-submenu-carat" ) && t . remove ( ) } ) , this . element . find ( ".ui-menu-divider" ) . removeClass ( "ui-menu-divider ui-widget-content" )
96+ } ,
7997 _keydown :function ( t ) { function a ( e ) { return e . replace ( / [ \- \[ \] { } ( ) * + ? . , \\ \^ $ | # \s ] / g, "\\$&" ) } var n , r , i , s , o , u = ! 0 ; switch ( t . keyCode ) { case e . ui . keyCode . PAGE_UP :this . previousPage ( t ) ; break ; case e . ui . keyCode . PAGE_DOWN :this . nextPage ( t ) ; break ; case e . ui . keyCode . HOME :this . _move ( "first" , "first" , t ) ; break ; case e . ui . keyCode . END :this . _move ( "last" , "last" , t ) ; break ; case e . ui . keyCode . UP :this . previous ( t ) ; break ; case e . ui . keyCode . DOWN :this . next ( t ) ; break ; case e . ui . keyCode . LEFT :this . collapse ( t ) ; break ; case e . ui . keyCode . RIGHT :this . active && ! this . active . is ( ".ui-state-disabled" ) && this . expand ( t ) ; break ; case e . ui . keyCode . ENTER :case e . ui . keyCode . SPACE :this . _activate ( t ) ; break ; case e . ui . keyCode . ESCAPE :this . collapse ( t ) ; break ; default :u = ! 1 , r = this . previousFilter || "" , i = String . fromCharCode ( t . keyCode ) , s = ! 1 , clearTimeout ( this . filterTimer ) , i === r ?s = ! 0 :i = r + i , o = new RegExp ( "^" + a ( i ) , "i" ) , n = this . activeMenu . children ( ".ui-menu-item" ) . filter ( function ( ) { return o . test ( e ( this ) . children ( "a" ) . text ( ) ) } ) , n = s && n . index ( this . active . next ( ) ) !== - 1 ?this . active . nextAll ( ".ui-menu-item" ) :n , n . length || ( i = String . fromCharCode ( t . keyCode ) , o = new RegExp ( "^" + a ( i ) , "i" ) , n = this . activeMenu . children ( ".ui-menu-item" ) . filter ( function ( ) { return o . test ( e ( this ) . children ( "a" ) . text ( ) ) } ) ) , n . length ?( this . focus ( t , n ) , n . length > 1 ?( this . previousFilter = i , this . filterTimer = this . _delay ( function ( ) { delete this . previousFilter } , 1e3 ) ) :delete this . previousFilter ) :delete this . previousFilter } u && t . preventDefault ( ) } ,
8098 _activate :function ( e ) { this . active . is ( ".ui-state-disabled" ) || ( this . active . children ( "a[aria-haspopup='true']" ) . length ?this . expand ( e ) :this . select ( e ) ) } ,
8199 refresh :function ( ) {
@@ -90,8 +108,19 @@ var r=e(t.target).closest(".ui-menu-item");
90108 . data ( "ui-menu-submenu-carat" , ! 0 ) ;
91109 r . attr ( "aria-haspopup" , "true" ) . prepend ( i ) , t . attr ( "aria-labelledby" , r . attr ( "id" ) ) } ) , t = r . add ( this . element ) , t . children ( ":not(.ui-menu-item):has(a)" ) . addClass ( "ui-menu-item" ) . attr ( "role" , "presentation" ) . children ( "a" ) . uniqueId ( ) . addClass ( "ui-corner-all" ) . attr ( { tabIndex :- 1 , role :this . _itemRole ( ) } ) , t . children ( ":not(.ui-menu-item)" ) . each ( function ( ) { var t = e ( this ) ; / [ ^ \- + � G � � G � � + � G � � G � � \s ] / . test ( t . text ( ) ) || t . addClass ( "ui-widget-content ui-menu-divider" ) } ) , t . children ( ".ui-state-disabled" ) . attr ( "aria-disabled" , "true" ) , this . active && ! e . contains ( this . element [ 0 ] , this . active [ 0 ] ) && this . blur ( ) } ,
92110 _itemRole :function ( ) { return { menu :"menuitem" , listbox :"option" } [ this . options . role ] } ,
93- focus :function ( e , t ) { var n , r ; this . blur ( e , e && e . type === "focus" ) , this . _scrollIntoView ( t ) , this . active = t . first ( ) , r = this . active . children ( "a" ) . addClass ( "ui-state-focus" ) , this . options . role && this . element . attr ( "aria-activedescendant" , r . attr ( "id" ) ) , this . active . parent ( ) . closest ( ".ui-menu-item" ) . children ( "a:first" ) . addClass ( "ui-state-active" ) , e && e . type === "keydown" ?this . _close ( ) :
94- this . timer = this . _delay ( function ( ) { this . _close ( ) } , this . delay ) , n = t . children ( ".ui-menu" ) , n . length && / ^ m o u s e / . test ( e . type ) && this . _startOpening ( n ) , this . activeMenu = t . parent ( ) , this . _trigger ( "focus" , e , { item :t } ) } ,
111+
112+ focus :function ( e , t ) { var n , r ; this . blur ( e , e && e . type === "focus" ) , this . _scrollIntoView ( t ) , this . active = t . first ( ) ,
113+ r = this . active
114+ //.children("a")
115+ . addClass ( "ui-state-focus" ) ,
116+ this . options . role && this . element . attr ( "aria-activedescendant" ,
117+ r . attr ( "id" ) ) ,
118+ this . active . parent ( ) . closest ( ".ui-menu-item" ) . children ( "a:first" ) . addClass ( "ui-state-active" ) ,
119+ e && e . type === "keydown" ?this . _close ( ) :
120+ this . timer = this . _delay ( function ( ) { this . _close ( ) } , this . delay ) ,
121+ n = t . children ( ".ui-menu" ) , n . length && / ^ m o u s e / . test ( e . type )
122+ && this . _startOpening ( n ) , this . activeMenu = t . parent ( ) ,
123+ this . _trigger ( "focus" , e , { item :t } ) } ,
95124 _scrollIntoView :function ( t ) { var n , r , i , s , o , u ; this . _hasScroll ( ) && ( n = parseFloat ( e . css ( this . activeMenu [ 0 ] , "borderTopWidth" ) ) || 0 , r = parseFloat ( e . css ( this . activeMenu [ 0 ] , "paddingTop" ) ) || 0 , i = t . offset ( ) . top - this . activeMenu . offset ( ) . top - n - r , s = this . activeMenu . scrollTop ( ) , o = this . activeMenu . height ( ) , u = t . height ( ) , i < 0 ?this . activeMenu . scrollTop ( s + i ) :i + u > o && this . activeMenu . scrollTop ( s + i - o + u ) ) } ,
96125 blur :function ( e , t ) {
97126
@@ -100,7 +129,11 @@ this.timer=this._delay(function(){this._close()},this.delay),n=t.children(".ui-m
100129 }
101130
102131
103- t || clearTimeout ( this . timer ) ; if ( ! this . active ) return ; this . active . children ( "a" ) . removeClass ( "ui-state-focus" ) , this . active = null , this . _trigger ( "blur" , e , { item :this . active } ) } ,
132+ t || clearTimeout ( this . timer ) ; if ( ! this . active ) return ;
133+
134+ this . active
135+ //.children("a")
136+ . removeClass ( "ui-state-focus" ) , this . active = null , this . _trigger ( "blur" , e , { item :this . active } ) } ,
104137 _startOpening :function ( e ) { clearTimeout ( this . timer ) ; if ( e . attr ( "aria-hidden" ) !== "true" ) return ; this . timer = this . _delay ( function ( ) { this . _close ( ) , this . _open ( e ) } , this . delay ) } ,
105138 _open :function ( t ) { var n = e . extend ( { of :this . active } , this . options . position ) ; clearTimeout ( this . timer ) , this . element . find ( ".ui-menu" ) . not ( t . parents ( ".ui-menu" ) ) . hide ( ) . attr ( "aria-hidden" , "true" ) , t . show ( ) . removeAttr ( "aria-hidden" ) . attr ( "aria-expanded" , "true" ) . position ( n ) } ,
106139 collapseAll :function ( t , n ) {
@@ -127,7 +160,9 @@ e.find(".ui-menu")
127160
128161
129162} ,
130- collapse :function ( e ) { var t = this . active && this . active . parent ( ) . closest ( ".ui-menu-item" , this . element ) ; t && t . length && ( this . _close ( ) , this . focus ( e , t ) ) } ,
163+ collapse :function ( e ) { var t = this . active && this . active . parent ( ) . closest ( ".ui-menu-item" , this . element ) ; t && t . length && ( this . _close ( ) ,
164+ this . focus ( e , t ) )
165+ } ,
131166 expand :function ( e ) { var t = this . active && this . active . children ( ".ui-menu " ) . children ( ".ui-menu-item" ) . first ( ) ; t && t . length && ( this . _open ( t . parent ( ) ) , this . _delay ( function ( ) { this . focus ( e , t ) } ) ) } ,
132167 next :function ( e ) { this . _move ( "next" , "first" , e ) } ,
133168 previous :function ( e ) { this . _move ( "prev" , "last" , e ) } ,
@@ -174,7 +209,7 @@ Swing.__getMenuStyle = function(applet) { return '\
174209 .swingjsPopupMenu .ui-icon-carat-1-e:after{content:"\\0025B6"}\
175210 .swingjsPopupMenu .ui-state-default{border:1px solid #c5dbec;background:#dfeffc;color:#2e6e9e}\
176211 .swingjsPopupMenu .ui-state-default a{color:#2e6e9e;text-decoration:none}\
177- .swingjsPopupMenu .ui-state-hover,.swingjsPopupMenu .ui-state-focus{border:1px solid #79b7e7; background:#d0e5f5;color:#1d5987}\
212+ .swingjsPopupMenu .ui-state-hover,.swingjsPopupMenu .ui-state-focus{background:#d0e5f5;color:#1d5987}\
178213 .swingjsPopupMenu .ui-state-hover a{color:#1d5987;text-decoration:none}\
179214 .swingjsPopupMenu .ui-state-active{border:1px solid #79b7e7;background:#f5f8f9;color:#e17009}\
180215 .swingjsPopupMenu .ui-state-active a{color:#e17009;text-decoration:none}\
0 commit comments