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

📄 au.js

📁 ZK 基础介绍 功能操作 模块 结合数据库操作
💻 JS
📖 第 1 页 / 共 4 页
字号:
							//skip to the first ID if timeout						zkau._doQueResps();					}				}, 3600);				break; //wait for timeout, or arrival of another response			}		} catch (e) {			if (!ex) ex = e;		}		if (!ex && ++j > 300) {			setTimeout(zkau._doQueResps, 0); //let browser breath			return;		}	}	if (zkau._checkProgress())		zkau.doneTime = $now();	if (ex) throw ex;};/** Process the specified response in XML. */zkau._doResps = function (cmds) {	while (cmds && cmds.length) {		if (zk.loading)			return false;		var cmd = cmds.shift();		try {			zkau.process(cmd.cmd, cmd.datanum,				cmd.dt0, cmd.dt1, cmd.dt2, cmd.dt3, cmd.dt4);		} catch (e) {			zk.error(mesg.FAILED_TO_PROCESS+cmd.cmd+"\n"+e.message+"\n"+cmd.dt0+"\n"+cmd.dt1);			throw e;		} finally {			zkau._evalOnResponse();		}	}	return true;};/** Process a command. */zkau.process = function (cmd, datanum, dt0, dt1, dt2, dt3, dt4) {	//I. process commands that dt0 is not UUID	var fn = zkau.cmd0[cmd];	if (fn) {		fn.call(zkau, dt0, dt1, dt2, dt3, dt4);		return;	}	//I. process commands that require uuid	var uuid = dt0;	if (!uuid) {		zk.error(mesg.ILLEGAL_RESPONSE+"uuid is required for "+cmd);		return;	}	var cmp = $e(uuid);	fn = zkau.cmd1[cmd];	if (fn) {//		zk.debug("cmd: "+cmd+", "+uuid+", "+dt1+", "+dt2);		fn.call(zkau, uuid, cmp, dt1, dt2, dt3, dt4);		return;	}	zk.error(mesg.ILLEGAL_RESPONSE+"Unknown command: "+cmd);};zk.process = zkau.process; //ZK assumes zk.process, so change it/** Cleans up if we detect obsolete or other severe errors. */zkau._cleanupOnFatal = function (ignorable) {	for (var uuid in zkau._metas) {		var meta = zkau._metas[uuid];		if (meta && meta.cleanupOnFatal)			meta.cleanupOnFatal(ignorable);	}};/** Invoke zk.initAt for siblings. Note: from and to are excluded. */zkau._initSibs = function (from, to, next) {	for (;;) {		from = next ? from.nextSibling: from.previousSibling;		if (!from || from == to) break;		zk.initAt(from);	}};/** Invoke zk.initAt for all children. Note: to is excluded. */zkau._initChildren = function (n, to) {	for (n = n.firstChild; n && n != to; n = n.nextSibling)		zk.initAt(n);};/** Invoke inserHTMLBeforeEnd and then zk.initAt. */zkau._insertAndInitBeforeEnd = function (n, html) {	if ($tag(n) == "TABLE" && zk.tagOfHtml(html) == "TR") {		if (!n.tBodies || !n.tBodies.length) {			var m = document.createElement("TBODY");			n.appendChild(m);			n = m;		} else {			n = n.tBodies[0];		}	}	var lc = n.lastChild;	zk.insertHTMLBeforeEnd(n, html);			if (lc) zkau._initSibs(lc, null, true);	else zkau._initChildren(n);};/** Sets an attribute (the default one). */zkau.setAttr = function (cmp, name, value) {	cmp = zkau._attr(cmp, name);	if ("visibility" == name) {		zk.show(cmp, "true" == value);	} else if ("value" == name) {		if (value != cmp.value) {			cmp.value = value;			if (cmp == zkau.currentFocus && cmp.select) cmp.select();				//fix a IE bug that cursor disappear if input being				//changed is onfocus		}		if (cmp.defaultValue != cmp.value)			cmp.defaultValue = cmp.value;	} else if ("checked" == name) {		value = "true" == value || "checked" == value;		if (value != cmp.checked)			cmp.checked = value;		if (cmp.defaultChecked != cmp.checked)			cmp.defaultChecked = cmp.checked;		//we have to update defaultChecked because click a radio		//might cause another to unchecked, but browser doesn't		//maintain defaultChecked	} else if ("selectAll" == name && $tag(cmp) == "SELECT") {		value = "true" == value;		for (var j = 0; j < cmp.options.length; ++j)			cmp.options[j].selected = value;	} else if ("style" == name) {		zk.setStyle(cmp, value);	} else if (name.startsWith("z.")) { //ZK attributes		setZKAttr(cmp, name.substring(2), value);	} else {		var j = name.indexOf('.'); 		if (j >= 0) {			if ("style" != name.substring(0, j)) {				zk.error(mesg.UNSUPPORTED+name);				return;			}			name = name.substring(j + 1).camelize();			if (typeof(cmp.style[name]) == "boolean") //just in case				value = "true" == value || name == value;			cmp.style[name] = value;			if ("width" == name && (!value || value.indexOf('%') < 0) //don't handle width with %			&& "true" != getZKAttr(cmp, "float")) {				var ext = $e(cmp.id + "!chdextr");				if (ext && $tag(ext) == "TD" && ext.colSpan == 1)					ext.style.width = value;			}			return;		}		if (name == "disabled" || name == "href")			zkau.setStamp(cmp, name);			//mark when this attribute is set (change or not), so			//modal dialog and other know how to process it			//--			//Better to call setStamp always but, to save memory,...		//Firefox cannot handle many properties well with getAttribute/setAttribute,		//such as selectedIndex, scrollTop...		var old = "class" == name ? cmp.className:			"selectedIndex" == name ? cmp.selectedIndex:			"disabled" == name ? cmp.disabled:			"readOnly" == name ? cmp.readOnly:			"scrollTop" == name ? cmp.scrollTop:			"scrollLeft" == name ? cmp.scrollLeft:				cmp.getAttribute(name);		//Note: "true" != true (but "123" = 123)		//so we have take care of boolean		if (typeof(old) == "boolean")			value = "true" == value || name == value; //e.g, reaonly="readOnly"		if (old != value) {			if ("selectedIndex" == name) cmp.selectedIndex = value;			else if ("class" == name) cmp.className = value;			else if ("disabled" == name) cmp.disabled = value;			else if ("readOnly" == name) cmp.readOnly = value;			else if ("scrollTop" == name) cmp.scrollTop = value;			else if ("scrollLeft" == name) cmp.scrollLeft = value;			else cmp.setAttribute(name, value);		}	}};zkau._attr = function (cmp, name) {	var real = $real(cmp);	if (real != cmp && real) {		if (name.startsWith("on")) return real;			//Client-side-action must be done at the inner tag		switch ($tag(real)) {		case "INPUT":		case "TEXTAREA":			switch(name) {			case "name": case "value": case "defaultValue":			case "checked": case "defaultChecked":			case "cols": case "size": case "maxlength":			case "type": case "disabled": case "readOnly":			case "rows":				return real;			}			break;		case "IMG":			switch (name) {			case "align": case "alt": case "border":			case "hspace": case "vspace": case "src":				return real;			}		}	}	return cmp;};/** Returns the time stamp. */zkau.getStamp = function (cmp, name) {	var stamp = getZKAttr(cmp, "stm" + name);	return stamp ? stamp: "";};/** Sets the time stamp. */zkau.setStamp = function (cmp, name) {	setZKAttr(cmp, "stm" + name, "" + ++zkau._stamp);};zkau.rmAttr = function (cmp, name) {	cmp = zkau._attr(cmp, name);	if ("class" == name) {		if (cmp.className) cmp.className = "";	} else if (name.startsWith("z.")) { //ZK attributes		rmZKAttr(cmp, name.substring(2));		return;	} else {		var j = name.indexOf('.'); 		if (j >= 0) {			if ("style" != name.substring(0, j)) {				zk.error(mesg.UNSUPPORTED+name);				return;			}			cmp.style[name.substring(j + 1)] = "";		} else if (!cmp.hasAttriute || cmp.hasAttribute(name)) {			cmp.setAttribute(name, "");		}	}};/** Corrects zIndex of the specified component, which must be absolute. * @param silent whether to send onZIndex * @param autoz whether to adjust zIndex only if necessary. * If false (used when creating a window), it always increases zIndex */zkau.fixZIndex = function (cmp, silent, autoz) {	if (!zkau._popups.length && !zkau._overlaps.length && !zkau._modals.length)		zkau.topZIndex = 12; //reset it!	var zi = $int(cmp.style.zIndex);	if (zi > zkau.topZIndex) {		zkau.topZIndex = zi;	} else if (!autoz || zi < zkau.topZIndex) {		cmp.style.zIndex = ++zkau.topZIndex;		if (!silent && cmp.id) {			cmp = $outer(cmp);			zkau.sendOnZIndex(cmp);		}	}};/** Automatically adjust z-index if node is part of popup/overalp/... */zkau.autoZIndex = function (node) {	for (; node; node = $parent(node)) {		if (node.style && node.style.position == "absolute") {			if (getZKAttr(node, "autoz"))				zkau.fixZIndex(node, false, true); //don't inc if equals			break;		}	}};//-- popup --//if (!zkau._popups) {	zkau._popups = []; //uuid	zkau._overlaps = []; //uuid	zkau._modals = []; //uuid (used zul.js or other modal)}//-- utilities --///** Returns the element of the specified element. * It is the same as Event.elemet(evt), but * it is smart enough to know whether evt is an element. * It is used to make a method able to accept either event or element. */zkau.evtel = function (evtel) {	if (!evtel) evtel = window.event;	else if (evtel.parentNode) return evtel;	return Event.element(evtel);};zkau.onfocus = function (evtel) { //accept both evt and cmp	var el = zkau.evtel(evtel);	zkau.currentFocus = el; //_onDocMousedown doesn't take care all cases	zkau.closeFloatsOnFocus(el);	if (zkau.valid) zkau.valid.uncover(el);	zkau.autoZIndex(el);	var cmp = $outer(el);	if (zkau.asap(cmp, "onFocus"))		zkau.send({uuid: cmp.id, cmd: "onFocus", data: null}, 100);};zkau.onblur = function (evtel) {	var el = zkau.evtel(evtel);	if (el == zkau.currentFocus) zkau.currentFocus = null;		//Note: _onDocMousedown is called before onblur, so we have to		//prevent it from being cleared	var cmp = $outer(el);	if (zkau.asap(cmp, "onBlur"))		zkau.send({uuid: cmp.id, cmd: "onBlur", data: null}, 100);};zkau.onimgover = function (evtel) {	var el = zkau.evtel(evtel);	if (el && el.src.indexOf("-off") >= 0)		el.src = zk.renType(el.src, "on");};zkau.onimgout = function (evtel) {	var el = zkau.evtel(evtel);	if (el && el.src.indexOf("-on") >= 0)		el.src = zk.renType(el.src, "off");};/** Handles window.unload. */zkau._onUnload = function () {	zkau._unloading = true; //to disable error message	if (zk.gecko) zk.restoreDisabled(); //Workaround Nav: Bug 1495382	//20061109: Tom Yeh: Failed to disable Opera's cache, so it's better not	//to remove the desktop. Side effect: BACK to an page, its content might	//not be consistent with server's (due to Opera incapable to restore	//DHTML content 100% correctly)	if (!zk.opera && !zk.keepDesktop) {		var ds = zkau._dtids;		for (var j = 0; j < ds.length; ++j) {			var content = "dtid="+ds[j]+"&cmd.0=rmDesktop";			var req;			if (window.ActiveXObject) { //IE				req = new ActiveXObject("Microsoft.XMLHTTP");			} else if (window.XMLHttpRequest) { //None-IE				req = new XMLHttpRequest();			}			if (req) {				try {					req.open("POST", zk_action, true);					req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");					req.send(content);				} catch (e) { //silent				}			}		}	}	if (zkau._oldUnload) zkau._oldUnload.apply(window, arguments);	zk.unlistenAll();};/** Handles window.onbeforeunload. */zkau._onBfUnload = function () {	if (!zk.skipBfUnload) {		if (zkau.confirmClose)			return zkau.confirmClose;		var s = zk.beforeUnload();		if (s) return s;	}	if (zkau._oldBfUnload)		return zkau._oldBfUnload.apply(window, arguments);	//Return nothing};/** Handle document.onmousedown. */zkau._onDocMousedown = function (evt) {	if (!evt) evt = window.event;	zkau._savepos(evt);	var node = Event.element(evt);	zkau.currentFocus = node;	zkau.closeFloatsOnFocus(node);	zkau.autoZIndex(node);};/** Handles the left click. */zkau._onDocLClick = function (evt) {	if (!evt) evt = window.event;	if (evt.which == 1 || (evt.button == 0 || evt.button == 1)) {		var cmp = Event.element(evt);		cmp = zkau._parentByZKAttr(cmp, "lfclk", "pop");		if (cmp) {			var ctx = getZKAttr(cmp, "pop");			if (ctx) {				ctx = zkau.getByZid(cmp, ctx);				if (ctx) {					var type = $type(ctx);					if (type) {						zkau.closeFloats(ctx, cmp);						ctx.style.position = "absolute";						zk.setVParent(ctx); //FF: Bug 1486840, IE: Bug 1766244						zkau._autopos(ctx, Event.pointerX(evt), Event.pointerY(evt));						zk.eval(ctx, "context", type, cmp);					}				}			}			if (getZKAttr(cmp, "lfclk") && zkau.insamepos(evt))				zkau.send({uuid: $uuid(cmp),					cmd: "onClick", data: zkau._getMouseData(evt, cmp), ctl: true});			//no need to Event.stop		}	}	//don't return anything. Otherwise, it replaces event.returnValue in IE (Bug 1541132)};/** Saves the mouse position to be used with insamepos. */zkau._savepos = function (evt) {	if (evt)		zkau._mspos = [Event.pointerX(evt), Event.pointerY(evt), Event.element(evt)];};/** Checks whether the position of the specified event is the same the one * stored with zkau._savepos. * Note: if the target element is different, it is considered as IN THE SAME POSITION. */zkau.insamepos = function (evt) {	if (!evt || !zkau._mspos) return true; //yes, true	if (Event.element(evt) != zkau._mspos[2]) return true; //yes, true	var x = Event.pointerX(evt) - zkau._mspos[0];	var y = Event.pointerY(evt) - zkau._mspos[1];	return x > -3 && x < 3 && y > -3 && y < 3;};/** Autoposition by the specified (x, y). */zkau._autopos = function (el, x, y) {	var ofs = zk.getDimension(el);	var wd = ofs[0], hgh = ofs[1];	var scx = zk.innerX(), scy = zk.innerY(),		scmaxx = scx + zk.innerWidth(), scmaxy = scy + zk.innerHeight();	if (x + wd > scmaxx) {		x = scmaxx - wd;		if (x < scx) x = scx;	}	if (y + hgh > scmaxy) {		y = scmaxy - hgh;		if (y < scy) y = scy;	}	ofs = zk.toStyleOffset(el, x, y);	el.style.left = ofs[0] + "px";	el.style.top = ofs[1] + "px";};/** Handles the double click. */zkau._onDocDClick = function (evt) {	if (!evt) evt = window.event;	var cmp = Event.element(evt);	cmp = zkau._parentByZKAttr(cmp, "dbclk");	if (cmp/* no need since browser handles it: && zkau.insamepos(evt)*/) {		var uuid = getZKAttr(cmp, "item"); //treerow (and other transparent)		if (!uuid) uuid = $uuid(cmp);		zkau.send({uuid: uuid,			cmd: "onDoubleClick", data: zkau._getMouseData(evt, cmp), ctl: true});		//no need to Event.stop	}};/** Handles the right click (context menu). */zkau._onDocCtxMnu = function (evt) {	if (!evt) evt = window.event;	var target = Event.element(evt);	var cmp = zkau._parentByZKAttr(target, "ctx", "rtclk");	if (cmp) {		var ctx = getZKAttr(cmp, "ctx");		var rtclk = getZKAttr(cmp, "rtclk");		if (ctx || rtclk) {

⌨️ 快捷键说明

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