1 line
7.4 KiB
JavaScript
1 line
7.4 KiB
JavaScript
!function(b,h){"use strict";var K="ht",u=b[K],G="innerHTML",i="className",j=null,A="px",_=u.Default,o=_.getInternal(),W="0",O=function(){return document},w=function(R){return O().createElement(R)},J=function(){return w("canvas")},L=function(S,v,R){S.style.setProperty(v,R,j)},l=function(d,A,o){_.def(u.widget[d],A,o)},E=function(P,W){P.appendChild(W)},d=function(e,L){e.removeChild(L)},D=o.addEventListener,F=o.removeEventListener,I=_.isTouchable,z=_.isTouchEvent;o.addMethod(_,{menuLabelFont:(I?"16":"13")+"px arial, sans-serif",menuLabelColor:"#000",menuBackground:"#F0EFEE",menuHoverBackground:"#648BFE",menuHoverLabelColor:"#fff",menuSeparatorWidth:1,menuSeparatorColor:"#999"},!0),u.widget.Menu=function(V){var S=this,l=S._view=o.createView(null,S),D=S.$1g=new u.widget.ContextMenu,p=w("ul");D._r=!0,D._view[i]+=" ht-widget-dropdownmenu",l[i]="ht-widget-menu",p[i]="header",L(l,"margin",W),L(l,"padding",W),L(l,"background",_.menuBackground),L(l,"-webkit-user-select","none"),L(l,"-moz-user-select","none"),L(l,"user-select","none"),L(l,"text-align","left"),L(l,"border-bottom",_.menuSeparatorWidth+"px solid "+_.menuSeparatorColor),L(l,"cursor","default"),L(l,"overflow","auto"),L(l,"white-space","nowrap"),L(l,"font",_.menuLabelFont),L(l,"color",_.menuLabelColor),L(l,"box-sizing","border-box"),L(l,"-moz-box-sizing","border-box"),L(p,"list-style","none"),L(p,"margin",W),L(p,"padding",W),L(p,"display","inline-block"),E(l,p),S.setItems(V),S.$2g=function(W){S.$3g(W)},S.$4g=function(P){S.$5g(P)},S.$6g=function(c){S.$7g(c)},S.$8g=function(U){S.$9g(U)},S.$9b=function(B){S.$10g(B)},S._autoShow=!0,S.setAutoShow(!1),D.afterHide=function(){S.$11g()},D.afterShow=function(){S.$12g()},F(O(),"keydown",D.$3b),S.$3b=function(r){S.$13g(r)},S.invalidate()},l("Menu",h,{_items:j,$14g:_.menuHoverBackground,$15g:_.menuHoverLabelColor,$16g:{},_enableGlobalKey:!1,ms_v:1,$21g:"smallicons",$22g:0,$23g:0,$24g:"left",getDropDownMenu:function(){return this.$1g},setLayout:function(g){var r=this;if(r.$21g=g,r.setItems(r._items),"largeicons"===g){for(var u=r._view.querySelectorAll(".header-item"),l=0,N=0;N<u.length;N++){var n=u[N];l=Math.max(l,n.clientWidth)}for(var N=0;N<u.length;N++){var n=u[N];L(n,"min-width",l+A)}}this.invalidate()},getLayout:function(){return this.$21g},setHeaderItemHGap:function(T){this.$22g=T;for(var R=this._view.querySelectorAll(".header-item"),U=0;U<R.length;U++){var b=R[U];L(b,"margin-left",T+A),L(b,"margin-right",T+A)}},getHeaderItemHGap:function(){return this.$22g},setHeaderItemVGap:function(k){this.$23g=k;for(var G=this._view.querySelectorAll(".header-item"),m=0;m<G.length;m++){var E=G[m];L(E,"margin-top",k+A),L(E,"margin-bottom",k+A)}},getHeaderItemVGap:function(){return this.$24g},setHeaderItemAlign:function(G){this.$24g=G,L(this._view,"text-align",G)},getHeaderItemAlign:function(){return this.$23g},enableGlobalKey:function(){var S=this,V=S._enableGlobalKey;V===!1&&(D(O(),"keydown",S.$3b),S._enableGlobalKey=!0)},disableGlobalKey:function(){this._enableGlobalKey=!1,F(O(),"keydown",this.$3b)},setHoverBackground:function(X){this.$14g=X},setHoverColor:function(D){this.$15g=D},setItems:function(V){var g=this,N=g._view,B=g.$21g;if(g._items=V,N.children[0][G]="",g.$16g={},V&&V.length){for(var m=N.children[0],Q=0,u=O().createDocumentFragment();Q<V.length;Q++){var r=V[Q],A=w("li"),K=w("span");if(r.icon){var k=J();k[i]="menu-item-icon","smallicons"===B?(L(k,"height","1.2em"),L(k,"width","1.2em"),L(k,"vertical-align","middle")):(L(k,"height","32px"),L(k,"width","32px"),L(k,"display","block"),L(k,"margin","0 auto")),k.$20g=r.icon,E(A,k)}A[i]="header-item",L(A,"display","inline-block"),L(A,"vertical-align","top"),L(A,"padding","0 1.2em"),L(A,"line-height","1.8em"),"largeicons"===B&&L(A,"text-align","center"),L(A,"background-color","rgba(0,0,0,0)"),A.setAttribute("data-index",Q),g.$16g[Q]=r.items,K[G]=r.label,"iconsonly"!==B&&E(A,K),E(u,A)}E(m,u)}},showDropdownMenu:function(W){var E=this,V=E.$16g[W],p=E.$1g,d=E._view.children[0].children[W],g=E.$17g;if(d&&d!==g){g&&E.hideDropdownMenu();var i=d.getBoundingClientRect(),N=_.getWindowInfo();E.$17g=d,p.setItems(V),p.show(i.left+N.left,i.top+i.height+N.top,!1)}},hideDropdownMenu:function(){this.$1g.hide()},getItemByProperty:function(a,K){var Q=this,S=Q._items;return S&&0!==S.length?Q.$1g.getItemByProperty(a,K,S):j},$12g:function(){var C=this,e=C.$17g;e.style.background=C.$14g,e.style.color=C.$15g,C._autoShow||D(O(),I?"touchstart":"mousedown",C.$9b)},$11g:function(){var u=this,T=u.$17g;T&&(T.style.background="",T.style.color="",u.$17g=j),F(O(),I?"touchstart":"mousedown",u.$9b)},$10g:function(E){var K=this,A=K._view,N=K.$1g,q=A.children[0];!O().body.contains(A)||q.contains(E.target)||N._view.contains(E.target)||K.hideDropdownMenu()},$13g:function(a){var D=this,p=D.$1g;O().body.contains(D._view)&&p.$13b.$4b.call(p.$13b,a,D._items)},setAutoShow:function(Z){var V=this,l=V.$1g,q=V._view;V._autoShow!==Z&&(V._autoShow?(F(q,"mouseover",V.$2g),F(q,"mouseout",V.$4g),F(l._view,"mouseout",V.$4g),I||(D(q,"mouseover",V.$8g),D(q,"mouseout",V.$8g)),D(q,I?"touchstart":"mousedown",V.$6g)):(F(q,"mouseover",V.$8g),F(q,"mouseout",V.$8g),F(q,I?"touchstart":"mousedown",V.$6g),F(O(),I?"touchstart":"mousedown",V.$9b),I||(D(q,"mouseover",V.$2g),D(q,"mouseout",V.$4g),D(l._view,"mouseout",V.$4g))),V._autoShow=Z)},$3g:function(u){var J=this,d=J._view.children[0],L=u.target;if(d!==L&&d.contains(L)){for(;"header-item"!==L[i];)L=L.parentNode;J.showDropdownMenu(L.getAttribute("data-index"))}},$5g:function(W){var F=this,x=F._view.children[0],K=F.$1g,C=W.target,$=W.relatedTarget;!x.contains(C)&&!K._view.contains(C)||x.contains($)||K._view.contains($)||F.hideDropdownMenu()},$7g:function(m){m.preventDefault();var r=this,T=r._view.children[0],Z=r.$1g,U=m.target;if(_.isLeftButton(m)&&T!==U&&T.contains(U))if(z(m)){for(;"header-item"!==U[i];)U=U.parentNode;var k=U.getAttribute("data-index"),Z=r.$1g,q=r._view.children[0].children[k],A=r.$17g;Z.isShowing()&&r.hideDropdownMenu(),q!==A&&r.showDropdownMenu(k)}else if(Z.isShowing())r.hideDropdownMenu();else{for(;"header-item"!==U[i];)U=U.parentNode;r.showDropdownMenu(U.getAttribute("data-index"))}},$9g:function(V){var o=this,a=o._view,u=o.$1g,F=V.target;if(a.contains(F)){for(var k=a.querySelectorAll(".header-item"),g=j,f=0;f<k.length;f++){var c=k[f];c.style.background="",c.style.color="","mouseover"===V.type?c.contains(F)&&(g=c):"mouseout"===V.type&&u.isShowing()&&o.$17g===c&&(g=c)}u.isShowing()&&(g||(g=o.$17g),o.showDropdownMenu(g.getAttribute("data-index"))),g&&(g.style.background=o.$14g,g.style.color=o.$15g)}},getShowingMenuIndex:function(){var j=this.$17g;return j?j.getAttribute("data-index"):-1},addTo:function(h){var W=this,B=W._view;E(h,B),W.invalidate()},dispose:function(){var G=this,l=G._view,V=G.$1g;l&&(G._autoShow?(F(l,"mouseover",G.$2g),F(l,"mouseout",G.$4g),F(V._view,"mouseout",G.$4g)):(F(l,"mouseover",G.$8g),F(l,"mouseout",G.$8g),F(l,I?"touchstart":"mousedown",G.$6g),F(O(),I?"touchstart":"mousedown",G.$9b)),F(O(),"keydown",G.$3b),V.dispose(),l.parentNode&&d(l.parentNode,l),G._view=G.$1g=G.$16g=G._items=G.$17g=G.$2g=G.$4g=G.$6g=G.$8g=G.$9b=G.$3b=j)},$19g:function(C,s,A,b){var T=o.initContext(C);o.translateAndScale(T,0,0,1),T.clearRect(0,0,A,b),_.drawStretchImage(T,_.getImage(s),"fill",0,0,A,b),T.restore()},validateImpl:function(){var H,U,t,h=this,O=h._view,X=O.querySelectorAll(".menu-item-icon");for(t=0;t<X.length;t++){var s=X[t];H=s.clientWidth,U=s.clientHeight,H&&U&&(o.setCanvas(s,H,U),h.$19g(s,_.getImage(s.$20g),H,U))}}})}("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:(0,eval)("this"),Object); |