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

📄 widget.js

📁 dojo与json创建无限级树的时候,当在父结点下添加了一个新结点,我怎么让父亲结点重新调用json加载一下子结点内容.
💻 JS
📖 第 1 页 / 共 2 页
字号:
					}else if(dojo.lang.isArray(this[x])){ // typeof [] == "object"						this[x] = args[x].split(";");					} else if (this[x] instanceof Date) {						this[x] = new Date(Number(args[x])); // assume timestamp					}else if(typeof this[x] == "object"){ 						// FIXME: should we be allowing extension here to handle						// other object types intelligently?						// if we defined a URI, we probablt want to allow plain strings						// to override it						if (this[x] instanceof dojo.uri.Uri){							this[x] = args[x];						}else{							// FIXME: unlike all other types, we do not replace the							// object with a new one here. Should we change that?							var pairs = args[x].split(";");							for(var y=0; y<pairs.length; y++){								var si = pairs[y].indexOf(":");								if((si != -1)&&(pairs[y].length>si)){									this[x][pairs[y].substr(0, si).replace(/^\s+|\s+$/g, "")] = pairs[y].substr(si+1);								}							}						}					}else{						// the default is straight-up string assignment. When would						// we ever hit this?						this[x] = args[x];					}				}			}else{				// collect any extra 'non mixed in' args				this.extraArgs[x.toLowerCase()] = args[x];			}		}		// dojo.profile.end("mixInProperties");	},		postMixInProperties: function(){	},	initialize: function(args, frag){		// dojo.unimplemented("dojo.widget.Widget.initialize");		return false;	},	postInitialize: function(args, frag){		return false;	},	postCreate: function(args, frag){		return false;	},	uninitialize: function(){		// dojo.unimplemented("dojo.widget.Widget.uninitialize");		return false;	},	buildRendering: function(){		// SUBCLASSES MUST IMPLEMENT		dojo.unimplemented("dojo.widget.Widget.buildRendering, on "+this.toString()+", ");		return false;	},	destroyRendering: function(){		// SUBCLASSES MUST IMPLEMENT		dojo.unimplemented("dojo.widget.Widget.destroyRendering");		return false;	},	cleanUp: function(){		// SUBCLASSES MUST IMPLEMENT		dojo.unimplemented("dojo.widget.Widget.cleanUp");		return false;	},	addedTo: function(parent){		// this is just a signal that can be caught	},	addChild: function(child){		// SUBCLASSES MUST IMPLEMENT		dojo.unimplemented("dojo.widget.Widget.addChild");		return false;	},	// Detach the given child widget from me, but don't destroy it	removeChild: function(widget){		for(var x=0; x<this.children.length; x++){			if(this.children[x] === widget){				this.children.splice(x, 1);				break;			}		}		return widget;	},	resize: function(width, height){		// both width and height may be set as percentages. The setWidth and		// setHeight  functions attempt to determine if the passed param is		// specified in percentage or native units. Integers without a		// measurement are assumed to be in the native unit of measure.		this.setWidth(width);		this.setHeight(height);	},	setWidth: function(width){		if((typeof width == "string")&&(width.substr(-1) == "%")){			this.setPercentageWidth(width);		}else{			this.setNativeWidth(width);		}	},	setHeight: function(height){		if((typeof height == "string")&&(height.substr(-1) == "%")){			this.setPercentageHeight(height);		}else{			this.setNativeHeight(height);		}	},	setPercentageHeight: function(height){		// SUBCLASSES MUST IMPLEMENT		return false;	},	setNativeHeight: function(height){		// SUBCLASSES MUST IMPLEMENT		return false;	},	setPercentageWidth: function(width){		// SUBCLASSES MUST IMPLEMENT		return false;	},	setNativeWidth: function(width){		// SUBCLASSES MUST IMPLEMENT		return false;	},	getPreviousSibling: function() {		var idx = this.getParentIndex(); 		 // first node is idx=0 not found is idx<0		if (idx<=0) return null; 		return this.getSiblings()[idx-1];	}, 	getSiblings: function() {		return this.parent.children;	}, 	getParentIndex: function() {		return dojo.lang.indexOf( this.getSiblings(), this, true);	}, 	getNextSibling: function() { 		var idx = this.getParentIndex(); 		if (idx == this.getSiblings().length-1) return null; // last node		if (idx < 0) return null; // not found 		return this.getSiblings()[idx+1]; 	}});// Lower case name cache: listing of the lower case elements in each widget.// We can't store the lcArgs in the widget itself because if B subclasses A,// then B.prototype.lcArgs might return A.prototype.lcArgs, which is not what we// wantdojo.widget.lcArgsCache = {};// TODO: should have a more general way to add tags or tag libraries?// TODO: need a default tags class to inherit from for things like getting propertySets// TODO: parse properties/propertySets into component attributes// TODO: parse subcomponents// TODO: copy/clone raw markup fragments/nodes as appropriatedojo.widget.tags = {};dojo.widget.tags.addParseTreeHandler = function(type){	var ltype = type.toLowerCase();	this[ltype] = function(fragment, widgetParser, parentComp, insertionIndex, localProps){ 		return dojo.widget.buildWidgetFromParseTree(ltype, fragment, widgetParser, parentComp, insertionIndex, localProps);	}}dojo.widget.tags.addParseTreeHandler("dojo:widget");dojo.widget.tags["dojo:propertyset"] = function(fragment, widgetParser, parentComp){	// FIXME: Is this needed?	// FIXME: Not sure that this parses into the structure that I want it to parse into...	// FIXME: add support for nested propertySets	var properties = widgetParser.parseProperties(fragment["dojo:propertyset"]);}// FIXME: need to add the <dojo:connect />dojo.widget.tags["dojo:connect"] = function(fragment, widgetParser, parentComp){	var properties = widgetParser.parseProperties(fragment["dojo:connect"]);}// FIXME: if we know the insertion point (to a reasonable location), why then do we://	- create a template node//	- clone the template node//	- render the clone and set properties//	- remove the clone from the render tree//	- place the clone// this is quite dumbdojo.widget.buildWidgetFromParseTree = function(type, frag, 												parser, parentComp, 												insertionIndex, localProps){	var stype = type.split(":");	stype = (stype.length == 2) ? stype[1] : type;	// FIXME: we don't seem to be doing anything with this!	// var propertySets = parser.getPropertySets(frag);	var localProperties = localProps || parser.parseProperties(frag["dojo:"+stype]);	// var tic = new Date();	var twidget = dojo.widget.manager.getImplementation(stype);	if(!twidget){		throw new Error("cannot find \"" + stype + "\" widget");	}else if (!twidget.create){		throw new Error("\"" + stype + "\" widget object does not appear to implement *Widget");	}	localProperties["dojoinsertionindex"] = insertionIndex;	// FIXME: we loose no less than 5ms in construction!	var ret = twidget.create(localProperties, frag, parentComp);	// dojo.debug(new Date() - tic);	return ret;}/* * Create a widget constructor function (aka widgetClass) */dojo.widget.defineWidget = function(widgetClass /*string*/, renderer /*string*/, superclasses /*function||array*/, init /*function*/, props /*object*/){	// This meta-function does parameter juggling for backward compat and overloading	// if 4th argument is a string, we are using the old syntax	// old sig: widgetClass, superclasses, props (object), renderer (string), init (function)	if(dojo.lang.isString(arguments[3])){		dojo.widget._defineWidget(arguments[0], arguments[3], arguments[1], arguments[4], arguments[2]);	}else{		// widgetClass		var args = [ arguments[0] ], p = 3;		if(dojo.lang.isString(arguments[1])){			// renderer, superclass			args.push(arguments[1], arguments[2]);		}else{			// superclass			args.push('', arguments[1]);			p = 2;		}		if(dojo.lang.isFunction(arguments[p])){			// init (function), props (object) 			args.push(arguments[p], arguments[p+1]);		}else{			// props (object) 			args.push(null, arguments[p]);		}		dojo.widget._defineWidget.apply(this, args);	}}dojo.widget.defineWidget.renderers = "html|svg|vml";dojo.widget._defineWidget = function(widgetClass /*string*/, renderer /*string*/, superclasses /*function||array*/, init /*function*/, props /*object*/){	// FIXME: uncomment next line to test parameter juggling ... remove when confidence improves	//dojo.debug('(c:)' + widgetClass + '\n\n(r:)' + renderer + '\n\n(i:)' + init + '\n\n(p:)' + props);	// widgetClass takes the form foo.bar.baz<.renderer>.WidgetName (e.g. foo.bar.baz.WidgetName or foo.bar.baz.html.WidgetName)	var namespace = widgetClass.split(".");	var type = namespace.pop(); // type <= WidgetName, namespace <= foo.bar.baz<.renderer>	var regx = "\\.(" + (renderer ? renderer + '|' : '') + dojo.widget.defineWidget.renderers + ")\\.";	var r = widgetClass.search(new RegExp(regx));	namespace = (r < 0 ? namespace.join(".") : widgetClass.substr(0, r));	dojo.widget.manager.registerWidgetPackage(namespace);	dojo.widget.tags.addParseTreeHandler("dojo:"+type.toLowerCase());	props=(props)||{};	props.widgetType = type;	if((!init)&&(props["classConstructor"])){		init = props.classConstructor;		delete props.classConstructor;	}	dojo.declare(widgetClass, superclasses, init, props);}

⌨️ 快捷键说明

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