📄 gui2.moz.js
字号:
/* * Bindows 1.5 * http://www.bindows.net/ * Copyright (c) 2003-2005 MB Technologies * * Bindows(tm) belongs to MB Technologies (Georgia, USA). All rights reserved. * You are not allowed to copy or modify this code. Commercial use requires * license. */var xulNs="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";var menuCache={_count:0,_idPrefix:"-menu-cache-",getId:function(){return this._idPrefix+this._count++;},remove:function(o){delete this[o.id];}};function BiMenu(){if(_biInPrototype)return;BiEventTarget.call(this);this._children=[];this._xulElement=document.createElementNS(xulNs,"menupopup");this.id=menuCache.getId();menuCache[this.id]=this;this._xulElement.setAttribute("id",this.id);this._xulElement.setAttribute("onpopupshowing","menuCache[this.id]._onbeforeshow()");this._xulElement.setAttribute("onpopupshown","menuCache[this.id]._onshow()");this._xulElement.setAttribute("onpopuphidden","menuCache[this.id]._onhide()");}
_p=_biExtend(BiMenu,BiEventTarget,"BiMenu");_p._parent=null;_p._left=0;_p._top=0;_p._width=null;_p._height=null;_p._component=null;_p._showTimeStamp=new Date(0);_p._hideTimeStamp=new Date(0);_p._visible=false;BiMenu.prototype.getShowTimeStamp=function(){return this._showTimeStamp;};BiMenu.prototype.getHideTimeStamp=function(){return this._hideTimeStamp;};_p._onbeforeshow=function()
{this.dispatchEvent(new BiEvent("beforeshow"));};_p._onshow=function()
{this._showTimeStamp=new Date;this._visible=true;this._updateLocation();this.dispatchEvent(new BiEvent("show"));};_p._onhide=function()
{this._hideTimeStamp=new Date;this._visible=false;this._updateLocation();this.dispatchEvent(new BiEvent("hide"));};_p.add=function(oChild,oBefore){if(oBefore)
this._xulElement.insertBefore(oChild._xulElement,oBefore._xulElement);else this._xulElement.appendChild(oChild._xulElement);var p=oChild._parent;if(oBefore==null){if(p!=null)
p.remove(oChild);this._children.push(oChild);}
else{if(oBefore._parent!=this)
throw new Error("Can only add components before siblings");if(p!=null)
p.remove(oChild);this._children.insertBefore(oChild,oBefore);}
oChild._parent=this;};_p.addAt=function(oChild,nIndex){if(nIndex!=null){var before=this._children[nIndex];this.add(oChild,before);}
else{this.add(oChild);}};_p.remove=function(oChild){this._xulElement.removeChild(oChild._xulElement);if(oChild._parent!=this)
throw new Error("Can only remove children");this._children.remove(oChild);oChild._parent=null;return oChild;};_p.removeAt=function(nIndex){this.remove(this._children[nIndex]);};_p.removeAll=function()
{var cs=this.getChildren();var c;var l=cs.length;for(var i=0;i<l;i++)
{c=cs[i];this.remove(c);c.dispose();}};BiMenu.prototype.getParent=function(){return this._parent;};_p.getParentMenu=function(){if(this._parent)
return this._parent.getParent();return null;};BiMenu.prototype.getChildren=function(){return this._children;};_p.hasChildren=function(){return this._children.length>0;};_p.getTopLevelComponent=function(){if(this._parent==null)return null;return this._parent.getTopLevelComponent();};_p.contains=function(oDescendant){if(oDescendant==this)return true;var p=oDescendant.getParent();if(p==null)return false;return this.contains(p);};_p.getFirstChild=function(){return this._children[0];};_p.getLastChild=function(){return this._children[this._children.length-1];};_p.setVisible=function(b){if(b)
{this._insertContextMenu();this._xulElement.showPopup();}
else {try
{this._xulElement.hidePopup();}
catch(ex){}}};_p.setLocation=function(nLeft,nTop){this._left=nLeft;this._top=nTop;this._updateLocation();};_p._insertContextMenu=function()
{var mbLeft=0,mbTop=0;var mb,m;if(!BiMenu._contextMenuBar)
{mb=BiMenu._contextMenuBar=document.createElementNS(xulNs,"menubar");mb.setAttribute("class","context-menu-menubar");m=document.createElementNS(xulNs,"menu");m.setAttribute("label","");m.setAttribute("style","-moz-opacity:0;opacity:0;");mb.appendChild(m);document.body.appendChild(mb);this._updateLocation();}
mb=BiMenu._contextMenuBar;m=mb.firstChild;BiMenu._contextMenuBar.removeChild(m);while(m.hasChildNodes())
m.removeChild(m.lastChild);m.appendChild(this._xulElement);BiMenu._contextMenuBar.appendChild(m);};_p._updateLocation=function()
{if(BiMenu._contextMenuBar)
{var mb=BiMenu._contextMenuBar;var mbLeft=0,mbTop=0;var docBo=document.getBoxObjectFor(document.documentElement);var mbHeight=mb.boxObject.height;if(this._left)
{this._left=Math.max(0,Math.min(this._left,window.screen.width-this.getWidth()));mbLeft=this._left-docBo.screenX;}
if(this._top)
{if(this._top+this.getHeight()>=window.screen.height)
this._top-=this.getHeight();mbTop=this._top-docBo.screenY;}
mb.setAttribute("style","position:absolute;overflow:hidden;"+"width:0;height:0;"+"left:"+mbLeft+"px;top:"+(mbTop-mbHeight)+"px;");}};_p.setLeft=function(nLeft){this.setLocation(nLeft,this.getTop());};_p.getLeft=function(){return this._xulElement.boxObject.x;};_p.getScreenLeft=function(){return this.getLeft();};_p.getScreenTop=function(){return this.getTop();};_p.setTop=function(nTop){this.setLocation(this.getLeft(),nTop);};_p.getTop=function(){return this._xulElement.boxObject.y;};_p.setSize=function(nWidth,nHeight)
{this._width=nWidth;this._height=nHeight;if(this.getIsVisible())
this._xulElement.sizeTo(nWidth,nHeight);};_p.setWidth=function(nWidth)
{this.setSize(nWidth,this.getHeight());};_p.getWidth=function(){if(!this._xulElement.parentNode)
this._insertContextMenu();return this._xulElement.boxObject.width;};_p.setHeight=function(nWidth)
{this.setSize(nWidth,this.getHeight());};_p.getHeight=function(){if(!this._xulElement.parentNode)
this._insertContextMenu();return this._xulElement.boxObject.height;};_p.getIsVisible=function(){return this._visible;};_p.getPreferredWidth=function(){return this.getWidth();};_p.getPreferredHeight=function(){return this.getHeight();};_p.getInsetLeft=function(){var w=this._xulElement.ownerDocument.defaultView;return parseInt(w.getComputedStyle(this._xulElement,"").borderLeftWidth);};_p.getInsetRight=function(){var w=this._xulElement.ownerDocument.defaultView;return parseInt(w.getComputedStyle(this._xulElement,"").borderRightpWidth);};_p.getInsetTop=function(){var w=this._xulElement.ownerDocument.defaultView;return parseInt(w.getComputedStyle(this._xulElement,"").borderTopWidth);};_p.getInsetBottom=function(){var w=this._xulElement.ownerDocument.defaultView;return parseInt(w.getComputedStyle(this._xulElement,"").borderBottomWidth);};_p.dispose=function(){if(this._disposed)return;BiEventTarget.prototype.dispose.call(this);var cs=this._children;for(var i=cs.length-1;i>=0;i--){cs[i].dispose();}
this._children=null;this._xulElement=null;this._component=null;this._parent=null;};BiMenu.prototype.getComponent=function(){return this._component;};_p.setRightToLeft=function(b)
{var s=this._xulElement.getAttribute("style");s=s.replace(/\s*direction\:[^;]*;?/gi,"");if(b==true)
s+=";direction:rtl";else if(b==false)
s+=";direction:ltr";this._xulElement.setAttribute("style",s);};_p.getRightToLeft=function()
{var w=this._xulElement.ownerDocument.defaultView;var v=w.getComputedStyle(this._xulElement,"").direction;if(v==null&&this._parent)
return this._parent.getRightToLeft();return v=="rtl";};_p._invalidate=function(){};_p.addXmlNode=function(oNode,oXmlResourceParser)
{if(oNode.nodeType==1)
{var c=oXmlResourceParser.fromNode(oNode);if(c instanceof BiMenuItem)
this.add(c);}};function BiMenuItem(sText,oSubMenu){if(_biInPrototype)return;BiEventTarget.call(this);this._subMenu=oSubMenu;if(oSubMenu){this._xulElement=document.createElementNS(xulNs,"menu");this._xulElement.appendChild(oSubMenu._xulElement);}
else this._xulElement=document.createElementNS(xulNs,"menuitem");this._xulElement.setAttribute("label",sText);this.id=menuCache.getId();menuCache[this.id]=this;this._xulElement.setAttribute("id",this.id);this._xulElement.setAttribute("oncommand","menuCache[this.id]._onaction();event.stopPropagation()");};_p=_biExtend(BiMenuItem,BiEventTarget,"BiMenuItem");BiMenuItem.prototype.getParent=function(){return this._parent;};_p.getTopLevelComponent=function(){if(this._parent==null)return null;return this._parent.getTopLevelComponent();};_p.contains=function(oDescendant){if(oDescendant==this)return true;var p=oDescendant.getParent();if(p==null)return false;return this.contains(p);};_p.getPreviousSibling=function(){var p=this.getParent();if(p==null)return null;var cs=p.getChildren();return cs[cs.indexOf(this)-1]};_p.getNextSibling=function(){var p=this.getParent();if(p==null)return null;var cs=p.getChildren();return cs[cs.indexOf(this)+1]};_p.getText=function(){var s=this._xulElement.getAttribute("label");return s!="undefined"?s:"";};_p.setText=function(sText){return this._xulElement.setAttribute("label",sText);};_p.getHtml=function()
{return BiLabel.textToHtml(this.getText());};_p.setHtml=function(sHtml)
{this.setText(BiLabel.htmlToText(sHtml));};_p.setIcon=function(oIcon){this._icon=oIcon;if(oIcon==null)
{this._xulElement.removeAttribute("style");this._xulElement.removeAttribute("class");}
else {this._xulElement.setAttribute("style","list-style-image: url('"+oIcon.getUri()+"');");this._xulElement.setAttribute("class","menuitem-iconic menu-iconic");}};_p.getIcon=function(){return this._icon;};_p.setMnemonic=function(s){this._xulElement.setAttribute("accesskey",s);};_p.getMnemonic=function(){return this._xulElement.getAttribute("accesskey");};BiMenuItem.prototype.getSubMenu=function(){return this._subMenu;};_p.setSubMenu=function(oMenu){if(this._subMenu!=oMenu)
{if(this._subMenu)
this._subMenu._parent=null;if(this._subMenu&&oMenu)
{this._xulElement.replaceChild(oMenu._xulElement,this._subMenu._xulElement);}
else if(this._subMenu&&!oMenu)
{var mi=document.createElementNS(xulNs,"menuitem");BiMenuItem._copyProperties(this._xulElement,mi);if(this._xulElement.parentNode)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -