⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 window.js

📁 在流览器上仿CS界面的JAVASCRIPT脚本
💻 JS
📖 第 1 页 / 共 4 页
字号:
/* * Bindows 1.10 * http://www.bindows.net/ * Copyright (c) 2003-2004 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. */function BiMoveHandle(oHandleFor){BiComponent.call(this);this.setCursor("move");this._handleFor=oHandleFor;this.addEventListener("mousedown",this._startMove,this);}
_p=BiMoveHandle.prototype=new BiComponent;_p._className="BiMoveHandle";_p._handleFor=null;_p._moveDirection="both";BiMoveHandle.prototype.getHandleFor=function(){return this._handleFor;};BiMoveHandle.prototype.setHandleFor=function(v){this._handleFor=v;};BiMoveHandle.prototype.getMoveDirection=function(){return this._moveDirection;};BiMoveHandle.prototype.setMoveDirection=function(v){this._moveDirection=v;};_p.startMove=function(e){this._startMove(e);};_p._startMove=function(e){if(!this._handleFor)return;if(this.dispatchEvent(new BiEvent("movestart"))){var c=this._handleFor;c.addEventListener("mousemove",this._continueMove,this);c.addEventListener("mouseup",this._endMove,this);c.addEventListener("losecapture",this._endMove,this);c.setCapture(true);this._moveData={screenX:e.getScreenX(),screenY:e.getScreenY(),startX:c.getLeft(),startY:c.getTop(),dx:e.getScreenX()-c.getScreenLeft(),dy:e.getScreenY()-c.getScreenTop()};e.preventDefault();}};_p._continueMove=function(e){var c=this._handleFor;var p=c.getParent();var ex=e.getScreenX();var ey=e.getScreenY();var r=p?p._getScreenClientArea():null;ex=Math.max(ex,p?r.left:0);ey=Math.max(ey,p?r.top:0);ex=Math.min(ex,p?r.left+r.width-1:screen.availWidth);ey=Math.min(ey,p?r.top+r.height-1:screen.availHeight);var x=ex-this._moveData.screenX+this._moveData.startX;var y=ey-this._moveData.screenY+this._moveData.startY;if(this.dispatchEvent(new BiEvent("beforemove"))){if(this._moveDirection=="both")
c.setLocation(x,y);else if(this._moveDirection=="horizontal")
c.setLeft(x);else c.setTop(y);this.dispatchEvent(new BiEvent("move"));}
e.preventDefault();};_p._endMove=function(e){var c=this._handleFor;c.removeEventListener("mousemove",this._continueMove,this);c.removeEventListener("mouseup",this._endMove,this);c.removeEventListener("losecapture",this._endMove,this);c.setCapture(false);this._moveData=null;this.dispatchEvent(new BiEvent("moveend"));e.preventDefault();};_p.dispose=function(){if(this._disposed)return;BiComponent.prototype.dispose.call(this);this._handleFor=null;this._moveData=null;};function BiResizeHandle(oHandleFor){BiComponent.call(this);this.setCssClassName("bi-resize-handle");this._handleChar1=new BiLabel("o");this._handleChar1.setCssClassName("bi-handle-char bi-handle-char-o");this._handleChar1.setRight(0);this._handleChar1.setBottom(0);this.add(this._handleChar1);this._handleChar2=new BiLabel("p");this._handleChar2.setCssClassName("bi-handle-char bi-handle-char-p");this._handleChar2.setRight(0);this._handleChar2.setBottom(0);this.add(this._handleChar2);this.setSize(18,18);this.setRight(0);this.setBottom(0);this._handleFor=oHandleFor;this.addEventListener("mousedown",this._startResize,this);}
var _p=BiResizeHandle.prototype=new BiComponent;_p._className="BiResizeHandle";_p._handleFor=null;_p._resizeDirection="se";BiResizeHandle.prototype.getHandleFor=function(){return this._handleFor;};BiResizeHandle.prototype.setHandleFor=function(v){this._handleFor=v;};_p.setResizeDirection=function(sDir){this._resizeDirection=sDir;this.setCursor(sDir+"-resize");};BiResizeHandle.prototype.getResizeDirection=function(){return this._resizeDirection;};_p.startResize=function(sDir,e){if(sDir)
this.setResizeDirection(sDir);this._startResize(e);};_p._startResize=function(e){if(!this._handleFor)return;if(this.dispatchEvent(new BiEvent("resizestart"))){var c=this._handleFor;c.addEventListener("mousemove",this._continueResize,this);c.addEventListener("mouseup",this._endResize,this);c.addEventListener("losecapture",this._endResize,this);c.setCapture(true);this._resizeData={screenX:e.getScreenX(),screenY:e.getScreenY(),startX:c.getLeft(),startY:c.getTop(),startW:c.getWidth(),startH:c.getHeight(),dx:e.getScreenX()-c.getScreenLeft(),dy:e.getScreenY()-c.getScreenTop()};e.preventDefault();}};_p._continueResize=function(e){var dir=this._resizeDirection;var c=this._handleFor;var p=c.getParent();var width=this._resizeData.startW;var height=this._resizeData.startH;var left=this._resizeData.startX;var top=this._resizeData.startY;var r=p?p._getScreenClientArea():null;var ex=e.getScreenX();var ey=e.getScreenY();ex=Math.max(ex,p?r.left:0);ey=Math.max(ey,p?r.top:0);ex=Math.min(ex,p?r.left+r.width-1:screen.availWidth);ey=Math.min(ey,p?r.top+r.height-1:screen.availHeight);if(/e/i.test(dir)){width=Math.max(Number(c.getMinimumWidth()),Math.min(Number(c.getMaximumWidth()),ex-(this._resizeData.screenX-this._resizeData.startW)));}
else if(/w/i.test(dir)){width=Math.max(Number(c.getMinimumWidth()),Math.min(Number(c.getMaximumWidth()),this._resizeData.startW+this._resizeData.startX-ex+(this._resizeData.screenX-this._resizeData.startX)));left=this._resizeData.startW+this._resizeData.startX-width;}
if(/s/i.test(dir)){height=Math.max(Number(c.getMinimumHeight()),Math.min(Number(c.getMaximumHeight()),ey-(this._resizeData.screenY-this._resizeData.startH)));}
else if(/n/i.test(dir)){height=Math.max(Number(c.getMinimumHeight()),Math.min(Number(c.getMaximumHeight()),this._resizeData.startH+this._resizeData.startY-ey+(this._resizeData.screenY-this._resizeData.startY)));top=this._resizeData.startH+this._resizeData.startY-height;}
if(this.dispatchEvent(new BiEvent("beforeresize"))){c.setSize(width,height);c.setLocation(left,top);this.dispatchEvent(new BiEvent("resize"));}
e.preventDefault();};_p._endResize=function(e){var c=this._handleFor;c.removeEventListener("mousemove",this._continueResize,this);c.removeEventListener("mouseup",this._endResize,this);c.removeEventListener("losecapture",this._endResize,this);c.setCapture(false);this._resizeData=null;this.dispatchEvent(new BiEvent("resizeend"));e.preventDefault();};_p.dispose=function(){if(this._disposed)return;BiComponent.prototype.dispose.call(this);this._handleFor=null;this._resizeData=null;};function BiWindow(sCaption){BiComponent.call(this);this.setCssClassName("bi-window");this.setSize(400,200);this.setTabIndex(0);this.setHideFocus(true);this._focusManager=new BiFocusManager;this._commands={};this._windowCaption=new BiComponent;this._windowCaption.setCssClassName("bi-window-caption");this._windowIcon=new BiImage(BiWindow.DEFAULT_ICON,16,16);this._captionLabel=new BiLabel(sCaption)
this._minimizeButton=new BiButton();this._minimizeButton.setHtml("<span>0</span>");this._minimizeButton.setTabIndex(-1);this._minimizeButton._setHtmlAttribute("buttontype","minimize");this._maximizeButton=new BiButton();this._maximizeButton.setHtml("<span>1</span>");this._maximizeButton.setTabIndex(-1);this._maximizeButton._setHtmlAttribute("buttontype","maximize");this._closeButton=new BiButton();this._closeButton.setHtml("<span>r</span>");this._closeButton.setTabIndex(-1);this._closeButton._setHtmlAttribute("buttontype","close");this._contentPane=new BiComponent;this._contentPane.setCursor("default");this._windowCaption.add(this._windowIcon);this._windowCaption.add(this._captionLabel);this._windowCaption.add(this._minimizeButton);this._windowCaption.add(this._maximizeButton);this._windowCaption.add(this._closeButton);BiComponent.prototype.add.call(this,this._windowCaption);BiComponent.prototype.add.call(this,this._contentPane);this._fixedLayout();this._resizeHandler=new BiResizeHandle(this);this._moveHandler=new BiMoveHandle(this);this._captionLabel.addEventListener("mousedown",this._onCaptionDown,this);this._minimizeButton.addEventListener("click",this._onMinimizeButtonClick,this);this._maximizeButton.addEventListener("click",this._onMaximizeButtonClick,this);this._closeButton.addEventListener("click",this._onCloseButtonClick,this);this._captionLabel.addEventListener("dblclick",this._onMaximizeButtonClick,this);this._windowIcon.addEventListener("dblclick",this._onCloseButtonClick,this);this.addEventListener("mousemove",this._checkForResize);this.addEventListener("mousedown",this._onEdgeDown);this.addEventListener("focusin",this._onFocusIn);this.addEventListener("focusout",this._onFocusOut);this.addEventListener("focus",this._onFocus);this.addEventListener("mouseover",this._onMouseEvent);this.addEventListener("mousemove",this._onMouseEvent);this.addEventListener("mouseout",this._onMouseEvent);this.addEventListener("mousedown",this._onMouseEvent);this.addEventListener("mouseup",this._onMouseEvent);this.addEventListener("click",this._onMouseEvent);this.addEventListener("dblclick",this._onMouseEvent);this.addEventListener("contextmenu",this._onMouseEvent);this.addEventListener("mousewheel",this._onMouseEvent);this.addEventListener("keydown",this._onkeydown);this.addEventListener("keydown",this._onDefaultButtonKeyDown);this.addEventListener("keydown",this._onKeyEvent);this.addEventListener("keypress",this._onKeyEvent);this.addEventListener("keyup",this._onKeyEvent);}
var _p=BiWindow.prototype=new BiComponent;_p._className="BiWindow";BiWindow.DEFAULT_ICON=application.getPath()+"images/default.16.gif";_p._showIcon=true;_p._showMinimize=true;_p._showMaximize=true;_p._showClose=true;_p._canMinimize=true;_p._resizable=true;_p._movable=true;_p._state="normal";_p._icon=null;_p._activeComponent=null;_p._lastActive=null;_p._hideChrome=false;_p._minimumWidth=120;_p._maximumWidth=Infinity;_p._minimumHeight=27;_p._maximumHeight=Infinity;_p.layoutAllChildren=function(){BiComponent.prototype.layoutAllChildren.call(this);this._layoutChrome();};_p.layoutAllChildrenX=function(){BiComponent.prototype.layoutAllChildrenX.call(this);this._layoutChromeX();};_p.layoutAllChildrenY=function(){BiComponent.prototype.layoutAllChildrenY.call(this);this._layoutChromeY();};_p._fixedLayout=function(){this._windowCaption.setLocation(2,2);this._windowCaption.setRight(2);this._windowCaption.setHeight(19);this._windowIcon.setLocation(2,1);this._minimizeButton.setSize(16,14);this._maximizeButton.setSize(16,14);this._closeButton.setSize(16,14);this._minimizeButton.setTop(2);this._maximizeButton.setTop(2);this._closeButton.setTop(2);this._closeButton.setRight(2);this._setContentPaneSize();this._captionLabel.setTop(0);this._captionLabel.setBottom(0);this._windowIcon.setVisible(this._showIcon);this._minimizeButton.setVisible(this._showMinimize);this._maximizeButton.setVisible(this._showMaximize);this._closeButton.setVisible(this._showClose);};_p._layoutChromeX=function(){if(this._showIcon)
this._captionLabel.setLeft(18);else this._captionLabel.setLeft(0);var r=2;if(this._showClose)r+=18;this._maximizeButton.setRight(r);if(this._showMaximize)r+=16;this._minimizeButton.setRight(r);if(this._showMinimize)r+=16;r+=2;this._captionLabel.setRight(r);};_p._layoutChromeY=function(){};_p._layoutChrome=function(){this._layoutChromeX();};BiWindow.prototype.getContentPane=function(){return this._contentPane;};_p.setContentPane=function(oComp){if(oComp&&oComp!=this._contentPane){this.add(oComp,this._contentPane);this.remove(this._contentPane);this._contentPane=oComp;this._setContentPaneSize();oComp.setCursor("default");}};BiWindow.prototype.getShowIcon=function(){return this._showIcon;};BiWindow.prototype.getShowMinimize=function(){return this._showMinimize;};BiWindow.prototype.getShowMaximize=function(){return this._showMaximize;};BiWindow.prototype.getShowClose=function(){return this._showClose;};_p.setShowIcon=function(b){if(this._showIcon!=b){this._showIcon=b;this._windowIcon.setVisible(b);this._layoutChrome();}};_p.setShowMinimize=function(b){if(this._showMinimize!=b){this._showMinimize=b;this._minimizeButton.setVisible(b);this._layoutChrome();}};_p.setShowMaximize=function(b){if(this._showMaximize!=b){this._showMaximize=b;this._maximizeButton.setVisible(b);this._layoutChrome();}};_p.setShowClose=function(b){if(this._showClose!=b){this._showClose=b;this._closeButton.setVisible(b);this._layoutChrome();}};_p.setCaption=function(sCaption){var oldCaption=this._captionLabel.getText();this._captionLabel.setText(sCaption);if(oldCaption!=this._captionLabel.getText())
this.dispatchEvent(new BiEvent("captionchanged"));};_p.getCaption=function(){return this._captionLabel.getText();};_p.getIcon=function(){if(this._icon==null)
this._icon=new BiImage(this._windowIcon.getUri(),16,16);return this._icon;};_p.setIcon=function(oImage){if(oImage==null)
oImage=new BiImage(BiWindow.DEFAULT_ICON,16,16);var oldUri=this.getIcon().getUri();this._windowIcon.setUri(oImage.getUri());this._icon=oImage;if(oldUri!=oImage.getUri())
this.dispatchEvent(new BiEvent("iconchanged"));};_p.setCanMinimize=function(b){if(this._canMinimize!=b){this._canMinimize=b;this._minimizeButton.setEnabled(b);}};BiWindow.prototype.getCanMinimize=function(){return this._canMinimize;};_p.setHideChrome=function(b){if(this._hideChrome!=b){this._hideChrome=b;this._windowCaption.setVisible(!b);this._setContentPaneSize();}};_p._setContentPaneSize=function(){if(this._hideChrome){this._contentPane.setLocation(0,0);this._contentPane.setRight(0);this._contentPane.setBottom(0);}
else{this._contentPane.setLocation(2,21);this._contentPane.setRight(2);this._contentPane.setBottom(2);}};BiWindow.prototype.getHideChrome=function(){return this._hideChrome;};_p.setResizable=function(b){if(this._resizable!=b){this._resizable=b;this._maximizeButton.setEnabled(b);}};BiWindow.prototype.getResizable=function(){return this._resizable;};_p.getMovable=function(){return this.getState()=="normal"&&this._movable;};BiWindow.prototype.setMovable=function(v){this._movable=v;};_p.getMaximumWidth=function(){return this._maximumWidth;};_p.getMinimumWidth=function(){return this._minimumWidth;};_p.getMaximumHeight=function(){return this._maximumHeight;};_p.getMinimumHeight=function(){return this._minimumHeight;};_p.getPreferredWidth=function(){return this.getInsetLeft()+this._contentPane.getLeft()+this._contentPane.getPreferredWidth()+this._contentPane.getRight()+this.getInsetRight();};_p.getPreferredHeight=function(){return this.getInsetTop()+this._contentPane.getTop()+this._contentPane.getPreferredHeight()+this._contentPane.getBottom()+this.getInsetBottom();};_p.layoutComponentX=function(){if(this._width!=null)
this._width=Math.max(this.getMinimumWidth(),Math.min(this.getMaximumWidth(),this._width));BiComponent.prototype.layoutComponentX.call(this);};_p.layoutComponentY=function(){if(this._height!=null)
this._height=Math.max(this.getMinimumHeight(),Math.min(this.getMaximumHeight(),this._height));BiComponent.prototype.layoutComponentY.call(this);};_p.layoutComponent=function(){if(this._width!=null)
this._width=Math.max(this.getMinimumWidth(),Math.min(this.getMaximumWidth(),this._width));if(this._height!=null)
this._height=Math.max(this.getMinimumHeight(),Math.min(this.getMaximumHeight(),this._height));BiComponent.prototype.layoutComponent.call(this);};_p.close=function(){var rv=this.dispatchEvent(new BiEvent("beforeclose"));if(rv){if(this._parent)
this._parent.remove(this);this.dispatchEvent(new BiEvent("close"));this.dispose();}};_p.setState=function(s){if(s=="minimized"&&!this._canMinimize||s=="maximized"&&!this._resizable)
return;if(this._state!=s){if(this._state=="normal"){this._normalWidth=this.getWidth();this._normalHeight=this.getHeight();this._normalLeft=this.getLeft();this._normalTop=this.getTop();if(this._normalLeft==null)
this._normalLeft=0;if(this._normalTop==null)
this._normalTop=0;}
this._state=s;this.setVisible(this._state!="minimized");if(this._state=="maximized"){var h=this.getContentPane().getHeight();this.setLocation(-4,-4);this.setRight(-4);this.setBottom(-4);this._maximizeButton.setHtml("<span>2</span>");this._maximizeButton._setHtmlAttribute("buttontype","restore");if(h<=0)
this.layoutAllChildren();}
else if(this._state=="normal"){this.setLocation(this._normalLeft,this._normalTop);this.setRight(null);this.setBottom(null);this.setSize(this._normalWidth,this._normalHeight);this._maximizeButton.setHtml("<span>1</span>");this._maximizeButton._setHtmlAttribute("buttontype","maximize");}
this.dispatchEvent(new BiEvent("statechanged"));}};BiWindow.prototype.getState=function(){return this._state;};_p.activate=function(){this.setActive(true);};_p.setActive=function(b){if(this._active!=b){this._active=b;this.setCssClassName("bi-window"+(b?" active":""));if(b){this.bringToFront();this.setFocused(true);this.dispatchEvent(new BiEvent("activated"));}
else{this.setFocused(false);this.dispatchEvent(new BiEvent("deactivated"));}}};BiWindow.prototype.getActive=function(){return this._active;};_p.bringToFront=function(){var p=this._parent;if(this.getCreated()&&p){var cs=p.getChildren();var max= -Infinity;for(var i=0;i<cs.length;i++)
max=Math.max(max,cs[i].getZIndex());}
this.setZIndex(max+1);};_p.sendToBack=function(){var p=this._parent;if(this.getCreated()&&p){var cs=p.getChildren();var min=Infinity;for(var i=0;i<cs.length;i++)
min=Math.min(min,cs[i].getZIndex());}
this.setZIndex(min-1);};_p.getFocusRoot=function(){return this;};_p.isFocusRoot=function(){return true;};_p.getActiveComponent=function(){if(this._activeComponent&&this._activeComponent.getDisposed())
this._activeComponent=null;return this._activeComponent;};BiWindow.prototype.getAcceptButton=function(){return this._acceptButton;};BiWindow.prototype.setAcceptButton=function(v){this._acceptButton=v;};BiWindow.prototype.getCancelButton=function(){return this._cancelButton;};BiWindow.prototype.setCancelButton=function(v){this._cancelButton=v;};_p.addCommand=function(c)
{if(c.getOwnerWindow())
c.getOwnerWindow().removeCommand(c);this._commands[c.toHashCode()]=c;c._ownerWindow=this;};_p.removeCommand=function(c)
{delete this._commands[c.toHashCode()];c._ownerWindow=null;};_p._onCloseButtonClick=function(e){this.close();};_p._onMinimizeButtonClick=function(e){if(this._canMinimize)
this.setState("minimized");};_p._onMaximizeButtonClick=function(e){if(this._resizable){if(this.getState()=="normal")
this.setState("maximized");else this.setState("normal");}};_p._onCaptionDown=function(e){this.setActive(true);if(!this.getMovable())return;this._moveHandler.startMove(e);};_p._onMouseEvent=function(e){e.stopPropagation();};_p._checkForResize=function(e){if(this._resizeData)return;this._resizeDir="";if(this._moveData==null&&e.getTarget()==this){if(this.getResizable()){var oy=e.getOffsetY();if(oy<=20)
this._resizeDir+="n";else if(oy>=this.getHeight()-20)
this._resizeDir+="s";var ox=e.getOffsetX();if(ox<=20)
this._resizeDir+="w";else if(ox>=this.getWidth()-20)
this._resizeDir+="e";}
if(this._resizeDir!="")
this.setCursor(this._resizeDir+"-resize");else this.setCursor("default");}};_p._onEdgeDown=function(e){this.setActive(true);if(this._resizeDir!=""&&e.getTarget()==this){this._resizeHandler.startResize(this._resizeDir,e);}};_p._onFocus=function(e){if(this._lastActive&&this.contains(this._lastActive)&&this._lastActive.getCanFocus()){this._lastActive.setFocused(true);}};_p._onFocusIn=function(e){if(e.getTarget()!=this)
this._lastActive=e.getTarget();this.activate();e.stopPropagation();};_p._onFocusOut=function(e){if(this.contains(e.getRelatedTarget()))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -