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

📄 boot.js

📁 ZK 基础介绍 功能操作 模块 结合数据库操作
💻 JS
📖 第 1 页 / 共 3 页
字号:
/* boot.js{{IS_NOTE	Purpose:		Bootstrap JavaScript	Description:			History:		Sun Jan 29 11:43:45     2006, Created by tomyeh}}IS_NOTECopyright (C) 2006 Potix Corporation. All Rights Reserved.{{IS_RIGHT	This program is distributed under GPL Version 2.0 in the hope that	it will be useful, but WITHOUT ANY WARRANTY.}}IS_RIGHT*///zk//if (!window.zk) { //avoid eval twice//////Customization/** Creates the error box to display the specified error message. * Developer can override this method to provide a customize errorbox. * If null is returned, alert() is used. * * @param id the progress box's ID * @param msg the message * @param x the x-coordinate of the box * @param y the y-coordinate of the box */if (!window.Boot_progressbox) { //not customized	window.Boot_progressbox = function (id, msg, x, y) {		var n = document.createElement("DIV");		document.body.appendChild(n);		var html = '<div id="'+id+'"';		var mask = zk.loading && !zk._prgsOnce;		if (mask) {			zk._prgsOnce = true; //do it only once			html += ' class="modal_mask" style="display:block"><div'		}		html += ' style="left:'+x+'px;top:'+y+'px;'		+'position:absolute;z-index:79000;background-color:#FFF0C8;'		+'white-space:nowrap;border:1px solid #77a;padding:6px;">'		+'<img alt="..." src="'+zk.getUpdateURI('/web/zk/img/progress.gif')+'"/> '		+msg+'</div>';		if (mask)			html += '</div>';		zk._setOuterHTML(n, html);		return $e(id);	};}/////// zkzk = {};zk.build = "7q"; //increase this if we want the browser to reload JavaScriptzk.voidf = Prototype.emptyFunction;/** Browser info. */zk.agent = navigator.userAgent.toLowerCase();zk.safari = zk.agent.indexOf("safari") != -1;zk.opera = zk.agent.indexOf("opera") != -1;zk.ie = zk.agent.indexOf("msie") != -1 && !zk.opera;zk.ie7 = zk.agent.indexOf("msie 7") != -1;zk.gecko = zk.agent.indexOf("gecko/") != -1 && !zk.safari && !zk.opera;zk.windows = zk.agent.indexOf("windows") != -1;//zk.macintosh = zk.agent.indexOf("macintosh") != -1;/** Listen an event. * Why not to use prototype's Event.observe? Performance. */zk.listen = function (el, evtnm, fn) {	if (el.addEventListener)		el.addEventListener(evtnm, fn, false);	else /*if (el.attachEvent)*/		el.attachEvent('on' + evtnm, fn);	//Bug 1811352	if ("submit" == evtnm && $tag(el) == "FORM") {		if (!el._submfns) el._submfns = [];		el._submfns.push(fn);	}};/** Un-listen an event. */zk.unlisten = function (el, evtnm, fn) {	if (el.removeEventListener)		el.removeEventListener(evtnm, fn, false);	else if (el.detachEvent) {		try {			el.detachEvent('on' + evtnm, fn);		} catch (e) {		}	}	//Bug 1811352	if ("submit" == evtnm && $tag(el) == "FORM" && el._submfns)		el._submfns.remove(fn);};if (zk.ie) { //Bug 1741959: avoid memory leaks	zk._ltns = {} // map(el, [evtnm, fn])	zk._unltns = []; //array of [el, [evtnm, fn]]	zk._listen = zk.listen;	zk.listen = function (el, evtnm, fn) {		zk._listen(el, evtnm, fn);		var ls = zk._ltns[el];		if (!ls) zk._ltns[el] = ls = {};		var fns = ls[evtnm];		if (!fns) ls[evtnm] = fns = [];		fns.push(fn);	};	zk._unlisten = zk.unlisten;	zk.unlisten = function (el, evtnm, fn) {		zk._unlisten(el, evtnm, fn);		var ls = zk._ltns[el];		var fns = ls ? ls[evtnm]: null;		if (fns) {			fns.remove(fn);			if (!fns.length) delete ls[evtnm];		}	};	/** Unlisten events associated with the specified ID.	 * Bug 1741959: IE meory leaks	 */	zk.unlistenAll = function (el) {		if (el) {			var ls = zk._ltns[el];			if (ls) {				zk._unltns.push([el, ls]);				delete zk._ltns[el];				setTimeout(zk._unlistenOne, 10000 + 20000*Math.random());					//Note: the performance is not good, so delay 10~30s			}		} else {			while (zk._unltns.length)				zk._unlistenOne();			for (var el in zk._ltns) {				var ls = zk._ltns[el];				if (ls) {					delete zk._ltns[el];					zk._unlistenNode(el, ls);				}			}		}	};	zk._unlistenOne = function () {		if (zk._unltns.length) {			var inf = zk._unltns.shift();			zk._unlistenNode(inf[0], inf[1]);		}	};	zk._unlistenNode = function (el, ls) {		for (var evtnm in ls) {			var fns = ls[evtnm];			delete ls[evtnm];			for (var j = fns.length; --j >= 0;) {				try {					zk._unlisten(el, evtnm, fns[j]);					fns[j] = null; //just in case				} catch (e) { //ignore				}			}			fns.length = 0; //just in case		}	};} else {	/** No function if not IE. */	zk.unlistenAll = zk.voidf;}/** disable ESC to prevent user from pressing ESC to stop loading */zk.disableESC = function () {	if (!zk._noESC) {		zk._noESC = function (evt) {			if (!evt) evt = window.event;			if (evt.keyCode == 27) {				if (evt.preventDefault) {					evt.preventDefault();					evt.stopPropagation();				} else {					evt.returnValue = false;					evt.cancelBubble = true;				}				return false;//eat			}			return true;		};		zk.listen(document, "keydown", zk._noESC);		//FUTURE: onerror not working in Safari and Opera		//if error occurs, loading will be never ended, so try to ignore		//we cannot use zk.listen. reason: no way to get back msg...(FF)		zk._oldOnErr = window.onerror;		zk._onErrChanged = true;		window.onerror =	function (msg, url, lineno) {		//We display errors only for local class web resource		//It is annoying to show error if google analytics's js not found		if (url.indexOf(location.host) >= 0) {			var v = zk_action.lastIndexOf(';');			var v = v >= 0 ? zk_action.substring(0, v): zk_action;			if (url.indexOf(v + "/web/") >= 0) {				msg = mesg.FAILED_TO_LOAD + url + "\n" + mesg.FAILED_TO_LOAD_DETAIL					+ "\n" + mesg.CAUSE + msg+" (line "+lineno + ")";				if (zk.error) zk.error(msg);				else alert(msg);				return true;			}		}	};	}};zk.disableESC(); //disable it as soon as possible/** Enables ESC to back to the normal mode. */zk.enableESC = function () {	if (zk._noESC) {		zk.unlisten(document, "keydown", zk._noESC);		delete zk._noESC;	}	if (zk._onErrChanged) {		window.onerror = zk._oldOnErr;		if (zk._oldOnErr) delete zk._oldOnErr;		delete zk._onErrChanged;	}};//////////////////////////////////////zk.mods = {}; //ZkFns depends on it/** Returns the current time (new Date().getTime()) (since 01/01/1970). * @since 3.0.0 */function $now() {	return new Date().getTime();}/** Note: it is easy to cause problem with EMBED, if we use prototype's $() since * it tried to extend the element. */function $e(id) {	return typeof id == 'string' ? id ? document.getElementById(id): null: id;		//strange but getElementById("") fails in IE7}/** A control might be enclosed by other tag while event is sent from * the control directly, so... */function $uuid(n) {	if (typeof n != 'string') {		for (; n; n = $parent(n))			if (n.id) {				n = n.id;				break;			}	}	if (!n) return "";	var j = n.lastIndexOf('!');	return j > 0 ? n.substring(0, j): n;}/** Returns the real element (ends with !real). * If a component's attributes are located in the inner tag, i.e., * you have to surround it with span or other tag, you have to place * uuid!real on the inner tag * * Note: !chdextr is put by the parent as the exterior of its children, * while !real is by the component itself */function $real(cmp) {	var id = $uuid(cmp);	if (id) {		var n = $e(id + "!real");		if (n) return n;		n = $e(id);		if (n) return n;	}	return cmp;}/** Returns the enclosing element (not ends with !real). * If not found, cmp is returned. */function $outer(cmp) {	var id = $uuid(cmp);	if (id) {		var n = $e(id);		if (n) return n;	}	return cmp;}/** Returns the type of a node without module. */function $type(n) {	var type = getZKAttr(n, "type");	if (type) {		var j = type.lastIndexOf('.');		return j >= 0 ? type.substring(j + 1): type;	}	return null;};/** Returns the peer (xxx!real => xxx, xxx => xxx!real), or null if n/a. *//*function $peer(id) {	return id ? $e(		id.endsWith("!real") ? id.substring(0, id.length-5): id+"!real"): null;}*//** Returns the exterior of the specified component (ends with !chdextr). * Some components, hbox nad vbox, need to add exterior to child compoents, * and the exterior is named with "uuid!chdextr". */function $childExterior(cmp) {	var n = $e(cmp.id + "!chdextr");	return n ? n: cmp;}/** Returns the parent node of the specified element. * It handles virtual parent. */function $parent(n) {	var p = zk._vpts[n.id];	return p ? p: n.parentNode;}/** Sets virtual parent. It is used if a popup is limited (cropped) by a parent div. * @since 3.0.0 */zk.setVParent = function (n) {	var id = n.id, p = n.parentNode;	if (!id) {		zk.error("id required, "+n);		return;	}	if (zk.isVParent(id))		return; //called twice	var sib = n.nextSibling;	if (sib) {		var agtx = document.createElement("SPAN");		agtx.id = id + "!agtx";		agtx.style.display = "none";		p.insertBefore(agtx, sib);	}	zk._vpts[id] = p;	if (!getZKAttr(n, "dtid")) setZKAttr(n, "dtid", zkau.dtid(n));	document.body.appendChild(n);};/** * Returns whether the element has a virtual parent. * @since 3.0.0 * @param {Object} or {String} n */zk.isVParent = function (n) {	return zk._vpts[n && n.id ? n.id: n];};/** Unsets virtual parent. * @since 3.0.0 */zk.unsetVParent = function (n) {	var id = n.id, p = zk._vpts[id];	delete zk._vpts[id];	if (p) {		var sib = $e(id + "!agtx");		if (sib) {			p.insertBefore(n, sib);			zk.remove(sib);		} else			p.appendChild(n);	}};/** unsetVParent if it is a child of the specified node, n. * 	Note: including itself. * @since 3.0.0 */zk.unsetChildVParent = function (n) {	var bo = [];	for (var id in zk._vpts)		if (zk.isAncestor(n, id))			bo.push(id);	for (var j = bo.length; --j >= 0;) {		n = $e(bo[j]);		zk.unsetVParent(n);	}	return bo;};//Note: we have to use string to access {}. Otherwise, the behavior is strangezk._vpts = {}; //a map of virtual parent (n.id, n's parent)/** Returns the nearest parent element, including el itself, with the specified type. */function $parentByType(el, type) {	for (; el; el = $parent(el))		if ($type(el) == type)			return el;	return null;};/** Returns the tag name in the upper case. */function $tag(el) {	return el && el.tagName ? el.tagName.toUpperCase(): "";};/** Returns the nearest parent element, including el itself, with the specified tag. */function $parentByTag(el, tagName) {	for (; el; el = $parent(el))		if ($tag(el) == tagName)			return el;	return null;};/** Returns whether an element is visible. * Returns false if none-existence. * Returns true if no style. */function $visible(el) {	return el && (!el.style || el.style.display != "none");}/** Converts to an integer. It handles null and "07" */function $int(v, b) {	return v ? parseInt(v, b || 10): 0;};/** Returns the ZK attribute of the specified name. * Note: the name space of ZK attributes is "http://www.zkoss.org/2005/zk" */function getZKAttr(el, nm) {	//20061120:	//1) getAttributeNS doesn't work properly to retrieve attribute back	//2) setAttribute("z:nm", val) doesn't work in Safari	try {		return el && el.getAttribute ? el.getAttribute("z." + nm): null;	} catch (e) {		return null; //IE6: failed if el is TABLE and attribute not there	}};/** Sets the ZK attribute of the specified name with the specified value. */function setZKAttr(el, nm, val) {	if (el && el.setAttribute) el.setAttribute("z." + nm, val);};function rmZKAttr(el, nm) {	if (el && el.removeAttribute) el.removeAttribute("z." + nm);	else setZKAttr(el, nm, "");};/** Returns the version of the specified module name. */

⌨️ 快捷键说明

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