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

📄 style.js

📁 dojo与json创建无限级树的时候,当在父结点下添加了一个新结点,我怎么让父亲结点重新调用json加载一下子结点内容.
💻 JS
📖 第 1 页 / 共 2 页
字号:
				index = ds.styleSheet.rules.length;				ds.styleSheet.removeRule(index);			}		}else if(document.styleSheets[0]){			if(!index){				index = ds.styleSheet.cssRules.length;			}			ds.styleSheet.deleteRule(index);		}		return true;	}	// calls css by XmlHTTP and inserts it into DOM as <style [widgetType="widgetType"]> *downloaded cssText*</style>	ds.insertCssFile = function(URI, doc, checkDuplicates){		if(!URI){ return; }		if(!doc){ doc = document; }		var cssStr = dojo.hostenv.getText(URI);		cssStr = ds.fixPathsInCssText(cssStr, URI);		if(checkDuplicates){			var styles = doc.getElementsByTagName("style");			var cssText = "";			for(var i = 0; i<styles.length; i++){				cssText = (styles[i].styleSheet && styles[i].styleSheet.cssText) ? styles[i].styleSheet.cssText : styles[i].innerHTML;				if(cssStr == cssText){ return; }			}		}		var style = ds.insertCssText(cssStr);		// insert custom attribute ex dbgHref="../foo.css" usefull when debugging in DOM inspectors, no?		if(style && djConfig.isDebug){			style.setAttribute("dbgHref", URI);		}		return style	}	// DomNode Style  = insertCssText(String ".dojoMenu {color: green;}"[, DomDoc document, dojo.uri.Uri Url ])	ds.insertCssText = function(cssStr, doc, URI){		if(!cssStr){ return; }		if(!doc){ doc = document; }		if(URI){// fix paths in cssStr			cssStr = ds.fixPathsInCssText(cssStr, URI);		}		var style = doc.createElement("style");		style.setAttribute("type", "text/css");		// IE is b0rken enough to require that we add the element to the doc		// before changing it's properties		var head = doc.getElementsByTagName("head")[0];		if(!head){ // must have a head tag 			dojo.debug("No head tag in document, aborting styles");			return;		}else{			head.appendChild(style);		}		if(style.styleSheet){// IE			style.styleSheet.cssText = cssStr;		}else{ // w3c			var cssText = doc.createTextNode(cssStr);			style.appendChild(cssText);		}		return style;	}	// String cssText = fixPathsInCssText(String cssStr, dojo.uri.Uri URI)	// usage: cssText comes from dojoroot/src/widget/templates/HtmlFoobar.css	// 	it has .dojoFoo { background-image: url(images/bar.png);} 	//	then uri should point to dojoroot/src/widget/templates/	ds.fixPathsInCssText = function(cssStr, URI){		if(!cssStr || !URI){ return; }		var pos = 0; var str = ""; var url = "";		while(pos!=-1){			pos = 0;url = "";			pos = cssStr.indexOf("url(", pos);			if(pos<0){ break; }			str += cssStr.slice(0,pos+4);			cssStr = cssStr.substring(pos+4, cssStr.length);			url += cssStr.match(/^[\t\s\w()\/.\\'"-:#=&?]*\)/)[0]; // url string			cssStr = cssStr.substring(url.length-1, cssStr.length); // remove url from css string til next loop			url = url.replace(/^[\s\t]*(['"]?)([\w()\/.\\'"-:#=&?]*)\1[\s\t]*?\)/,"$2"); // clean string			if(url.search(/(file|https?|ftps?):\/\//)==-1){				url = (new dojo.uri.Uri(URI,url).toString());			}			str += url;		};		return str+cssStr;	}	ds.getBackgroundColor = function(node) {		node = dojo.byId(node);		var color;		do{			color = ds.getStyle(node, "background-color");			// Safari doesn't say "transparent"			if(color.toLowerCase() == "rgba(0, 0, 0, 0)") { color = "transparent"; }			if(node == document.getElementsByTagName("body")[0]) { node = null; break; }			node = node.parentNode;		}while(node && dojo.lang.inArray(color, ["transparent", ""]));		if(color == "transparent"){			color = [255, 255, 255, 0];		}else{			color = dojo.graphics.color.extractRGB(color);		}		return color;	}	ds.getComputedStyle = function(node, cssSelector, inValue){		node = dojo.byId(node);		// cssSelector may actually be in camel case, so force selector version		var cssSelector = ds.toSelectorCase(cssSelector);		var property = ds.toCamelCase(cssSelector);		if(!node || !node.style){			return inValue;		}else if(document.defaultView){ // W3, gecko, KHTML			try{							var cs = document.defaultView.getComputedStyle(node, "");				if (cs){ 					return cs.getPropertyValue(cssSelector);				} 			}catch(e){ // reports are that Safari can throw an exception above				if (node.style.getPropertyValue){ // W3					return node.style.getPropertyValue(cssSelector);				}else return inValue;			}		}else if(node.currentStyle){ // IE			return node.currentStyle[property];		}if(node.style.getPropertyValue){ // W3			return node.style.getPropertyValue(cssSelector);		}else{			return inValue;		}	}	/** 	 * Retrieve a property value from a node's style object.	 */	ds.getStyleProperty = function(node, cssSelector){		node = dojo.byId(node);		// FIXME: should we use node.style.getPropertyValue over style[property]?		// style[property] works in all (modern) browsers, getPropertyValue is W3 but not supported in IE		// FIXME: what about runtimeStyle?		return (node && node.style ? node.style[ds.toCamelCase(cssSelector)] : undefined);	}	/** 	 * Retrieve a property value from a node's style object.	 */	ds.getStyle = function(node, cssSelector){		var value = ds.getStyleProperty(node, cssSelector);		return (value ? value : ds.getComputedStyle(node, cssSelector));	}	ds.setStyle = function(node, cssSelector, value){		node = dojo.byId(node);		if(node && node.style){			var camelCased = ds.toCamelCase(cssSelector);			node.style[camelCased] = value;		}	}	ds.toCamelCase = function(selector) {		var arr = selector.split('-'), cc = arr[0];		for(var i = 1; i < arr.length; i++) {			cc += arr[i].charAt(0).toUpperCase() + arr[i].substring(1);		}		return cc;			}	ds.toSelectorCase = function(selector) {		return selector.replace(/([A-Z])/g, "-$1" ).toLowerCase() ;	}	/* float between 0.0 (transparent) and 1.0 (opaque) */	ds.setOpacity = function setOpacity(node, opacity, dontFixOpacity) {		node = dojo.byId(node);		if(!dontFixOpacity){			if( opacity >= 1.0){				if(h.ie){					ds.clearOpacity(node);					return;				}else{					opacity = 0.999999;				}			}else if( opacity < 0.0){ opacity = 0; }		}		if(h.ie){			if(node.nodeName.toLowerCase() == "tr"){				// FIXME: is this too naive? will we get more than we want?				var tds = node.getElementsByTagName("td");				for(var x=0; x<tds.length; x++){					tds[x].style.filter = "Alpha(Opacity="+opacity*100+")";				}			}			node.style.filter = "Alpha(Opacity="+opacity*100+")";		}else if(h.moz){			node.style.opacity = opacity; // ffox 1.0 directly supports "opacity"			node.style.MozOpacity = opacity;		}else if(h.safari){			node.style.opacity = opacity; // 1.3 directly supports "opacity"			node.style.KhtmlOpacity = opacity;		}else{			node.style.opacity = opacity;		}	}			ds.getOpacity = function getOpacity (node){		node = dojo.byId(node);		if(h.ie){			var opac = (node.filters && node.filters.alpha &&				typeof node.filters.alpha.opacity == "number"				? node.filters.alpha.opacity : 100) / 100;		}else{			var opac = node.style.opacity || node.style.MozOpacity ||				node.style.KhtmlOpacity || 1;		}		return opac >= 0.999999 ? 1.0 : Number(opac);	}	ds.clearOpacity = function clearOpacity(node){		node = dojo.byId(node);		var ns = node.style;		if(h.ie){			try {				if( node.filters && node.filters.alpha ){					ns.filter = ""; // FIXME: may get rid of other filter effects				}			} catch(e) {				/*				 * IE7 gives error if node.filters not set;				 * don't know why or how to workaround (other than this)				 */			}		}else if(h.moz){			ns.opacity = 1;			ns.MozOpacity = 1;		}else if(h.safari){			ns.opacity = 1;			ns.KhtmlOpacity = 1;		}else{			ns.opacity = 1;		}	}	/** 	* Set the given style attributes for the node. 	* Patch submitted by Wolfram Kriesing, 22/03/2006.	*	* Ie. dojo.style.setStyleAttributes(myNode, "position:absolute; left:10px; top:10px;") 	* This just makes it easier to set a style directly without the need to  	* override it completely (as node.setAttribute() would). 	* If there is a dojo-method for an attribute, like for "opacity" there 	* is setOpacity, the dojo method is called instead. 	* For example: dojo.style.setStyleAttributes(myNode, "opacity: .4"); 	*  	* Additionally all the dojo.style.set* methods can also be used. 	* Ie. when attributes contains "outer-height: 10;" it will call dojo.style.setOuterHeight("10"); 	* 	* @param object The node to set the style attributes for. 	* @param string Ie. "position:absolute; left:10px; top:10px;" 	*/ 	ds.setStyleAttributes = function(node, attributes) { 		var methodMap={ 			"opacity":dojo.style.setOpacity,			"content-height":dojo.style.setContentHeight,			"content-width":dojo.style.setContentWidth,			"outer-height":dojo.style.setOuterHeight,			"outer-width":dojo.style.setOuterWidth 		} 		var splittedAttribs=attributes.replace(/(;)?\s*$/, "").split(";"); 		for(var i=0; i<splittedAttribs.length; i++){ 			var nameValue=splittedAttribs[i].split(":"); 			var name=nameValue[0].replace(/\s*$/, "").replace(/^\s*/, "").toLowerCase();			var value=nameValue[1].replace(/\s*$/, "").replace(/^\s*/, "");			if(dojo.lang.has(methodMap,name)) { 				methodMap[name](node,value); 			} else { 				node.style[dojo.style.toCamelCase(name)]=value; 			} 		} 	} 	ds._toggle = function(node, tester, setter){		node = dojo.byId(node);		setter(node, !tester(node));		return tester(node);	}	// show/hide are library constructs	// show() 	// if the node.style.display == 'none' then 	// set style.display to '' or the value cached by hide()	ds.show = function(node){		node = dojo.byId(node);		if(ds.getStyleProperty(node, 'display')=='none'){			ds.setStyle(node, 'display', (node.dojoDisplayCache||''));			node.dojoDisplayCache = undefined;	// cannot use delete on a node in IE6		}	}	// if the node.style.display == 'none' then 	// set style.display to '' or the value cached by hide()	ds.hide = function(node){		node = dojo.byId(node);		if(typeof node["dojoDisplayCache"] == "undefined"){ // it could == '', so we cannot say !node.dojoDisplayCount			var d = ds.getStyleProperty(node, 'display')			if(d!='none'){				node.dojoDisplayCache = d;			}		}		ds.setStyle(node, 'display', 'none');	}	// setShowing() calls show() if showing is true, hide() otherwise	ds.setShowing = function(node, showing){		ds[(showing ? 'show' : 'hide')](node);	}	// isShowing() is true if the node.style.display is not 'none'	// FIXME: returns true if node is bad, isHidden would be easier to make correct	ds.isShowing = function(node){		return (ds.getStyleProperty(node, 'display') != 'none');	}	// Call setShowing() on node with the complement of isShowing(), then return the new value of isShowing()	ds.toggleShowing = function(node){		return ds._toggle(node, ds.isShowing, ds.setShowing);	}	// display is a CSS concept	// Simple mapping of tag names to display values	// FIXME: simplistic 	ds.displayMap = { tr: '', td: '', th: '', img: 'inline', span: 'inline', input: 'inline', button: 'inline' };	// Suggest a value for the display property that will show 'node' based on it's tag	ds.suggestDisplayByTagName = function(node)	{		node = dojo.byId(node);		if(node && node.tagName){			var tag = node.tagName.toLowerCase();			return (tag in ds.displayMap ? ds.displayMap[tag] : 'block');		}	}	// setDisplay() sets the value of style.display to value of 'display' parameter if it is a string.	// Otherwise, if 'display' is false, set style.display to 'none'.	// Finally, set 'display' to a suggested display value based on the node's tag	ds.setDisplay = function(node, display){		ds.setStyle(node, 'display', (dojo.lang.isString(display) ? display : (display ? ds.suggestDisplayByTagName(node) : 'none')));	}	// isDisplayed() is true if the the computed display style for node is not 'none'	// FIXME: returns true if node is bad, isNotDisplayed would be easier to make correct	ds.isDisplayed = function(node){		return (ds.getComputedStyle(node, 'display') != 'none');	}	// Call setDisplay() on node with the complement of isDisplayed(), then	// return the new value of isDisplayed()	ds.toggleDisplay = function(node){		return ds._toggle(node, ds.isDisplayed, ds.setDisplay);	}	// visibility is a CSS concept	// setVisibility() sets the value of style.visibility to value of	// 'visibility' parameter if it is a string.	// Otherwise, if 'visibility' is false, set style.visibility to 'hidden'.	// Finally, set style.visibility to 'visible'.	ds.setVisibility = function(node, visibility){		ds.setStyle(node, 'visibility', (dojo.lang.isString(visibility) ? visibility : (visibility ? 'visible' : 'hidden')));	}	// isVisible() is true if the the computed visibility style for node is not 'hidden'	// FIXME: returns true if node is bad, isInvisible would be easier to make correct	ds.isVisible = function(node){		return (ds.getComputedStyle(node, 'visibility') != 'hidden');	}	// Call setVisibility() on node with the complement of isVisible(), then	// return the new value of isVisible()	ds.toggleVisibility = function(node){		return ds._toggle(node, ds.isVisible, ds.setVisibility);	}	// in: coordinate array [x,y,w,h] or dom node	// return: coordinate array	ds.toCoordinateArray = function(coords, includeScroll) {		if(dojo.lang.isArray(coords)){			// coords is already an array (of format [x,y,w,h]), just return it			while ( coords.length < 4 ) { coords.push(0); }			while ( coords.length > 4 ) { coords.pop(); }			var ret = coords;		} else {			// coords is an dom object (or dom object id); return it's coordinates			var node = dojo.byId(coords);			var pos = ds.getAbsolutePosition(node, includeScroll);			var ret = [				pos.x,				pos.y,				ds.getBorderBoxWidth(node),				ds.getBorderBoxHeight(node)			];		}		ret.x = ret[0];		ret.y = ret[1];		ret.w = ret[2];		ret.h = ret[3];		return ret;	};})();

⌨️ 快捷键说明

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