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

📄 wnd.js

📁 ZK 基础介绍 功能操作 模块 结合数据库操作
💻 JS
📖 第 1 页 / 共 2 页
字号:
/* wnd.js{{IS_NOTE	Purpose:			Description:		Window	History:		Thu Mar 15 16:00:23     2007, Created by tomyeh}}IS_NOTECopyright (C) 2007 Potix Corporation. All Rights Reserved.{{IS_RIGHT}}IS_RIGHT*/zk.load("zul.zul"); //zul and msgzul////// window //zkWnd = {};zkWnd._szs = {} //Map(id, Draggable)zkWnd._clean2 = {}; //Map(id, mode): to be cleanup the modal effectzkWnd._modal2 = {}; //Map(id, todo): to do 2nd phase modaling (disable)zkWnd.init = function (cmp) {	zkWnd._fixHgh(cmp);	var btn = $e(cmp.id + "!close");	if (btn) {		zk.listen(btn, "click", function (evt) {zkau.sendOnClose(cmp, true); Event.stop(evt);});		zk.listen(btn, "mouseover", function () {if (window.zkau) zkau.onimgover(btn);});			//FF: at the moment of browsing to other URL, listen is still attached but			//our js are unloaded. It causes JavaScript error though harmlessly			//This is a dirty fix (since onclick and others still fail but hardly happen)		zk.listen(btn, "mouseout", function () {zkau.onimgout(btn);});		if (!btn.style.cursor) btn.style.cursor = "default";	}	zk.listen(cmp, "mousemove", function (evt) {if(window.zkWnd) zkWnd.onmouseove(evt, cmp);});		//FF: at the moment of browsing to other URL, listen is still attached but		//our js are unloaded. It causes JavaScript error though harmlessly		//This is a dirty fix (since onclick and others still fail but hardly happen)	zkWnd.setSizable(cmp, zkWnd.sizable(cmp));	zkWnd._initMode(cmp);};zkWnd.cleanup = function (cmp) {	zkWnd.setSizable(cmp, false);	zkWnd._cleanMode(cmp);};/** Fixed the content div's height. */zkWnd.onVisi = zkWnd._fixHgh = function (cmp) {	var hgh = cmp.style.height;	if (hgh && hgh != "auto") {		var n = $e(cmp.id + "!cave");		if (n) {			hgh = cmp.clientHeight;			for (var p = n, q; q = p.previousSibling;) {				if (q.offsetHeight) hgh -= q.offsetHeight; //may undefined				p = q;			}			for (var p = n, q; q = p.nextSibling;) {				if (q.offsetHeight) hgh -= q.offsetHeight; //may undefined				p = q;			}			zk.setOffsetHeight(n, hgh);		}	}};zkWnd._embedded = function (cmp) {	var v = getZKAttr(cmp, "mode");	return !v || v == "embedded";};zkWnd.setAttr = function (cmp, nm, val) {	switch (nm) {	case "visibility":		var visible = val == "true",			embedded = zkWnd._embedded(cmp),			order = embedded ? 0: 1;		//three cases:		//order=0: cmp and all its ancestor are embedded		//1: cmp is the first non-embedded, i.e., all its ancestors are embeded		//2: cmp has an ancesor is non-embedded		//		//Since vparent is used if order=1, we have to handle visibility diff		for (var n = cmp; n = $parent(n);) {			if ($type(n) == "Wnd" && !zkWnd._embedded(n)) {				order = 2;				break;			}		}		if (order == 1) { //with vparent			setZKAttr(cmp, "vvisi", visible ? 't': 'f');			visible = visible && zk.isRealVisible($parent(cmp));			zkau.setAttr(cmp, nm, visible ? "true": "false");			if (visible) zk.setVParent(cmp); //Bug 1816451		} else {			//order=0: might have a child with vparent, and realVisi changed			if (order == 0 && (visible != zk.isRealVisible(cmp))) {				for (var id in zk._vpts)					if (zk.isAncestor(cmp, id)) {						var n = $e(id);						if (n) {							var vvisi = getZKAttr(n, "vvisi");							if (vvisi != 'f') {								var nvisi = $visible(n);								if (nvisi != visible) {									if (!vvisi)										setZKAttr(n, "vvisi", nvisi ? 't': 'f');									zkau.setAttr(n, nm, val);								}							}						}					}			}			rmZKAttr(cmp, "vvisi"); //just in case			zkau.setAttr(cmp, nm, val);		}		if (!embedded) zkau.hideCovered(); //Bug 1719826		return true;	case "z.sizable":		zkau.setAttr(cmp, nm, val);		zkWnd.setSizable(cmp, val == "true");		return true;	case "z.cntStyle":		var n = $e(cmp.id + "!cave");		if (n) {			zk.setStyle(n, val != null ? val: "");			zkWnd._fixHgh(cmp); //border's dimension might be changed		}		return true;  //no need to store z.cntType	case "z.cntScls":		var n = $e(cmp.id + "!cave");		if (n) {			n.className = val != null ? val: "";			zkWnd._fixHgh(cmp); //border's dimension might be changed		}		return true; //no need to store it	case "z.pos":		zkau.setAttr(cmp, nm, val);		if (val && !zkWnd._embedded(cmp)) {			zkWnd._center(cmp, null, val);			//if val is null, it means no change at all			zkau.hideCovered(); //Bug 1719826 		}		return true;	case "style":	case "style.height":		zkau.setAttr(cmp, nm, val);		zkWnd._fixHgh(cmp);		if (nm == "style.height") {			zk.onResize(0, cmp);// Note: IE6 is broken, because its offsetHeight doesn't update.	
		}		return true;	case "style.width":		zk.onResize(0, cmp);		return false;	}	return false;};////////// Handle sizable window //zkWnd.sizable = function (cmp) {	return getZKAttr(cmp, "sizable") == "true";};zkWnd.setSizable = function (cmp, sizable) {	var id = cmp.id;	if (sizable) {		if (!zkWnd._szs[id]) {			var orgpos = cmp.style.position; //Bug 1679593			zkWnd._szs[id] = new Draggable(cmp, {				starteffect: zkau.closeFloats,				endeffect: zkWnd._endsizing, ghosting: zkWnd._ghostsizing,				revert: true, reverteffect: zk.voidf,				ignoredrag: zkWnd._ignoresizing			});			cmp.style.position = orgpos;		}	} else {		if (zkWnd._szs[id]) {			zkWnd._szs[id].destroy();			delete zkWnd._szs[id];		}	}};/** 0: none, 1: top, 2: right-top, 3: right, 4: right-bottom, 5: bottom, * 6: left-bottom, 7: left, 8: left-top */zkWnd._insizer = function (cmp, x, y) {	var ofs = Position.cumulativeOffset(cmp);	var r = ofs[0] + cmp.offsetWidth, b = ofs[1] + cmp.offsetHeight;	if (x - ofs[0] <= 5) {		if (y - ofs[1] <= 5) return 8;		else if (b - y <= 5) return 6;		else return 7;	} else if (r - x <= 5) {		if (y - ofs[1] <= 5) return 2;		else if (b - y <= 5) return 4;		else return 3;	} else {		if (y - ofs[1] <= 5) return 1;		else if (b - y <= 5) return 5;	}};zkWnd.onmouseove = function (evt, cmp) {	var target = Event.element(evt);	if (zkWnd.sizable(cmp)) {		var c = zkWnd._insizer(cmp, Event.pointerX(evt), Event.pointerY(evt));		if (c) {			zk.backupStyle(cmp, "cursor");			cmp.style.cursor = c == 1 ? 'n-resize': c == 2 ? 'ne-resize':				c == 3 ? 'e-resize': c == 4 ? 'se-resize':				c == 5 ? 's-resize': c == 6 ? 'sw-resize':				c == 7 ? 'w-resize': 'nw-resize';		} else {			zk.restoreStyle(cmp, "cursor");		}	}};/** Called by zkWnd._szs[]'s ignoredrag for resizing window. */zkWnd._ignoresizing = function (cmp, pointer) {	var dg = zkWnd._szs[cmp.id];	if (dg) {		var v = zkWnd._insizer(cmp, pointer[0], pointer[1]);		if (v) {			switch (dg.z_dir = v) {			case 1: case 5: dg.options.constraint = 'vertical'; break;			case 3: case 7: dg.options.constraint = 'horizontal'; break;			default: dg.options.constraint = null;			}			dg.z_orgzi = cmp.style.zIndex;			return false;		}	}	return true;};zkWnd._endsizing = function (cmp, evt) {	var dg = zkWnd._szs[cmp.id];	if (!dg) return;	if (dg.z_orgzi != null) {		cmp.style.zIndex = dg.z_orgzi; //restore it (Bug 1619349)		dg.z_orgzi = null	}	if (dg.z_szofs && (dg.z_szofs[0] || dg.z_szofs[1])) {		var keys = "";		if (evt) {			if (evt.altKey) keys += 'a';			if (evt.ctrlKey) keys += 'c';			if (evt.shiftKey) keys += 's';		}		//adjust size		setTimeout("zkWnd._resize($e('"+cmp.id+"'),"+dg.z_dir+","			+dg.z_szofs[0]+","+dg.z_szofs[1]+",'"+keys+"')", 50);		dg.z_dir = dg.z_szofs = null;	}};zkWnd._resize = function (cmp, dir, ofsx, ofsy, keys) {	var l, t, w = cmp.offsetWidth, h = cmp.offsetHeight;	if (ofsy) {		if (dir == 8 || dir <= 2) {			h -= ofsy;			if (h < 0) {				ofsy = cmp.offsetHeight;				h = 0;			}			t = $int(cmp.style.top) + ofsy;		}		if (dir >= 4 && dir <= 6) {			h += ofsy;			if (h < 0) h = 0;		}	}	if (ofsx) {		if (dir >= 6 && dir <= 8) {			w -= ofsx;			if (w < 0) {				ofsx = cmp.offsetWidth;				w = 0;			}			l = $int(cmp.style.left) + ofsx;		}		if (dir >= 2 && dir <= 4) {			w += ofsx;			if (w < 0) w = 0;		}	}	if (w != cmp.offsetWidth || h != cmp.offsetHeight) {		if (w != cmp.offsetWidth) cmp.style.width = w + "px";		if (h != cmp.offsetHeight) {			cmp.style.height = h + "px";			zkWnd._fixHgh(cmp);		}		zkau.sendOnSize(cmp, keys);	}	if (l != null || t != null) {		if (l != null) cmp.style.left = l + "px";		if (t != null) cmp.style.top = t + "px";		zkau.sendOnMove(cmp, keys);	}	if (!zkWnd._embedded(cmp))		zkau.hideCovered();};/* @param ghosting whether to create or remove the ghosting */zkWnd._ghostsizing = function (dg, ghosting, pointer) {	if (ghosting) {		var ofs = zkau.beginGhostToDIV(dg);		var html =			'<div id="zk_ddghost" style="position:absolute;top:'			+ofs[1]+'px;left:'+ofs[0]+'px;width:'			+zk.offsetWidth(dg.element)+'px;height:'+zk.offsetHeight(dg.element)			+'px;';

⌨️ 快捷键说明

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