📄 guicomponents.js
字号:
{ if (this._preferredHeight != null) return this._preferredHeight; 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.bottom - bcr.top + this.getInsetTop() + this.getPaddingTop() + this.getInsetBottom() + this.getPaddingBottom(); } else { return this._element.scrollHeight; }};_p.setPadding = function(nLeft, nRight, nTop, nBottom){ if (arguments.length == 1) { nRight = nTop = nBottom = nLeft; } else if (arguments.length == 2) { nTop = nBottom = nRight nRight = nLeft; } this.setPaddingLeft(nLeft); this.setPaddingRight(nRight); this.setPaddingTop(nTop); this.setPaddingBottom(nBottom);};_p.setPaddingLeft = function(nPaddingLeft){ this.setStyleProperty("paddingLeft", nPaddingLeft + "px");} ;_p.getPaddingLeft = function(){ return parseInt(this.getStyleProperty("paddingLeft"));} ;_p.setPaddingRight = function(nPaddingRight){ this.setStyleProperty("paddingRight", nPaddingRight + "px");} ;_p.getPaddingRight = function(){ return parseInt(this.getStyleProperty("paddingRight"));} ;_p.setPaddingTop = function(nPaddingTop){ this.setStyleProperty("paddingTop", nPaddingTop + "px");} ;_p.getPaddingTop = function(){ return parseInt(this.getStyleProperty("paddingTop"));} ;_p.setPaddingBottom = function(nPaddingBottom){ this.setStyleProperty("paddingBottom", nPaddingBottom + "px");} ;_p.getPaddingBottom = function(){ return parseInt(this.getStyleProperty("paddingBottom"));} ;_p.dispose = function(){ if (this._disposed) return; if (this._element) { if (BiBrowserCheck.moz) this._element.removeEventListener("input", BiComponent.__oninlineevent, false); else this._element.onpropertychange = null; } BiComponent.prototype.dispose.call(this); this._validator = null; this._invalidMessage = null; if (this._font) this._font.dispose(); this._font = null; this._valueOnFocus = null; this._text = null;};_p._create = function(oDocument){ BiComponent.prototype._create.call(this, oDocument); if (BiBrowserCheck.moz) this._element.addEventListener("input", BiComponent.__oninlineevent, false); else this._element.onpropertychange = BiComponent.__oninlineevent;};_p._oninlineevent = function(e){ if (!e) e = this._document.parentWindow.event; if (e.type == "propertychange" && e.propertyName == "value" || e.type == "input") { this.dispatchEvent(new BiEvent("textchanged")); } else BiComponent.prototype._oninlineevent.call(this, e);};_p._onKeyPress = function(e){ if (e.getKeyCode() == BiKeyboardEvent.ENTER && !e.getAltKey()) { this.dispatchEvent(new BiEvent("action")); if (this._command) this._command.execute(); }};_p._onFocus = function(e){ this._valueOnFocus = this.getText();} ;_p._onBlur = function(e){ if (this.getText() != this._valueOnFocus) this.dispatchEvent(new BiEvent("change")); delete this._valueOnFocus;};_p.addXmlNode = function(oNode, oXmlResourceParser){ if (oNode.nodeType == 3) { this.setText(this.getText() + oNode.nodeValue); } else BiComponent.prototype.addXmlNode.call(this, oNode, oXmlResourceParser);};function BiPasswordField(sText){ BiTextField.call(this, sText); this.setHtmlProperty("type", "password");}var _p = BiPasswordField.prototype = new BiTextField;_p._className = "BiPasswordField";function BiTextArea(sText){ BiTextField.call(this, sText); this.setOverflow("auto"); this.removeHtmlProperty("type"); this.setHeight(50); this.addEventListener("keydown", this._onKeyDown);}var _p = BiTextArea.prototype = new BiTextField;_p._className = "BiTextArea";_p._tagName = "TEXTAREA";_p._acceptsEnter = true;_p._acceptsEsc = false;_p.setWrap = function(bWrap){ if (BiBrowserCheck.ie) this.setHtmlProperty("wrap", bWrap ? "soft" : "off"); else this.setStyleProperty("whiteSpace", bWrap ? "normal" : "nowrap");};_p.getWrap = function(){ if (BiBrowserCheck.ie) return this.setHtmlProperty("wrap") != "off"; else return this.setStyleProperty("whiteSpace") == "normal";};_p._onKeyDown = function(e){ if (e.getKeyCode() == BiKeyboardEvent.ESC) e.preventDefault();};function BiGroupBox(sText){ BiComponent.call(this); this.setCssClassName("bi-group-box"); if (sText != null) this.setText(sText); if (BiBrowserCheck.moz) this.addEventListener("create", this._mozForceLegendUpdate);}var _p = BiGroupBox.prototype = new BiComponent;_p._className = "BiGroupBox";if (BiBrowserCheck.ie) _p._tagName = "FIELDSET";_p._groupBoxTitle = null;_p._titlePosition = "left";_p.getGroupBoxTitle = function(){ return this._groupBoxTitle;} ;_p.setGroupBoxTitle = function(oGroupBoxTitle){ if (this._groupBoxTitle && this._groupBoxTitle != oGroupBoxTitle) this.remove(this._groupBoxTitle); this._groupBoxTitle = oGroupBoxTitle; if (this._groupBoxTitle) { this.add(this._groupBoxTitle, this.getFirstChild()); this._groupBoxTitle.setTitlePosition(this._titlePosition); if (BiBrowserCheck.moz) this._mozForceLegendUpdate(); }};_p.setTitlePosition = function(sTitlePosition){ this._titlePosition = sTitlePosition; if (this._groupBoxTitle) this._groupBoxTitle.setTitlePosition(this._titlePosition);};BiGroupBox.prototype.getTitlePosition = function(){ return this._titlePosition;} ;_p.setText = function(sText){ if (sText == null) { this.setGroupBoxTitle(null); } else { if (this._groupBoxTitle == null) this.setGroupBoxTitle(new BiGroupBoxTitle(sText)); else this._groupBoxTitle.setText(sText); }};_p.getText = function(){ if (this._groupBoxTitle) return this._groupBoxTitle.getText(); return null;};_p._mozForceLegendUpdate = function(){ if (this._created) { var ns = this._element.nextSibling; var p = this._element.parentNode; p.removeChild(this._element); p.insertBefore(this._element, ns); }};function BiGroupBoxTitle(sText){ BiLabel.call(this, sText); this.setCssClassName("bi-group-box-title");}var _p = BiGroupBoxTitle.prototype = new BiLabel;_p._className = "BiGroupBoxTitle";if (BiBrowserCheck.ie) _p._tagName = "LEGEND";_p._titlePosition = "left";_p.setTitlePosition = function(sTitlePosition){ this._titlePosition = sTitlePosition; this.setHtmlProperty("align", sTitlePosition); if (BiBrowserCheck.moz && this._created) this.getParent()._mozForceLegendUpdate();};BiGroupBoxTitle.prototype.getTitlePosition = function(){ return this._titlePosition;} ;_p.setLeft = function(nLeft){} ;_p.setRight = function(nBottom){} ;_p.setTop = function(nTop){} ;_p.setBottom = function(nBottom){} ;_p.layoutComponent = function(){} ;function BiRangeModel(){ BiComponent.call(this);}var _p = BiRangeModel.prototype = new BiComponent;_p._className = "BiRangeModel";_p._value = 0;_p._minimum = 0;_p._maximum = 100;_p.setValue = function(nValue){ nValue = Math.max(this._minimum, Math.min(this._maximum, Math.floor(nValue))); if (this._value != nValue) { this._value = nValue this.dispatchEvent(new BiEvent("change")); }};BiRangeModel.prototype.getValue = function(){ return this._value;} ;_p.setMaximum = function(nMaximum){ nMaximum = Math.floor(nMaximum); if (this._maximum != nMaximum) { this._maximum = Math.max(this._minimum, nMaximum); this._value = Math.min(this._value, this._maximum); this.dispatchEvent(new BiEvent("change")); }};BiRangeModel.prototype.getMaximum = function(){ return this._maximum;} ;_p.setMinimum = function(nMinimum){ nMinimum = Math.floor(nMinimum); if (this._minimum != nMinimum) { this._minimum = Math.min(this._maximum, nMinimum); this._value = Math.max(this._value, this._minimum); this.dispatchEvent(new BiEvent("change")); }};BiRangeModel.prototype.getMinimum = function(){ return this._minimum;} ;function BiProgressBar(nValue){ BiComponent.call(this); this.setCssClassName("bi-progress-bar"); this._rangeModel = new BiRangeModel(); if (nValue) this.setValue(nValue); this._rangeModel.addEventListener("change", this._onchange, this);}_p = BiProgressBar.prototype = new BiComponent;_p._className = "BiProgressBar";_p._preferredHeight = 16;_p._preferredWidth = 200;_p.setValue = function(nValue){ this._rangeModel.setValue(nValue);} ;_p.getValue = function(){ return this._rangeModel.getValue();} ;_p.setMaximum = function(nMaximum){ this._rangeModel.setMaximum(nMaximum);} ;_p.getMaximum = function(){ return this._rangeModel.getMaximum();} ;_p.setMinimum = function(nMinimum){ this._rangeModel.setMinimum(nMinimum);} ;_p.getMinimum = function(){ return this._rangeModel.getMinimum();} ;_p._layoutThumb = function(){ if (this._thumb) { this._thumb.style.width = 100 * (this.getValue() - this.getMinimum()) / (this.getMaximum() - this.getMinimum()) + "%"; }};_p._create = function(oDocument){ BiComponent.prototype._create.call(this, oDocument); this._thumb = this._document.createElement("DIV"); this._thumb.className = "bi-progress-bar-thumb"; this._element.insertBefore(this._thumb, this._element.firstChild); this._layoutThumb();};_p.dispose = function(){ if (this._disposed) return; BiComponent.prototype.dispose.call(this); this._rangeModel.dispose(); this._rangeModel = null; if (this._thumb) this._thumb.style.filter = "none"; this._thumb = null;};_p._onchange = function(e){ this._layoutThumb(); this.dispatchEvent(new BiEvent("change"));};function BiUndeterminedProgressBar(){ BiProgressBar.call(this); this._rangeModel.setMaximum(50); this._timer = new BiTimer(50); this._timer.addEventListener("tick", this._ontick, this); this.addEventListener("create", this._layoutThumb);};_p = BiUndeterminedProgressBar.prototype = new BiProgressBar;_p._className = "BiUndeterminedProgressBar";_p.layoutComponentX = function(){ this._layoutThumb(); return BiProgressBar.prototype.layoutComponentX.call(this);};_p.layoutComponent = function(){ this._layoutThumb(); return BiProgressBar.prototype.layoutComponent.call(this);};_p._layoutThumb = function(){ if (this.getCreated()) { var max = this.getMaximum(); var min = this.getMinimum(); var size = max - min; var v = (this.getValue() - min) / size; var w = 0.3; var left, right, width; if (v <= 0.5) { right = (v * 2) * (1 + w); left = right - w; this._thumb.className = "bi-progress-bar-thumb"; } else { left = 1 - (1 + w) * 2 * (v - 0.5); right = left + w; this._thumb.className = "bi-progress-bar-reverse-thumb"; } left = Math.max(0, Math.min(1, left)); right = Math.max(0, Math.min(1, right)); width = right - left; var cw = this.getClientWidth(); this._thumb.style.marginLeft = Math.round(left * cw) + "px"; this._thumb.style.width = Math.round(width * cw) + "px"; }};_p._ontick = function(e){ if (this.getValue() == this.getMaximum()) this.setValue(this.getMinimum()); else this.setValue(this.getValue() + 1);};_p.start = function(){ this._timer.start();} ;_p.stop = function(){ this._timer.stop();} ;_p.getStarted = function(){ return this._timer.getEnabled();} ;_p.dispose = function(){ if (this._disposed) return; BiProgressBar.prototype.dispose.call(this); this._timer.dispose(); this._timer = null;};function BiSlider(sOrientation){ BiComponent.call(this); this._rangeModel = new BiRangeModel(); this._line = new BiComponent;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -