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

📄 coreclasses.js

📁 Bindows 1.01 完全版 Bindows 框架提供给你: 基于类的面向对象 API; 一个完整的窗口系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
_p._setCssProperties = function(){    var es = this._element.style;    var sp = this._style;    for (var p in sp)    {        es[p] = sp[p];    }};_p._setHtmlProperties = function(){    var el = this._element;    var hp = this._htmlProperties;    for (var p in hp)    {        el[p] = hp[p];    }};_p._setHtmlAttributes = function(){    var el = this._element;    var ha = this._htmlAttributes;    for (var n in ha)        el.setAttribute(n, ha[n]);};_p._addHtmlElementToParent = function(oParent, oBefore, bLayout){    if (this._lazyCreate && !this.getVisible())        return;    if (bLayout == null)        bLayout = true;    if (!this._created)        this._create(oParent._document);    if (oBefore && oBefore._element)        oParent._element.insertBefore(this._element, oBefore._element);    else        oParent._element.appendChild(this._element);    this._created = true;    this._createChildren(oParent._document, false);    if (bLayout)        oParent.layoutChild(this);    this.dispatchEvent(BiComponent._createEvent);};_p._removeHtmlElement = function(oChild){    oChild._removeHtmlElementFromParent(this);} ;_p._removeHtmlElementFromParent = function(oParent){    if (this._created && !(application && application._disposed))        oParent._element.removeChild(this._element);};_p._oninlineevent = function(e){    if (this._disposed)        return;    if (!e)        e = this._document.parentWindow.event;    switch (e.type)    {        case "losecapture":        this._capture = false;        this.getTopLevelComponent()._eventManager.setCaptureComponent(null);        break;        case "focus":        if (this.getCanFocus())            this.getTopLevelComponent()._eventManager._mozOnFocus(e, this, this._element);        return;    }    this.dispatchEvent(new BiEvent(e.type));};_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();    if (this._border != BiComponent.prototype._border)        this._border.dispose();    this._border = null;    var el = this._element;    if (el)    {        el._biComponent = null;        el.onscroll = el.onresize = el.onfocus = el.onlosecapture = null;    }    this.__oninlineevent = null;    this._document = null;    this._style = null;    this._htmlProperties = null;    this._children = null;    this._parent = null;    this._element = null;    this._created = false;};_p.addXmlNode = function(oNode, oParser){    if (oNode.nodeType == 1)    {        var c = oParser.fromNode(oNode);        if (c instanceof BiComponent)            this.add(c);    }};_p.setAttribute = function(sName, sValue, oParser){    switch (sName)    {        case "border":        if (sValue.charAt(0) == "#")        {            sValue = sValue.substr(1);            var b = oParser.getComponentById(sValue);            this.setBorder(b);        }        else            this.setBorder(BiBorder.fromString(sValue));        break;        case "contextMenu":        case "toolTip":        case "command":        if (sValue.charAt(0) == "#")            sValue = sValue.substr(1);        var ref = oParser.getComponentById(sValue);        this.setProperty(sName, ref);        break;        default:            BiEventTarget.prototype.setAttribute.apply(this, arguments);    }};_p._command = null;BiComponent.prototype.getCommand = function(){    return this._command;} ;_p.setCommand = function(oCommand){    if (this._command != oCommand)    {        if (this._command)        {            this._command.removeEventListener("enabledchanged", this._syncWithCommmand, this);            this._command.removeEventListener("checkedchanged", this._syncWithCommmand, this);            this._command.removeEventListener("uservaluechanged", this._syncWithCommmand, this);            this._command.removeEventListener("shortcutchanged", this._syncWithCommmand, this);        }        this._command = oCommand;        if (this._command)        {            this._syncWithCommmand();            this._command.addEventListener("enabledchanged", this._syncWithCommmand, this);            this._command.addEventListener("checkedchanged", this._syncWithCommmand, this);            this._command.addEventListener("uservaluechanged", this._syncWithCommmand, this);            this._command.addEventListener("shortcutchanged", this._syncWithCommmand, this);        }    }};_p._syncWithCommmand = function(){    if (this._command)    {        this.setEnabled(this._command.getEnabled());    }};function BiApplicationWindow(){    BiComponent.call(this);    this.removeHtmlProperty("className");    this.removeHtmlProperty("id");    this.setRightToLeft(false);    this._shownDialogs = [];    this._commands = {    };    this._eventManager = new BiEventManager;    this._focusManager = new BiFocusManager;    this._glassPane = new BiComponent;    this._glassPane.setCssClassName("bi-glass-pane");    this._glassPane.setLocation(0, 0);    this._glassPane.setRight(0);    this._glassPane.setBottom(0);    this.addEventListener("resize", this._onresize);    this.addEventListener("keydown", this._ondefaultbuttonkeydown);    this.addEventListener("keydown", this._onkeyevent);    this.addEventListener("keypress", this._onkeyevent);};var _p = BiApplicationWindow.prototype = new BiComponent;_p._className = "BiApplicationWindow";_p._diff = null;_p._insets = null;_p._insetLeft = 4;_p._insetRight = 4;_p._insetTop = 30;_p._insetBottom = 4;_p._lastActive = null;_p._activeComponent = null;_p._globalCursor = null;_p.setLeft = function(nLeft){    this._window.moveTo(nLeft, this.getTop());} ;_p.setRight = function(nRight){    this.setLeft(this._window.screen.width - this.getWidth() - nRight);} ;_p.getScreenLeft = _p.getLeft = function(){    if (BiBrowserCheck.ie)        return this._window.screenLeft - this._getInsets().left;    else        return this._window.screenX;};_p.getRight = function(){    return this._window.screen.width - this.getLeft() - this.getWidth();} ;_p.setTop = function(nTop){    this._window.moveTo(this.getLeft(), nTop);} ;_p.setBottom = function(nBottom){    this.setTop(this._window.screen.height - this.getHeight() - nBottom);} ;_p.setLocation = function(nLeft, nTop){    this._window.moveTo(nLeft, nTop);} ;_p.getScreenTop = _p.getTop = function(){    if (BiBrowserCheck.ie)        return this._window.screenTop - this._getInsets().top;    else        return this._window.screenY;};_p.getBottom = function(){    return this._window.screen.height - this.getTop() - this.getHeight();} ;_p.setWidth = function(nWidth){    if (BiBrowserCheck.ie)        this._window.resizeTo(nWidth, this.getHeight());    else        this._window.outerWidth = nWidth;};_p.getWidth = function(){    if (BiBrowserCheck.ie)        return this._getSize().width;    else        return this._window.outerWidth;};_p.setHeight = function(nHeight){    if (BiBrowserCheck.ie)        this._window.resizeTo(this.getWidth(), nHeight);    else        this._window.outerHeight = nHeight;};_p.setSize = function(nWidth, nHeight){    this._window.resizeTo(nWidth, nHeight);} ;_p.getHeight = function(){    if (BiBrowserCheck.ie)        return this._getSize().height;    else        return this._window.outerHeight;};_p.getInsetLeft = function(){    return this._getInsets().left + BiComponent.prototype.getInsetLeft.call(this);} ;_p.getInsetRight = function(){    return this.getWidth() - this.getInsetLeft() - this.getClientWidth();} ;_p.getInsetTop = function(){    return this._getInsets().top + BiComponent.prototype.getInsetTop.call(this);} ;_p.getInsetBottom = function(){    return this.getHeight() - this.getInsetTop() - this.getClientHeight();} ;_p.getClientLeft = function(){    return -this.getInsetLeft();} ;_p.getClientTop = function(){    return -this.getInsetTop();} ;_p._getScreenClientArea = function(){    if (BiBrowserCheck.ie)        return{            left: this._window.screenLeft, top: this._window.screenTop, width: this._element.clientWidth, height: this._element.clientHeight        };    else    {        var bo = this._document.getBoxObjectFor(this._document.documentElement);        return {            left: bo.screenX, top: bo.screenY, width: this._element.clientWidth, height: this._element.clientHeight        };    }};_p.setZIndex = _p.getZIndex = _p.setVisible = _p.getVisible = function(){    throw new Error("Not supported");} ;_p.getTopLevelComponent = function(){    return this;} ;_p.getIsVisible = function(){    return true;} ;_p.getCaption = function(){    return this._window.document.title;} ;_p.setCaption = function(sTitle){    this._window.document.title = sTitle;} ;_p.getFullScreen = function(){    throw new Error("Not yet implemented");} ;_p.getResizable = function(){    throw new Error("Not yet implemented");} ;_p.close = function(){    this._window.close();} ;_p.print = function(){    this._window.print();} ;_p.isFocusRoot = function(){    return true;} ;_p.getFocusRoot = function(){    return this;} ;_p.getActiveComponent = function(){    if (this._activeComponent && this._activeComponent.getDisposed())        this._activeComponent = null;    return this._activeComponent;};BiApplicationWindow.prototype.getAcceptButton = function(){    return this._acceptButton;} ;BiApplicationWindow.prototype.setAcceptButton = function(v){    this._acceptButton = v;} ;BiApplicationWindow.prototype.getCancelButton = function(){    return this._cancelButton;} ;BiApplicationWindow.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.updateGlassPane = function(oDialog, bVisible){    this._shownDialogs.remove(oDialog);    if (bVisible)    {        this.add(this._glassPane, oDialog);        this._glassPane.setZIndex(oDialog.getZIndex());        if (BiBrowserCheck.moz)        {            oDialog.setZIndex(oDialog.getZIndex() + 1);            oDialog.setZIndex(oDialog.getZIndex() - 1);        }        this._shownDialogs.push(oDialog);    }    else    {        if (this._shownDialogs.length == 0)            this.remove(this._glassPane);        else        {            var d = this._shownDialogs[this._shownDialogs.length - 1];            this._glassPane.setZIndex(d.getZIndex());            d.setActive(true);        }    }};BiApplicationWindow.prototype.getGlobalCursor = function(){    return this._globalCursor;} ;_p.setGlobalCursor = function(sCursor){    this._globalCursor = sCursor;    if (BiBrowserCheck.ie)    {        if (!this._cursorStyleEl)            this._cursorStyleEl = this._document.createStyleSheet();        if (sCursor == null || sCursor == "")            this._cursorStyleEl.cssText = "";        else            this._cursorStyleEl.cssText = "*{cursor:" + sCursor + " !important}";        this.setCapture(true);        this.setCapture(false);    }    else        throw new Error("BiApplicationWindow setGlobalCursor is not yet implemented");};_p._create = function(oWindow){    this._window = oWindow || window;    this._document = this._window.document;    var el = this._element = this._document.body;    el._biComponent = this;    this._window._biComponent = this;    this._document.documentElement._biComponent = this;    this._eventManager.attachToWindow(this._window);    this._setHtmlProperties();    this._setCssProperties();    if (BiBrowserCheck.ie)        el.onscroll = el.onresize = BiComponent.__oninlineevent;    else    {        this._setHtmlAttributes();        el.onscroll = el.onfocus = BiComponent.__oninlineevent;    }    this._created = true;    var cs = this._children;    var l = cs.length;    for (var i = 0; i < l; i++)    {        cs[i]._addHtmlElementToParent(this);    }};_p.dispose = function(){    if (this.getDisposed())        return;    BiComponent.prototype.dispose.call(this);    if (this._cursorStyleEl)    {        this._cursorStyleEl.disabled = true;        this._cursorStyleEl.cssText = "";        this._cursorStyleEl = null    }    for (var i = this._shownDialogs.length - 1; i >= 0; i--)        this._shownDialogs[i] = null;    this._shownDialogs = null;    for (var c in this._commands)        delete this._commands;    this._commands = null;    this._glassPane.dispose();    this._window.document.documentElement._biComponent = null;    this._window._biComponent = null;    this._window = null;};_p._onresize = function(e){    ( new BiPopupManager).hideAutoHiding();    this.layoutAllChildren();};_p._onkeyevent = function(e){    this._focusManager.processKeyEvent(this, e);} ;_p._ondef

⌨️ 快捷键说明

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