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

📄 boot.js

📁 ZK 基础介绍 功能操作 模块 结合数据库操作
💻 JS
📖 第 1 页 / 共 3 页
字号:
zk.getBuild = function (nm) {	return zk.mods[nm] || zk.build;};/** Adds a function that will be invoked after all components are * initialized. * <p>Note: it is called after all components are initialized. * <p>The function is removed from the list right before invoked, * so it won't be called twice (unless you call zk.addInit again). * @param front whether to add the function to the front of the list * @param unique whether not to add if redundant. If true, fn is added * only if fn was not added before. */zk.addInit = function (fn, front, unique) {	zk._addfn(zk._initfns, fn, front, unique);};/** Adds a function that will be invoked 25 milliseconds, after * all components are initialized. * Like zk.addInit, the function is called after all components are * initialized. However, the function added by addInitLater is invoked * with a timer that is called 25 milliseconds. * Thus, it is designed to add functions that cannot be called * immediately after initialization (zkType.init). * * <p>The function is removed from the list right before invoked, * so it won't be called twice (unless you call zk.addInitLater again). * * @param front whether to add the function to the front of the list * @param unique whether not to add if redundant. If true, fn is added * only if fn was not added before. * @since 3.0.0 */zk.addInitLater = function (fn, front, unique) {	zk._addfn(zk._inLatfns, fn, front, unique);};zk._addfn = function (fns, fn, front, unique) {	if (unique)		for (var j = fns.length; j;)			if (fns[--j] == fn)				return;	if (front) fns.unshift(fn);	else fns.push(fn);};/** Adds a function for module initialization. * It is called after all javascript fies are loaded, and before * initializing the components. * * <p>In other words, ZK invokes functions added by zk.addModuleInit, * then initializes all components, and finally invokes functions added * by zk.addInit. * * <p>The function is removed from the list right before invoked, * so it won't be called twice (unless you call zk.addModuleInit again). */zk.addModuleInit = function (fn) {	zk._initmods.push(fn);};/** Adds a component that must be initialized after * all modules are loaded and initialized. */zk.addInitCmp = function (cmp) {	zk._initcmps.push(cmp);};/** Adds a function that will be invoked after all components are * cleaned up. * Unlike zk.addCleanupLater, the components being cleaned up are * still available when fn is called. * <p>Note: it is called after all components are initialized. * <p>The function is removed from the list right before invoked, * so it won't be called twice (unless you call zk.addInit again). * @param front whether to add the function to the front of the list * @param unique whether not to add if redundant. If true, fn is added * only if fn was not added before. */zk.addCleanup = function (fn, front, unique) {	zk._addfn(zk._cufns, fn, front, unique);};/** Adds a function that will be invoked 25 milliseconds, after * all components are cleaned up. * Note: when fn is called, the component being cleaned up may be removed. * * <p>The function is removed from the list right before invoked, * so it won't be called twice (unless you call zk.addInitLater again). * * @param front whether to add the function to the front of the list * @param unique whether not to add if redundant. If true, fn is added * only if fn was not added before. * @since 3.0.0 */zk.addCleanupLater = function (fn, front, unique) {	zk._addfn(zk._cuLatfns, fn, front, unique);};/** Adds a function that will be invoked when the browser is resized * (window's resize). * <p>Unlike zk.addInit, the function won't be detached after invoked. * * @param front whether to add the function to the front of the list * @param unique whether not to add if redundant. If true, fn is added * only if fn was not added before. * @since 3.0.0 */zk.addOnResize = function (fn, front, unique) {	zk._addfn(zk._reszfns, fn, front, unique);};/** Removes a function that was added by calling zk.addOnResize. * @since 3.0.0 */zk.rmOnResize = function (fn) {	zk._reszfns.remove(fn);};/** Invokes all functions added by zk.addOnResize. * @since 3.0.0 */zk.onResize = function (timeout) {	//Tom Yeh: 20051230:	//In certain case, IE will keep sending onresize (because	//grid/listbox may adjust size, which causes IE to send onresize again)	//To avoid this endless loop, we ignore onresize a whilf if _reszfn	//is called	if (!zk._tmResz || $now() > zk._tmResz) {		++zk._reszcnt;		setTimeout(zk._onResize,			timeout ? timeout: zk.ie && zk._reszcnt < 4 ? 200: 35);			//IE: we have to prolong since onresize might come too fast			//It is an experimental value. Not sure the real cause.	} else {		setTimeout(zk.onResize, 100);	}};zk._onResize = function () {	if (--zk._reszcnt == 0) {		if (zk.loading)			return zk.onResize();		if (zk.ie) zk._tmResz = $now() + 800;		for (var j = 0; j < zk._reszfns.length; ++j)			zk._reszfns[j]();	}};/** Adds a function that will be invoked before the browser is unloading * the page. * If the function returns a string, then the whole execution will stop * and the string is returned to browser (to warning the user). * If nothing is returned, the following functions will be invoked. * * @param front whether to add the function to the front of the list * @since 3.0.0 */zk.addBeforeUnload = function (fn, front) {	if (front) zk._bfunld.unshift(fn);	else zk._bfunld.push(fn);};/** Removes the function added by zk.addBeforeUnload. * @since 3.0.0 */zk.rmBeforeUnload = function (fn) {	zk._bfunld.remove(fn);};/** Called when window.onbeforeunload is called. * Note: you rarely need to invoke this directly (except au.js). * @since 3.0.0 */zk.beforeUnload = function () {	for (var j = 0; j < zk._bfunld.length; ++j) {		var s = zk._bfunld[j]();		if (s) return s;	}};/** Invokes the specified function that depends on the specified module. * If the module is not loaded yet, it will be loaded first. * If it is loaded, the function executes directly. * @since 3.0.0 */zk.invoke = function (nm, fn) {	if (!zk._modules[nm]) zk.load(nm, fn);	else if (zk.loading) zk.addModuleInit(fn);	else fn();};/** Loads the specified module (JS). If a feature is called "a.b.c", then * zk_action + "/web/js" + "a/b/c.js" is loaded. * * <p>To load a JS file that other modules don't depend on, use zk.loadJS. * * @param nm the module name if no / is specified, or filename if / is * specified, or URL if :// is specified. * @param initfn the function that will be added to zk.addModuleInit * @param ckfn used ONLY if URL (i.e., xxx://) is used as nm, * and the file being loaded doesn't invoke zk.ald(). * @param modver the version of the module, or null to use zk.getBuild(nm) */zk.load = function (nm, initfn, ckfn, modver) {	if (!nm) {		zk.error("Module name must be specified");		return;	}	if (!zk._modules[nm]) {		zk._modules[nm] = true;		if (initfn) zk.addModuleInit(initfn);		zk._load(nm, modver);		if (ckfn) zk._ckfns.push(ckfn);	}};/** Loads the required module for the specified component. * Note: it DOES NOT check any of its children. * @return true if z.type is defined. */zk.loadByType = function (n) {	var type = getZKAttr(n, "type");	if (type) {		var j = type.lastIndexOf('.');		if (j > 0) zk.load(type.substring(0, j));		return true;	}	return false;}/** Loads the javascript. It invokes _bld before loading. * * <p>The JavaScript file being loaded must<br/> * 1) call zk.ald() after loaded<br/> * 2) pass ckfn to test whether it is loaded. */zk._load = function (nm, modver) {	zk._bld();	var e = document.createElement("script");	e.type = "text/javascript" ;	var zcb;	if (zk.gecko) {		e.onload = zk.ald;		zcb = "";	} else {		zcb = "/_zcbzk.ald";			//Note: we use /_zcb to enforce callback of zk.ald	}	var uri = nm;	if (uri.indexOf("://") > 0) {		e.src = uri;	} else if (uri.indexOf('/') >= 0) {		if (uri.charAt(0) != '/') uri = '/' + uri;		e.charset = "UTF-8";		e.src = zk.getUpdateURI("/web" + zcb + uri, false, modver);	} else { //module name		uri = uri.replace(/\./g, '/');		var j = uri.lastIndexOf('!');		uri = j >= 0 ?			uri.substring(0, j) + ".js." + uri.substring(j + 1):			uri + ".js";		if (uri.charAt(0) != '/') uri = '/' + uri;		e.charset = "UTF-8";		if (!modver) modver = zk.getBuild(nm);		e.src = zk.getUpdateURI("/web" + zcb + "/js" + uri, false, modver);	}	document.getElementsByTagName("HEAD")[0].appendChild(e);		//Bug 1815074: IE bug:		//zk.ald might be called before returning from appendChild};/** before load. */zk._bld = function () {	if (zk.loading ++) {		zk._updCnt();	} else {		zk.disableESC();		zk._ckload = setInterval(function () {			for (var j = 0; j < zk._ckfns.length; ++j)				if (zk._ckfns[j]()) {					zk._ckfns.splice(j--, 1);					zk.ald();				} else return; //wait a while		}, 10);		setTimeout(function () {			if (zk.loading) {				var n = $e("zk_loadprog");				if (!n)					Boot_progressbox("zk_loadprog",						'Loading (<span id="zk_loadcnt">'+zk.loading+'</span>)',						zk.innerX() + 30, zk.innerY() + 50);			}		}, 350);	}};/** after load. */zk.ald = function () {	if (--zk.loading) {		try {			zk._updCnt();		} catch (ex) {			zk.error("Failed to count. "+ex.message);		}	} else {		try {			zk.enableESC();			if (zk._ckload) {				clearInterval(zk._ckload);				delete zk._ckload;			}			var n = $e("zk_loadprog");			if (n) n.parentNode.removeChild(n);		} catch (ex) {			zk.error("Failed to stop counting. "+ex.message);		}				if (zk._ready) zk._evalInit(); //zk._loadAndInit mihgt not finish	}};zk._updCnt = function () {	var n = $e("zk_loadcnt");	if (n) n.innerHTML = "" + zk.loading;};/** Initializes the dom tree. */zk.initAt = function (node) {	if (!node) return;	var stk = [];	stk.push(node);	zk._loadAndInit({stk: stk, nosibling: true});};/** Loads all required module and initializes components. */zk._loadAndInit = function (inf) {	zk._ready = false;	//The algorithm here is to mimic deep-first tree traversal	//We cannot use recursive algorithm because it might take too much time	//to execute and browser will alert users for aborting!	for (var j = 0; inf.stk.length;) {		if (++j > 3000) {			setTimeout(function() {zk._loadAndInit(inf);}, 0);			return; //let browser breath		}		var n = inf.stk.pop();	//FF remembers the previous value that user entered when reload	//We have to reset them because the server doesn't know any of them		if (zk.gecko) {			switch ($tag(n)) {			case "INPUT":				if (n.type == "checkbox" || n.type == "radio") {					if (n.checked != n.defaultChecked)						n.checked = n.defaultChecked;					break;				}				if (n.type != "text" && n.type != "password") break;				//fall thru			case "TEXTAREA":				if (n.value != n.defaultValue				&& n.defaultValue != "zk_wrong!~-.zk_pha!6")					n.value = n.defaultValue;				break;			case "OPTION":				if (n.selected != n.defaultSelected)					n.selected = n.defaultSelected;				//break;			}		} else if (zk.ie) {			switch ($tag(n)) {			case "A":				//Bug 1635685 and 1612312				if (n.href.indexOf("javascript:") >= 0)					zk.listen(n, "click", zk._ieFixBfUnload);				break;			case "FORM":				//Bug 1811352				zk.fixSubmit(n);				//break;			}		}		var v = getZKAttr(n, "dtid");		if (v) zkau.addDesktop(v); //desktop's ID found		if (zk.loadByType(n) || getZKAttr(n, "drag")		|| getZKAttr(n, "drop") || getZKAttr(n, "zid"))			zk._initcmps.push(n);		//if nosibling, don't process its sibling (only process children)		if (inf.nosibling) inf.nosibling = false;		else if (n.nextSibling) inf.stk.push(n.nextSibling);		if (n.firstChild) inf.stk.push(n.firstChild);	}	zk._evalInit();	zk._ready = true;};/** Fix bug 1635685 and 1612312 (IE/IE7 only): * IE invokes onbeforeunload if <a href="javascript;"> is clicked (sometimes) * It actually ignores window.beforeunload temporary by * set zk.skipBfUnload. */if (zk.ie) {	zk._ieFixBfUnload = function () {		zk.skipBfUnload = true;		setTimeout(zk._skipBackBF, 0); //restore	};	zk._skipBackBF = function () {		zk.skipBfUnload = false;	};}/** Initial components and init functions. */zk._evalInit = function () {	do {		while (!zk.loading && zk._initmods.length)			(zk._initmods.shift())();		//Note: if loading, zk._doLoad will execute zk._evalInit after finish		for (var j = 0; zk._initcmps.length && !zk.loading;) {			var n = zk._initcmps.pop(); //reverse-order			var m = zk.eval(n, "init");			if (m) n = m; //it might be transformed			if (getZKAttr(n, "zid")) zkau.initzid(n);			if (getZKAttr(n, "drag")) zkau.initdrag(n);			if (getZKAttr(n, "drop")) zkau.initdrop(n);			var type = $type(n);			if (type) {				var o = window["zk" + type];				if (o) {					if (o["onVisi"]) zk._visicmps[n.id] = true;					if (o["onHide"]) zk._hidecmps[n.id] = true;					if (o["onSize"]) zk._sizecmps[n.id] = true;				}			}			if (++j > 3000 || zk.loading) {				if (!zk.loading)					setTimeout(zk._evalInit, 0); //let browser breath				return;			}		}		while (!zk.loading && zk._initfns.length)			(zk._initfns.shift())();		setTimeout(zk._initLater, 25);	} while (!zk.loading && (zk._initmods.length || zk._initcmps.length

⌨️ 快捷键说明

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