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

📄 event.js

📁 dojo与json创建无限级树的时候,当在父结点下添加了一个新结点,我怎么让父亲结点重新调用json加载一下子结点内容.
💻 JS
📖 第 1 页 / 共 2 页
字号:
	}	// the index of the 'around' that is currently being executed.	this.around_index = -1;}dojo.event.MethodInvocation.prototype.proceed = function() {	this.around_index++;	if(this.around_index >= this.jp_.around.length){		return this.jp_.object[this.jp_.methodname].apply(this.jp_.object, this.args);		// return this.jp_.run_before_after(this.object, this.args);	}else{		var ti = this.jp_.around[this.around_index];		var mobj = ti[0]||dj_global;		var meth = ti[1];		return mobj[meth].call(mobj, this);	}} dojo.event.MethodJoinPoint = function(obj, methname){	this.object = obj||dj_global;	this.methodname = methname;	this.methodfunc = this.object[methname];	this.before = [];	this.after = [];	this.around = [];}dojo.event.MethodJoinPoint.getForMethod = function(obj, methname) {	// if(!(methname in obj)){	if(!obj){ obj = dj_global; }	if(!obj[methname]){		// supply a do-nothing method implementation		obj[methname] = function(){};		if(!obj[methname]){			// e.g. cannot add to inbuilt objects in IE6			dojo.raise("Cannot set do-nothing method on that object "+methname);		}	}else if((!dojo.lang.isFunction(obj[methname]))&&(!dojo.lang.isAlien(obj[methname]))){		return null; // FIXME: should we throw an exception here instead?	}	// we hide our joinpoint instance in obj[methname + '$joinpoint']	var jpname = methname + "$joinpoint";	var jpfuncname = methname + "$joinpoint$method";	var joinpoint = obj[jpname];	if(!joinpoint){		var isNode = false;		if(dojo.event["browser"]){			if( (obj["attachEvent"])||				(obj["nodeType"])||				(obj["addEventListener"]) ){				isNode = true;				dojo.event.browser.addClobberNodeAttrs(obj, [jpname, jpfuncname, methname]);			}		}		var origArity = obj[methname].length;		obj[jpfuncname] = obj[methname];		// joinpoint = obj[jpname] = new dojo.event.MethodJoinPoint(obj, methname);		joinpoint = obj[jpname] = new dojo.event.MethodJoinPoint(obj, jpfuncname);		obj[methname] = function(){ 			var args = [];			if((isNode)&&(!arguments.length)){				var evt = null;				try{					if(obj.ownerDocument){						evt = obj.ownerDocument.parentWindow.event;					}else if(obj.documentElement){						evt = obj.documentElement.ownerDocument.parentWindow.event;					}else{						evt = window.event;					}				}catch(e){					evt = window.event;				}				if(evt){					args.push(dojo.event.browser.fixEvent(evt, this));				}			}else{				for(var x=0; x<arguments.length; x++){					if((x==0)&&(isNode)&&(dojo.event.browser.isEvent(arguments[x]))){						args.push(dojo.event.browser.fixEvent(arguments[x], this));					}else{						args.push(arguments[x]);					}				}			}			// return joinpoint.run.apply(joinpoint, arguments); 			return joinpoint.run.apply(joinpoint, args); 		}		obj[methname].__preJoinArity = origArity;	}	return joinpoint;}dojo.lang.extend(dojo.event.MethodJoinPoint, {	unintercept: function(){		this.object[this.methodname] = this.methodfunc;		this.before = [];		this.after = [];		this.around = [];	},	disconnect: dojo.lang.forward("unintercept"),	run: function() {		var obj = this.object||dj_global;		var args = arguments;		// optimization. We only compute once the array version of the arguments		// pseudo-arr in order to prevent building it each time advice is unrolled.		var aargs = [];		for(var x=0; x<args.length; x++){			aargs[x] = args[x];		}		var unrollAdvice  = function(marr){ 			if(!marr){				dojo.debug("Null argument to unrollAdvice()");				return;			}		  			var callObj = marr[0]||dj_global;			var callFunc = marr[1];						if(!callObj[callFunc]){				dojo.raise("function \"" + callFunc + "\" does not exist on \"" + callObj + "\"");			}						var aroundObj = marr[2]||dj_global;			var aroundFunc = marr[3];			var msg = marr[6];			var undef;			var to = {				args: [],				jp_: this,				object: obj,				proceed: function(){					return callObj[callFunc].apply(callObj, to.args);				}			};			to.args = aargs;			var delay = parseInt(marr[4]);			var hasDelay = ((!isNaN(delay))&&(marr[4]!==null)&&(typeof marr[4] != "undefined"));			if(marr[5]){				var rate = parseInt(marr[5]);				var cur = new Date();				var timerSet = false;				if((marr["last"])&&((cur-marr.last)<=rate)){					if(dojo.event.canTimeout){						if(marr["delayTimer"]){							clearTimeout(marr.delayTimer);						}						var tod = parseInt(rate*2); // is rate*2 naive?						var mcpy = dojo.lang.shallowCopy(marr);						marr.delayTimer = setTimeout(function(){							// FIXME: on IE at least, event objects from the							// browser can go out of scope. How (or should?) we							// deal with it?							mcpy[5] = 0;							unrollAdvice(mcpy);						}, tod);					}					return;				}else{					marr.last = cur;				}			}			// FIXME: need to enforce rates for a connection here!			if(aroundFunc){				// NOTE: around advice can't delay since we might otherwise depend				// on execution order!				aroundObj[aroundFunc].call(aroundObj, to);			}else{				// var tmjp = dojo.event.MethodJoinPoint.getForMethod(obj, methname);				if((hasDelay)&&((dojo.render.html)||(dojo.render.svg))){  // FIXME: the render checks are grotty!					dj_global["setTimeout"](function(){						if(msg){							callObj[callFunc].call(callObj, to); 						}else{							callObj[callFunc].apply(callObj, args); 						}					}, delay);				}else{ // many environments can't support delay!					if(msg){						callObj[callFunc].call(callObj, to); 					}else{						callObj[callFunc].apply(callObj, args); 					}				}			}		}		if(this.before.length>0){			dojo.lang.forEach(this.before, unrollAdvice);		}		var result;		if(this.around.length>0){			var mi = new dojo.event.MethodInvocation(this, obj, args);			result = mi.proceed();		}else if(this.methodfunc){			result = this.object[this.methodname].apply(this.object, args);		}		if(this.after.length>0){			dojo.lang.forEach(this.after, unrollAdvice);		}		return (this.methodfunc) ? result : null;	},	getArr: function(kind){		var arr = this.after;		// FIXME: we should be able to do this through props or Array.in()		if((typeof kind == "string")&&(kind.indexOf("before")!=-1)){			arr = this.before;		}else if(kind=="around"){			arr = this.around;		}		return arr;	},	kwAddAdvice: function(args){		this.addAdvice(	args["adviceObj"], args["adviceFunc"], 						args["aroundObj"], args["aroundFunc"], 						args["adviceType"], args["precedence"], 						args["once"], args["delay"], args["rate"], 						args["adviceMsg"]);	},	addAdvice: function(	thisAdviceObj, thisAdvice, 							thisAroundObj, thisAround, 							advice_kind, precedence, 							once, delay, rate, asMessage){		var arr = this.getArr(advice_kind);		if(!arr){			dojo.raise("bad this: " + this);		}		var ao = [thisAdviceObj, thisAdvice, thisAroundObj, thisAround, delay, rate, asMessage];				if(once){			if(this.hasAdvice(thisAdviceObj, thisAdvice, advice_kind, arr) >= 0){				return;			}		}		if(precedence == "first"){			arr.unshift(ao);		}else{			arr.push(ao);		}	},	hasAdvice: function(thisAdviceObj, thisAdvice, advice_kind, arr){		if(!arr){ arr = this.getArr(advice_kind); }		var ind = -1;		for(var x=0; x<arr.length; x++){			var aao = (typeof thisAdvice == "object") ? (new String(thisAdvice)).toString() : thisAdvice;			var a1o = (typeof arr[x][1] == "object") ? (new String(arr[x][1])).toString() : arr[x][1];			if((arr[x][0] == thisAdviceObj)&&(a1o == aao)){				ind = x;			}		}		return ind;	},	removeAdvice: function(thisAdviceObj, thisAdvice, advice_kind, once){		var arr = this.getArr(advice_kind);		var ind = this.hasAdvice(thisAdviceObj, thisAdvice, advice_kind, arr);		if(ind == -1){			return false;		}		while(ind != -1){			arr.splice(ind, 1);			if(once){ break; }			ind = this.hasAdvice(thisAdviceObj, thisAdvice, advice_kind, arr);		}		return true;	}});

⌨️ 快捷键说明

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