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

📄 html.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 3 页
字号:
	var _sumAncestorProperties = function(node, prop){		if(!(node = (node||0).parentNode)){return 0};		var val, retVal = 0, _b = d.body();		while(node && node.style){			if(gcs(node).position == "fixed"){				return 0;			}			val = node[prop];			if(val){				retVal += val - 0;				// opera and khtml #body & #html has the same values, we only				// need one value				if(node == _b){ break; }			}			node = node.parentNode;		}		return retVal;	//	integer	}	dojo._docScroll = function(){		var 			_b = d.body(),			_w = d.global,			de = d.doc.documentElement;		return {			y: (_w.pageYOffset || de.scrollTop || _b.scrollTop || 0),			x: (_w.pageXOffset || d._fixIeBiDiScrollLeft(de.scrollLeft) || _b.scrollLeft || 0)		};	};		dojo._isBodyLtr = function(){		//FIXME: could check html and body tags directly instead of computed style?  need to ignore case, accept empty values		return !("_bodyLtr" in d) ? 			d._bodyLtr = gcs(d.body()).direction == "ltr" :			d._bodyLtr; // Boolean 	}		dojo._getIeDocumentElementOffset = function(){		// summary		// The following values in IE contain an offset:		//     event.clientX 		//     event.clientY 		//     node.getBoundingClientRect().left		//     node.getBoundingClientRect().top		// But other position related values do not contain this offset, such as		// node.offsetLeft, node.offsetTop, node.style.left and node.style.top.		// The offset is always (2, 2) in LTR direction. When the body is in RTL		// direction, the offset counts the width of left scroll bar's width.		// This function computes the actual offset.		//NOTE: assumes we're being called in an IE browser		var de = d.doc.documentElement;		//FIXME: use this instead?			var de = d.compatMode == "BackCompat" ? d.body : d.documentElement;		return (d.isIE >= 7) ?			{x: de.getBoundingClientRect().left, y: de.getBoundingClientRect().top}		:			// IE 6.0			{x: d._isBodyLtr() || window.parent == window ?				de.clientLeft : de.offsetWidth - de.clientWidth - de.clientLeft, 				y: de.clientTop}; // Object	};		dojo._fixIeBiDiScrollLeft = function(/*Integer*/ scrollLeft){		// In RTL direction, scrollLeft should be a negative value, but IE 		// returns a positive one. All codes using documentElement.scrollLeft		// must call this function to fix this error, otherwise the position		// will offset to right when there is a horizontal scrollbar.		var dd = d.doc;		if(d.isIE && !dojo._isBodyLtr()){			var de = dd.compatMode == "BackCompat" ? dd.body : dd.documentElement;			return scrollLeft + de.clientWidth - de.scrollWidth; // Integer		}		return scrollLeft; // Integer	}	dojo._abs = function(/*DomNode*/node, /*Boolean?*/includeScroll){		//	summary:		//		Gets the position of the passed element relative to		//		the viewport (if includeScroll==false), or relative to the		//		document root (if includeScroll==true).		//		//		Returns an object of the form:		//			{ x: 100, y: 300 }		//		if includeScroll is passed, the x and y values will include any		//		document offsets that may affect the position relative to the		//		viewport.		// FIXME: need to decide in the brave-new-world if we're going to be		// margin-box or border-box.		var ownerDocument = node.ownerDocument;		var ret = {			x: 0,			y: 0		};		// targetBoxType == "border-box"		var db = d.body();		if(d.isIE || (d.isFF >= 3)){			var client = node.getBoundingClientRect();			var offset = (d.isIE) ? d._getIeDocumentElementOffset() : { x: 0, y: 0};			ret.x = client.left - offset.x;			ret.y = client.top - offset.y;		}else if(ownerDocument["getBoxObjectFor"]){			// mozilla			var bo = ownerDocument.getBoxObjectFor(node),				b = d._getBorderExtents(node);			ret.x = bo.x - b.l - _sumAncestorProperties(node, "scrollLeft");			ret.y = bo.y - b.t - _sumAncestorProperties(node, "scrollTop");		}else{			if(node["offsetParent"]){				var endNode;				// in Safari, if the node is an absolutely positioned child of				// the body and the body has a margin the offset of the child				// and the body contain the body's margins, so we need to end				// at the body				// FIXME: getting contrary results to the above in latest WebKit.				if(d.isSafari &&					//(node.style.getPropertyValue("position") == "absolute") &&					(gcs(node).position == "absolute") &&					(node.parentNode == db)){					endNode = db;				}else{					endNode = db.parentNode;				}				if(node.parentNode != db){					var nd = node;					if(d.isOpera){ nd = db; }					ret.x -= _sumAncestorProperties(nd, "scrollLeft");					ret.y -= _sumAncestorProperties(nd, "scrollTop");				}				var curnode = node;				do{					var n = curnode.offsetLeft;					//FIXME: ugly hack to workaround the submenu in 					//popupmenu2 does not shown up correctly in opera. 					//Someone have a better workaround?					if(!d.isOpera || n > 0){						ret.x += isNaN(n) ? 0 : n;					}					var t = curnode.offsetTop;					ret.y += isNaN(t) ? 0 : t;					if(d.isSafari && curnode != node){						var cs = gcs(curnode);						ret.x += px(curnode, cs.borderLeftWidth);						ret.y += px(curnode, cs.borderTopWidth);					}					curnode = curnode.offsetParent;				}while((curnode != endNode) && curnode);			}else if(node.x && node.y){				ret.x += isNaN(node.x) ? 0 : node.x;				ret.y += isNaN(node.y) ? 0 : node.y;			}		}		// account for document scrolling		// if offsetParent is used, ret value already includes scroll position		// so we may have to actually remove that value if !includeScroll		if(includeScroll){			var scroll = d._docScroll();			ret.y += scroll.y;			ret.x += scroll.x;		}		return ret; // object	}	// FIXME: need a setter for coords or a moveTo!!	dojo.coords = function(/*DomNode|String*/node, /*Boolean?*/includeScroll){		//	summary:		//		Returns an object that measures margin box width/height and		//		absolute positioning data from dojo._abs().		//		//	description:		//		Returns an object that measures margin box width/height and		//		absolute positioning data from dojo._abs().		//		Return value will be in the form:		//			`{ l: 50, t: 200, w: 300: h: 150, x: 100, y: 300 }`		//		Does not act as a setter. If includeScroll is passed, the x and		//		y params are affected as one would expect in dojo._abs().		var n=d.byId(node), s=gcs(n), mb=d._getMarginBox(n, s);		var abs = d._abs(n, includeScroll);		mb.x = abs.x;		mb.y = abs.y;		return mb;	}	// =============================	// Element attribute Functions	// =============================	var _fixAttrName = function(/*String*/name){		switch(name.toLowerCase()){			case "tabindex":				// Internet Explorer will only set or remove tabindex				// if it is spelled "tabIndex"				// console.debug((dojo.isIE && dojo.isIE < 8)? "tabIndex" : "tabindex");				return (d.isIE && d.isIE < 8) ? "tabIndex" : "tabindex";			default:				return name;		}	}	// non-deprecated HTML4 attributes with default values	// http://www.w3.org/TR/html401/index/attributes.html	// FF and Safari will return the default values if you	// access the attributes via a property but not	// via getAttribute()	var _attrProps = {		colspan: "colSpan",		enctype: "enctype",		frameborder: "frameborder",		method: "method",		rowspan: "rowSpan",		scrolling: "scrolling",		shape: "shape",		span: "span",		type: "type",		valuetype: "valueType"	}	dojo.hasAttr = function(/*DomNode|String*/node, /*String*/name){		//	summary:		//		Returns true if the requested attribute is specified on the		//		given element, and false otherwise.		//	node:		//		id or reference to the element to check		//	name:		//		the name of the attribute		//	returns:		//		true if the requested attribute is specified on the		//		given element, and false otherwise		var attr = d.byId(node).getAttributeNode(_fixAttrName(name));		return attr ? attr.specified : false; // Boolean	}	var _evtHdlrMap = {			}	var _ctr = 0;	var _attrId = dojo._scopeName + "attrid";	dojo.attr = function(/*DomNode|String*/node, /*String|Object*/name, /*String?*/value){		//	summary:		//		Gets or sets an attribute on an HTML element.		//	description:		//		Handles normalized getting and setting of attributes on DOM		//		Nodes. If 2 arguments are passed, and a the second argumnt is a		//		string, acts as a getter.		//			//		If a third argument is passed, or if the second argumnt is a		//		map of attributes, acts as a setter.		//		//		When passing functions as values, note that they will not be		//		directly assigned to slots on the node, but rather the default		//		behavior will be removed and the new behavior will be added		//		using `dojo.connect()`, meaning that event handler properties		//		will be normalized and that some caveats with regards to		//		non-standard behaviors for onsubmit apply. Namely that you		//		should cancel form submission using `dojo.stopEvent()` on the		//		passed event object instead of returning a boolean value from		//		the handler itself.		//	node:		//		id or reference to the element to get or set the attribute on		//	name:		//		the name of the attribute to get or set.		//	value:		//		The value to set for the attribute		//	returns:		//		when used as a getter, the value of the requested attribute		//		or null if that attribute does not have a specified or		//		default value;		//		//		when user as a setter, undefined		//	example:		//	|	// get the current value of the "foo" attribute on a node		//	|	dojo.attr(dojo.byId("nodeId"), "foo");		//	|			//	|	// we can just pass the id:		//	|	dojo.attr("nodeId", "foo");		//	|		//	|	// use attr() to set the tab index		//	|	dojo.attr("nodeId", "tabindex", 3);		//	|		//	|	// set multiple values at once, including event handlers:		//	|	dojo.attr("formId", {		//	|		"foo": "bar",		//	|		"tabindex": -1,		//	|		"method": "POST",		//	|		"onsubmit": function(e){		//	|			// stop submitting the form. Note that the IE behavior		//	|			// of returning true or false will have no effect here		//	|			// since our handler is connect()ed to the built-in		//	|			// onsubmit behavior and so we need to use		//	|			// dojo.stopEvent() to ensure that the submission		//	|			// doesn't proceed.		//	|			dojo.stopEvent(e);		//	|		//	|			// submit the form with Ajax		//	|			dojo.xhrPost({ form: "formId" });		//	|		}		//	|	});		var args = arguments.length;		if(args == 2 && !d.isString(name)){			for(var x in name){ d.attr(node, x, name[x]); }			return;		}		node = d.byId(node);		name = _fixAttrName(name);		if(args == 3){			if(d.isFunction(value)){				// clobber if we can				var attrId = d.attr(node, _attrId);				if(!attrId){					attrId = _ctr++;					d.attr(node, _attrId, attrId);				}				if(!_evtHdlrMap[attrId]){					_evtHdlrMap[attrId] = {};				}				var h = _evtHdlrMap[attrId][name];				if(h){					d.disconnect(h);				}else{					try{						delete node[name];					}catch(e){}				}				// ensure that event objects are normalized, etc.				_evtHdlrMap[attrId][name] = d.connect(node, name, value);			}else if(typeof value == "boolean"){ // e.g. onsubmit, disabled				// if a function, we should normalize the event object here!!!				node[name] = value;			}else{				node.setAttribute(name, value);			}			return;		}else{			// should we access this attribute via a property or			// via getAttribute()?			var prop = _attrProps[name.toLowerCase()];			if(prop){				return node[prop];			}else{				var value = node[name];				return (typeof value == 'boolean' || typeof value == 'function') ? value : (d.hasAttr(node, name) ? node.getAttribute(name) : null);			}		}	}	dojo.removeAttr = function(/*DomNode|String*/node, /*String*/name){		//	summary:		//		Removes an attribute from an HTML element.		//	node:		//		id or reference to the element to remove the attribute from		//	name:		//		the name of the attribute to remove		d.byId(node).removeAttribute(_fixAttrName(name));	}})();// =============================// (CSS) Class Functions// =============================dojo.hasClass = function(/*DomNode|String*/node, /*String*/classStr){	//	summary:	//		Returns whether or not the specified classes are a portion of the	//		class list currently applied to the node. 	return ((" "+dojo.byId(node).className+" ").indexOf(" "+classStr+" ") >= 0);  // Boolean};dojo.addClass = function(/*DomNode|String*/node, /*String*/classStr){	//	summary:	//		Adds the specified classes to the end of the class list on the	//		passed node.	node = dojo.byId(node);	var cls = node.className;	if((" "+cls+" ").indexOf(" "+classStr+" ") < 0){		node.className = cls + (cls ? ' ' : '') + classStr;	}};dojo.removeClass = function(/*DomNode|String*/node, /*String*/classStr){	// summary: Removes the specified classes from node.	node = dojo.byId(node);	var t = dojo.trim((" " + node.className + " ").replace(" " + classStr + " ", " "));	if(node.className != t){ node.className = t; }};dojo.toggleClass = function(/*DomNode|String*/node, /*String*/classStr, /*Boolean?*/condition){	//	summary: 		//		Adds a class to node if not present, or removes if present.	//		Pass a boolean condition if you want to explicitly add or remove.	//	condition:	//		If passed, true means to add the class, false means to remove.	if(condition === undefined){		condition = !dojo.hasClass(node, classStr);	}	dojo[condition ? "addClass" : "removeClass"](node, classStr);};}

⌨️ 快捷键说明

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