📄 containeritem.js
字号:
// and return the item! return item;},//> @method containerItem.getInnerHTML() (A)//// Return the HTML needed to draw this item.//// @param values (string) Value of the element (unused).// @return (string) HTML to draw this item.//<_$suppressDoublingCSS:isc.Canvas._$noStyleDoublingCSS,getInnerHTML : function (values, includeHint, includeErrors, returnArray) { if (!values) values = {}; // if the items haven't been set for this element, call setItems to do so now // this lets subclasses defer setting items until draw time if (!this.items || this.recalculateItemsOnRedraw || !isc.isA.FormItem(this.items[0])) this.setItems(); if (!this.items) return "No items set for containerItem " + this; // form items are only actually responsible for writing out error HTML if error orientation // is left or right var errorOrientation = this.getErrorOrientation(), showErrors, errorOnLeft = errorOrientation == isc.Canvas.LEFT, errorHTML; if (includeErrors && (errorOnLeft || errorOrientation == isc.Canvas.RIGHT)) { var errors = this.getErrors(); if (errors) { showErrors = true; errorHTML = this.getErrorHTML(errors); } } // get a StringBuffer to hold the output var output = isc.StringBuffer.newInstance(); // If we need to write out a hidden native data element, do so now. if (this._useHiddenDataElement()) { output.append(this._getHiddenDataElementHTML()); } // start the table output.append(this.getTableStartHTML()); // Check Visibility / Disabled State // -------------------------------------------------------------------------------------------- var items = this.items; // iterate through the items, marking items as invisible if their .showIf is false for (var itemNum = 0; itemNum < items.length; itemNum++) { var item = items[itemNum]; // note that the value of this item can't possibly be dirty item._markValueAsNotDirty() // set the form of the item to the same form we draw in item.form = this.form; // if the item has a showIf property // evaluate that to see whether the item should be visible or not // (note if the visible states of any items changes) if (item.showIf) { // CALLBACK API: available variables: "value" // Convert a string callback to a function if (!isc.isA.Function(item.showIf)) { isc.Func.replaceWithMethod(item, "showIf", "item,value,form"); } var value = this.getItemValue(item, values); var visible = (item.showIf(item,value,this.form) != false) ; if (visible != item.visible) { item.visible = visible; } } } // DynamicForm.getInnerHTML() makes use of applyTableResizePolicy() to determine the desired // sizes for it's component form items. // This (among other things) sets up the _size property on the form items to an array containing // the desired width and height. // Certain form items make use of this _size property in their getInnerHTML() methods. If // the property is not set they will default to using item.width and item.height. // Draw HTML for Items // -------------------------------------------------------------------------------------------- // for each field in the list for (var itemNum = 0, len = this.items.length; itemNum < len; itemNum++) { // get a pointer to the item for that field var item = this.items[itemNum]; // if a null item, skip it if (!item) continue; // if the item has been marked as invisble, skip it if (!item.visible) continue; var value = this.getItemValue(item, values); // if the item should start it row or passes the name boundary // output the end and start row tag if (item._startRow || itemNum == 0) { if (itemNum != 0) output.append("</TR>"); output.append("<TR>"); } // If we show the error on the left write the error cell out before the first item in // the first row // Note: this means if there is no first item we'll fail to write out the error HTML // not a known use case for this. if (itemNum == 0 && showErrors && errorOnLeft) { // rowspan ensures that if we are showing multiple rows, the error text really shows up // on the left of all items var numRows = 1; for (var ii = 1; ii < this.items.length; ii++) { if (this.items[ii]._startRow) numRows++; } output.append("<TD ROWSPAN=",numRows,">",errorHTML,"</TD>"); } // output the tag start for the item if it has a positive row and colSpan output.append(this.getCellStartHTML(item)); // output the innerHTML for the item (including the hint, if there is one) output.append(item.getInnerHTML(value, true)); // append the tag end for the item output.append(this.getCellEndHTML(item)); } // If we are showing icons (or might be showing icons in the future), draw them into // a table cell after any sub-items - this prevents them being wrapped and shown up on the // next line of the page. // If 'showPickerIcon' is true write out a picker icon before any other icons if (this.showPickerIcon || (this.showIcons && this.icons != null)) { var width = this.getTotalIconsWidth(); // have to explicitly add width of pickerIcon if we're showing it. if (this.showPickerIcon) width += this.getPickerIconWidth(); // output the tag start for the item if it has a positive row and colSpan output.append( this._getCellStartHTML( (this.form.isRTL() ? isc.Canvas.RIGHT : isc.Canvas.LEFT), // align this.getCellStyle(), // classname 1, 1, // rowSpan / colSpan width, // width // can leave height, extrastuff unspecified null, null, // Avoid double border/margin/padding this._$suppressDoublingCSS, // Don't pass in itemID or formID - don't write out a click handler on this cell null, null, null, // Suppress wrapping of icons (if we have more than one in the cell) (this.icons && (this.showPickerIcon || this.icons.length > 1)) ) ); if (this.showPickerIcon) output.append(this.getIconHTML(this.getPickerIcon())); output.append(this.getIconsHTML()); // append the tag end for the item (again suppress wrapping within the cell) output.append(this._getCellEndHTML(true)); } // use the hint cell to write out right-orientated errors if (showErrors && !errorOnLeft) includeHint = true; if (includeHint) { var hint = this.getHint(), rightError = !errorOnLeft ? errorHTML : null, hintString = (hint && rightError) ? hint+rightError : (hint || rightError); if (hintString && !isc.isA.emptyString(hintString)) { // We inherit our _$hintCellTemplate from the FormItem class this._$hintCellTemplate[1] = this.getHintStyle(); this._$hintCellTemplate[3] = hintString; output.append(this._$hintCellTemplate); } } // end the table output.append("</TR></TABLE>"); return output.toString();},// get item value - used by getInnerHTML() to retrieve the value of a sub item of this container.getItemValue : function (item, values) { if (values == null) values = {}; if (!isc.isA.FormItem(item)) item = this.getItem(item); if (!item) return null; // get the value and error for this form element var name = item.getFieldName(), value = null ; // if the value was specified on the item, use that if (item.value != null) value = item.value; // if a name was specified in the item, if (value == null && name) { // get the value from the form.values value = values[name]; } if (value == null) { // otherwise get the value dynamically from the item default // (for headers, etc. that don't specify a name because they aren't submitted) value = item.getDefaultValue(); if (value == null && this.form && this.form.values) value = this.form.values[name]; } return value;}, // override _itemValueIsDirty() to check for each sub-item being dirty._itemValueIsDirty : function () { if (this.items == null) return false; for (var i = 0; i < this.items.length; i++) { if (this.items[i]._itemValueIsDirty()) return true; } return this._valueIsDirty;},// override _markValueAsNotDirty to mark the value as not dirty for this, and each item._markValueAsNotDirty : function () { this._valueIsDirty = false; for (var i = 0; i < this.items.length; i++) { this.items[i]._markValueAsNotDirty(); } },// override updateDisabled to enable / disable all the child items.updateDisabled : function () { this.Super("updateDisabled", arguments); if (this.items) { for (var i = 0; i< this.items.length; i++) this.items[i].updateDisabled(); }},//> @method containerItem.getTextDirection() (A)// Get the text direction of this canvas.// @group appearance// @platformNotes IE win only!// @return (TextDirection) direction -- Canvas.LTR or Canvas.RTL//<getTextDirection : function () { return this.form.getTextDirection();},// Override getLeft() / getTop() to look at the position table element for the containerItemgetLeft : function () { var element = this._getTableElement(); if (element == null) { this.logWarn("getLeft() Unable to determine position for " + (this.name == null ? "this item " : this.name) + ". Position cannot be determined before the item is drawn " + "- returning zero"); return 0; } return this._getElementLeft(element); },getTop : function () { var element = this._getTableElement(); if (element == null) { // We will not find an element if we are not drawn into the DOM this.logWarn("getTop() Unable to determine position for " + (this.name == null ? "this item " : this.name) + ". Position cannot be determined before the item is drawn " + "- returning zero"); return 0; } return this._getElementTop(element); },// Ditto with getVisibleWidth() / getVisibleHeight()getVisibleWidth : function () { var element = this._getTableElement(); if (element == null) return this.Super("getVisibleWidth", arguments); return element.offsetWidth;},getVisibleHeight : function () { var element = this._getTableElement(); if (element == null) return this.Super("getVisibleHeight", arguments); return element.offsetHeight; }});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -