import ko from "knockout" ; const supportTouchEvents = "ontouchstart" in window ; ko . bindingHandlers . menuButton = { init ( element , valueAccessor ) { if ( ko . unwrap ( valueAccessor ( ) ) ) { if ( supportTouchEvents ) { element . addEventListener ( "touchstart" , ( ) => { ko . utils . toggleDomNodeCssClass ( element , "hover active" , true ) ; } ) ; element . addEventListener ( "touchend" , ( ) => { ko . utils . toggleDomNodeCssClass ( element , "hover active" , false ) ; } ) ; } else { element . addEventListener ( "mouseover" , ( ) => { ko . utils . toggleDomNodeCssClass ( element , "hover" , true ) ; } ) ; element . addEventListener ( "mousedown" , ( ) => { ko . utils . toggleDomNodeCssClass ( element , "active" , true ) ; } ) ; element . addEventListener ( "mouseup" , ( ) => { ko . utils . toggleDomNodeCssClass ( element , "active" , false ) ; } ) ; element . addEventListener ( "mouseout" , ( ) => { ko . utils . toggleDomNodeCssClass ( element , "hover" , false ) ; ko . utils . toggleDomNodeCssClass ( element , "active" , false ) ; window . getSelection ( ) . removeAllRanges ( ) ; } ) ; } } } } ;