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

📄 contentpane.js

📁 dojo-0.3.0-ajax开 源 项 目
💻 JS
📖 第 1 页 / 共 2 页
字号:
					case "src":// falltrough					case "href":						// this hopefully covers most common protocols						if(attr[3].search(/^(?:[#]|(?:(?:https?|ftps?|file|javascript|mailto|news):))/)==-1){							fixedPath = (new dojo.uri.Uri(url, attr[3]).toString());						} else {							pos2 = pos2 + attr[3].length;							continue;						}						break;					case "style":// style						fixedPath = dojo.style.fixPathsInCssText(attr[3], url);						break;					default:						pos2 = pos2 + attr[3].length;						continue;				}				regex = " " + attr[1] + "=" + attr[2] + attr[3] + attr[2];				regexlen = regex.length;				fix = " " + attr[1] + "=" + attr[2] + fixedPath + attr[2];				pos2 = tag.search(new RegExp(dojo.string.escapeRegExp(regex)));			}			str += tagFix + tag;			pos = 0; // reset for next mainloop		}		s = str+s;		// cut out all script tags, push them into scripts array		match = []; var tmp = [];		while(match){			match = s.match(/<script([^>]*)>([\s\S]*?)<\/script>/i);			if(!match){ break; }			if(match[1]){				attr = match[1].match(/src=(['"]?)([^"']*)\1/i);				if(attr){					// remove a dojo.js or dojo.js.uncompressed.js from remoteScripts					// we declare all files with dojo.js as bad, regardless of folder					var tmp = attr[2].search(/.*(\bdojo\b(?:\.uncompressed)?\.js)$/);					if(tmp > -1){						dojo.debug("Security note! inhibit:"+attr[2]+" from  beeing loaded again.");					}else{						remoteScripts.push(attr[2]);					}				}			}			if(match[2]){				// strip out all djConfig variables from script tags nodeValue				// this is ABSOLUTLY needed as reinitialize djConfig after dojo is initialised				// makes a dissaster greater than Titanic, update remove writeIncludes() to				var sc = match[2].replace(/(?:var )?\bdjConfig\b(?:[\s]*=[\s]*\{[^}]+\}|\.[\w]*[\s]*=[\s]*[^;\n]*)?;?|dojo\.hostenv\.writeIncludes\(\s*\);?/g, "");				if(!sc){ continue; }				// cut out all dojo.require (...) calls, if we have execute 				// scripts false widgets dont get there require calls				// does suck out possible widgetpackage registration as well				tmp = [];				while(tmp && requires.length<100){					tmp = sc.match(/dojo\.(?:(?:require(?:After)?(?:If)?)|(?:widget\.(?:manager\.)?registerWidgetPackage)|(?:(?:hostenv\.)?setModulePrefix))\((['"]).*?\1\)\s*;?/);					if(!tmp){ break;}					requires.push(tmp[0]);					sc = sc.replace(tmp[0], "");				}				scripts.push(sc);			}			s = s.replace(/<script[^>]*>[\s\S]*?<\/script>/i, "");		}		// scan for scriptScope in html eventHandlers and replace with link to this pane		if(this.executeScripts){			var regex = /(<[a-zA-Z][a-zA-Z0-9]*\s[^>]*\S=(['"])[^>]*[^\.\]])scriptScope([^>]*>)/;			var pos = 0;var str = "";match = [];var cit = "";			while(pos > -1){				pos = s.search(regex);				if(pos > -1){					cit = ((RegExp.$2=="'") ? '"': "'");					str += s.substring(0, pos);					s = s.substr(pos).replace(regex, "$1dojo.widget.byId("+ cit + this.widgetId + cit + ").scriptScope$3");				}			}			s = str + s;		}		// cut out all <link rel="stylesheet" href="..">		match = [];		while(match){			match = s.match(/<link ([^>]*rel=['"]?stylesheet['"]?[^>]*)>/i);			if(!match){ break; }			attr = match[1].match(/href=(['"]?)([^'">]*)\1/i);			if(attr){				linkStyles.push(attr[2]);			}			s = s.replace(new RegExp(match[0]), "");		}		return {"xml": s, // Object			"styles": styles,			"linkStyles": linkStyles,			"titles": titles,			"requires": 	requires,			"scripts": scripts,			"remoteScripts": remoteScripts,			"url": url};	},		_setContent: function(/*String*/ xml){		// summary: 		//		private internal function without path regExpCheck and no onLoad calls aftervards		// remove old children from current content		this.destroyChildren();		// remove old stylenodes from HEAD		if(this._remoteStyles){			for(var i = 0; i < this._remoteStyles.length; i++){				if(this._remoteStyles[i] && this._remoteStyles.parentNode){					this._remoteStyles[i].parentNode.removeChild(this._remoteStyles[i]);				}			}			this._remoteStyles = null;		}		var node = this.containerNode || this.domNode;		try{			if(typeof xml != "string"){				node.innerHTML = "";				node.appendChild(xml);			}else{				node.innerHTML = xml;			}		} catch(e){			e = "Could'nt load html:"+e;			this._handleDefaults(e, "onContentError");		}	},	setContent: function(/*String*/ data){		// summary:		// 	Destroys old content and setting new content, and possibly initialize any widgets within 'data'		if(this._callOnUnLoad){ // this tells a remote script clean up after itself			this.onUnLoad();		}		this._callOnUnLoad = true;		if(!data || dojo.dom.isNode(data)){			// if we do a clean using setContent(""); or setContent(#node) bypass all parseing, extractContent etc			this._setContent(data);		}else{			// need to run splitAndFixPaths? ie. manually setting content			 if(!data.xml){				data = this.splitAndFixPaths(data);			}			if(this.extractContent) {				var matches = data.xml.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);				if(matches) { data.xml = matches[1]; }			}			// insert styleNodes, from <style>....			for(var i = 0; i < data.styles.length; i++){				if(i==0){ 					this._remoteStyles = []; 				}				this._remoteStyles.push(dojo.style.insertCssText(data.styles[i]));			}			// insert styleNodes, from <link href="...">			for(var i = 0; i < data.linkStyles.length; i++){				if(i==0){ 					this._remoteStyles = []; 				}				this._remoteStyles.push(dojo.style.insertCssFile(data.linkStyles[i]));			}			this._setContent(data.xml);			if(this.parseContent){				for(var i = 0; i < data.requires.length; i++){					try{ 						eval(data.requires[i]);					} catch(e){						this._handleDefaults(e, "onContentError", true);					}				}				var node = this.containerNode || this.domNode;				var parser = new dojo.xml.Parse();				var frag = parser.parseElement(node, null, true);				// createSubComponents not createComponents because frag has already been created				dojo.widget.getParser().createSubComponents(frag, this);			}			if(this.executeScripts){				this._executeScripts(data);			}		}		this.onResized(); // move this here so that resize is called when we set "" to reset sizing code		this.onLoad(); // tell system that we have finished	},	// Generate pane content from given java function	setHandler: function(handler) {		var fcn = dojo.lang.isFunction(handler) ? handler : window[handler];		if(!dojo.lang.isFunction(fcn)) {			// FIXME: needs testing! somebody with java knowledge needs to try this			this._handleDefaults("Unable to set handler, '" + handler + "' not a function.", "onExecError", true);			return;		}		this.handler = function() {			return fcn.apply(this, arguments);		}	},	_runHandler: function() {		if(dojo.lang.isFunction(this.handler)) {			this.handler(this, this.domNode);			return false;		}		return true;	},	_executeScripts: function(data) {		// do remoteScripts first		var self = this;		for(var i = 0; i < data.remoteScripts.length; i++){			dojo.io.bind({				"url": data.remoteScripts[i],				"useCash":	this.cacheContent,				"load":     function(type, scriptStr){						dojo.lang.hitch(self, data.scripts.push(scriptStr));				},				"error":    function(type, error){						self._handleDefaults.call(self, type + " downloading remote script", "onExecError", true);				},				"mimetype": "text/plain",				"sync":     true			});		}		var scripts = "";		for(var i = 0; i < data.scripts.length; i++){			scripts += data.scripts[i];		}			// initialize a new anonymous container for our script, dont make it part of this widgets scope chain			// instead send in a variable that points to this widget, usefull to connect events to onLoad, onUnLoad etc..			this.scriptScope = null;			this.scriptScope = new (new Function('_container_', scripts+'; return this;'))(self);	try{		}catch(e){			this._handleDefaults("Error running scripts from content:\n"+e, "onExecError", true);		}	}});dojo.widget.tags.addParseTreeHandler("dojo:ContentPane");

⌨️ 快捷键说明

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