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

📄 loader_xd.js

📁 ajax框架原吗,dojo目前很流行的,希望大家多多学习啊
💻 JS
📖 第 1 页 / 共 2 页
字号:
	}};dojo._xdInitExtraLocales = function(){	// Simulate the extra locale work that dojo.requireLocalization does.	var extra = djConfig.extraLocale;	if(extra){		if(!extra instanceof Array){			extra = [extra];		}		dojo._xdReqLoc = dojo.xdRequireLocalization;		dojo.xdRequireLocalization = function(m, b, locale, fLocales){			dojo._xdReqLoc(m,b,locale, fLocales);			if(locale){return;}			for(var i=0; i<extra.length; i++){				dojo._xdReqLoc(m,b,extra[i], fLocales);			}		};	}}dojo._xdBundleMap = {};dojo.xdRequireLocalization = function(/*String*/moduleName, /*String*/bundleName, /*String?*/locale, /*String*/availableFlatLocales){	//summary: Internal xd loader function. The xd version of dojo.requireLocalization.		//Account for allowing multiple extra locales. Do this here inside the function	//since dojo._xdInitExtraLocales() depends on djConfig being set up, but that only	//happens after hostenv_browser runs. loader_xd has to come before hostenv_browser	//though since hostenv_browser can do a dojo.require for the debug module.	if(dojo._xdInitExtraLocales){		dojo._xdInitExtraLocales();		dojo._xdInitExtraLocales = null;		dojo.xdRequireLocalization.apply(dojo, arguments);		return;	}	var locales = availableFlatLocales.split(",");		//Find the best-match locale to load.	//Assumes dojo.i18n has already been loaded. This is true for xdomain builds,	//since it is included in dojo.xd.js.	var jsLoc = dojo.i18n.normalizeLocale(locale);	var bestLocale = "";	for(var i = 0; i < locales.length; i++){		//Locale must match from start of string.		if(jsLoc.indexOf(locales[i]) == 0){			if(locales[i].length > bestLocale.length){				bestLocale = locales[i];			}		}	}	var fixedBestLocale = bestLocale.replace('-', '_');	//See if the bundle we are going to use is already loaded. 	var bundleResource = dojo.getObject([moduleName, "nls", bundleName].join("."));	if(bundleResource && bundleResource[fixedBestLocale]){		bundle[jsLoc.replace('-', '_')] = bundleResource[fixedBestLocale];	}else{		//Need to remember what locale we wanted and which one we actually use.		//Then when we load the one we are actually using, use that bundle for the one		//we originally wanted.		var mapName = [moduleName, (fixedBestLocale||"root"), bundleName].join(".");		var bundleMap = dojo._xdBundleMap[mapName];		if(!bundleMap){			bundleMap = dojo._xdBundleMap[mapName] = {};		}		bundleMap[jsLoc.replace('-', '_')] = true;				//Do just a normal dojo.require so the resource tracking stuff works as usual.		dojo.require(moduleName + ".nls" + (bestLocale ? "." + bestLocale : "") + "." + bundleName);	}}// Replace dojo.requireLocalization with a wrapperdojo._xdRealRequireLocalization = dojo.requireLocalization;dojo.requireLocalization = function(/*String*/moduleName, /*String*/bundleName, /*String?*/locale, /*String*/availableFlatLocales){    // summary: loads a bundle intelligently based on whether the module is     // local or xd. Overrides the local-case implementation.        var modulePath = this.moduleUrl(moduleName).toString();    if (this._xdIsXDomainPath(modulePath)) {        // call cross-domain loader        return dojo.xdRequireLocalization.apply(dojo, arguments);    } else {        // call local-loader        return dojo._xdRealRequireLocalization.apply(dojo, arguments);    }}//This is a bit brittle: it has to know about the dojo methods that deal with dependencies//It would be ideal to intercept the actual methods and do something fancy at that point,//but I have concern about knowing which provide to match to the dependency in that case,//since scripts can load whenever they want, and trigger new calls to dojo._xdResourceLoaded().dojo._xdUnpackDependency = function(/*Array*/dep){	//summary: Internal xd loader function. Determines what to do with a dependency	//that was listed in an xd version of a module contents.	//Extract the dependency(ies).	var newDeps = null;	var newAfterDeps = null;	switch(dep[0]){		case "requireIf":		case "requireAfterIf":			//First arg (dep[1]) is the test. Depedency is dep[2].			if(dep[1] === true){				newDeps = [{name: dep[2], content: null}];			}			break;		case "platformRequire":			var modMap = dep[1];			var common = modMap["common"]||[];			var newDeps = (modMap[dojo.hostenv.name_]) ? common.concat(modMap[dojo.hostenv.name_]||[]) : common.concat(modMap["default"]||[]);				//Flatten the array of arrays into a one-level deep array.			//Each result could be an array of 3 elements  (the 3 arguments to dojo.require).			//We only need the first one.			if(newDeps){				for(var i = 0; i < newDeps.length; i++){					if(newDeps[i] instanceof Array){						newDeps[i] = {name: newDeps[i][0], content: null};					}else{						newDeps[i] = {name: newDeps[i], content: null};					}				}			}			break;		case "require":			//Just worry about dep[1]			newDeps = [{name: dep[1], content: null}];			break;		case "i18n._preloadLocalizations":			//We can eval these immediately, since they load i18n bundles.			//Since i18n bundles have no dependencies, whenever they are loaded			//in a script tag, they are evaluated immediately, so we do not have to			//treat them has an explicit dependency for the dependency mapping.			//We can call it immediately since dojo.i18n is part of dojo.xd.js.			dojo.i18n._preloadLocalizations.apply(dojo.i18n._preloadLocalizations, dep.slice(1));			break;	}	//The requireIf and requireAfterIf needs to be evaluated after the current resource is evaluated.	if(dep[0] == "requireAfterIf" || dep[0] == "requireIf"){		newAfterDeps = newDeps;		newDeps = null;	}	return {requires: newDeps, requiresAfter: newAfterDeps}; //Object}dojo._xdWalkReqs = function(){	//summary: Internal xd loader function. 	//Walks the requires and evaluates module resource contents in	//the right order.	var reqChain = null;	var req;	for(var i = 0; i < this._xdOrderedReqs.length; i++){		req = this._xdOrderedReqs[i];		if(this._xdDepMap[req]){			reqChain = [req];			reqChain[req] = true; //Allow for fast lookup of the req in the array			this._xdEvalReqs(reqChain);		}	}}dojo._xdEvalReqs = function(/*Array*/reqChain){	//summary: Internal xd loader function. 	//Does a depth first, breadth second search and eval of required modules.	while(reqChain.length > 0){		var req = reqChain[reqChain.length - 1];		var res = this._xdDepMap[req];		if(res){			//Trace down any requires for this resource.			//START dojo._xdTraceReqs() inlining for small Safari 2.0 call stack			var reqs = res.requires;			if(reqs && reqs.length > 0){				var nextReq;				for(var i = 0; i < reqs.length; i++){					nextReq = reqs[i].name;					if(nextReq && !reqChain[nextReq]){						//New req depedency. Follow it down.						reqChain.push(nextReq);						reqChain[nextReq] = true;						this._xdEvalReqs(reqChain);					}				}			}			//END dojo._xdTraceReqs() inlining for small Safari 2.0 call stack			//Evaluate the resource.			var contents = this._xdContents[res.contentIndex];			if(!contents.isDefined){				var content = contents.content;				content["resourceName"] = contents["resourceName"];				content["resourcePath"] = contents["resourcePath"];				this._xdDefList.push(content);				contents.isDefined = true;			}			this._xdDepMap[req] = null;			//Trace down any requireAfters for this resource.			//START dojo._xdTraceReqs() inlining for small Safari 2.0 call stack			var reqs = res.requiresAfter;			if(reqs && reqs.length > 0){				var nextReq;				for(var i = 0; i < reqs.length; i++){					nextReq = reqs[i].name;					if(nextReq && !reqChain[nextReq]){						//New req depedency. Follow it down.						reqChain.push(nextReq);						reqChain[nextReq] = true;						this._xdEvalReqs(reqChain);					}				}			}			//END dojo._xdTraceReqs() inlining for small Safari 2.0 call stack		}		//Done with that require. Remove it and go to the next one.		reqChain.pop();	}}dojo._xdClearInterval = function(){	//summary: Internal xd loader function.	//Clears the interval timer used to check on the	//status of in-flight xd module resource requests.	clearInterval(this._xdTimer);	this._xdTimer = 0;}dojo._xdWatchInFlight = function(){	//summary: Internal xd loader function.	//Monitors in-flight requests for xd module resources.	var noLoads = "";	var waitInterval = (djConfig.xdWaitSeconds || 15) * 1000;	var expired = (this._xdStartTime + waitInterval) < (new Date()).getTime();	//If any xdInFlight are true, then still waiting for something to load.	//Come back later. If we timed out, report the things that did not load.	for(var param in this._xdInFlight){		if(this._xdInFlight[param] === true){			if(expired){				noLoads += param + " ";			}else{				return;			}		}	}	//All done. Clean up and notify.	this._xdClearInterval();	if(expired){		throw "Could not load cross-domain resources: " + noLoads;	}	this._xdWalkReqs();		var defLength = this._xdDefList.length;	for(var i= 0; i < defLength; i++){		var content = dojo._xdDefList[i];		if(djConfig["debugAtAllCosts"] && content["resourceName"]){			if(!this["_xdDebugQueue"]){				this._xdDebugQueue = [];			}			this._xdDebugQueue.push({resourceName: content.resourceName, resourcePath: content.resourcePath});		}else{			//Evaluate the resource to bring it into being.			//Pass dojo in so that later, to support multiple versions of dojo			//in a page, we can pass which version of dojo to use.				content(dojo);		}	}	//Evaluate any resources that were not evaled before.	//This normally shouldn't happen with proper dojo.provide and dojo.require	//usage, but providing it just in case. Note that these may not be executed	//in the original order that the developer intended.	//Pass dojo in so that later, to support multiple versions of dojo	//in a page, we can pass which version of dojo to use.	for(var i = 0; i < this._xdContents.length; i++){		var current = this._xdContents[i];		if(current.content && !current.isDefined){			current.content(dojo);		}	}	//Clean up for the next round of xd loading.	this._xdReset();	if(this["_xdDebugQueue"] && this._xdDebugQueue.length > 0){		this._xdDebugFileLoaded();	}else{		this._xdNotifyLoaded();	}}dojo._xdNotifyLoaded = function(){	//Clear inflight count so we will finally do finish work.	this._inFlightCount = 0; 		//Only trigger call loaded if dj_load_init has run. 	if(this._initFired && !this._loadNotifying){ 		this._callLoaded();	}}}

⌨️ 快捷键说明

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