📄 popuptextareaitem.js
字号:
setupPopUpForm : function () { if (this._popUpForm != null) return; var PUF = isc.DynamicForm.create({ autoDraw:false, ID:this.getID() + "_popUpForm", _generated:true, separateContentInsertion: false, cellPadding:0, // Hang a pointer back to this item on both the pop up form and the text area. targetItem:this, values : {textArea:this.getValue()}, //numCols:1, items:[ {name:"textArea", showTitle:false, type:"textArea", //width:"*", //height:"100%", selectOnFocus:true, // if the user tabs out of the item, hide it. // Note: we set up the rowNum / colNum vars below targetItem:this, // "Dirty" our targetItem on keypress so updateValue gets called at the // right moments keyDown : function (item, form, keyName, characterValue) { this.targetItem._markValueAsDirty(); return this.targetItem.textAreaKeyDown(item, keyName, characterValue); }, keyPress : function (item, form, keyName, characterValue) { return this.targetItem.textAreaKeyPress(item, keyName, characterValue); }, blur: function () { this.targetItem.textAreaBlur(); } } ], //showEdges:true, //canDragResize:true, hide : function (a,b,c,d) { var returnVal = this.invokeSuper(isc.DynamicForm, "hide", a,b,c,d); this.hideClickMask(); return returnVal; } }); this._popUpForm = PUF; var container = this.containerWidget; // Destroy if the item is destroyed PUF.observe(container, "destroy", "observer.hide();observer.destroy()"); }, // hidePopUP - method to hide the pop up (and ensure our value is up to date) hidePopUp : function () { if (this._popUpForm) { // updateValue will look at the value of the pop up form textArea this.updateValue(); this._popUpForm.hide(); } }, // Override 'destroy' to ensure we also destroy the pop-up textArea's form destroy : function () { if (this._popUpForm) { this._popUpForm.destroy(); delete this._popUpForm; } return this.Super("destroy", arguments); }, //> @method popUptextAreaItem.getTextAreaTop() // Method to determine where the pop up text area should be shown. Default implementation // will display the pop up over this item. // @return (number) Page level top coordinate for the text area in px. //< getTextAreaTop : function () { // by default look at the position of this form item var top = this.getPageTop(); if (isc.Browser.isIE) top -= 1; return top; }, //> @method popUptextAreaItem.getTextAreaLeft() // Method to determine where the pop up text area should be shown. Default implementation // will display the pop up over this item. // @return (number) Page level left coordinate for the text area in px. //< getTextAreaLeft : function () { return this.getPageLeft(); }, //> @method popUptextAreaItem.getTextAreaWidth() // How wide should the text area be drawn. Default implementation looks at // <code>this.textAreaWidth</code>. // @return (number) Width to apply to this textArea //< getTextAreaWidth : function () { return Math.max(this.textAreaWidth, this.getInnerWidth()); }, //> @method popUptextAreaItem.getTextAreaHeight() // How tall should the text area be drawn. Default implementation looks at // <code>this.textAreaHeight</code>. // @return (number) Height to apply to this textArea //< getTextAreaHeight : function () { return this.textAreaHeight; }, // MapValueToDisplay - override to show blank if necessary mapValueToDisplay : function () { if (this.iconOnly) return ""; return this.Super("mapValueToDisplay", arguments); }, // By Default, on blur of the T.A., hide the T.A. textAreaBlur : function () { this.hidePopUp(); }, //> @method popUptextAreaItem.textAreaKeyPress() // Handler for keypress occurring on the textarea. // <P> // The TextAreaItem from the pop-up is passed is as "item", while "this" is the // PopUpTextAreaItem. // @param item (formItem) item that recieved the event (a pointer to the text area itself) // @param keyName (keyName) which key was pressed // @param characterValue (number) numeric value of the character produced by the keypress // (will be null for non character keys) // @return (boolean) Return false to cancel the key event //< // No-op by default. textAreaKeyPress : function (item, keyName, characterValue) { }, textAreaKeyDown : function (item, keyName, characterValue) { }, //Override setValue -- if we're showing the pop up, update its value setValue : function (newValue) { var oldDisplayValue = this.mapValueToDisplay(this.getValue()); this.Super("setValue", arguments); var newDisplayValue = this.mapValueToDisplay(this.getValue()); if (oldDisplayValue != newDisplayValue) { this.setElementValue(newDisplayValue) if (this._popUpForm && this._popUpForm.isVisible()) { this._popUpForm.setValue("textArea", newDisplayValue); } } }, // Override 'updateValue' -- if we're showing the pop-up, get the value from the pop up // [ensuring it's up to date first] updateValue : function () { if (this._popUpForm && this._popUpForm.isVisible() && !this._popUpForm._setValuesPending) { var item = this._popUpForm.getItem("textArea"); item.updateValue(); var newValue = this._popUpForm.getValue("textArea"); // fire the change handler, and bail if the change failed validation, etc. // Note: this method will call 'setValue()' to reset to the old value, or any value // suggested by the validators if (this.handleChange(newValue, this._value) == false) return; // check for updates to the value performed by the change method newValue = this._changeValue; delete this._changeValue; this.setElementValue(this.mapValueToDisplay(newValue)); // save the value if (newValue != this._value) this.saveValue(newValue); } else { return this.Super("updateValue", arguments); } }, // Override setElementValue to set the value of the static text setElementValue : function (newVal) { if (this.iconOnly) return; return this.Super("setElementValue", arguments); }, // override 'focusInItem' - by default we'll want to put focus in the textArea if it's // visible - otherwise on the icon that launches it. focusInItem : function () { if (this._popUpForm && this._popUpForm.isVisible()) { this._popUpForm.focusInItem('textArea'); } else if (this.showIcons) { this.focusInIcon(this.icons[0]); } else { // showIcons:false - in the absence of a visible icon the pop-up must show // immediately on focus, as there would otherwise be no element to hold/show the // current focus this.showPopUp(true); } }, // override setElementTabIndex() -- we want to reset the tabIndex of the icons and avoid // redrawing the form. _setElementTabIndex : function (tabIndex) { this._elementTabIndex = tabIndex; if (!this.isVisible() || !this.containerWidget.isDrawn()) return; this._updateIconTabIndices(); }});//!<Deferred
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -