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

📄 domwidget.js

📁 struts hibernet spring
💻 JS
📖 第 1 页 / 共 3 页
字号:
					dojo.widget.wai.setAttr(baseNode, wai.name, "role", val);				}else{					// this is a state-value pair					var statePair = val.split('-');					dojo.widget.wai.setAttr(baseNode, wai.name, statePair[0], statePair[1]);				}			}		}, this);		var onBuild = baseNode.getAttribute(this.onBuildProperty);		if(onBuild){			eval("var node = baseNode; var widget = targetObj; "+onBuild);		}	}}dojo.widget.getDojoEventsFromStr = function(/*String*/str){	// summary:	//		generates a list of properties with names that match the form	//		dojoOn*	// str: the template string to search		// var lstr = str.toLowerCase();	var re = /(dojoOn([a-z]+)(\s?))=/gi;	var evts = str ? str.match(re)||[] : [];	var ret = [];	var lem = {};	for(var x=0; x<evts.length; x++){		if(evts[x].length < 1){ continue; }		var cm = evts[x].replace(/\s/, "");		cm = (cm.slice(0, cm.length-1));		if(!lem[cm]){			lem[cm] = true;			ret.push(cm);		}	}	return ret; // Array}/*dojo.widget.buildAndAttachTemplate = function(obj, templatePath, templateCssPath, templateString, targetObj) {	this.buildFromTemplate(obj, templatePath, templateCssPath, templateString);	var node = dojo.dom.createNodesFromText(obj.templateString, true)[0];	this.attachTemplateNodes(node, targetObj||obj, dojo.widget.getDojoEventsFromStr(templateString));	return node;}*/// summary://		dojo.widget.DomWidget is the superclass that provides behavior for all//		DOM-based renderers, including HtmlWidget and SvgWidget. DomWidget//		implements the templating system that most widget authors use to define//		the UI for their widgets.dojo.declare("dojo.widget.DomWidget", 	dojo.widget.Widget,	function(){		if((arguments.length>0)&&(typeof arguments[0] == "object")){			this.create(arguments[0]);		}	},	{							 		// DomNode: a node that represents the widget template. Pre-empts both templateString and templatePath.		templateNode: null,		// String:		//		a string that represents the widget template. Pre-empts the		//		templatePath. In builds that have their strings "interned", the		//		templatePath is converted to an inline templateString, thereby		//		preventing a synchronous network call.		templateString: null,		// String:		//		a string that represents the CSS for the widgettemplate.		//		Pre-empts the templateCssPath. In builds that have their		//		strings "interned", the templateCssPath is converted to an		//		inline templateCssString, thereby preventing a synchronous		//		network call.		templateCssString: null,		// Boolean:		//		should the widget not replace the node from which it was		//		constructed? Widgets that apply behaviors to pre-existing parts		//		of a page can be implemented easily by setting this to "true".		//		In these cases, the domNode property will point to the node		//		which the widget was created from.		preventClobber: false,		// DomNode:		//		this is our visible representation of the widget! Other DOM		//		Nodes may by assigned to other properties, usually through the		//		template system's dojoAttachPonit syntax, but the domNode		//		property is the canonical "top level" node in widget UI.		domNode: null, 		// DomNode:		//		holds child elements. "containerNode" is generally set via a		//		dojoAttachPoint assignment and it designates where widgets that		//		are defined as "children" of the parent will be placed		//		visually.		containerNode: null,		// Boolean:		//		should we parse the template to find widgets that might be		//		declared in markup inside it? false by default.		widgetsInTemplate: false,		addChild: function(	/*Widget*/				widget, 							/*DomNode, optional*/	overrideContainerNode, 							/*String, optional*/	pos, 							/*DomNode, optional*/	ref,							/*int, optional*/		insertIndex){			// summary:			//		Process the given child widget, inserting it's dom node as			//		a child of our dom node			// overrideContainerNode: a non-default container node for the widget			// pos:			//		can be one of "before", "after", "first", or "last". This			//		has the same meaning as in dojo.dom.insertAtPosition()			// ref: a node to place the widget relative to			// insertIndex: DOM index, same meaning as in dojo.dom.insertAtIndex()			// FIXME: should we support addition at an index in the children arr and			// order the display accordingly? Right now we always append.			if(!this.isContainer){ // we aren't allowed to contain other widgets, it seems				dojo.debug("dojo.widget.DomWidget.addChild() attempted on non-container widget");				return null;			}else{				if(insertIndex == undefined){					insertIndex = this.children.length;				}				this.addWidgetAsDirectChild(widget, overrideContainerNode, pos, ref, insertIndex);				this.registerChild(widget, insertIndex);			}			return widget; // Widget: the widget that was inserted		},				addWidgetAsDirectChild: function(	/*Widget*/				widget, 											/*DomNode*/				overrideContainerNode, 											/*String, optional*/	pos, 											/*DomNode, optional*/	ref, 											/*int, optional*/		insertIndex){			// summary:			//		Process the given child widget, inserting it's dom node as			//		a child of our dom node			// overrideContainerNode: a non-default container node for the widget			// pos:			//		can be one of "before", "after", "first", or "last". This			//		has the same meaning as in dojo.dom.insertAtPosition()			// ref: a node to place the widget relative to			// insertIndex: DOM index, same meaning as in dojo.dom.insertAtIndex()			if((!this.containerNode)&&(!overrideContainerNode)){				this.containerNode = this.domNode;			}			var cn = (overrideContainerNode) ? overrideContainerNode : this.containerNode;			if(!pos){ pos = "after"; }			if(!ref){ 				if(!cn){ cn = dojo.body(); }				ref = cn.lastChild; 			}			if(!insertIndex) { insertIndex = 0; }			widget.domNode.setAttribute("dojoinsertionindex", insertIndex);			// insert the child widget domNode directly underneath my domNode, in the			// specified position (by default, append to end)			if(!ref){				cn.appendChild(widget.domNode);			}else{				// FIXME: was this meant to be the (ugly hack) way to support insert @ index?				//dojo.dom[pos](widget.domNode, ref, insertIndex);				// CAL: this appears to be the intended way to insert a node at a given position...				if (pos == 'insertAtIndex'){					// dojo.debug("idx:", insertIndex, "isLast:", ref === cn.lastChild);					dojo.dom.insertAtIndex(widget.domNode, ref.parentNode, insertIndex);				}else{					// dojo.debug("pos:", pos, "isLast:", ref === cn.lastChild);					if((pos == "after")&&(ref === cn.lastChild)){						cn.appendChild(widget.domNode);					}else{						dojo.dom.insertAtPosition(widget.domNode, cn, pos);					}				}			}		},		registerChild: function(/*Widget*/widget, /*int*/insertionIndex){			// summary: record that given widget descends from me			// widget: the widget that is now a child			// inesrtionIndex: where in the children[] array to place it			// we need to insert the child at the right point in the parent's 			// 'children' array, based on the insertionIndex			widget.dojoInsertionIndex = insertionIndex;			var idx = -1;			for(var i=0; i<this.children.length; i++){				//This appears to fix an out of order issue in the case of mixed				//markup and programmatically added children.  Previously, if a child				//existed from markup, and another child was addChild()d without specifying				//any additional parameters, it would end up first in the list, when in fact				//it should be after.  I can't see cases where this would break things, but				//I could see no other obvious solution. -dustin				if (this.children[i].dojoInsertionIndex <= insertionIndex){					idx = i;				}			}			this.children.splice(idx+1, 0, widget);			widget.parent = this;			widget.addedTo(this, idx+1);						// If this widget was created programatically, then it was erroneously added			// to dojo.widget.manager.topWidgets.  Fix that here.			delete dojo.widget.manager.topWidgets[widget.widgetId];		},		removeChild: function(/*Widget*/widget){			// summary: detach child domNode from parent domNode			dojo.dom.removeNode(widget.domNode);			// remove child widget from parent widget 			return dojo.widget.DomWidget.superclass.removeChild.call(this, widget); // Widget		},		getFragNodeRef: function(/*Object*/frag){			// summary:			//		returns the source node, if any, that the widget was			//		declared from			// frag:			//		an opaque data structure generated by the first-pass parser			if(!frag){return null;} // null			if(!frag[this.getNamespacedType()]){				dojo.raise("Error: no frag for widget type " + this.getNamespacedType() 					+ ", id " + this.widgetId					+ " (maybe a widget has set it's type incorrectly)");			}			return frag[this.getNamespacedType()]["nodeRef"]; // DomNode		},				postInitialize: function(/*Object*/args, /*Object*/frag, /*Widget*/parentComp){			// summary:			//		Replace the source domNode with the generated dom			//		structure, and register the widget with its parent.			//		This is an implementation of the stub function defined in			//		dojo.widget.Widget.						//dojo.profile.start(this.widgetType + " postInitialize");						var sourceNodeRef = this.getFragNodeRef(frag);			// Stick my generated dom into the output tree			//alert(this.widgetId + ": replacing " + sourceNodeRef + " with " + this.domNode.innerHTML);			if (parentComp && (parentComp.snarfChildDomOutput || !sourceNodeRef)){				// Add my generated dom as a direct child of my parent widget				// This is important for generated widgets, and also cases where I am generating an				// <li> node that can't be inserted back into the original DOM tree				parentComp.addWidgetAsDirectChild(this, "", "insertAtIndex", "",  args["dojoinsertionindex"], sourceNodeRef);			} else if (sourceNodeRef){				// Do in-place replacement of the my source node with my generated dom				if(this.domNode && (this.domNode !== sourceNodeRef)){					var oldNode = sourceNodeRef.parentNode.replaceChild(this.domNode, sourceNodeRef);				}			}			// Register myself with my parent, or with the widget manager if			// I have no parent			// TODO: the code below erroneously adds all programatically generated widgets			// to topWidgets (since we don't know who the parent is until after creation finishes)			if ( parentComp ) {				parentComp.registerChild(this, args.dojoinsertionindex);			} else {				dojo.widget.manager.topWidgets[this.widgetId]=this;			}			if(this.widgetsInTemplate){				var parser = new dojo.xml.Parse();				var subContainerNode;				//TODO: use xpath here?				var subnodes = this.domNode.getElementsByTagName("*");				for(var i=0;i<subnodes.length;i++){					if(subnodes[i].getAttribute('dojoAttachPoint') == 'subContainerWidget'){						subContainerNode = subnodes[i];//						break;					}					if(subnodes[i].getAttribute('dojoType')){						subnodes[i].setAttribute('_isSubWidget', true);					}				}				if (this.isContainer && !this.containerNode){					//no containerNode is available, which means a widget is used as a container. find it here and move					//all dom nodes defined in the main html page as children of this.domNode into the actual container					//widget's node (at this point, the subwidgets defined in the template file is not parsed yet)					if(subContainerNode){						var src = this.getFragNodeRef(frag);						if (src){

⌨️ 快捷键说明

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