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

📄 guicomponents.js

📁 Bindows 1.01 完全版 Bindows 框架提供给你: 基于类的面向对象 API; 一个完整的窗口系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
        if (el == this._input)            return;        this.setChecked(true);        this.dispatchEvent(new BiEvent("action"));    }};_p._oninlineevent = function(e){    if (BiBrowserCheck.ie)    {        var e = this._document.parentWindow.event;        if (e.type == "click")            e.cancelBubble = e.srcElement != this._input;        else            BiComponent.prototype._oninlineevent.call(this, e);    }    else        BiComponent.prototype._oninlineevent.call(this, e);};_p.setAttribute = function(sName, sValue, oParser){    switch (sName)    {        case "group":        if (sValue.charAt(0) == "#")            sValue = sValue.substr(1);        var c = oParser.getComponentById(sValue);        this.setGroup(c);        break;        default:            BiLabel.prototype.setAttribute.apply(this, arguments);    }};_p._syncWithCommmand = function(){    if (this._command)    {        this.setEnabled(this._command.getEnabled());        this.setChecked(this._command.getChecked());        this.setUserValue(this._command.getUserValue());    }};_p.setValue = _p.setChecked;_p.getValue = _p.getChecked;function BiRadioGroup(){    BiEventTarget.call(this);    this._items = [];    this._groupName = BiRadioGroup._radioGroupName + ++BiRadioGroup._radioGroupCount;}BiRadioGroup._radioGroupName = "bi-radio-group-";BiRadioGroup._radioGroupCount = 0;_p = BiRadioGroup.prototype = new BiEventTarget;_p._className = "BiRadioGroup";_p._selected = null;_p._enabled = true;BiRadioGroup.prototype.getItems = function(){    return this._items;} ;_p.add = function(oRadioButton){    if (!this._items.contains(oRadioButton))    {        this._items.push(oRadioButton);        oRadioButton.setGroup(this);        if (oRadioButton.getChecked() || this.getUserValue() != null            && oRadioButton.getUserValue() == this.getUserValue())        {            this.setSelected(oRadioButton);        }        oRadioButton.setEnabled(this.getEnabled());    }};_p.remove = function(oRadioButton){    this._items.remove(oRadioButton);    oRadioButton._group = null;    if (oRadioButton.getChecked())        this.setSelected(null);};_p.setSelected = function(oRadioButton){    if (this._selected != oRadioButton)    {        if (this._selected)            this._selected.setChecked(false);        this._selected = oRadioButton;        if (this._selected)            this._selected.setChecked(true);        this.dispatchEvent(new BiEvent("change"));        if (this._command)            this._command.setUserValue(oRadioButton.getUserValue());    }};BiRadioGroup.prototype.getSelected = function(){    return this._selected;} ;_p.selectNext = function(oRadioButton){    var index = this._items.indexOf(oRadioButton);    if (index == -1)        return;    var i = 0;    var l = this._items.length;    index = (index + 1) % l;    while (i < l && !this._items[index].getIsEnabled())    {        index = (index + 1) % l;        i++;    }    if (this._items[index].getIsEnabled())    {        this.setSelected(this._items[index]);        this._items[index].setFocused(true);    }};_p.selectPrevious = function(oRadioButton){    var index = this._items.indexOf(oRadioButton);    if (index == -1)        return;    var i = 0;    var l = this._items.length;    index = (index - 1 + l) % l;    while (i < l && !this._items[index].getIsEnabled())    {        index = (index - 1 + l) % l;        i++;    }    if (this._items[index].getIsEnabled())    {        this.setSelected(this._items[index]);        this._items[index].setFocused(true);    }};_p.setEnabled = function(b){    if (this._enabled != b)    {        this._enabled = b;        for (var i = 0; i < this._items.length; i++)        {            this._items[i].setEnabled(b);        }        this.dispatchEvent(new BiEvent("enabledchanged"));    }};BiRadioGroup.prototype.getEnabled = function(){    return this._enabled;} ;_p.getUserValue = function(){    var s = this.getSelected()    return s ? s.getUserValue() : null;};_p.setUserValue = function(v){    if (this.getUserValue() != v)    {        for (var i = 0; i < this._items.length; i++)        {            if (this._items[i].getUserValue() == v)            {                this._items[i].setChecked(true);                break;            }        }        if (this._command)            this._command.setUserValue(v);    }};_p._command = null;BiRadioGroup.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("uservaluechanged", this._syncWithCommmand, this);        }        this._command = oCommand;        if (this._command)        {            this._syncWithCommmand();            this._command.addEventListener("enabledchanged", this._syncWithCommmand, this);            this._command.addEventListener("uservaluechanged", this._syncWithCommmand, this);        }    }};_p._syncWithCommmand = function(){    if (this._command)    {        this.setEnabled(this._command.getEnabled());        this.setUserValue(this._command.getUserValue());    }};_p.setAttribute = function(sName, sValue, oParser){    switch (sName)    {        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);    }};function BiTextField(sText){    BiComponent.call(this);    if (sText)        this._text = sText;    this.setCssClassName("bi-text-field");    this.setTabIndex(1);    this.setCanSelect(true);    this.setHtmlProperty("value", this._text);    this.setHtmlProperty("type", "text");    this.addEventListener("keypress", this._onKeyPress);    this.addEventListener("focus", this._onFocus);    this.addEventListener("blur", this._onBlur);}_p = BiTextField.prototype = new BiComponent;_p._className = "BiTextField";_p._tagName = "INPUT";_p._text = "";_p._invalidMessage = "";_p._validator = null;_p.setText = function(sText){    var oldText = this._text;    this._text = sText;    this.setHtmlProperty("value", sText);    if (this._created && BiBrowserCheck.moz && oldText != sText)        this.dispatchEvent(new BiEvent("textchanged"));};_p.getText = function(){    if (this.getCreated())        return this._text = this._element.value;    return this._text;};_p.setFont = function(oFont){    this._font = oFont;    oFont.paintFont(this);};_p.getFont = function(){    return this._font ? this._font : new BiFont;} ;_p.setAlign = function(sAlign){    this.setStyleProperty("textAlign", sAlign);} ;_p.getAlign = function(){    return this.getStyleProperty("textAlign");} ;_p.setVerticalAlign = function(sVerticalAlign){    this.setStyleProperty("verticalAlign", sVerticalAlign);} ;_p.setMaxLength = function(nMaxLength){    this.setHtmlProperty("maxLength", nMaxLength);} ;_p.getMaxLength = function(){    return this.getHtmlProperty("maxLength");} ;_p.setReadOnly = function(bReadOnly){    this.setHtmlProperty("readOnly", bReadOnly);} ;_p.getReadOnly = function(){    return this.getHtmlProperty("readOnly");} ;BiTextField.prototype.getValidator = function(){    return this._validator;} ;BiTextField.prototype.setValidator = function(v){    this._validator = v;} ;BiTextField.prototype.getInvalidMessage = function(){    return this._invalidMessage;} ;BiTextField.prototype.setInvalidMessage = function(v){    this._invalidMessage = v;} ;_p.getIsValid = function(){    if (typeof this._validator != "function")        return true;    return this._validator(this.getText());};BiTextField.createRegExpValidator = function(oRegExp){    return function(s)    {        return oRegExp.test(s);    } ;} ;_p.setSelectionStart = function(nSelectionStart){    if (BiBrowserCheck.ie)    {        var r = this._getRange();        r.collapse();        r.move("character", nSelectionStart);        r.select();    }    else    {        if (!this._created)            throw new Error("Visual property on non created component");        this._element.selectionStart = nSelectionStart;    }};_p.getSelectionStart = function(){    if (BiBrowserCheck.ie)    {        var r = this._getRange();        var sr = this._getSelectionRange();        if (!this._element.contains(sr.parentElement()))            return -1;        r.setEndPoint("EndToStart", sr);        return r.text.length;    }    else    {        if (!this._created)            throw new Error("Visual property on non created component");        return this._element.selectionStart;    }};_p.setSelectionLength = function(nSelectionLength){    if (BiBrowserCheck.ie)    {        var sr = this._getSelectionRange();        if (!this._element.contains(sr.parentElement()))            return;        sr.collapse();        sr.moveEnd("character", nSelectionLength);        sr.select();    }    else    {        if (!this._created)            throw new Error("Visual property on non created component");        this._element.selectionEnd = this._element.selectionStart + nSelectionLength;    }};_p.getSelectionLength = function(){    if (BiBrowserCheck.ie)    {        var sr = this._getSelectionRange();        if (!this._element.contains(sr.parentElement()))            return 0;        return sr.text.length;    }    else    {        if (!this._created)            throw new Error("Visual property on non created component");        return this._element.selectionEnd - this._element.selectionStart;    }};_p.setSelectionText = function(sText){    if (BiBrowserCheck.ie)    {        var sr = this._getSelectionRange();        if (!this._element.contains(sr.parentElement()))            return;        sr.text = sText;    }    else    {        if (!this._created)            throw new Error("Visual property on non created component");        var s = this._element.value;        var before = s.substr(0, this.getSelectionStart());        var after = s.substr(this._element.selectionEnd);        this._element.value = before + sText + after;    }};_p.getSelectionText = function(){    if (BiBrowserCheck.ie)    {        var sr = this._getSelectionRange();        if (!this._element.contains(sr.parentElement()))            return "";        return sr.text;    }    else    {        if (!this._created)            throw new Error("Visual property on non created component");        return this._element.value.substr(this.getSelectionStart(), this.getSelectionLength());    }};_p._getRange = function(){    if (!this._created)        throw new Error("Visual property on non created component");    return this._element.createTextRange();};_p._getSelectionRange = function(){    if (!this._created)        throw new Error("Visual property on non created component");    return this._document.selection.createRange();};_p.selectAll = function(){    if (!this._created)        throw new Error("Visual property on non created component");    this._element.select();};_p._selectOnTabFocus = function(){    this.selectAll();} ;_p._deselectOnTabBlur = function(){    if (BiBrowserCheck.ie)    {        var sr = this._getSelectionRange();        if (!this._element.contains(sr.parentElement()))            return;        sr.collapse();        sr.select();    }    else    {    }};_p.getPreferredWidth = function(){    if (this._preferredWidth != null)        return this._preferredWidth;    if (!this._created)        throw new Error("Visual property on non created component");    if (BiBrowserCheck.ie)    {        var r = this._getRange();        var bcr = r.getBoundingClientRect();        return bcr.right - bcr.left + this.getInsetLeft() + this.getPaddingLeft() + this.getInsetRight()            + this.getPaddingRight();    }    else    {        return this._element.scrollWidth;    }};_p.getPreferredHeight = function()

⌨️ 快捷键说明

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