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

📄 wnd.js

📁 ZK 基础介绍 功能操作 模块 结合数据库操作
💻 JS
📖 第 1 页 / 共 2 页
字号:
		if (dg.z_dir == 8 || dg.z_dir <= 2)			html += 'border-top:3px solid darkgray;';		if (dg.z_dir >= 2 && dg.z_dir <= 4)			html += 'border-right:3px solid darkgray;';		if (dg.z_dir >= 4 && dg.z_dir <= 6)			html += 'border-bottom:3px solid darkgray;';		if (dg.z_dir >= 6 && dg.z_dir <= 8)			html += 'border-left:3px solid darkgray;';		document.body.insertAdjacentHTML("afterbegin", html + '"></div>');		dg.element = $e("zk_ddghost");	} else {		var org = zkau.getGhostOrgin(dg);		if (org) {			//calc how much window is resized			var ofs1 = Position.cumulativeOffset(dg.element);			var ofs2 = Position.cumulativeOffset(org);			dg.z_szofs = [ofs1[0] - ofs2[0], ofs1[1] - ofs2[1]];		} else {			dg.z_szofs = null;		}		zkau.endGhostToDIV(dg);	}};////////// Handling Overlapped, Modal, Popup and Embedded //zkWnd._initMode = function (cmp) {	var mode = getZKAttr(cmp, "mode");	var replace = zkWnd._clean2[cmp.id] == mode;	if (replace) //replace with the same mode		delete zkWnd._clean2[cmp.id]; //and _doXxx will handle it	else if (zkWnd._clean2[cmp.id])		zkWnd._cleanMode2(cmp.id, true); //replace with a new mode	switch (mode) {	case "modal":	case "highlighted":		zkWnd._doModal(cmp, replace);		break;	case "overlapped":		zkWnd._doOverlapped(cmp, replace);		break;	case "popup":		zkWnd._doPopup(cmp, replace);	//default: embedded	}};zkWnd._cleanMode = function (cmp) {	var mode = getZKAttr(cmp, "mode");	if (mode) {		zkWnd._stick(cmp); //cleanup draggable or so		zkWnd._clean2[cmp.id] = mode;		setTimeout("zkWnd._cleanMode2('"+cmp.id+"')", 5);			//don't clean immediately since it might be replaced			//(due to invalidate)	}};/** 2nd phase of cleaning mode. */zkWnd._cleanMode2 = function (uuid, replace) {	var mode = zkWnd._clean2[uuid];	if (mode) {		delete zkWnd._clean2[uuid];		switch (mode) {		case "modal":		case "highlighted":			zkWnd._endModal(uuid, replace);			break;		case "overlapped":			zkWnd._endOverlapped(uuid, replace);			break;		case "popup":			zkWnd._endPopup(uuid, replace);	//default: embedded		}	}};/** Shows the window with the anima effect, if any. */zkWnd._show = function (cmp) {	if (getZKAttr(cmp, "conshow")) //enforce the anima effect, if any		cmp.style.display = "none";	zk.show(cmp);};//Overlap/Popup///** Makes the component as popup. */zkWnd._doPopup = function (cmp, replace) {	zkWnd._doOverpop(cmp, zkau._popups, replace);};/** Makes the popup component as normal. */zkWnd._endPopup = function (uuid, replace) {	zkWnd._endOverpop(uuid, zkau._popups, replace);};/** Makes the component as overlapped. */zkWnd._doOverlapped = function (cmp, replace) {	zkWnd._doOverpop(cmp, zkau._overlaps, replace);};/** Makes the popup component as normal. */zkWnd._endOverlapped = function (uuid, replace) {	zkWnd._endOverpop(uuid, zkau._overlaps, replace);};zkWnd._doOverpop = function (cmp, storage, replace) {	var pos = getZKAttr(cmp, "pos");	var isV = zkWnd.shallVParent(cmp);	if (!pos && isV && !cmp.style.top && !cmp.style.left) {				var xy = zk.revisedOffset(cmp);		cmp.style.left = xy[0] + "px";		cmp.style.top = xy[1] + "px";	}	if (isV) zk.setVParent(cmp);		if (replace) {		zkau.fixZIndex(cmp);		zkWnd._float(cmp);		return;	}		if (pos) zkWnd._center(cmp, null, pos); //unlike modal, change only if pos	zkau.closeFloats(cmp);	zkau.fixZIndex(cmp);	zkWnd._float(cmp);	storage.push(cmp.id); //store ID because it might cease before endPopup	zkau.hideCovered();	if ($visible(cmp)) //it happens when closing a modal (becomes overlap)		zkWnd._show(cmp);	zk.asyncFocusDown(cmp.id);};zkWnd._endOverpop = function (uuid, storage, replace) {	storage.remove(uuid);			var cmp = $e(uuid);	if (cmp) {		zk.unsetVParent(cmp);		zkau.hideCovered();		if (!replace) zkWnd._stick(cmp);	}};/** Test whether el shall become a virtual parent (when overlap/...). * Note: only the first overlap/... need to setVParent */zkWnd.shallVParent = function (el) {	while (el = $parent(el))		if ($type(el) == "Wnd" && !zkWnd._embedded(el))			return false; //only one of them shall become a virtual parent	return true;};//Modal///** Makes the window as modal. */zkWnd._doModal = function (cmp, replace) {	if (replace) {		zkWnd._float(cmp);		return;	}	//center component	var nModals = zkau._modals.length;	zkau.fixZIndex(cmp, true); //let fixZIndex reset topZIndex if possible	var zi = ++zkau.topZIndex; //mask also need another index		if (zkWnd.shallVParent(cmp)) zk.setVParent(cmp);	zkWnd._center(cmp, zi, getZKAttr(cmp, "pos")); //called even if pos not defined		//show dialog first to have better response.	zkWnd._show(cmp); //unlike other mode, it must be visible	zkau.closeFloats(cmp);	var maskId = cmp.id + ".mask";	var mask = $e(maskId);	if (!mask) {		//Note: a modal window might be a child of another		var bMask = true;		for (var j = 0; j < nModals; ++j) {			var n = $e(zkau._modals[j]);			if (n && zk.isAncestor(n, cmp)) {				bMask = false;				break;			}		}		if (bMask) {			//bug 1510218: we have to make it as a sibling to cmp			cmp.insertAdjacentHTML(				"beforebegin", '<div id="'+maskId+'" class="modal_mask"></div>');			mask =  $e(maskId);		}	}	//position mask to be full window	if (mask) {		zkWnd._posMask(mask);		mask.style.display = "block";		mask.style.zIndex = zi - 1;		if (zkau.currentFocus) //store it			mask.setAttribute("zk_prevfocus", zkau.currentFocus.id);	}	zkau._modals.push(cmp.id);	if (nModals == 0) {		zk.listen(window, "resize", zkWnd._onMoveMask);		zk.listen(window, "scroll", zkWnd._onMoveMask);	}	zkWnd._float(cmp);	zk.asyncFocusDown(cmp.id);	zkWnd._modal2[cmp.id] = true;	setTimeout("zkWnd._doModal2('"+cmp.id+"')", 5); //process it later for better responsive};/** Does the 2nd phase processing of modal. */zkWnd._doModal2 = function (uuid) {	if (zkWnd._modal2[uuid]) {		delete zkWnd._modal2[uuid];		var cmp = $e(uuid);		if (cmp) {			zk.restoreDisabled(cmp); //there might be two or more modal dlgs			zk.disableAll(cmp);		}	}};/** Clean up the modal component. */zkWnd._endModal = function (uuid, replace) {	var maskId = uuid + ".mask";	var mask = $e(maskId);	var prevfocusId;	if (mask) {		prevfocusId = mask.getAttribute("zk_prevfocus");		zk.remove(mask);	}	zkau._modals.remove(uuid);	delete zkWnd._modal2[uuid];		var cmp = $e(uuid);	if (cmp) zk.unsetVParent(cmp);	if (zkau._modals.length == 0) {		zk.unlisten(window, "resize", zkWnd._onMoveMask);		zk.unlisten(window, "scroll", zkWnd._onMoveMask);		window.onscroll = null;		zk.restoreDisabled();	} else {		var lastid = zkau._modals[zkau._modals.length - 1];		var last = $e(lastid);		if (last) {			zk.restoreDisabled(last);			if (!prevfocusId && !zk.inAsyncFocus) zk.asyncFocusDown(lastid, 2);		}	}	if (!replace && cmp) zkWnd._stick(cmp);	if (prevfocusId && !zk.inAsyncFocus) zk.asyncFocus(prevfocusId, 2);};/** Handles onsize to re-position mask. */zkWnd._onMoveMask = function (evt) {	for (var j = zkau._modals.length; --j >= 0;) {		var mask = $e(zkau._modals[j] + ".mask");		if (mask) {			zkWnd._posMask(mask);			return;		}	}};/** Position the mask window. */zkWnd._posMask = function (mask) {	var ofs = zk.toStyleOffset(mask, zk.innerX(), zk.innerY());	mask.style.left = ofs[0] + "px";	mask.style.top = ofs[1] + "px";	mask.style.width = zk.innerWidth() + "px";	mask.style.height = zk.innerHeight() + "px";};/** Makes a window in the center. */zkWnd._center = function (cmp, zi, pos) {	cmp.style.position = "absolute"; //just in case	zk.center(cmp, pos);	zkau.sendOnMove(cmp);	if (zi || zi == 0) {		cmp.style.zIndex = zi;		zkau.sendOnZIndex(cmp);		//let the server know the position. otherwise, invalidate will		//cause it to be moved to center again	}}//Utilities///** Makes a window movable. */zkWnd._float = function (cmp) {	if (cmp) {		var handle = $e(cmp.id + "!caption");		if (handle) {			cmp.style.position = "absolute"; //just in case			zul.initMovable(cmp, {				handle: handle, starteffect: zkau.closeFloats,				change: zkau.hideCovered,				endeffect: zkWnd._onWndMove});			//we don't use options.change because it is called too frequently		}	}};/** Makes a window un-movable. */zkWnd._stick = function (cmp) {	if (cmp) {		zul.cleanMovable(cmp.id);		cmp.style.position = ""; //aculous changes it to relative	}};/** Called back when overlapped and popup is moved. */zkWnd._onWndMove = function (cmp, evt) {	var keys = "";	if (evt) {		if (evt.altKey) keys += 'a';		if (evt.ctrlKey) keys += 'c';		if (evt.shiftKey) keys += 's';	}	zkau.sendOnMove(cmp, keys);};

⌨️ 快捷键说明

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