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

📄 common.js

📁 ZK 基础介绍 功能操作 模块 结合数据库操作
💻 JS
📖 第 1 页 / 共 4 页
字号:
				else txt += zk.formatFixed(val.getFullYear(), len);				break;			case 'M':				if (len <= 2) txt += zk.formatFixed(val.getMonth()+1, len);				else if (len == 3) txt += zk.SMON[val.getMonth()];				else txt += zk.FMON[val.getMonth()];				break;			case 'd':				txt += zk.formatFixed(val.getDate(), len);				break;			default://case 'E':				if (len <= 3) txt += zk.SDOW[val.getDay()];				else txt += zk.FDOW[val.getDay()];			}			j = k - 1;		} else {			txt += cc;		}	}	return txt;};/** Returns an integer of the attribute of the specified element. */zk.getIntAttr = function (el, nm) {	return $int(el.getAttribute(nm));};//selection//zk.clearSelection = function(){	try{		if(window["getSelection"]){ 			if(zk.safari){				window.getSelection().collapse();			}else{				window.getSelection().removeAllRanges();			}		}else if(document.selection){			if(document.selection.empty){				document.selection.empty();			}else if(document.selection.clear){				document.selection.clear();			}		}		return true;	} catch (e){		return false;	}}/** Disable whether the specified element is selectable. */zk.disableSelection = function (el) {	el = $e(el);	if (el)		if (zk.gecko)			el.style.MozUserSelect = "none";		else if (zk.safari)			el.style.KhtmlUserSelect = "none"; 		else if (zk.ie)			el.onselectstart = function () {return false;};};/** Enables whether the specified element is selectable. */zk.enableSelection = function (el) {	el = $e(el);	if (el)		if (zk.gecko)			el.style.MozUserSelect = ""; 		else if (zk.safari)			el.style.KhtmlUserSelect = "";		else if (zk.ie)			el.onselectstart = null;};/** Clears selection, if any. */zk.clearSelection = function (){	try {		if (window["getSelection"]){ 			if (zk.safari) window.getSelection().collapse();			else window.getSelection().removeAllRanges();		} else if (document.selection){			if (document.selection.empty) document.selection.empty();			else if(document.selection.clear) document.selection.clear();		}	} catch (e){ //ignore	}}/*Float: used to be added to zkau.floats * Derives must provide an implementation of _close(el). */zk.Float = Class.create();zk.Float.prototype = {	initialize: function () {	},	/** Closes this float if the specified ID is matched.	 * @return whether it is closed	 */	close: function (id) {		if (this._ftid == id)			this.closeFloats();	},	/** Closes (hides) all floats.	 * @param arguments a list of components that shall be closed	 */	closeFloats: function () {		return this._closeFloats(false, arguments);	},	/** Closes all floats when a component is getting the focus.	 * @param arguments a list of components that shall be closed	 */	closeFloatsOnFocus: function () {		return this._closeFloats(true, arguments);	},	_closeFloats: function (onfocus, ancestors) {		if (this._ftid) {			var n = $e(this._ftid);			if ($visible(n)			&& getZKAttr(n, "animating") != "hide"			&& (!onfocus || !zk.isAncestorX(n, ancestors, true))) {				this._close(n);				this._ftid = null;				return true;			}		}		return false;	},	/** Adds elements that we have to hide what they covers.	 */	addHideCovered: function (ary) {		if (this._ftid) {			var el = $e(this._ftid);			if (el) ary.push(el);		}	},//zk.Float doesn't support asPopup. Reason: if asPopup is true, there must//be multiple floats, i.e., zk.Floats shall be used instead	/** Sets the popup ID.	 */	setFloatId: function (id) {		this._ftid = id;	}};/*Floats: used to be added to zkau.floats * Derives must provide an implementation of _close(el). */zk.Floats = Class.create();zk.Floats.prototype = {	initialize: function () {		this._ftids = [];		this._aspps = {}; //(id, whether a float behaves like a popup)	},	/** Closes this float if the specified ID is matched.	 * @return whether it is closed	 */	close: function (id) {		for (var j = this._ftids.length; j;)			if (this._ftids[--j] == id) {				this.closeFloats();				return true;			}		return false;	},	/** Closes (hides) all floats.	 * @param arguments a list of components that shall be closed	 */	closeFloats: function () {		return this._closeFloats(false, arguments);	},	/** Closes all floats when a component is getting the focus.	 * @param arguments a list of components that shall be closed	 */	closeFloatsOnFocus: function () {		return this._closeFloats(true, arguments);	},	_closeFloats: function (onfocus, ancestors) {		var closed;		for (var j = this._ftids.length; --j >= 0;) {			var id = this._ftids[j];			var n = $e(id);			if ($visible(n)			&& getZKAttr(n, "animating") != "hide"			&& ((!onfocus && !this._aspps[id]) || !zk.isAncestorX(n, ancestors, true))) {				this._ftids.splice(j, 1);				this._close(n);				closed = true;			}		}		return closed;	},	/** Adds elements that we have to hide what they covers.	 */	addHideCovered: function (ary) {		for (var j = 0; j < this._ftids.length; ++j) {			var el = $e(this._ftids[j]);			if (el) ary.push(el);		}	},	getFloatIds: function () {		return this._ftids;	},	/** Adds the float ID.	 *	 * @param asPopup whether the float behaves like a popup window	 * (i.e., it remains open if closeFloats is called due to	 * the activities of its child),	 * Otherwise, the float is always closed when closeFloats is called.	 */	addFloatId: function (id, asPopup) {		this._ftids.push(id);		if (asPopup) this._aspps[id] = true;	},	removeFloatId: function (id) {		this._ftids.remove(id);		delete this._aspps[id];	}};//Histroy//zk.History = Class.create();zk.History.prototype = {	initialize: function () {		this.curbk = "";		setInterval("zkau.history.checkBookmark()", 520);			//Though IE use history.html, timer is still required 			//because user might specify URL directly	},	/** Sets a bookmark that user can use forward and back buttons */	bookmark: function (nm) {		if (this.curbk != nm) {			this.curbk = nm; //to avoid loop back the server			var encnm = encodeURIComponent(nm);			window.location.hash = zk.safari ? encnm: '#' + encnm;			if (zk.ie /*|| zk.safari*/) this.bkIframe(nm);		}	},	/** Checks whether the bookmark is changed. */	checkBookmark: function() {		var nm = this.getBookmark();		if (nm != this.curbk) {			this.curbk = nm;			zkau.send({uuid: '', cmd: "onBookmarkChanged", data: [nm]}, 50);		}	},	getBookmark: function () {		var nm = window.location.hash;		var j = nm.indexOf('#');		return j >= 0 ? decodeURIComponent(nm.substring(j + 1)): '';	}};if (zk.ie /*|| zk.safari*/) {	/** bookmark iframe */	zk.History.prototype.bkIframe = function (nm) {		var url = zk.getUpdateURI("/web/js/zk/html/history.html", true);		if (nm) url += '?' +encodeURIComponent(nm);		var ifr = $e('zk_histy');		if (ifr) {			ifr.src = url;		} else {			zk.newFrame('zk_histy', url,				/*zk.safari ? "width:0;height:0;display:inline":*/ "display:none");		}	};	/** called when history.html is loaded*/	zk.History.prototype.onHistoryLoaded = function (src) {		var j = src.indexOf('?');		var nm = j >= 0 ? src.substring(j + 1): '';		window.location.hash = nm ? /*zk.safari ? nm:*/ '#' + nm: '';		this.checkBookmark();	};}/** Removes a node. */zk.remove = function (n) {	if (n) Element.remove(n);};//////show & hide/** The lowest level to make a component visible/invisible. * CSA shall not call this method. */zk.show = function (id, bShow) {	if (bShow == false) {		zk.hide(id);		return;	}	var n = $e(id);	if (n) {		var js = getZKAttr(n, "conshow");		if (js) {			rmZKAttr(n, "conshow"); //avoid dead loop			try {				eval(js);			} finally {				setZKAttr(n, "conshow", js);			}		} else {			action.show(n);		}	}};/** The lowest level to make a component invisible/visible. * CSA shall not call this method. */zk.hide = function (id, bHide) {	if (bHide == false) {		zk.show(id);		return;	}	var n = $e(id);	if (n) {		var js = getZKAttr(n, "conhide");		if (js) {			rmZKAttr(n, "conhide"); //avoid dead loop			try {				eval(js);			} finally {				setZKAttr(n, "conhide", js);			}		} else {			action.hide(n);		}	}};/** Shows the exterior. */zk._showExtr = function (n) {	if ("true" != getZKAttr(n, "float")) {		var ext = $e(n.id + "!chdextr");		if (ext && "true" == getZKAttr(ext, "coexist")) {			ext.style.display = "";			ext = $e(n.id + "!chdextr2"); //hbox/vbox			if (ext) ext.style.display = "";		}	}};/** Hides the exterior. */zk._hideExtr = function (n) {	if ("true" != getZKAttr(n, "float")) {		var ext = $e(n.id + "!chdextr");		if (ext && "true" == getZKAttr(ext, "coexist")) {			ext.style.display = "none";			ext = $e(n.id + "!chdextr2"); //hbox/vbox			if (ext) ext.style.display = "none";		}	}};///////////////// ACTION ////** Basic utilities for Client Side Action. */action = {};/** Makes a component visible. */action.show = function (id) {	var n = $e(id);	if (n)		if (getZKAttr(n, "animating")) {			zk._addAnique(n.id, "zk.show");		} else {			zk._showExtr(n);  //parent visible first			n.style.display = "";			zk.onVisiAt(n); //callback later		}};/** Makes a component invisible. */action.hide = function (id) {	var n = $e(id);	if (n)		if (getZKAttr(n, "animating")) {			zk._addAnique(n.id, "zk.hide");		} else {			zk.onHideAt(n); //callback first			n.style.display = "none";			zk._hideExtr(n); //hide parent later		}};///////////// anima ///* Animation effects. It requires the component to have the <div><div> * structure. */anima = {}/** Make a component visible by increasing the opacity. * @param id component or its ID */anima.appear = function (id, dur) {	var n = $e(id);	if (n) {		if (getZKAttr(n, "animating")) {			zk._addAnique(n.id, "anima.appear");		} else {			setZKAttr(n, "animating", "show");			zk._showExtr(n);  //parent visible first			Effect.Appear(n, {duration:dur ? dur/1000: 0.8, afterFinish: anima._afterVisi});		}	}};/** Make a component visible by sliding down. * @param id component or its ID */anima.slideDown = function (id, dur) {	var n = $e(id);	if (n) {		if (getZKAttr(n, "animating")) {			zk._addAnique(n.id, "anima.slideDown");		} else {			setZKAttr(n, "animating", "show");			zk._showExtr(n);  //parent visible first			Effect.SlideDown(n, {duration:dur ? dur/1000: 0.4, afterFinish: anima._afterVisi});				//duration must be less than 0.5 since other part assumes it		}	}};/** Make a component invisible by sliding up. * @param id component or its ID */anima.slideUp = function (id, dur) {	var n = $e(id);	if (n) {		if (getZKAttr(n, "animating")) {			zk._addAnique(n.id, "anima.slideUp");		} else {			setZKAttr(n, "animating", "hide");			zk.onHideAt(n); //callback first			Effect.SlideUp(n, {duration:dur ? dur/1000: 0.4, afterFinish: anima._afterHide});				//duration must be less than 0.5 since other part assumes it		}	}};/** Make a component invisible by fading it out. * @param id component or its ID */anima.fade = function (id, dur) {	var n = $e(id);	if (n) {		if (getZKAttr(n, "animating")) {			zk._addAnique(n.id, "anima.fade");		} else {			setZKAttr(n, "animating", "hide");			zk.onHideAt(n); //callback first			Effect.Fade(n, {duration:dur ? dur/1000: 0.55, afterFinish: anima._afterHide});		}	}};/** Make a component invisible by puffing away. * @param id component or its ID */anima.puff = function (id, dur) {	var n = $e(id);	if (n) {		if (getZKAttr(n, "animating")) {			zk._addAnique(n.id, "anima.puff");		} else {			setZKAttr(n, "animating", "hide");			zk.onHideAt(n); //callback first			Effect.Puff(n, {duration:dur ? dur/1000: 0.7, afterFinish: anima._afterHide0});		}	}};/** Make a component invisible by fading and dropping out. * @param id component or its ID */anima.dropOut = function (id, dur) {	var n = $e(id);	if (n) {		if (getZKAttr(n, "animating")) {			zk._addAnique(n.id, "anima.dropOut");		} else {			setZKAttr(n, "animating", "hide");			zk.onHideAt(n); //callback first			Effect.DropOut(n, {duration:dur ? dur/1000: 0.7, afterFinish: anima._afterHide0});		}	}};anima._afterVisi = function (ef) {	var n = ef.element;	if (n) {		rmZKAttr(n, "animating");		zk.onVisiAt(n);		zk._doAnique(n.id);	}};anima._afterHide = function (ef) {	var n = ef.element;	if (n) {		zk._hideExtr(n); //hide parent later		rmZKAttr(n, "animating");		zk._doAnique(n.id);	}};anima._afterHide0 = function (ef) {	var n = ef.effects[0].element;	if (n) {		zk._hideExtr(n); //hide parent later		rmZKAttr(n, "animating");		zk._doAnique(n.id);	}};//animation queuezk._anique = {};	//queue for waiting animating to clear: map(id, array(js_func_name))zk._addAnique = function(id, funcnm) {	var ary = zk._anique[id];	if (!ary)		ary = zk._anique[id] = [];	ary.push(funcnm);};zk._doAnique = function (id) {	var ary = zk._anique[id];	if (ary) {		var n = $e(id);		while (ary.length) {			if (getZKAttr(n, "animating"))				break;			var js = ary.shift();			eval(js+"('"+id+"')");		}					if (!ary.length)			delete zk._anique[id];	}};} //if (!window.anima)

⌨️ 快捷键说明

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