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

📄 treebasiccontrollerv3.js

📁 struts hibernet spring
💻 JS
📖 第 1 页 / 共 2 页
字号:
			 iterator.forward();		}					var iterator = new dojo.widget.TreeTimeoutIterator(nodeOrTree, callFunc, this);		iterator.setFilter(filterFunc);						iterator.timeout = this.batchExpandTimeout;				//dojo.debug("here "+nodeOrTree+" level "+level);				iterator.setMaxLevel(nodeOrTree.isTreeNode ? level-1 : level);						return iterator.start(nodeOrTree.isTreeNode);	},		getWidgetByNode: function(node) {		var widgetId;		var newNode = node;		while (! (widgetId = newNode.widgetId) ) {			newNode = newNode.parentNode;			if (newNode == null) { break; }		}		if (widgetId) { return dojo.widget.byId(widgetId); }		else if (node == null) { return null; }		else{ return dojo.widget.manager.byNode(node); }	},	/**	 * callout activated even if node is expanded already	 */	expand: function(node) {				//dojo.profile.start("expand");				//dojo.debug("Expand "+node.isFolder);				if (node.isFolder) {						node.expand(); // skip trees or non-folders		}						//dojo.profile.end("expand");					},	/**	 * safe to call on tree and non-folder	 */	collapse: function(node) {		if (node.isFolder) {			node.collapse();		}	},			// -------------------------- TODO: Inline edit node ---------------------	canEditLabel: function(node) {		if (node.actionIsDisabledNow(node.actions.EDIT)) return false;		return true;	},				editLabelStart: function(node) {				if (!this.canEditLabel(node)) {			return false;		}				if (!this.editor.isClosed()) {			//dojo.debug("editLabelStart editor open");			this.editLabelFinish(this.editor.saveOnBlur);					}						this.doEditLabelStart(node);				},			editLabelFinish: function(save) {		this.doEditLabelFinish(save);			},			doEditLabelStart: function(node) {		if (!this.editor) {			dojo.raise(this.widgetType+": no editor specified");		}				//dojo.debug("editLabelStart editor open "+node);				this.editor.open(node);			},		doEditLabelFinish: function(save, server_data) {		//dojo.debug("Finish "+save);		//dojo.debug((new Error()).stack)		if (!this.editor) {			dojo.raise(this.widgetType+": no editor specified");		}		var node = this.editor.node;			var editorTitle = this.editor.getContents();				this.editor.close(save);		if (save) {			var data = {title:editorTitle};						if (server_data) { // may be undefined				dojo.lang.mixin(data, server_data);			}									if (node.isPhantom) {							// I can't just set node phantom's title, because widgetId/objectId/widgetName...				// may be provided by server				var parent = node.parent;				var index = node.getParentIndex();								node.destroy();				// new node was added!				dojo.widget.TreeBasicControllerV3.prototype.doCreateChild.call(this, parent, index, data);			} else {				var title = server_data && server_data.title ? server_data.title : editorTitle;				// use special method to make sure everything updated and event sent				node.setTitle(title); 			}		} else {			//dojo.debug("Kill phantom on cancel");			if (node.isPhantom) {				node.destroy();			}		}	},					makeDefaultNode: function(parent, index) {		var data = {title:parent.tree.defaultChildTitle};		return dojo.widget.TreeBasicControllerV3.prototype.doCreateChild.call(this,parent,index,data);	},		/**	 * check that something is possible	 * run maker to do it	 * run exposer to expose result to visitor immediatelly	 *   exposer does not affect result	 */	runStages: function(check, prepare, make, finalize, expose, args) {				if (check && !check.apply(this, args)) {			return false;		}				if (prepare && !prepare.apply(this, args)) {			return false;		}				var result = make.apply(this, args);						if (finalize) {			finalize.apply(this,args);					}					if (!result) {			return result;		}							if (expose) {			expose.apply(this, args);		}				return result;	}});// create and editdojo.lang.extend(dojo.widget.TreeBasicControllerV3, {			createAndEdit: function(parent, index) {		var data = {title:parent.tree.defaultChildTitle};				if (!this.canCreateChild(parent, index, data)) {			return false;		}				var child = this.doCreateChild(parent, index, data);		if (!child) return false;		this.exposeCreateChild(parent, index, data);				child.isPhantom = true;				if (!this.editor.isClosed()) {			//dojo.debug("editLabelStart editor open");			this.editLabelFinish(this.editor.saveOnBlur);					}										this.doEditLabelStart(child);				}	});// =============================== clone ============================dojo.lang.extend(dojo.widget.TreeBasicControllerV3, {		canClone: function(child, newParent, index, deep){		return true;	},			clone: function(child, newParent, index, deep) {		return this.runStages(			this.canClone, this.prepareClone, this.doClone, this.finalizeClone, this.exposeClone, arguments		);				},	exposeClone: function(child, newParent) {		if (newParent.isTreeNode) {			this.expand(newParent);		}	},	doClone: function(child, newParent, index, deep) {		//dojo.debug("Clone "+child);		var cloned = child.clone(deep);		newParent.addChild(cloned, index);						return cloned;	}	});// =============================== detach ============================dojo.lang.extend(dojo.widget.TreeBasicControllerV3, {	canDetach: function(child) {		if (child.actionIsDisabledNow(child.actions.DETACH)) {			return false;		}		return true;	},	detach: function(node) {		return this.runStages(			this.canDetach, this.prepareDetach, this.doDetach, this.finalizeDetach, this.exposeDetach, arguments		);				},	doDetach: function(node, callObj, callFunc) {		node.detach();	}	});// =============================== destroy ============================dojo.lang.extend(dojo.widget.TreeBasicControllerV3, {	canDestroyChild: function(child) {				if (child.parent && !this.canDetach(child)) {			return false;		}		return true;	},	destroyChild: function(node) {		return this.runStages(			this.canDestroyChild, this.prepareDestroyChild, this.doDestroyChild, this.finalizeDestroyChild, this.exposeDestroyChild, arguments		);				},	doDestroyChild: function(node) {		node.destroy();	}	});// =============================== move ============================dojo.lang.extend(dojo.widget.TreeBasicControllerV3, {	/**	 * check for non-treenodes	 */	canMoveNotANode: function(child, parent) {		if (child.treeCanMove) {			return child.treeCanMove(parent);		}				return true;	},	/**	 * Checks whether it is ok to change parent of child to newParent	 * May incur type checks etc	 *	 * It should check only hierarchical possibility w/o index, etc	 * because in onDragOver event for Between Dnd mode we can't calculate index at once on onDragOVer.	 * index changes as client moves mouse up-down over the node	 */	canMove: function(child, newParent){		if (!child.isTreeNode) {			return this.canMoveNotANode(child, newParent);		}								if (child.actionIsDisabledNow(child.actions.MOVE)) {			return false;		}		// if we move under same parent then no matter if ADDCHILD disabled for him		// but if we move to NEW parent then check if action is disabled for him		// also covers case for newParent being a non-folder in strict mode etc		if (child.parent !== newParent && newParent.actionIsDisabledNow(newParent.actions.ADDCHILD)) {			return false;		}		// Can't move parent under child. check whether new parent is child of "child".		var node = newParent;		while(node.isTreeNode) {			//dojo.debugShallow(node.title)			if (node === child) {				// parent of newParent is child				return false;			}			node = node.parent;		}		return true;	},	move: function(child, newParent, index/*,...*/) {		return this.runStages(this.canMove, this.prepareMove, this.doMove, this.finalizeMove, this.exposeMove, arguments);				},	doMove: function(child, newParent, index) {		//dojo.debug("MOVE "+child);		child.tree.move(child, newParent, index);		return true;	},		exposeMove: function(child, newParent) {				if (newParent.isTreeNode) {			this.expand(newParent);		}	}		});dojo.lang.extend(dojo.widget.TreeBasicControllerV3, {	// -----------------------------------------------------------------------------	//                             Create node stuff	// -----------------------------------------------------------------------------	canCreateChild: function(parent, index, data) {		if (parent.actionIsDisabledNow(parent.actions.ADDCHILD)) {			return false;		}		return true;	},	/* send data to server and add child from server */	/* data may contain an almost ready child, or anything else, suggested to server */	/*in Rpc controllers server responds with child data to be inserted */	createChild: function(parent, index, data) {		return this.runStages(this.canCreateChild, this.prepareCreateChild, this.doCreateChild, this.finalizeCreateChild, this.exposeCreateChild, arguments);			},	doCreateChild: function(parent, index, data) {		//dojo.debug("doCreateChild parent "+parent+" index "+index+" data "+data);				var newChild = parent.tree.createNode(data); 		//var newChild = dojo.widget.createWidget(widgetType, data);		parent.addChild(newChild, index);		return newChild;	},		exposeCreateChild: function(parent) {		return this.expand(parent);	}});

⌨️ 快捷键说明

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