📄 au.js
字号:
//Give the component a chance to handle right-click for (var n = target; n; n = $parent(n)) { var type = $type(n); if (type) { var o = window["zk" + type]; if (o && o.onrtclk) if (o.onrtclk(n)) ctx = rtclk = null; } if (n == cmp) break; //only up to the one with right click } } if (ctx) { ctx = zkau.getByZid(cmp, ctx); if (ctx) { var type = $type(ctx); if (type) { zkau.closeFloats(ctx, cmp); ctx.style.position = "absolute"; zk.setVParent(ctx); //FF: Bug 1486840, IE: Bug 1766244 zkau._autopos(ctx, Event.pointerX(evt), Event.pointerY(evt)); zk.eval(ctx, "context", type, cmp); } } } if (rtclk/*no need since oncontextmenu: && zkau.insamepos(evt)*/) { var uuid = getZKAttr(cmp, "item"); //treerow (and other transparent) if (!uuid) uuid = $uuid(cmp); zkau.send({uuid: uuid, cmd: "onRightClick", data: zkau._getMouseData(evt, cmp), ctl: true}); } Event.stop(evt); return false; } return !zk.ie || evt.returnValue;};zkau._onDocMouseover = function (evt) { if (!evt) evt = window.event; var cmp = Event.element(evt); /** Request 1628075: give up. Why? the wait cursor won't disappear until users move the cursor if (cmp && cmp.style && cmp.getAttribute && $tag(cmp) != "HTML") { var bk = cmp.getAttribute("z_bk4wait"); if (zk.progressPrompted) { if (!bk) { var cr = cmp.style.cursor; cmp.setAttribute("z_bk4wait", cr ? cr: "nil"); cmp.style.cursor = "wait"; } } else if (bk) { cmp.removeAttribute("z_bk4wait"); cmp.style.cursor = bk == "nil" ? "": bk; } }*/ cmp = zkau._parentByZKAttr(cmp, "tip"); if (cmp && !zk.progressing) { //skip tip if in processing var tip = getZKAttr(cmp, "tip"); tip = zkau.getByZid(cmp, tip); if (tip) { var open = zkau._tipz && zkau._tipz.open; if (!open || zkau._tipz.cmpId != cmp.id) { zkau._tipz = { tipId: tip.id, cmpId: cmp.id, x: Event.pointerX(evt) + 1, y: Event.pointerY(evt) + 2 //Bug 1572286: position tooltip with some offset to allow }; if (open) zkau._openTip(cmp.id); else setTimeout("zkau._openTip('"+cmp.id+"')", zk_tipto); } return; //done } } if (zkau._tipz) { if (zkau._tipz.open) { var tip = $e(zkau._tipz.tipId); if (tip && zk.isAncestor(tip, Event.element(evt))) { zkau._tipz.shallClose = false; //don't close it } else { zkau._tipz.shallClose = true; setTimeout(zkau._tryCloseTip, 300); } } else zkau._tipz = null; }};/** document.onmouseout */zkau._onDocMouseout = function (evt) { if (!evt) evt = window.event; if (zkau._tipz) if (zkau._tipz.open) { zkau._tipz.shallClose = true; setTimeout(zkau._tryCloseTip, 300); } else zkau._tipz = null;};/** window.onresize */zkau._onResize = function () { if (zkau._cInfoReg) { //since IE keeps sending onresize when dragging the browser border, //we reduce # of packs sent to the server by use of timeout zkau._cInfoPend = true; setTimeout(zkau._doClientInfo, 100); } zk.onResize(); //invoke functions added by zk.addOnResize};/** send clientInfo to the server ontimeout. */zkau._doClientInfo = function () { if (zkau._cInfoPend) { zkau._cInfoPend = false; zkau.cmd0.clientInfo(); }};zkau._openTip = function (cmpId) { //We have to filter out non-matched cmpId because user might move //from one component to another if (zkau._tipz && !zkau._tipz.open && (!cmpId || cmpId == zkau._tipz.cmpId)) { var tip = $e(zkau._tipz.tipId); zkau.closeFloats(tip, $e(cmpId)); if (tip) { var cmp = $e(cmpId); zkau._tipz.open = true; tip.style.position = "absolute"; zk.setVParent(tip); //FF: Bug 1486840, IE: Bug 1766244 zkau._autopos(tip, zkau._tipz.x, zkau._tipz.y); zk.eval(tip, "context", null, cmp); } else { zkau._tipz = null; } }};/** Closes tooltip if _tipz.shallClose is set. */zkau._tryCloseTip = function () { if (zkau._tipz && zkau._tipz.shallClose) { if (zkau._tipz.open) zkau.closeFloats(); zkau._tipz = null; }};/** Returns the target of right-click, or null if not found. */zkau._parentByZKAttr = function (n, attr1, attr2) { for (; n; n = $parent(n)) { if (attr1 && getZKAttr(n, attr1)) return n; if (attr2 && getZKAttr(n, attr2)) return n; } return null;};/** Handles document.onkeydown. */zkau._onDocKeydown = function (evt) { if (!evt) evt = window.event; var target = Event.element(evt); var zkAttrSkip, evtnm, ctkeys, shkeys, alkeys, exkeys; var keycode = evt.keyCode, zkcode; //zkcode used to search z.ctkeys switch (keycode) { case 13: //ENTER var tn = $tag(target); if (tn == "TEXTAREA" || tn == "BUTTON" || (tn == "INPUT" && target.type.toLowerCase() == "button")) return true; //don't change button's behavior (Bug 1556836) //fall thru case 27: //ESC if (zkau.closeFloats(target)) { Event.stop(evt); return false; //eat } if (keycode == 13) { zkAttrSkip = "skipOK"; evtnm = "onOK"; } else { zkAttrSkip = "skipCancel"; evtnm = "onCancel"; } break; case 16: //Shift case 17: //Ctrl case 18: //Alt return true; case 44: //Ins case 45: //Del zkcode = keycode == 44 ? 'I': 'J'; break; default: if (keycode >= 33 && keycode <= 40) { //PgUp, PgDn, End, Home, L, U, R, D zkcode = String.fromCharCode('A'.charCodeAt(0) + (keycode - 33)); //A~H: PgUp, ... break; } else if (keycode >= 112 && keycode <= 123) { //F1: 112, F12: 123 zkcode = String.fromCharCode('P'.charCodeAt(0) + (keycode - 112)); //M~Z: F1~F12 break; } else if (evt.ctrlKey || evt.altKey) { zkcode = String.fromCharCode(keycode).toLowerCase(); break; } return true; } if (zkcode) evtnm = "onCtrlKey"; for (var n = target; n; n = $parent(n)) { if (n.id && n.getAttribute) { if (getZKAttr(n, evtnm) == "true" && (!zkcode || zkau._inCtkeys(evt, zkcode, getZKAttr(n, "ctkeys")))) { var bSend = true; if (zkau.currentFocus) { var inp = zkau.currentFocus; switch ($tag(inp)) { case "INPUT": var type = inp.type.toLowerCase(); if (type != "text" && type != "password") break; //ignore it //fall thru case "TEXTAREA": bSend = zkau.textbox && zkau.textbox.updateChange(inp, false); } } var req = {uuid: n.id, cmd: evtnm, ctl: true, data: [keycode, evt.ctrlKey, evt.shiftKey, evt.altKey]}; if (zk.gecko && $tag(inp) == "SELECT" && $type(inp)) zkau.lateReq = req; //Bug 1756559:let SELECT to send (see sel.js) else zkau.send(req, 38); Event.stop(evt); return false; } if ("onCancel" == evtnm && $type(n) == "Wnd") { if (getZKAttr(n, "closable") == "true") { zkau.sendOnClose(n); Event.stop(evt); return false; //20060504: Bug 1481676: Tom Yeh //We have to stop ESC event. Otherwise, it terminates //Ajax connection (issue by close) } break; } if (zkAttrSkip && getZKAttr(n, zkAttrSkip) == "true") break; //nothing to do } } return true; //no special processing}/** returns whether a key code is specified in keys. */zkau._inCtkeys = function (evt, zkcode, keys) { if (keys) { //format: ctl+k;alt+k;shft+k;k var cc = evt.ctrlKey ? '^': evt.altKey ? '@': evt.shiftKey ? '$': '#'; var j = keys.indexOf(cc), k = keys.indexOf(';', j + 1); if (j >=0 && k >= 0) { keys = keys.substring(j + 1, k); return keys.indexOf(zkcode) >= 0; } } return false;};zkau.sendOnMove = function (cmp, keys) { zkau.send({uuid: cmp.id, cmd: "onMove", data: [cmp.style.left, cmp.style.top, keys ? keys: ""]}, zkau.asapTimeout(cmp, "onMove"));};zkau.sendOnZIndex = function (cmp) { zkau.send({uuid: cmp.id, cmd: "onZIndex", data: [cmp.style.zIndex]}, zkau.asapTimeout(cmp, "onZIndex"));};zkau.sendOnSize = function (cmp, keys) { zkau.send({uuid: cmp.id, cmd: "onSize", data: [cmp.style.width, cmp.style.height, keys]}, zkau.asapTimeout(cmp, "onSize")); zk.onResize(0, cmp); if (zk.ie && !zk.ie7) setTimeout(function () {zk.onResize(0, cmp);}, 800); // If the vflex component in the window component, the offsetHeight of the specific component is wrong at the same time on IE6. // Thus, we have to invoke the zk.onResize function again.};zkau.sendOnClose = function (uuid, closeFloats) { var el = $e(uuid); if (closeFloats) zkau.closeFloats(el); zkau.send({uuid: el.id, cmd: "onClose", data: null}, 5);};/** Closes popups and floats. * Return false if nothing changed. * @param arguments a list of component (or its ID) to exclude if * a popup contains any of them */zkau.closeFloats = function () { return zkau._closeFloats("closeFloats", arguments);};/** Similar to zkau.closeFloats, except it is called when a component * is getting the focus. * More precisely, it treats all floats as popup windows, i.e., * floats remains if it is an ancestor of aruments. */zkau.closeFloatsOnFocus = function () { return zkau._closeFloats("closeFloatsOnFocus", arguments);};zkau._closeFloats = function (method, ancestors) { var closed; for (var j = zkau._popups.length; --j >=0;) { //reverse order is important if popup contains another //otherwise, IE seem have bug to handle them correctly var n = $e(zkau._popups[j]); if ($visible(n) && getZKAttr(n, "animating") != "hide" && !zk.isAncestorX(n, ancestors, true)) { //we avoid hiding twice we have to check animating closed = true; zk.unsetVParent(n); zk.hide(n); zkau.send({uuid: n.id, cmd: "onOpen", data: [false]}, zkau.asapTimeout(n, "onOpen")); //We have to send onOpen since the server need to know //whether the popup becomes invsibile } } //floats: combobox, context menu... for (var j = zkau.floats.length; --j >= 0;) { var n = zkau.floats[j]; if (n[method].apply(n, ancestors)) closed = true; } if (closed) zkau.hideCovered(); return closed;};zkau.hideCovered = function() { var ary = []; for (var j = 0; j < zkau._popups.length; ++j) { var el = $e(zkau._popups[j]); if ($visible(el)) ary.push(el); } for (var j = 0; j < zkau.floats.length; ++j) zkau.floats[j].addHideCovered(ary); for (var j = 0; j < zkau._overlaps.length; ++j) { var el = $e(zkau._overlaps[j]); if ($visible(el)) ary.push(el); } zk.hideCovered(ary); if (zkau.valid) zkau.valid.uncover();};/** Returns the meta info associated with the specified cmp or its UUID. */zkau.getMeta = function (cmp) { var id = typeof cmp == 'string' ? cmp: cmp ? cmp.id: null; if (!id) return null; return zkau._metas[$uuid(id)];};/** Returns the meta info associated with the specified cmp or its UUID. */zkau.setMeta = function (cmp, info) { var id = typeof cmp == 'string' ? cmp: cmp ? cmp.id: null; if (!id) { zk.error(mesg.COMP_OR_UUID_REQUIRED); return; } if (info) zkau._metas[$uuid(id)] = info; else delete zkau._metas[$uuid(id)]; //save memory};/** Returns the info by specified any child component and the type. */zkau.getMetaByType = function (el, type) { el = $parentByType(el, type); return el != null ? zkau.getMeta(el): null;};/** Cleans up meta of the specified component. * <p>Note: this method is called automatically if z.type is defined. * So, you need to call this method only if no z.type -- very rare. */zkau.cleanupMeta = function (cmp) { var meta = zkau.getMeta(cmp); if (meta) { if (meta.cleanup) meta.cleanup(); zkau.setMeta(cmp, null); }};//Server Push///** Sets the info of the server push. * @since 3.0.0 */zkau.setSPushInfo = function (dtid, info) { var i = zkau._spushInfo[dtid]; if (!i) i = zkau._spushInfo[dtid] = {}; if (info.min != null) i.min = info.min; if (info.max != null) i.max = info.max; if (info.factor != null) i.factor = info.factor;};/** Returns the info of the server push. * @since 3.0.0 */zkau.getSPushInfo = function (dtid) { return zkau._spushInfo[dtid];};//////ID Space///** Returns element of the specified zid. */zkau.getByZid = function (n, zid) { var oid = zkau._zidOwner(n); var v = zkau._zidsp[oid]; if (v) { v = v[zid]; if (v) return $e(v); }};zkau.initzid = function (n, zid) { var oid = zkau._zidOwner(n); var ary = zkau._zidsp[oid]; if (!ary) ary = zkau._zidsp[oid] = {}; if (!zid) zid = getZKAttr(n, "zid"); ary[zid] = n.id;};zkau.cleanzid = function (n) { var oid = zkau._zidOwner(n); var ary = zkau._zidsp[oid]; if (ary) delete ary[getZKAttr(n, "zid")];};/** Clean an ID space. */zkau.cleanzidsp = function (n) { delete zkau._zidsp[n.id];};/** Returns the space owner that n belongs to, or null if not found. */zkau._zidOwner = function (n) { //zidsp currently applied only to page, since we'd like //developers easy to reference other component in the same page //If you want to support a new space, just generae zidsp="true" for (var p = n; p; p = $parent(p)) { if (getZKAttr(p, "zidsp")) return p.id; } return "_zdt_" + zkau.dtid(n);};/////////////////Drag & Drop//zkau.initdrag = function (n) { zkau._drags[n.id] = new Draggable(n, { starteffect: zkau.closeFloats, endeffect: zkau._enddrag, change: zkau._dragging, ghosting: zkau._ghostdrag, z_dragdrop: true, revert: zkau._revertdrag, ignoredrag: zkau._ignoredrag });};zkau.cleandrag = function (n) { if (zkau._drags[n.id]) { zkau._drags[n.id].destroy(); delete zkau._drags[n.id]; }};zkau.initdrop = function (n) { zkau._drops.unshift(n); //last created, first matched};zkau.cleandrop = function (n) { zkau._drops.remove(n);};zkau._ignoredrag = function (el, pointer) { return zk.eval(el, "ignoredrag", null, pointer);};zkau._dragging = function (dg, pointer) { var e = zkau._getDrop(dg.z_elorg || dg.element, pointer); if (!e || e != dg.zk_lastDrop) { zkau._cleanLastDrop(dg); if (e) { dg.zk_lastDrop = e; Droppable_effect(e); } }};zkau._revertdrag = function (cmp, pointer) { if (zkau._getDrop(cmp, pointer) == null) return true; //Note: we hve to revert when zkau._onRespReady called, since app might //change cmp's position var dg = zkau._drags[cmp.id]; var orgpos = cmp.style.position; zkau._revertpending = function () { //Bug 1599737: a strange bar appears if (zk.ie && orgpos != 'absolute' && orgpos != 'relative') zkau._fixie4drop(cmp, orgpos); if (dg.z_x != null) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -