UNPKG

sunshine-ui-layx

Version:

基于Layx的Web弹窗组件

866 lines 115 kB
/*! * file : layx.js * gitee : https://gitee.com/monksoul/LayX * github : https://github.com/MonkSoul/Layx/ * author : 百小僧/MonkSoul * version : v2.5.4 * create time : 2018.05.11 * update time : 2018.11.03 */ (function(G, b, U) { var c = { version: "2.5.4", defaults: { id: "", icon: !0, title: "", width: 800, height: 600, minWidth: 200, minHeight: 200, position: "ct", storeStatus: !0, control: !0, style: "", controlStyle: "", existFlicker: !0, bgColor: "#fff", shadow: !0, border: !0, borderRadius: "3px", skin: "default", type: "html", focusToReveal: !0, enableDomainFocus: !0, dialogType: "", frames: [], frameIndex: 0, preload: 1, mergeTitle: !0, content: "", dialogIcon: !1, cloneElementContent: !0, url: "", useFrameTitle: !1, opacity: 1, escKey: !0, floatTarget: !1, floatDirection: "bottom", shadable: !1, shadeDestroy: !1, readonly: !1, loadingText: "内容正在加载中,请稍后", dragInTopToMax: !0, isOverToMax: !0, stickMenu: !1, stickable: !0, minMenu: !0, minable: !0, maxMenu: !0, maxable: !0, closeMenu: !0, closable: !0, debugMenu: !1, restorable: !0, resizable: !0, autodestroy: !1, autodestroyText: "此窗口将在 <strong>{second}</strong> 秒内自动关闭.", resizeLimit: { t: !1, r: !1, b: !1, l: !1, lt: !1, rt: !1, lb: !1, rb: !1 }, buttonKey: "enter", buttons: [], movable: !0, moveLimit: { vertical: !1, horizontal: !1, leftOut: !0, rightOut: !0, topOut: !0, bottomOut: !0 }, focusable: !0, alwaysOnTop: !1, allowControlDbclick: !0, statusBar: !1, statusBarStyle: "", event: { onload: { before: function(e, a) { }, after: function(e, a) { } }, onmin: { before: function(e, a) { }, after: function(e, a) { } }, onmax: { before: function(e, a) { }, after: function(e, a) { } }, onrestore: { before: function(e, a) { }, after: function(e, a) { } }, ondestroy: { before: function(e, a, t, r, i) { }, after: function() { } }, onvisual: { before: function(e, a, t, r, i) { }, after: function(e, a, t) { } }, onmove: { before: function(e, a) { }, progress: function(e, a) { }, after: function(e, a) { } }, onresize: { before: function(e, a) { }, progress: function(e, a) { }, after: function(e, a) { } }, onfocus: function(e, a) { }, onexist: function(e, a) { }, onswitch: { before: function(e, a, t) { }, after: function(e, a, t) { } }, onstick: { before: function(e, a) { }, after: function(e, a) { } } } }, defaultButtons: { label: "确定", callback: function(e, a, t) { }, id: "", classes: [], style: "" }, defaultFrames: { id: "", title: "", type: "html", url: "", content: "", useFrameTitle: !1, cloneElementContent: !0, bgColor: "#fff" }, zIndex: 1e7, windows: {}, stickZIndex: 2e7, prevFocusId: null, focusId: null, create: function(e) { var a = this, t = layxDeepClone({}, a.defaults, e || {}), r = {}; if (!t.id) { console.error("窗口id不能为空且唯一"); return; } c.prevFocusId = c.focusId, c.focusId = t.id; var i = a.windows[t.id]; if (i) { i.status === "min" && a.restore(i.id), i.existFlicker === !0 && a.flicker(t.id), u.isFunction(t.event.onexist) && t.event.onexist(i.layxWindow, i); var fe = setInterval(function() { t.id !== c.focusId ? a.updateZIndex(t.id) : clearInterval(fe); }, 0); return i; } if (u.isArray(t.frames)) { for (var o = 0; o < t.frames.length; o++) if (t.frames[o] = layxDeepClone({}, a.defaultFrames, t.frames[o]), !t.frames[o].id) { console.error("窗口组窗口id不能为空且窗口组内唯一"); return; } } if (u.isArray(t.buttons)) for (var o = 0; o < t.buttons.length; o++) t.buttons[o] = layxDeepClone({}, a.defaultButtons, t.buttons[o]); if (t.shadable === !0 || /^(0(\.[0-9])?$)|(1)$/.test(t.shadable)) { var s = document.createElement("div"); s.setAttribute("id", "layx-" + t.id + "-shade"), s.classList.add("layx-shade"), s.style.zIndex = t.alwaysOnTop === !0 ? ++a.stickZIndex : ++a.zIndex, /^(0(\.[0-9])?$)|(1)$/.test(t.shadable) && (s.style.backgroundColor = "rgba(0,0,0," + t.shadable + ")"), s.oncontextmenu = function(h) { return h = h || window.event, h.returnValue = !1, !1; }, s.onclick = function(h) { h = h || window.event, t.shadeDestroy === !0 ? a.destroy(t.id, null, !0) : t.existFlicker === !0 && a.flicker(t.id), h.stopPropagation(); }, document.body.appendChild(s); } if (t.style) { var l = document.getElementById("layx-style"); l ? l.innerHTML += t.style : (l = document.createElement("style"), l.setAttribute("id", "layx-style"), l.type = "text/css", l.innerHTML = t.style, document.getElementsByTagName("HEAD").item(0).appendChild(l)); } var n = document.createElement("div"); n.setAttribute("id", "layx-" + t.id), n.classList.add("layx-window"), n.classList.add("layx-flexbox"), n.classList.add("layx-skin-" + t.skin), t.shadow === !0 && (n.style.setProperty("box-shadow", "1px 1px 24px rgba(0, 0, 0, .3)"), n.style.setProperty("-moz-box-shadow", "1px 1px 24px rgba(0, 0, 0, .3)"), n.style.setProperty("-webkit-box-shadow", "1px 1px 24px rgba(0, 0, 0, .3)")); var d, f, m, p, y, x; d = u.compileLayxWidthOrHeight("width", t.minWidth, a.defaults.minWidth), f = u.compileLayxWidthOrHeight("height", t.minHeight, a.defaults.minHeight), m = u.compileLayxWidthOrHeight("width", t.width, a.defaults.width), p = u.compileLayxWidthOrHeight("height", t.height, a.defaults.height), m = Math.max(m, d), p = Math.max(p, f); var w = u.compileLayxPosition(m, p, t.position); if (y = w.top, x = w.left, y = Math.max(y, 0), y = Math.min(b.innerHeight - 15, y), x = Math.max(x, -(m - 15)), x = Math.min(x, b.innerWidth - 15), t.storeStatus === !0 && t.floatTarget === !1) { var L = a.getStoreWindowAreaInfo(t.id); L ? (m = L.width, p = L.height, y = L.top, x = L.left) : a.storeWindowAreaInfo(t.id, { width: m, height: p, top: y, left: x }); } else a.removeStoreWindowAreaInfo(t.id); if (u.isDom(t.floatTarget)) { n.classList.add("layx-bubble-type"); var k = document.createElement("div"); k.classList.add("layx-bubble"), k.classList.add("layx-bubble-" + t.floatDirection), n.appendChild(k); var D = document.createElement("div"); D.classList.add("layx-bubble-inlay"), D.classList.add("layx-bubble-inlay-" + t.floatDirection), k.appendChild(D); } n.style.zIndex = t.alwaysOnTop === !0 ? ++a.stickZIndex : ++a.zIndex, n.style.width = m + "px", n.style.height = p + "px", n.style.minWidth = d + "px", n.style.minHeight = f + "px", n.style.top = y + "px", n.style.left = x + "px", n.style.setProperty("border", u.isBoolean(t.border) ? t.skin === "default" && t.border === !0 ? "" : "none" : t.border), n.style.backgroundColor = t.bgColor, n.style.setProperty("border-radius", t.borderRadius), n.style.setProperty("-moz-border-radius", t.borderRadius), n.style.setProperty("-webkit-border-radius", t.borderRadius), n.style.opacity = /^(0(\.[0-9])?$)|(1)$/.test(t.opacity) ? t.opacity : 1, t.focusable === !0 && (n.onclick = function(h) { if (u.isFunction(t.event.onfocus)) { var C = u.isFunction(t.event.onfocus); if (C === !1) return; t.event.onfocus(n, r); } a.updateZIndex(t.id); }), document.body.appendChild(n); var T = n.currentStyle ? n.currentStyle : b.getComputedStyle(n, null); if (r.id = t.id, r.title = t.title, r.layxWindowId = n.getAttribute("id"), r.layxWindow = n, r.createDate = /* @__PURE__ */ new Date(), r.status = "normal", r.type = t.type, r.buttons = t.buttons, r.frames = t.frames, r.useFrameTitle = t.useFrameTitle, r.cloneElementContent = t.cloneElementContent, r.storeStatus = t.storeStatus, r.url = t.url, r.content = t.content, r.escKey = t.escKey, r.focusToReveal = t.focusToReveal, r.dialogType = t.dialogType, r.enableDomainFocus = t.enableDomainFocus, r.buttonKey = t.buttonKey, r.existFlicker = t.existFlicker, r.groupCurrentId = u.isArray(t.frames) && t.frames.length > 0 && t.frames[t.frameIndex] ? t.frames[t.frameIndex].id : null, r.area = { width: m, height: p, minWidth: d, minHeight: f, top: y, left: x }, r.border = t.border, r.control = t.control, r.isFloatTarget = u.isDom(t.floatTarget), r.floatTarget = t.floatTarget, r.floatDirection = t.floatDirection, r.loadingText = t.loadingText, r.focusable = t.focusable, r.isStick = t.alwaysOnTop === !0, r.zIndex = t.alwaysOnTop === !0 ? a.stickZIndex : a.zIndex, r.movable = t.movable, r.moveLimit = t.moveLimit, r.resizable = t.resizable, r.resizeLimit = t.resizeLimit, r.stickable = t.stickable, r.minable = t.minable, r.maxable = t.maxable, r.restorable = t.restorable, r.closable = t.closable, r.skin = t.skin, r.event = t.event, r.dragInTopToMax = t.dragInTopToMax, a.windows[t.id] = r, t.control === !0) { var E = document.createElement("div"); if (E.classList.add("layx-control-bar"), E.classList.add("layx-flexbox"), E.style.setProperty("border-radius", T.borderRadius + " " + T.borderRadius + " 0 0"), E.style.setProperty("-moz-border-radius", T.borderRadius + " " + T.borderRadius + " 0 0"), E.style.setProperty("-webkit-border-radius", T.borderRadius + " " + T.borderRadius + " 0 0"), t.controlStyle && E.setAttribute("style", t.controlStyle), t.type === "group" && t.mergeTitle === !0 && E.classList.add("layx-type-group"), n.appendChild(E), t.icon !== !1) { var $ = document.createElement("div"); $.classList.add("layx-left-bar"), $.classList.add("layx-flexbox"), $.classList.add("layx-flex-vertical"), E.appendChild($); var _ = document.createElement("div"); _.classList.add("layx-icon"), _.classList.add("layx-window-icon"), _.innerHTML = t.icon === !0 ? '<svg class="layx-iconfont" aria-hidden="true"><use xlink:href="#layx-icon-default-icon"></use></svg>' : t.icon, t.icon === !0 && (_.ondblclick = function(h) { h = h || window.event, a.destroy(t.id, null, !0), h.stopPropagation(); }), $.appendChild(_); } var z = document.createElement("div"); if (z.classList.add("layx-title"), z.classList.add("layx-flexauto"), z.classList.add("layx-flexbox"), z.classList.add("layx-flex-vertical"), t.type === "group" && t.mergeTitle === !0 && z.classList.add("layx-type-group"), t.allowControlDbclick === !0 && (z.ondblclick = function(h) { h = h || window.event, t.restorable === !0 && a.restore(t.id), h.stopPropagation(); }), t.movable === !0 && u.isDom(t.floatTarget) == !1 && new g(z), E.appendChild(z), t.type !== "group") { var q = document.createElement("label"); q.classList.add("layx-label"), q.innerHTML = t.useFrameTitle === !0 ? "" : t.title, z.setAttribute("title", q.innerText), z.appendChild(q); } else if (u.isArray(t.frames)) { if (t.mergeTitle === !1) { var j = document.createElement("div"); j.classList.add("layx-group-tab"), j.classList.add("layx-flexbox"), j.classList.add("layx-type-group"), n.appendChild(j); var q = document.createElement("label"); q.classList.add("layx-label"), q.innerHTML = t.useFrameTitle === !0 ? "" : t.title, z.setAttribute("title", q.innerText), z.appendChild(q); } for (var o = 0; o < t.frames.length; o++) { var W = layxDeepClone({}, a.defaultFrames, t.frames[o]), I = document.createElement("div"); I.setAttribute("data-frameId", W.id), I.classList.add("layx-group-title"), I.classList.add("layx-flexauto"), I.classList.add("layx-flex-vertical"), o === t.frameIndex && I.setAttribute("data-enable", "1"), u.isSupportTouch ? (I.ontouchstart = function(C) { a._setGroupIndex(t.id, this); }, u.IsPC() && (I.onclick = function(C) { C = C || window.event, a._setGroupIndex(t.id, this), C.stopPropagation(); })) : I.onclick = function(C) { C = C || window.event, a._setGroupIndex(t.id, this), C.stopPropagation(); }, t.mergeTitle === !1 ? j.appendChild(I) : z.appendChild(I); var oe = document.createElement("label"); oe.classList.add("layx-label"), oe.innerHTML = W.title, I.setAttribute("title", oe.innerText), I.appendChild(oe); } } var V = document.createElement("div"); V.classList.add("layx-right-bar"), V.classList.add("layx-flexbox"), E.appendChild(V); var de = document.createElement("div"); if (de.classList.add("layx-custom-menus"), de.classList.add("layx-flexbox"), V.appendChild(de), t.stickMenu === !0 || t.minMenu === !0 || t.maxMenu === !0 || t.closeMenu === !0 || t.debugMenu === !0) { var O = document.createElement("div"); if (O.classList.add("layx-inlay-menus"), O.classList.add("layx-flexbox"), V.appendChild(O), !u.isDom(t.floatTarget)) { if (t.debugMenu === !0) { var R = document.createElement("div"); R.classList.add("layx-icon"), R.classList.add("layx-flexbox"), R.classList.add("layx-flex-center"), R.classList.add("layx-debug-menu"), R.setAttribute("title", "调试信息"), R.innerHTML = '<svg class="layx-iconfont" aria-hidden="true"><use xlink:href="#layx-icon-debug"></use></svg>', R.onclick = function(h) { var C = JSON.stringify(r, null, 4).replace(/</g, "&lt;").replace(/>/g, "&gt;"); a.create({ id: "layx-" + t.id + "-debug", title: "窗口调试信息", width: 300, height: 300, content: '<div class="layx-padding" style="padding:10px;height:100%;overflow:hidden;"><div class="layx-code"><pre class="layx-pre">' + C + "</pre></div></div>", shadable: !0, debugMenu: !1, minMenu: !1, minable: !1, position: [n.offsetTop + 10, n.offsetLeft + 10], storeStatus: !1 }); }, O.appendChild(R); } if (t.stickMenu === !0 || t.alwaysOnTop === !0 && t.stickMenu) { var M = document.createElement("div"); M.classList.add("layx-icon"), M.classList.add("layx-flexbox"), M.classList.add("layx-flex-center"), M.classList.add("layx-stick-menu"), t.alwaysOnTop === !0 ? M.setAttribute("title", "取消置顶") : M.setAttribute("title", "置顶"), t.alwaysOnTop === !0 && M.setAttribute("data-enable", "1"), M.innerHTML = '<svg class="layx-iconfont" aria-hidden="true"><use xlink:href="#layx-icon-stick"></use></svg>', t.stickable === !0 && (M.onclick = function(h) { a.stickToggle(t.id); }), O.appendChild(M); } if (t.minMenu === !0) { var P = document.createElement("div"); P.classList.add("layx-icon"), P.classList.add("layx-flexbox"), P.classList.add("layx-flex-center"), P.classList.add("layx-min-menu"), P.setAttribute("title", "最小化"), P.setAttribute("data-menu", "min"), P.innerHTML = '<svg class="layx-iconfont" aria-hidden="true"><use xlink:href="#layx-icon-min"></use></svg>', P.onclick = function(h) { this.classList.contains("layx-restore-menu") ? t.restorable === !0 && a.restore(t.id) : t.minable === !0 && a.min(t.id); }, O.appendChild(P); } if (t.maxMenu === !0) { var H = document.createElement("div"); H.classList.add("layx-icon"), H.classList.add("layx-flexbox"), H.classList.add("layx-flex-center"), H.classList.add("layx-max-menu"), H.setAttribute("title", "最大化"), H.setAttribute("data-menu", "max"), H.innerHTML = '<svg class="layx-iconfont" aria-hidden="true"><use xlink:href="#layx-icon-max"></use></svg>', H.onclick = function(h) { this.classList.contains("layx-restore-menu") ? t.restorable === !0 && a.restore(t.id) : t.maxable === !0 && a.max(t.id); }, O.appendChild(H); } } if (t.closeMenu === !0) { var N = document.createElement("div"); N.classList.add("layx-icon"), N.classList.add("layx-flexbox"), N.classList.add("layx-flex-center"), N.classList.add("layx-destroy-menu"), N.setAttribute("title", "关闭"), N.innerHTML = '<svg class="layx-iconfont" aria-hidden="true"><use xlink:href="#layx-icon-destroy"></use></svg>', N.onclick = function(h) { t.closable === !0 && a.destroy(t.id, null, !0); }, O.appendChild(N); } } } var S = document.createElement("div"); if (S.classList.add("layx-main"), S.classList.add("layx-flexauto"), t.statusBar || (S.style.setProperty("border-radius", "0 0 " + T.borderRadius + " " + T.borderRadius), S.style.setProperty("-moz-border-radius", "0 0 " + T.borderRadius + " " + T.borderRadius), S.style.setProperty("-webkit-border-radius", "0 0 " + T.borderRadius + " " + T.borderRadius)), n.appendChild(S), t.readonly === !0) { var ne = document.createElement("div"); ne.classList.add("layx-readonly"), ne.oncontextmenu = function(h) { return h = h || window.event, h.returnValue = !1, !1; }, t.focusable === !0 && (ne.onclick = function(h) { if (h = h || window.event, u.isFunction(t.event.onfocus)) { var C = u.isFunction(t.event.onfocus); if (C === !1) return; t.event.onfocus(n, r); } a.updateZIndex(t.id), h.stopPropagation(); }), S.appendChild(ne); } switch (t.type) { case "html": default: if (u.isFunction(t.event.onload.before)) { var X = t.event.onload.before(n, r); if (X === !1) return; } var K = a.createContenLoadAnimate(S, t.loadingText, r); a.createHtmlBody(S, t, t.content), K && S.removeChild(K), r.loadingTextTimer && (clearInterval(r.loadingTextTimer), delete r.loadingTextTimer), u.isFunction(t.event.onload.after) && t.event.onload.after(n, r); break; case "url": if (u.isFunction(t.event.onload.before)) { var X = t.event.onload.before(n, r); if (X === !1) return; } var K = a.createContenLoadAnimate(S, t.loadingText, r); a.createFrameBody(S, t, n, r); break; case "group": if (u.isArray(t.frames)) { if (u.isFunction(t.event.onload.before)) { var X = t.event.onload.before(n, r); if (X === !1) return; } var K = a.createContenLoadAnimate(S, t.loadingText, r); t.preload = /(^[1-9]\d*$)/.test(t.preload) === !1 ? !0 : Math.min(t.preload, t.frames.length); for (var me = setInterval(function() { var C = n.querySelectorAll(".layx-group-main[data-complete='1']"); (C.length === u.isBoolean(t.preload) ? t.frames.length : t.preload) && (clearInterval(me), r.loadingTextTimer && (clearInterval(r.loadingTextTimer), delete r.loadingTextTimer), n.setAttribute("data-group-init", "1"), K && S.removeChild(K), u.isFunction(t.event.onload.after) && t.event.onload.after(n, r)); }, 100), o = 0; o < t.frames.length; o++) { var W = layxDeepClone({}, a.defaultFrames, t.frames[o]), Z = document.createElement("div"); Z.classList.add("layx-group-main"), Z.style.backgroundColor = W.bgColor, Z.setAttribute("data-frameId", W.id), o === t.frameIndex && Z.setAttribute("data-enable", "1"), S.appendChild(Z); var ue = o === t.frameIndex || u.isBoolean(t.preload) ? !0 : o + 1 <= t.preload; W.type === "html" ? (a.createHtmlBody(Z, t, W.content, "group", W, ue), ue && Z.setAttribute("data-complete", "1")) : W.type === "url" && a.createFrameBody(Z, t, n, r, "group", W, ue); } } break; } if (/(^[1-9]\d*$)/.test(t.autodestroy)) { var se = t.autodestroy / 1e3; if (t.autodestroyText !== !1) { var le = document.createElement("div"); le.classList.add("layx-auto-destroy-tip"), le.innerHTML = t.autodestroyText.replace("{second}", se), n.appendChild(le); } r.destroyTimer = setInterval(function() { --se, t.autodestroyText !== !1 && (le.innerHTML = t.autodestroyText.replace("{second}", se)), se <= 0 && (clearInterval(r.destroyTimer), a.destroy(t.id, null, !0)); }, 1e3); } var F = document.createElement("div"); F.classList.add("layx-resizes"), t.resizable === !1 && F.setAttribute("data-enable", "0"), n.appendChild(F); var Y = document.createElement("div"); Y.classList.add("layx-resize-top"), u.isSupportTouch && Y.classList.add("layx-reisize-touch"), t.resizeLimit.t === !0 && Y.setAttribute("data-enable", "0"), new v(Y, !0, !1, !0, !1), F.appendChild(Y); var J = document.createElement("div"); J.classList.add("layx-resize-left"), u.isSupportTouch && J.classList.add("layx-reisize-touch"), t.resizeLimit.l === !0 && J.setAttribute("data-enable", "0"), new v(J, !1, !0, !1, !0), F.appendChild(J); var Q = document.createElement("div"); Q.classList.add("layx-resize-left-top"), u.isSupportTouch && Q.classList.add("layx-reisize-touch"), t.resizeLimit.lt === !0 && Q.setAttribute("data-enable", "0"), new v(Q, !0, !0, !1, !1), F.appendChild(Q); var ee = document.createElement("div"); ee.classList.add("layx-resize-right-top"), u.isSupportTouch && ee.classList.add("layx-reisize-touch"), t.resizeLimit.rt === !0 && ee.setAttribute("data-enable", "0"), new v(ee, !0, !1, !1, !1), F.appendChild(ee); var te = document.createElement("div"); te.classList.add("layx-resize-left-bottom"), u.isSupportTouch && te.classList.add("layx-reisize-touch"), t.resizeLimit.lb === !0 && te.setAttribute("data-enable", "0"), new v(te, !1, !0, !1, !1), F.appendChild(te); var ae = document.createElement("div"); ae.classList.add("layx-resize-right"), u.isSupportTouch && ae.classList.add("layx-reisize-touch"), t.resizeLimit.r === !0 && ae.setAttribute("data-enable", "0"), new v(ae, !1, !1, !1, !0), F.appendChild(ae); var re = document.createElement("div"); re.classList.add("layx-resize-bottom"), u.isSupportTouch && re.classList.add("layx-reisize-touch"), t.resizeLimit.b === !0 && re.setAttribute("data-enable", "0"), new v(re, !1, !1, !0, !1), F.appendChild(re); var ie = document.createElement("div"); if (ie.classList.add("layx-resize-right-bottom"), u.isSupportTouch && ie.classList.add("layx-reisize-touch"), t.resizeLimit.rb === !0 && ie.setAttribute("data-enable", "0"), new v(ie, !1, !1, !1, !1), F.appendChild(ie), t.statusBar) { var B = document.createElement("div"); if (B.classList.add("layx-statu-bar"), B.style.setProperty("border-radius", "0 0 " + T.borderRadius + " " + T.borderRadius), B.style.setProperty("-moz-border-radius", "0 0 " + T.borderRadius + " " + T.borderRadius), B.style.setProperty("-webkit-border-radius", "0 0 " + T.borderRadius + " " + T.borderRadius), t.statusBarStyle && B.setAttribute("style", t.statusBarStyle), t.statusBar === !0 && u.isArray(t.buttons)) { var ce = a.createLayxButtons(t.buttons, t.id, t.dialogType === "prompt"); ce && B.appendChild(ce); } else u.isDom(t.statusBar) ? B.appendChild(t.statusBar) : B.innerHTML = t.statusBar; n.appendChild(B); } u.isDom(t.floatTarget) && a.updateFloatWinPosition(t.id, t.floatDirection), t.isOverToMax === !0 && u.isDom(t.floatTarget) === !1 && (m > window.innerWidth || p > window.innerHeight) && a.max(t.id); var fe = setInterval(function() { t.id !== c.focusId ? a.updateZIndex(t.id) : clearInterval(fe); }, 0); return r; }, updateFloatWinPosition: function(e, a) { var t = this, r = "layx-" + e, i = document.getElementById(r), o = t.windows[e], s = ["top", "bottom", "left", "right"]; if (i && o && o.isFloatTarget === !0) { a = s.indexOf(a) > -1 ? a : o.floatDirection; var l = i.querySelector(".layx-bubble"), n = i.querySelector(".layx-bubble-inlay"); if (l && n) { l.classList.remove("layx-bubble-" + o.floatDirection), l.style["border" + o.floatDirection.toFirstUpperCase() + "Color"] = "transparent", n.classList.remove("layx-bubble-inlay-" + o.floatDirection), n.style["border" + o.floatDirection.toFirstUpperCase() + "Color"] = "transparent", l.classList.add("layx-bubble-" + a), n.classList.add("layx-bubble-inlay-" + a); var d = i.currentStyle ? i.currentStyle : b.getComputedStyle(i, null), f = i.querySelector(".layx-control-bar"), m = f && (f.currentStyle ? f.currentStyle : b.getComputedStyle(f, null)); o.control === !0 && f && m ? (l.style["border" + a.toFirstUpperCase() + "Color"] = d.borderColor === "rgba(0, 0, 0, 0)" || d.borderColor === "transparent" || !d.borderColor || u.isBoolean(o.border) ? o.skin === "default" ? "#3baced" : m.backgroundColor : d.borderColor, n.style["border" + a.toFirstUpperCase() + "Color"] = m.backgroundColor) : (l.style["border" + a.toFirstUpperCase() + "Color"] = d.borderColor === "rgba(0, 0, 0, 0)" || d.borderColor === "transparent" || !d.borderColor || u.isBoolean(o.border) ? o.skin === "default" ? "#3baced" : "#fff" : d.borderColor, n.style["border" + a.toFirstUpperCase() + "Color"] = d.backgroundColor); var p = u.compilebubbleDirection(a, o.floatTarget, o.area.width, o.area.height); t.setPosition(e, { top: p.top, left: p.left }, !0); var y = u.getElementPos(o.floatTarget); (a === "top" || a === "bottom") && (l.style.left = Math.abs(y.x + o.floatTarget.offsetWidth / 2 - o.layxWindow.offsetLeft - 9) + "px"), (a === "left" || a === "right") && (l.style.top = Math.abs(y.y + o.floatTarget.offsetHeight / 2 - o.layxWindow.offsetTop - 9) + "px"), (a === "top" || (a === "right" || a === "left") && o.control === !0 && f && m && l.offsetTop > f.offsetHeight) && (l.style["border" + a.toFirstUpperCase() + "Color"] = d.borderColor === "rgba(0, 0, 0, 0)" || d.borderColor === "transparent" || !d.borderColor || u.isBoolean(o.border) ? o.skin === "default" ? "#3baced" : "#fff" : d.borderColor, n.style["border" + a.toFirstUpperCase() + "Color"] = d.backgroundColor), o.floatDirection = a, t.updateFloatWinResize(e, a); } } }, updateFloatWinResize: function(e, a) { var t = this, r = "layx-" + e, i = document.getElementById(r), o = t.windows[e], s = ["top", "bottom", "left", "right"]; if (i && o && o.isFloatTarget === !0) switch (a = s.indexOf(a) > -1 ? a : o.floatDirection, a) { case "bottom": i.querySelector(".layx-resize-left").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-top").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-left-top").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-left-bottom").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-right-top").setAttribute("data-enable", "0"), o.resizeLimit.r === !1 && i.querySelector(".layx-resize-right").removeAttribute("data-enable"), o.resizeLimit.b === !1 && i.querySelector(".layx-resize-bottom").removeAttribute("data-enable"), o.resizeLimit.rb === !1 && i.querySelector(".layx-resize-right-bottom").removeAttribute("data-enable"); break; case "top": i.querySelector(".layx-resize-left").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-left-top").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-bottom").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-left-bottom").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-right-bottom").setAttribute("data-enable", "0"), o.resizeLimit.r === !1 && i.querySelector(".layx-resize-right").removeAttribute("data-enable"), o.resizeLimit.t === !1 && i.querySelector(".layx-resize-top").removeAttribute("data-enable"), o.resizeLimit.rt === !1 && i.querySelector(".layx-resize-right-top").removeAttribute("data-enable"); break; case "right": i.querySelector(".layx-resize-left").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-top").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-left-top").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-left-bottom").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-right-top").setAttribute("data-enable", "0"), o.resizeLimit.r === !1 && i.querySelector(".layx-resize-right").removeAttribute("data-enable"), o.resizeLimit.b === !1 && i.querySelector(".layx-resize-bottom").removeAttribute("data-enable"), o.resizeLimit.rb === !1 && i.querySelector(".layx-resize-right-bottom").removeAttribute("data-enable"); break; case "left": i.querySelector(".layx-resize-top").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-right").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-left-top").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-right-top").setAttribute("data-enable", "0"), i.querySelector(".layx-resize-right-bottom").setAttribute("data-enable", "0"), o.resizeLimit.l === !1 && i.querySelector(".layx-resize-left").removeAttribute("data-enable"), o.resizeLimit.b === !1 && i.querySelector(".layx-resize-bottom").removeAttribute("data-enable"), o.resizeLimit.lb === !1 && i.querySelector(".layx-resize-left-bottom").removeAttribute("data-enable"); break; } }, removeStoreWindowAreaInfo: function(e) { var a = "layx-" + e, t = typeof Storage < "u" && !(b.location.protocol.indexOf("file:") > -1) && localStorage.getItem(a); t && localStorage.removeItem(a); }, storeWindowAreaInfo: function(e, a) { var t = "layx-" + e; typeof Storage < "u" && !(b.location.protocol.indexOf("file:") > -1) && localStorage.setItem(t, JSON.stringify(a)); }, getStoreWindowAreaInfo: function(e) { var a = "layx-" + e, t = typeof Storage < "u" && !(b.location.protocol.indexOf("file:") > -1) && localStorage.getItem(a); return t ? JSON.parse(t) : null; }, _setGroupIndex: function(e, a) { var t = this, r = "layx-" + e, i = document.getElementById(r), o = t.windows[e]; if (i && o && o.type === "group") { var s = i.querySelector(".layx-group-title[data-enable='1']"); if (s !== a) { if (u.isFunction(o.event.onswitch.before)) { var l = o.event.onswitch.before(i, o, s.getAttribute("data-frameId")); if (l === !1) return; } s.removeAttribute("data-enable"), a.setAttribute("data-enable", "1"); var n = a.getAttribute("data-frameId"), d = i.querySelector(".layx-group-main[data-enable='1']"), f = i.querySelector(".layx-group-main[data-frameId='" + n + "']"); if (f !== d && (d.removeAttribute("data-enable"), f.setAttribute("data-enable", "1"), o.groupCurrentId = n, f.getAttribute("data-preload") === "1")) { var m = t.getGroupFrame(o.frames, n); m.type === "url" && (t.setGroupUrl(e, n, m.url), f.removeAttribute("data-preload")), m.type === "html" && (t.setGroupContent(e, n, m.content, m.cloneElementContent), f.removeAttribute("data-preload")); } u.isFunction(o.event.onswitch.after) && o.event.onswitch.after(i, o, a.getAttribute("data-frameId")); } } }, setGroupIndex: function(e, a) { var t = this, r = "layx-" + e, i = document.getElementById(r), o = t.windows[e]; if (i && o) { var s = i.querySelector(".layx-group-title[data-frameId='" + a + "']"); s.click(); } }, cloneStore: {}, createHtmlBody: function(e, a, t, r, i, o) { var s = document.createElement("div"); s.classList.add("layx-html"), s.setAttribute("id", "layx-" + a.id + (r === "group" ? "-" + i.id + "-" : "-") + "html"); var l; if (o !== !1) if (u.isDom(t)) { var n = t.currentStyle ? t.currentStyle : b.getComputedStyle(t, null); r !== "group" && a.cloneElementContent === !1 && (c.cloneStore[a.id] = { prev: t.previousSibling, parent: t.parentNode, next: t.nextSibling, display: n.display }), r === "group" && i.cloneElementContent === !1 && (c.cloneStore[a.id] || (c.cloneStore[a.id] = { frames: {} }), c.cloneStore[a.id].frames[i.id] = { prev: t.previousSibling, parent: t.parentNode, next: t.nextSibling, display: n.display }), l = s.appendChild((r === "group" ? i : a).cloneElementContent === !0 ? t.cloneNode(!0) : t); } else s.innerHTML = t; else e.setAttribute("data-preload", "1"); if (e.appendChild(s), u.isDom(l)) { var d = l.currentStyle ? l.currentStyle : b.getComputedStyle(l, null); d.display === "none" && (l.style.display = ""); } }, frameLoadHandle: function(e, a, t, r, i, o, s, l) { var n = this, d = (o === "group" ? e.parentNode.parentNode : e.parentNode).querySelector(".layx-content-shade"); try { t.focusable === !0 && t.enableDomainFocus === !0 && (e.getAttribute("data-focus") || (A.track(e, function() { if (u.isFunction(t.event.onfocus)) { var m = u.isFunction(t.event.onfocus); if (m === !1) return; t.event.onfocus(r, i); } n.updateZIndex(t.id); }), e.setAttribute("data-focus", "true"))); var f = t.title; o === "group" ? s.useFrameTitle === !0 && (f = e.contentWindow.document.querySelector("title").innerText, n.setGroupTitle(t.id, s.id, f)) : t.useFrameTitle === !0 && (f = e.contentWindow.document.querySelector("title").innerText, n.setTitle(t.id, f)), e.contentWindow.document.addEventListener("click", function(m) { var p = m || window.event || arguments.callee.caller.arguments[0]; if (t.focusable === !0) { if (u.isFunction(t.event.onfocus)) { var y = u.isFunction(t.event.onfocus); if (y === !1) return; t.event.onfocus(r, i); } n.updateZIndex(t.id); } }, !1), e.contentWindow.document.addEventListener("keydown", function(m) { var p = m || window.event || arguments.callee.caller.arguments[0], y = c.windows[c.focusId]; if (p && p.keyCode == 27 && y && c.destroy(c.focusId, {}, !1, !0), p && p.keyCode === 13 && y && y.buttons.length > 0) { if (y.buttonKey.toLowerCase() === "enter" && !p.ctrlKey) if (y.dialogType !== "prompt") y.buttons[0].callback(y.id, c.getButton(y.id, y.buttons[0].id, p)); else { var x = c.getPromptTextArea(y.id); y.buttons[0].callback(y.id, (x ? x.value : "").replace(/(^\s*)|(\s*$)/g, ""), x, c.getButton(y.id, y.buttons[0].id, p)); } else if (y.buttonKey.toLowerCase() === "ctrl+enter" && p.ctrlKey) if (y.dialogType !== "prompt") y.buttons[0].callback(y.id, c.getButton(y.id, y.buttons[0].id, p)); else { var x = c.getPromptTextArea(y.id); y.buttons[0].callback(y.id, (x ? x.value : "").replace(/(^\s*)|(\s*$)/g, ""), x, c.getButton(y.id, y.buttons[0].id, p)); } } }, !1); } catch (m) { o === "group" && d && d.parentNode.removeChild(d), console.warn(m); } finally { o === "group" ? (l && a.setAttribute("data-complete", "1"), r.getAttribute("data-group-init") === "1" && (i.loadingTextTimer && (clearInterval(i.loadingTextTimer), delete i.loadingTextTimer), d && d.parentNode.removeChild(d), u.isFunction(t.event.onload.after) && t.event.onload.after(r, i))) : (d && d.parentNode.removeChild(d), i.loadingTextTimer && (clearInterval(i.loadingTextTimer), delete i.loadingTextTimer), u.isFunction(t.event.onload.after) && t.event.onload.after(r, i)); } }, createFrameBody: function(e, a, t, r, i, o, s) { var l = this, n = document.createElement("iframe"); n.setAttribute("id", "layx-" + a.id + (i === "group" ? "-" + o.id + "-" : "-") + "iframe"), n.classList.add("layx-iframe"), n.classList.add("layx-flexbox"), n.setAttribute("allowtransparency", "true"), n.setAttribute("frameborder", "0"), b.navigator.userAgent.toLowerCase().indexOf("iphone") > -1 || navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) ? n.setAttribute("scrolling", "no") : n.setAttribute("scrolling", "auto"), n.setAttribute("allowfullscreen", ""), n.setAttribute("mozallowfullscreen", ""), n.setAttribute("webkitallowfullscreen", ""), n.src = s !== !1 && (i === "group" ? o.url : a.url) || "about:blank", n.attachEvent ? n.attachEvent("onreadystatechange", function() { (n.readyState === "complete" || n.readyState == "loaded") && (n.detachEvent("onreadystatechange", arguments.callee), l.frameLoadHandle(n, e, a, t, r, i, o, s)); }) : n.addEventListener("load", function() { this.removeEventListener("load", arguments.call, !1), l.frameLoadHandle(n, e, a, t, r, i, o, s); }, !1), s === !1 && e.setAttribute("data-preload", "1"), e.appendChild(n); }, setContent: function(e, a, t) { var r = this, i = "layx-" + e, o = document.getElementById(i), s = r.windows[e]; if (o && s && s.type === "html") { var l = o.querySelector("#layx-" + e + "-html"); if (l) { if (u.isFunction(s.event.onload.before)) { var n = s.event.onload.before(o, s); if (n === !1) return; } try { var d = r.createContenLoadAnimate(l.parentNode, s.loadingText, s); t = u.isBoolean(t) ? t : s.cloneElementContent; var f; if (u.isDom(a)) { var m = a.currentStyle ? a.currentStyle : b.getComputedStyle(a, null); t === !1 && (c.cloneStore[e] = { prev: a.previousSibling, parent: a.parentNode, next: a.nextSibling, display: m.display }), l.innerHTML = "", f = l.appendChild(t === !0 ? a.cloneNode(!0) : a); } else l.innerHTML = a; if (u.isDom(f)) { var p = f.currentStyle ? f.currentStyle : window.getComputedStyle(f, null); p.display === "none" && (f.style.display = ""); } s.content = a; } finally { d && l.parentNode.removeChild(d), s.loadingTextTimer && (clearInterval(s.loadingTextTimer), delete s.loadingTextTimer), u.isFunction(s.event.onload.after) && s.event.onload.after(o, s); } } } }, getGroupFrame: function(e, a) { for (var t = {}, r = 0; r < e.length; r++) if (e[r].id === a) { t = e[r]; break; } return t; }, reloadGroupFrame: function(e, a) { var t = this, r = "layx-" + e, i = document.getElementById(r), o = t.windows[e]; if (i && o && o.type === "group") { var s = t.getGroupFrame(o.frames, a); if (s.type === "url") { var l = i.querySelector("#layx-" + e + "-" + a + "-iframe"); if (l) { var n = l.getAttribute("src"); t.setGroupUrl(e, a, n); } } } }, setGroupContent: function(e, a, t, r) { var i = this, o = "layx-" + e, s = document.getElementById(o), l = i.windows[e]; if (s && l && l.type === "group") { var n = i.getGroupFrame(l.frames, a); if (n.type === "html") { var d = s.querySelector("#layx-" + e + "-" + a + "-html"); if (d) { if (u.isFunction(l.event.onload.before)) { var f = l.event.onload.before(s, l); if (f === !1) return; } try { var m = i.createContenLoadAnimate(d.parentNode.parentNode, l.loadingText, l); r = u.isBoolean(r) ? r : n.cloneElementContent; var p; if (u.isDom(t)) { var y = t.currentStyle ? t.currentStyle : b.getComputedStyle(t, null); r === !1 && (c.cloneStore[e] || (c.cloneStore[e] = { frames: {} }), c.cloneStore[e].frames[a] = { prev: t.previousSibling, parent: t.parentNode, next: t.nextSibling, display: y.display }), d.innerHTML = "", p = d.appendChild(r === !0 ? t.cloneNode(!0) : t); } else d.innerHTML = t; if (u.isDom(p)) { var x = p.currentStyle ? p.currentStyle : window.getComputedStyle(p, null); x.display === "none" && (p.style.display = ""); } n.content = t; } finally { m && d.parentNode.parentNode.removeChild(m), l.loadingTextTimer && (clearInterval(l.loadingTextTimer), delete l.loadingTextTimer), u.isFunction(l.event.onload.after) && l.event.onload.after(s, l); } } } } }, createContenLoadAnimate: function(e, a, t, r) { var i = this; if (a !== !1) { if (u.isArray(a) && a.length === 2 && a[0] === !0) return i.createContenLoadAnimate(e, a[1], t, !1); var o = document.createElement("div"); if (o.classList.add("layx-content-shade"), o.classList.add("layx-flexbox"), o.classList.add("layx-flex-center"), u.isDom(a)) o.appendChild(a); else { r !== !1 && o.appendChild(i.createLoadAnimate()); var s = document.createElement("div"); s.classList.add("layx-load-content-msg"), s.innerHTML = a, o.appendChild(s); var l = document.createElement("span"); l.classList.add("layx-dot"), s.appendChild(l); var n = 0; t.loadingTextTimer = setInterval(function() { n === 5 && (n = 0), ++n; for (var d = "", f = 0; f < n; f++) d += "."; l.innerHTML = d; }, 200); } return e.appendChild(o); } }, setUrl: function(e, a) { a = a || "about:blank"; var t = this, r = "layx-" + e, i = document.getElementById(r), o = t.windows[e]; if (i && o && o.type === "url") { var s = i.querySelector("#layx-" + e + "-iframe"); if (s) { if (u.isFunction(o.event.onload.before)) { var l = o.event.onload.before(i, o); if (l === !1) return; } t.createContenLoadAnimate(s.parentNode, o.loadingText, o), s.setAttribute("src", a); } } }, setGroupUrl: function(e, a, t) { t = t || "about:blank"; var r = this, i = "layx-" + e, o = document.getElementById(i), s = r.windows[e]; if (o && s && s.type === "group") { var l = r.getGroupFrame(s.frames, a); if (l.type === "url") { var n = o.querySelector("#layx-" + e + "-" + a + "-iframe"); if (n) { if (u.isFunction(s.event.onload.before)) { var d = s.event.onload.before(o, s); if (d === !1) return; } n.parentNode.removeAttribute("data-complete"), r.createContenLoadAnimate(n.parentNode.parentNode, s.loadingText, s), n.setAttribute("src", t); } } } }, setGroupTitle: function(e, a, t, r) { var i = this, o = "layx-" + e, s = document.getElementById(o), l = i.windows[e]; if (s && l && l.type === "group") { var n = s.querySelector(".layx-group-title[data-frameId='" + a + "']"); if (n) { var d = i.getGroupFrame(l.frames, a); if (r === !0 && d.type === "url") { var f = s.querySelector("#layx-" + e + "-" + a + "-iframe"); try { t = f.contentDocument.querySelector("title").innerText; } catch { } } var m = n.querySelector(".layx-label"); m && (m.innerHTML = t, n.setAttribute("title", m.innerHTML), d.title = t); } } }, setTitle: function(e, a, t) { var r = this, i = "layx-" + e, o = document.getElementById(i), s = r.windows[e]; if (o && s) { var l = o.querySelector(".layx-title"); if (l) { if (t === !0 && s.type === "url") { var n = o.querySelector("#layx-" + e + "-iframe"); try { a = n.contentDocument.querySelector("title").innerText; } catch { } } var d = l.querySelector(".layx-label"); d && (d.innerHTML = a, l.setAttribute("title", d.innerHTML), s.title = a); } } }, stickToggle: function(e) { var a = this, t = "layx-" + e, r = document.getElementById(t), i = a.windows[e]; if (r && i) { if (a.updateZIndex(e), u.isFunction(i.event.onstick.before)) { var o = i.event.onstick.before(r, i); if (o === !1) return; } i.isStick = !i.isStick; var s = r.querySelector(".layx-stick-menu"); s && (s.setAttribute("data-enable", i.isStick ? "1" : "0"), i.isStick ? s.setAttribute("title", "取消置顶") : s.setAttribute("title", "置顶")), a.updateZIndex(e), u.isFunction(i.event.onstick.after) && i.event.onstick.after(r, i); } }, reloadFrame: function(e) { var a = this, t = "layx-" + e, r = document.getElementById(t), i = a.windows[e]; if (r && i && i.type === "url") { var o = r.querySelector("#layx-" + e + "-iframe"); if (o) { var s = o.getAttribute("src"); a.setUrl(e, s); } } }, restore: function(e) { var a = this, t = "layx-" + e, r = document.getElementById(t), i = a.windows[e]; if (r && i) { if (i.restorable !== !0) return; if (a.updateZIndex(e), u.isFunction(i.event.onrestore.before)) { var o = i.event.onrestore.before(r, i); if (o === !1) return; } var s = i.area; if (i.status === "normal") a.max(e); else if (i.status === "max") { document.body.classList.contains("ilayx-body") && document.body.classList.remove("ilayx-body"), r.style.top = s.top + "px", r.style.left = s.left + "px", r.style.width = s.width + "px", r.style.height = s.height + "px", r.classList.remove("layx-max-statu"), i.status = "normal"; var l = r.querySelector(".layx-restore-menu[data-menu='max']"); l && (l.classList.remove("layx-restore-menu"), l.classList.add("layx-max-menu"), l.setAttribute("title", "最大化"), l.innerHTML = '<svg class="layx-iconfont" aria-hidden="true"><use xlink:href="#layx-icon-max"></use></svg>'); var n = r.querySelector(".layx-resizes"); n && n.removeAttribute("data-enable"); } if (i.status === "min") { if (i.minBefore === "normal") { r.style.top = s.top + "px", r.style.left = s.left + "px", r.style.width = s.width + "px", r.style.height = s.height + "px", i.status = "normal"; var l = r.querySelector(".layx-restore-menu[data-menu='min']"); l && (l.classList.remove("layx-restore-menu"), l.classList.add("layx-min-menu"), l.setAttribute("title", "最小化"), l.innerHTML = '<svg class="layx-iconfont" aria-hidden="true"><use xlink:href="#layx-icon-min"></use></svg>'); var n = r.querySelector(".layx-resizes"); n && n.removeAttribute("data-enable"); } else i.minBefore === "max" && a.max(e); a.updateMinLayout(); } var d = layxDeepClone({}, {}, i); delete a.windows[e], a.windows[e] = d, a.updateMinLayout(), r.classList.contains("layx-min-statu") && r.classList.remove("layx-min-statu"), u.isFunction(d.event.onrestore.after) && d.event.onrestore.after(r, d); } }, min: function(e) { var a = this, t = "layx-" + e, r = document.getElementById(t), i = a.windows[e]; if (r && i && i.isFloatTarget === !1) { if (i.minable !== !0 || i.status === "min") return; if (a.updateZIndex(e), u.isFunction(i.event.onmin.before)) { var o = i.event.onmin.before(r, i); if (o === !1) return; } u.innerArea(), i.minBefore = i.status, i.status = "min"; var s = r.querySelector(".layx-min-menu");