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

📄 boot.js

📁 ZK 基础介绍 功能操作 模块 结合数据库操作
💻 JS
📖 第 1 页 / 共 3 页
字号:
	|| zk._initfns.length));	//Bug 1815074: _initfns might cause _initmods to be added};zk._initLater = function () {	while (!zk.loading && zk._inLatfns.length)		(zk._inLatfns.shift())();};/** Evaluate a method of the specified component. * * It assumes fn is a method name of a object called "zk" + type * (in window). * Nothing happens if no such object or no such method. * * @param n the component * @param fn the method name, e.g., "init" * @param type the component type. If omitted, $type(n) * is assumed. * @param a0 the first of extra arguments; null to omitted * @return the result */zk.eval = function (n, fn, type, a0, a1, a2, a3, a4, a5, a6, a7) {	if (!type) type = $type(n);	if (type) {		var o = window["zk" + type];		if (o) {			var f = o[fn];			if (f) {				try {					return f(n,a0,a1,a2,a3,a4,a5,a6,a7);				} catch (ex) {					zk.error("Failed to invoke zk"+type+"."+fn+"\n"+ex.message);				}			}		}	}	return false;};/** Check z.type and invoke zkxxx.cleanup if declared. */zk.cleanupAt = function (n) {	zk._cleanupAt(n);	while (zk._cufns.length)		(zk._cufns.shift())();	setTimeout(zk._cleanLater, 25);};zk._cleanLater = function () {	while (zk._cuLatfns.length)		(zk._cuLatfns.shift())();};zk._cleanupAt = function (n) {	if (getZKAttr(n, "zid")) zkau.cleanzid(n);	if (getZKAttr(n, "zidsp")) zkau.cleanzidsp(n);	if (getZKAttr(n, "drag")) zkau.cleandrag(n);	if (getZKAttr(n, "drop")) zkau.cleandrop(n);	var type = $type(n);	if (type) {		zk.eval(n, "cleanup", type);		zkau.cleanupMeta(n); //note: it is called only if type is defined		zk.unlistenAll(n); //Bug 1741959: memory leaks		delete zk._visicmps[n.id];		delete zk._hidecmps[n.id];		delete zk._sizecmps[n.id];	}	for (n = n.firstChild; n; n = n.nextSibling)		zk._cleanupAt(n); //recursive for child component};/** To notify a component that it becomes visible because one its ancestors * becomes visible. All descendants of n is invoked if onVisi is declared. */zk.onVisiAt = function (n) {	for (var nid in zk._visicmps) {		var elm = $e(nid);		for (var e = elm; e; e = $parent(e)) {			if (e == n) { //elm is a child of n				zk.eval(elm, "onVisi");				break;			}			if (!$visible(e))				break;		}	}};/** To notify a component that it becomes invisible because one its ancestors * becomes invisible. All descendants of n is invoked if onHide is declared. */zk.onHideAt = function (n) {	//Bug 1526542: we have to blur if we want to hide a focused control in gecko and IE	var f = zkau.currentFocus;	if (f && zk.isAncestor(n, f)) {		zkau.currentFocus = null;		try {f.blur();} catch (e) {}	}	for (var nid in zk._hidecmps) {		var elm = $e(nid);		for (var e = elm; e; e = $parent(e)) {			if (e == n) { //elm is a child of n				zk.eval(elm, "onHide");				break;			}			if (!$visible(e)) //yes, ignore hidden ones				break;		}	}}/** To notify a component that its size is changed. *  All descendants of n is invoked if onSize is declared. * Note: since onSize usually triggers another onSize, it handles them * asynchronously. */zk.onSizeAt = function (n) {	for (var nid in zk._sizecmps) {		var elm = $e(nid);		for (var e = elm; e; e = $parent(e)) {			if (e == n) { //elm is a child of n				if (!zk._tmOnSizeAt)					zk._tmOnSizeAt = setTimeout(zk._onSizeAt, 550);				zk._toOnSize[nid] = true;				break;			}			if (!$visible(e))				break;		}	}};zk._onSizeAt = function () {	delete zk._tmOnSizeAt;	var once;	for (var nid in zk._toOnSize) {		if (once) {			if (!zk._tmOnSizeAt)				zk._tmOnSizeAt = setTimeout(zk._onSizeAt, 0);			break; //only once		}		once = true;		delete zk._toOnSize[nid];		var elm = $e(nid);		if (elm) zk.eval(elm, "onSize");	}};//extra///** Loads the specified style sheet (CSS). * @param uri Example, "/a/b.css". It will be prefixed with zk_action + "/web", * unless http:// or https:// is specified */zk.loadCSS = function (uri) {	var e = document.createElement("LINK");	e.rel = "stylesheet";	e.type = "text/css";	if (uri.indexOf("://") < 0) {		if (uri.charAt(0) != '/') uri = '/' + uri;		uri = zk.getUpdateURI("/web" + uri);	}	e.href = uri;	document.getElementsByTagName("HEAD")[0].appendChild(e);};/** Loads the specified JavaScript file directly. * @param uri Example, "/a/b.css". It will be prefixed with zk_action + "/web", * unless http:// or https:// is specified * @param fn the function to execute after loading. It is optional. * Not function under safari */zk.loadJS = function (uri, fn) {	var e = document.createElement("script");	e.type	= "text/javascript" ;	e.charset = "UTF-8";	if (fn)		e.onload = e.onreadystatechange = function() {			if (!e.readyState || e.readyState == 'loaded') fn();		};	if (uri.indexOf("://") < 0) {		if (uri.charAt(0) != '/') uri = '/' + uri;		uri = zk.getUpdateURI("/web" + uri);	}	e.src = uri;	document.getElementsByTagName("HEAD")[0].appendChild(e);};/** Returns the proper URI. * @param ignoreSessId whether not to append session ID. * @param modver the module version to insert into uri, or null to use zk.build. * Note: modver is used if uri starts with /uri */zk.getUpdateURI = function (uri, ignoreSessId, modver) {	if (!uri) return zk_action;	if (uri.charAt(0) != '/') uri = '/' + uri;	if (modver && uri.length >= 5 && uri.substring(0, 5) == "/web/")		uri = "/web/_zver" + modver + uri.substring(4);	var j = zk_action.lastIndexOf(';'), k = zk_action.lastIndexOf('?');	if (j < 0 && k < 0) return zk_action + uri;	if (k >= 0 && (j < 0 || k < j)) j = k;	var prefix = zk_action.substring(0, j);	if (ignoreSessId)		return prefix + uri;	var suffix = zk_action.substring(j);	var l = uri.indexOf('?');	return l >= 0 ?		k >= 0 ?		  prefix + uri.substring(0, l) + suffix + '&' + uri.substring(l+1):		  prefix + uri.substring(0, l) + suffix + uri.substring(l):		prefix + uri + suffix;};//-- progress --///** Turn on the progressing dialog after the specified timeout. */zk.progress = function (timeout) {	zk.progressing = true;	if (timeout > 0) setTimeout(zk._progress, timeout);	else zk._progress();};zk.progressDone = function() {	zk.progressing = zk.progressPrompted = false;	var n = $e("zk_prog");	if (n) n.parentNode.removeChild(n);};/** Generates the progressing dialog. */zk._progress = function () {	if (zk.progressing) {		var n = $e("zk_prog");		if (!n) {			var msg;			try {msg = mesg.PLEASE_WAIT;} catch (e) {msg = "Processing...";}				//when the first boot, mesg is not ready			Boot_progressbox("zk_prog", msg, zk.innerX(), zk.innerY());			zk.progressPrompted = true;		}	}};//-- utilities --//zk.https = function () {	var p = location.protocol;	return p && "https:" == p.toLowerCase();};/** Returns the x coordination of the visible part. */zk.innerX = function () {    return window.pageXOffset		|| document.documentElement.scrollLeft		|| document.body.scrollLeft || 0;};/** Returns the y coordination of the visible part. */zk.innerY = function () {    return window.pageYOffset		|| document.documentElement.scrollTop		|| document.body.scrollTop || 0;};zk.innerWidth = function () {	return typeof window.innerWidth == "number" ? window.innerWidth:		document.compatMode == "CSS1Compat" ?			document.documentElement.clientWidth: document.body.clientWidth;};zk.innerHeight = function () {	return typeof window.innerHeight == "number" ? window.innerHeight:		document.compatMode == "CSS1Compat" ?			document.documentElement.clientHeight: document.body.clientHeight;};zk.pageWidth = function () {	var a = document.body.scrollWidth, b = document.body.offsetWidth;	return a > b ? a: b;};zk.pageHeight = function () {	var a = document.body.scrollHeight, b = document.body.offsetHeight;	return a > b ? a: b;};zk._setOuterHTML = function (n, html) {	if (n.outerHTML) n.outerHTML = html;	else { //non-IE		var range = document.createRange();		range.setStartBefore(n);		var df = range.createContextualFragment(html);		n.parentNode.replaceChild(df, n);	}};/** Pause milliseconds. */zk.pause = function (millis) {	if (millis) {		var d = $now(), n;		do {			n = $now();		} while (n - d < millis);	}};//-- HTML/XML --//zk.encodeXML = function (txt, multiline) {	var out = "";	if (txt)		for (var j = 0; j < txt.length; ++j) {			var cc = txt.charAt(j);			switch (cc) {			case '<': out += "&lt;"; break;			case '>': out += "&gt;"; break;			case '&': out += "&amp;"; break;			case '"': out += "&quot;"; break;			case '\n':				if (multiline) {					out += "<br/>";					break;				}			default:				out += cc;			}		}	return out};//-- debug --///** Generates a message for debugging. */zk.message = function (msg) {	zk._msg = zk._msg ? zk._msg + msg: msg;	zk._msg +=  '\n';	setTimeout(zk._domsg, 600);		//for better performance and less side effect, execute later};zk._domsg = function () {	if (zk._msg) {		var console = $e("zk_msg");		if (!console) {			console = document.createElement("DIV");			document.body.appendChild(console);			var html = '<div style="border:1px solid #77c">'+'<table cellpadding="0" cellspacing="0" width="100%"><tr>'+'<td width="20pt"><button onclick="zk._msgclose(this)">close</button><br/>'+'<button onclick="$e(\'zk_msg\').value = \'\'">clear</button></td>'+'<td><textarea id="zk_msg" style="width:100%" rows="3"></textarea></td></tr></table></div>';			zk._setOuterHTML(console, html);			console = $e("zk_msg");		}		console.value = console.value + zk._msg + '\n';		zk._msg = null;	}};zk._msgclose = function (n) {	while ((n = n.parentNode) != null)		if ($tag(n) == "DIV") {			n.parentNode.removeChild(n);			return;		}};//FUTURE: developer could control whether to turn on/offzk.debug = zk.message;/** Error message must be a popup. */zk.error = function (msg) {	if (!zk._errcnt) zk._errcnt = 1;	var id = "zk_err_" + zk._errcnt++;	var box = document.createElement("DIV");	document.body.appendChild(box);	var html = '<div style="position:absolute;z-index:99000;padding:3px;left:'+(zk.innerX()+50)+'px;top:'+(zk.innerY()+20)+'px;width:550px;border:1px solid #963;background-color:#fc9" id="'+id+'"><table cellpadding="2" cellspacing="2" width="100%"><tr valign="top">'+'<td width="20pt"><button onclick="zk._msgclose(this)">close</button></td>'+'<td style="border:1px inset">'+zk.encodeXML(msg, true) //Bug 1463668: security+'</td></tr></table></div>';	zk._setOuterHTML(box, html);	box = $e(id); //we have to retrieve back	try {		new Draggable(box, {			handle: box, zindex: box.style.zIndex,			starteffect: zk.voidf, starteffect: zk.voidf, endeffect: zk.voidf});	} catch (e) {	}};//-- bootstrapping --//zk.loading = 0;zk._modules = {}; //Map(String nm, boolean loaded)zk._initfns = []; //used by addInitzk._inLatfns = []; //used by addInitLaterzk._initmods = []; //used by addModuleInitzk._cufns = []; //used by addCleanupzk._cuLatfns = []; //used by addCleanupLaterzk._reszfns = []; //used by addOnResizezk._reszcnt = 0; //# of pending zk.onResizezk._bfunld = []; //used by addBeforeUnloadzk._initcmps = []; //comps to initzk._ckfns = []; //functions called to check whether a module is loaded (zk._load)zk._visicmps = {}; //a set of component's ID that requires zkType.onVisizk._hidecmps = {}; //a set of component's ID that requires zkType.onHidezk._sizecmps = {}; //a set of component's ID that requires zkType.onSizezk._toOnSize = {}; //a set of component's waiting to execute onSizefunction myload() {	var f = zk._onload;	if (f) {		zk._onload = null; //called only once		f();	}}zk._onload = function () {	//It is possible to move javascript defined in zul's language.xml	//However, IE has bug to order JavaScript properly if zk._load is used	zk.progress(600);	zk.addInit(zk.progressDone);	zk.initAt(document.body);};//Source: http://dean.edwards.name/weblog/2006/06/again/if (zk.ie && !zk.https()) {	//IE consider the following <script> insecure, so skip is https	document.write('<script id="_zie_load" defer src="javascript:void(0)"><\/script>');	var e = $e("_zie_load");	e.onreadystatechange = function() {		if ("complete" == this.readyState) //don't check loaded!	        myload(); // call the onload handler	};	e.onreadystatechange();} else if (zk.safari) {    var timer = setInterval(function() {		if (/loaded|complete/.test(document.readyState)) {			clearInterval(timer);			delete timer;			myload();		}	}, 10);} else {	//Bug 1619959: FF not always fire DOMContentLoaded (such as in 2nd iframe),	//so we have to use onload in addition to register DOMContentLoaded	if (zk.gecko)		zk.listen(document, "DOMContentLoaded", myload)	zk._oldOnload = window.onload;	window.onload = function () {		myload();		if (zk._oldOnload)			zk._oldOnload.apply(window, arguments);	}}} //if (!window.zk)

⌨️ 快捷键说明

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