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

📄 sel.js

📁 ZK 基础介绍 功能操作 模块 结合数据库操作
💻 JS
📖 第 1 页 / 共 3 页
字号:
					for (;; ++j) {//no need to check length again						r = rows[j];						if ($visible(r)) break;					}					h = zk.offsetTop(r) + zk.offsetHeight(r);					if (h >= hgh) {						if (h > hgh + 2) ++sz; //experimental						break;					}				}				this.realsize(sz);				this.body.style.height = hgh + "px";								if (this.body.offsetHeight) {} // bug #1812001				// note: we have to invoke the body.offestHeight to resolve the scrollbar disappearing in IE6 				// and IE7 at initializing phase.				return; //done			}		}		hgh = 0;		var diff = 2/*experiment*/, sz = this.size();		if (!sz) {			if (getZKAttr(this.element, "vflex") == "true") {				hgh = this._vflexSize();								if (zk.ie && $int(getZKAttr(this.element, "hgh")) != hgh) {					hgh -= 1; // need to display the bottom border.					setZKAttr(this.element, "hgh", hgh);				}				if (hgh < 25) hgh = 25;				var rowhgh = zk.offsetHeight(firstVisiRow);				if (!rowhgh) rowhgh = this._headHgh(20);				sz = Math.round((hgh - diff)/ rowhgh);				if (sz < 3) { //minimal 3 rows if auto-size					sz = 3;					hgh = rowhgh * 3 + diff;				}			}			this.realsize(sz);		}		if (sz) {			if (!hgh) {				if (!len) hgh = this._headHgh(20) * sz;				else if (sz <= len) {					var r = this._visiRowAt(sz - 1);					hgh = zk.offsetTop(r) + zk.offsetHeight(r);				} else {					hgh = zk.offsetTop(lastVisiRow) + zk.offsetHeight(lastVisiRow);					hgh = Math.ceil((sz * hgh) / len);				}				if (zk.ie) hgh += diff; //strange in IE (or scrollbar shown)			}			this.body.style.height = hgh + "px";						if (this.body.offsetHeight) {} // bug #1812001			// note: we have to invoke the body.offestHeight to resolve the scrollbar disappearing in IE6 			// and IE7 at initializing phase.		} else {			//if no hgh but with horz scrollbar, IE will show vertical scrollbar, too			//To fix the bug, we extend the height			hgh = this.element.style.height;			if (zk.ie && (!hgh || hgh == "auto")			&& this.body.offsetWidth - this.body.clientWidth > 11) {				if (!len) this.body.style.height = ""; // bug #1806152 if start with 0px and no hgh, IE doesn't calculate the height of the element.				else this.body.style.height =						(this.body.offsetHeight * 2 - this.body.clientHeight) + "px";			} else {				this.body.style.height = "";			}		}	},	/* Height of the head row. If now header, defval is returned. */	_headHgh: function (defVal) {		var n = this.headtbl;		n = n && n.rows.length ? n.rows[0]: null;		var hgh = n ? zk.offsetHeight($real(n)): 0; // Bug #1823218 		return hgh ? hgh: defVal;	},	/** Returns the size for vflex	 */	_vflexSize: function () {		return this.element.offsetHeight - 2 - (this.head ? this.head.offsetHeight : 0)			- (this.foot ? this.foot.offsetHeight : 0); // Bug #1815882	},	/** Recalculate the size. */	recalcSize: function (cleansz) {		if (!zk.isRealVisible(this.element)) return;		setTimeout("zkSel._calcSize('"+this.id+"')", 50);	},	/** Resize the specified column. */	resizeCol: function (cmp, icol, col, wd, keys) {		if (this.bodyrows)			zulHdr.resizeAll(this, cmp, icol, col, wd, keys);	},	/** Sels all items (don't notify server and change focus, because it is from server). */	_selectAll: function () {		var rows = this.bodyrows;		for (var j = 0; j < rows.length; ++j)			this._changeSelect(rows[j], true);		this._setSelectedId(rows.length ? rows[0].id: null);	},	/** Notifies the server the selection is changed (callable only if multiple). */	_sendSelect: function () {		//To reduce # of bytes to send, we use a string instead of array.		var data = "";		for (var j = 0; j < this.bodyrows.length; ++j) {			var r = this.bodyrows[j];			if (this._isSelected(r))				data += "," + this.getItemUuid(r);		}		if (data) data = data.substring(1);		zkau.send({uuid: this.id, cmd: "onSelect", data: [data]},				zkau.asapTimeout(this.element, "onSelect"));	},	/** Returns z.selId (aka., the id of the selected item), or null if	 * no one is ever selected.	 */	_getSelectedId: function () {		var selId = getZKAttr(this.element, "selId");		if (!selId) {			alert(mesg.INVALID_STRUCTURE + "z.selId not found");			return null;		}		return selId == "zk_n_a" ? null: selId;	},	/** Sets z.selId (aka., the id of the selected item). */	_setSelectedId: function (selId) {		setZKAttr(this.element, "selId", selId ? selId: "zk_n_a");	},	/** Fixes z.selId to the first selected item. */	_fixSelelectedId: function () {		var selId = null;		for (var j = 0; j < this.bodyrows.length; ++j) {			var r = this.bodyrows[j];			if (this._isSelected(r)) {				selId = r.id;				break;			}		}		this._setSelectedId(selId);	},	/** Whether an item is selected. */	_isSelected: function (row) {		return getZKAttr(row, "sel") == "true";	},	/** Whether an item has focus. */	_isFocus: function (row) {		return $e(row.id + "!sel") || $e(row.id + "!cm");	},	/** Whether the component is multiple.	 */	_isMultiple: function () {		return getZKAttr(this.element, "multiple") == "true";	},	/** Changes the multiple status. Note: it won't notify the server any change	 */	_setMultiple: function (multiple) {		setZKAttr(this.element, "multiple", multiple ? "true": "false");		if (!multiple) {			var row = $e(this._getSelectedId());			this._unsetSelectAllExcept(row);				//no need to unfocus because we don't want to change focus		}	},	/** Returns whether the row is valid. */	_isValid: function (row) {		return row && !row.id.endsWith("!child");	},	/** Called when the form enclosing it is submitting. */	onsubmit: function () {		var nm = getZKAttr(this.element, "name");		if (!nm || !this.form) return;		for (var j = 0; j < this.form.elements.length; ++j){			var el = this.form.elements[j];			if (getZKAttr(el, "hiddenBy") == this.id) {				zk.remove(el);				--j;			}		}		for (var j = 0; j < this.bodyrows.length; ++j) {			var r = this.bodyrows[j];			if (this._isSelected(r))				setZKAttr(					zk.newHidden(nm, getZKAttr(r, "value"), this.form),					"hiddenBy", this.id);		}	}};////// Utilities to help implement zk.Selectable //zkSel = {};zkSel._init = function (uuid) {	var meta = zkau.getMeta(uuid);	if (meta) meta._init();};zkSel._calcSize = function (uuid) {	var meta = zkau.getMeta(uuid);	if (meta) meta._calcSize();};zkSel._renderNow = function (uuid) {	var meta = zkau.getMeta(uuid);	if (meta) meta._renderNow();};zkSel._shallIgnoreEvent = function (el) {	var tn = $tag(el);	return !el || ((tn == "INPUT" && !el.id.endsWith("!cm"))	|| tn == "TEXTAREA" || tn == "BUTTON" || tn == "SELECT" || tn == "OPTION");};/** row's onmouseover. */zkSel.onover = function (evt) {	if (!zk.dragging) {		if (!evt) evt = window.event;		var row = $parentByTag(Event.element(evt), "TR");		if (row) Selectable_effect(row);	}};/** row's onmouseout. */zkSel.onout = function (evt) {	if (!zk.dragging) {		if (!evt) evt = window.event;		zkSel.onoutTo($parentByTag(Event.element(evt), "TR"));	}};zkSel.onoutTo = function (row) {	if (row) Selectable_effect(row, true);};/** (!cm or !sel)'s onfocus. */zkSel.cmonfocus = function (evt) {	if (!evt) evt = window.event;	zkSel.cmonfocusTo($parentByTag(Event.element(evt), "TR"));};/** (!cm or !sel)'s onblur. */zkSel.cmonblur = function (evt) {	if (!evt) evt = window.event;	zkSel.cmonblurTo($parentByTag(Event.element(evt), "TR"));};zkSel.cmonfocusTo = function (row) {	if (row) zk.addClass(row, "focusd");};zkSel.cmonblurTo = function (row) {	if (row) zk.rmClass(row, "focusd");};////// listbox //zkLibox = {}; //listbox/** Called when the body got a key stroke. */zkLibox.bodyonkeydown = function (evt) {	if (!evt) evt = window.event;	var target = Event.element(evt);	var meta = zkau.getMetaByType(target, "Libox");	return !meta || meta.dobodykeydown(evt, target);};/** Called when a listitem got a key stroke. */zkLibox.onkeydown = function (evt) {	if (!evt) evt = window.event;	var target = Event.element(evt);	var meta = zkau.getMetaByType(target, "Libox");	return !meta || meta.dokeydown(evt, target);};/** Called when mouse click. */zkLibox.onclick = function (evt) {	if (!evt) evt = window.event;	var target = Event.element(evt);	var meta = zkau.getMetaByType(target, "Libox");	if (meta) meta.doclick(evt, target);};/** Called when focus command is received. */zkLibox.focus = function (cmp) {	var meta = zkau.getMeta(cmp);	if (meta) meta._refocus();	return true;};/** Process the setAttr cmd sent from the server, and returns whether to * continue the processing of this cmd */zkLibox.setAttr = function (cmp, nm, val) {	var meta = zkau.getMeta(cmp);	return meta && meta.setAttr(nm, val);};/** Init (and re-init) a listbox. */zkLibox.init = function (cmp) {	var meta = zkau.getMeta(cmp);	if (meta) meta.init();	else {		meta = new zk.Selectable(cmp);		if (meta.body)			zk.listen(meta.body, "keydown", zkLibox.bodyonkeydown);	}};/** Called when a listbox becomes visible because of its parent. */zkLibox.onVisi = zkLibox.onSize = function (cmp) {	var meta = zkau.getMeta(cmp);	if (meta) meta.init();};zkLit = {}; //listitemzkLit.init = function (cmp) {	//zk.disableSelection(cmp);	//Tom Yeh: 20060106: side effect: unable to select textbox if turned on	zk.listen(cmp, "click", zkLibox.onclick);	zk.listen(cmp, "keydown", zkLibox.onkeydown);	zk.listen(cmp, "mouseover", zkSel.onover);	zk.listen(cmp, "mouseout", zkSel.onout);	zkLit.stripe(cmp);};zkLit.cleanup = function (cmp) {	zkLit.stripe(cmp, true);};zkLit.stripe = function (cmp, isClean) {	var libox = $parentByType(cmp, "Libox");	var meta = zkau.getMeta(libox);	if (meta) {		if (!meta.fixedStripe) meta.fixedStripe = function () {meta.stripe();};		if (isClean) zk.addCleanupLater(meta.fixedStripe, false, true);		else zk.addInitLater(meta.fixedStripe, false, true);	}};zkLic = {}; //listcell or TreecellzkLic.init = function (cmp) {	var isTree = $type(cmp.parentNode) == "Trow";	var libox = $parentByType(cmp, isTree ? "Tree" : "Libox");	var meta = zkau.getMeta(libox);	if (meta) {		meta.putCellQue(cmp);		if (!meta.fixedSize)			meta.fixedSize = function () {meta.init(true);};			zk.addInitLater(meta.fixedSize, false, true);	}};zkLic.setAttr = function (cmp, nm, val) {	if ("style" == nm) {		var cell = $e(cmp.id + "!cave");		var v = zk.getTextStyle(val);		if (v) zkau.setAttr(cell, nm, v);		zkau.setAttr(cmp, nm, val);		return true;	}	return false;};/** Called when _onDocCtxMnu is called. */zkLit.onrtclk = function (cmp) {	var meta = zkau.getMetaByType(cmp, "Libox");	if (meta && !meta._isSelected(cmp)) meta.doclick(null, cmp);};zkLcfc = {}; //checkmark or the first hyperlink of listcellzkLcfc.init = function (cmp) {	zk.listen(cmp, "focus", zkSel.cmonfocus);	zk.listen(cmp, "blur", zkSel.cmonblur);};zk.addModuleInit(function () {	//Listheader	//init it later because zul.js might not be loaded yet	zkLhr = {}	Object.extend(zkLhr, zulHdr);	/** Resize the column. */	zkLhr.resize = function (col1, icol, wd1, keys) {		var box = $parentByType(col1, "Libox");		if (box) {			var meta = zkau.getMeta(box);			if (meta)				meta.resizeCol(					$parentByType(col1, "Lhrs"), icol, col1, wd1, keys);		}	};	//Listhead	zkLhrs = zulHdrs;});////// listbox mold=select //zkLisel = {};zkLisel.init = function (cmp) {	zk.listen(cmp, "change", zkLisel.onchange);	zk.listen(cmp, "focus", zkau.onfocus);	zk.listen(cmp, "blur", zkau.onblur);};/** Handles onchange from select/list. */zkLisel.onchange = function (evtel) {	var cmp = zkau.evtel(evtel); //backward compatible with 2.4 or before	var data;	if (cmp.multiple) {		//To reduce # of bytes to send, we use a string instead of array.		data = "";		var opts = cmp.options;		for (var j = 0; j < opts.length; ++j) {			var opt = opts[j];			if (opt.selected)				data += ","+opt.id;		}		if (data) data = data.substring(1);		//Design consideration: we could use defaultSelected to minimize		//# of options to transmit. However, we often to set selectedIndex		//which won't check defaultSelected		//Besides, most of items are not selected	} else {		var opt = cmp.options[cmp.selectedIndex];		data = opt.id;	}	var uuid = $uuid(cmp);	zkau.send({uuid: uuid, cmd: "onSelect", data: [data]},			zkau.asapTimeout(uuid, "onSelect"));	//Bug 1756559: see au.js	if (zkau.lateReq) {		zkau.send(zkau.lateReq, 25);		delete zkau.lateReq;	}};

⌨️ 快捷键说明

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