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

📄 containeritem.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 2 页
字号:
/*
 * Isomorphic SmartClient
 * Version 6.5 (2008-04-30)
 * Copyright(c) 1998-2007 Isomorphic Software, Inc. All rights reserved.
 * "SmartClient" is a trademark of Isomorphic Software, Inc.
 *
 * licensing@smartclient.com
 *
 * http://smartclient.com/license
 */
 /*	OPEN ISSUES    * how to handle CanvasItems in containerItems?	* how to handle values for a containerItem?	* how to handle "name" for a containerItem?*///>	@class	ContainerItem////	Container formItem to show a filter for a set of datasource fields.////<isc.ClassFactory.defineClass("ContainerItem", "FormItem");isc.ContainerItem.addProperties({	//>	@attr	containerItem.items		(array : null : IRW)	//		Array of sub-items for this container item.	//<	cellSpacing:0,	cellPadding:2,	cellBorder:0,    //>	@attr	containerItem.recalculateItemsOnRedraw		(boolean : false : IR)	//			If true, we recalculate the list of sub-items every time	//			this.getInnerHTML is called.  Otherwise we do it automatically only	//			when this.items is null.	//<	recalculateItemsOnRedraw:false,        //>	@attr   containerItem._hasDataElement   (boolean : false : AR)    //      Container items have no data element of their own.    //<     _hasDataElement:false,        // Set changeOnKeypress to false since keypresses get bubbled and the keypress may occur    // on a sub item for which we don't want to update        changeOnKeypress:false        //> @attr   containItem.itemCellStyle   (FormItemBaseStyle : null : IRA)    // If specified this style will be written into each sub-item's cell, overriding the    // items own "cellStyle" property.    //<	});// take methods directly from the DynamicForm itselfisc.ContainerItem.addMethods(isc.applyMask(isc.DynamicForm.getPrototype(), [	 // get all the routines that deal with outputting the table around the elements	 "getTableStartHTML", "_getTableElementID", "_getTableElement",     "getCellStartHTML", "_getCellStartHTML", "getCellEndHTML", "_getCellEndHTML",     "getTitleAlign", "getItemPromptHTML",	 // get things that deal with nested sets of items	 "getItem"	]));isc.ContainerItem.addMethods({//>	@method	ContainerItem.init()	(A)//		initialize the containerItem object.////		@param	[all arguments]	(object)	objects with properties to override from default//<init : function () {	this.Super("init", arguments);	// initialize the list of sub items, defaulting to an empty list	this.setItems(this.items ? this.items : null);},// override destroy to destroy all items toodestroy : function () {    this.Super("destroy", arguments);    if (this.items) {        for (var i = 0; i < this.items.length; i++) {            this.items[i].destroy();        }    }},//>	@method	containerItem.setItems()	(A)//// 	Reset the list of items displayed by this class.////	@param	itemList	(array)		Array of item objects.  If they are not already//	                                FormItem subclasses, they will be converted.//<setItems : function (itemList) {	if (itemList) this.items = itemList;	if (!this.items) return null;	//>DEBUG    this.logDebug("Creating " + this.items.length + " contained items");	//<DEBUG	itemList = this.items;	// iterate through all the items, creating FormItems from object literals    var appliedAccessKey = false;	for (var itemNum = 0; itemNum < itemList.length; itemNum++) {		var item = itemList[itemNum];		// remove any empty items from the list		if (!item) {			itemList.removeItem(itemNum--);			continue;		}                // override '_getElementTabIndex' for each item so the container item controls the        // tabIndex of it's child-items        // For now we don't allow child items to control their tab indices separately from         // their container items tab index.                isc.addMethods(            item,             {   _getElementTabIndex : function () {                    return this.parentItem._getElementTabIndex();                }            }        );                 // The sub-item is contained in the same containerWidget as this form item        item.containerWidget = this.containerWidget;		// set the item.parentItem and eventParent to point back to us		item.parentItem = this;        item.eventParent = this;		item.form = this.form;                // note that the sub items will never have a title cell written out for them        item.showTitle = false;        		// convert from a simple object into a FormItem        		if (!isc.isA.FormItem(item)) itemList[itemNum] = item = isc.FormItemFactory.makeItem(item);        // Also apply the 'accessKey' to the first focusable sub item        if (this.accessKey != null && !appliedAccessKey && item._canFocus()) {            item.accessKey = this.accessKey;            appliedAccessKey = true;        }         		// if the item has a name property, add a reference to the object to us under that name        // (We don't use the ID, since that is already a global pointer to the sub item)		if (item.name != null) this[item.name] = item;	}	// set the items pointer	this.items = itemList;	// redraw this form item (default implementation will redraw the form / containing widget)    this.redraw();},// override getTitleHTML() to avoid writing a <label> tag around the title, and setting an // accessKey property on that label.  This is appropriate as we are setting up the accessKey// directly on the first sub-element in the group (implemented in setItems)getTitleHTML : function () {    var title = this.getTitle();        if (this.accessKey != null) {        title = isc.Canvas.hiliteCharacter(title, this.accessKey);    }                return title;},// Override '_setElementTabIndex()', as the superclass implementation forces a form.redraw()// for any focusable items without elements, and this may not be necessary._setElementTabIndex : function (tabIndex) {    if (!this.isVisible() || !this.containerWidget.isDrawn()) return;    this._elementTabIndex = tabIndex;        for (var i = 0; i < this.items.length; i++) {        if (this.items[i]._canFocus()) this.items[i]._setElementTabIndex(tabIndex);    }    // If none of the sub items forced this form to markForRedraw(), simply update our icons    // and we're done - otherwise the form will redraw and write out the correct tabIndices    // on everything anyway.    if (!this.form.isDirty()) {        this._updateIconTabIndices();    }},// Container items are non-editable by default.// Subclasses that allow editing will override this value as appropriateisEditable : function () {    return false;},//> @method ContainerItem._canFocus()   (A)//  Override _canFocus() to return true if any of our sub-elements can accept keyboard focus//  @return (boolean)   true if this form item can accept keyboard focus//<_canFocus : function () {    for (var i=0; i < this.items.length; i++) {        if (this.items[i]._canFocus()) return true;    }    return false;},//> @method ContainerItem.focusInItem()   (A)//  Override focusInItem to focus in the first sub-item that will accept focus//<focusInItem : function () {    if (!this.isVisible() || !this._canFocus()) return;    for (var i=0; i < this.items.length; i++) {        if (this.items[i]._canFocus()) {            this.items[i].focusInItem();            break;        }    }},//> @method ContainerItem.blurItem()   (A)//  Override blurItem to call 'blurItem' on whichever sub-item is marked as having focus.//<blurItem : function () {    for (var i=0; i < this.items.length; i++) {        if (this.items[i].hasFocus) {            this.items[i].blurItem();            break;        }    }},// Override _applyHandlersToElement() - we have no 'focusElement', even if _canFocus() is true// so only apply handlers to icons._applyHandlersToElement : function () {    this._setUpIconEventHandlers();},// Notify sub items that they've been drawn/cleared at the appropriate times.drawn : function () {    var items = this.items;    if (!items) return;    for (var i = 0; i < items.length; i++) {        if (items[i].visible != false) items[i].drawn();    }    return this.Super("drawn", arguments);},redrawn : function () {    var items = this.items;    if (!items) return;    for (var i = 0; i < items.length; i++) {        var item = items[i];        if (item.visible != false) {            if (!item.isDrawn()) item.drawn();            else item.redrawn();        } else {            if (item.isDrawn()) item.cleared();        }    }    return this.Super("redrawn", arguments);},cleared : function () {    var items = this.items;    if (!items) return;    for (var i = 0; i < items.length; i++) {        if (items[i].isDrawn()) items[i].cleared();    }    return this.Super("cleared", arguments);},//>	@method	ContainerItem.makeNamedItem()	(A)// Make a particular item of the specified name, taking it from this object or from the// FormItem class.//// This implementation caches items so we don't end up creating them over and over for the same// object.//<makeNamedItem : function (itemName, extraProperties) {	// create the itemCache if it hasn't been made already	if (!this.itemCache) this.itemCache = {};	// get the item from the itemCache by name	var item = this.itemCache[itemName];	// if it wasn't found	if (!item) {		// find the item specification in either this object or as a constant in the FilterItem class		item = (this[itemName] || this.getClass()[itemName]);		// if any extra properties were passed in, create a new blank object and add them to the item properties		if (extraProperties != null) {			item = isc.addProperties({}, item, extraProperties);		}		// now create the item as a real FormItem, and store it in the cache for later		item = this.itemCache[itemName] = isc.FormItemFactory.makeItem(item);	}

⌨️ 快捷键说明

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