/*! * 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 (n, t) { var r = { 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: "此窗口将在 {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 () { }, after: function () { } }, onmin: { before: function () { }, after: function () { } }, onmax: { before: function () { }, after: function () { } }, onrestore: { before: function () { }, after: function () { } }, ondestroy: { before: function () { }, after: function () { } }, onvisual: { before: function () { }, after: function () { } }, onmove: { before: function () { }, progress: function () { }, after: function () { } }, onresize: { before: function () { }, progress: function () { }, after: function () { } }, onfocus: function () { }, onexist: function () { }, onswitch: { before: function () { }, after: function () { } }, onstick: { before: function () { }, after: function () { } } } }, defaultButtons: { label: "确定", callback: function () { }, 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 (n) { var s = this, e = layxDeepClone({}, s.defaults, n || {}), o = {}, ct, lt, at, h, vi, yi, d, rt, ut, ft, ki, yt, oi, pi, l, p, pt, wt, v, bt, g, y, si, kt, wi, et, ot, k, nt, tt, st, a, hi, dt, vt, gi, c, b, ht, bi, ci, li, w, gt, ni, ti, ii, ri, ui, fi, ei, it, di, ai; if (!e.id) { console.error("窗口id不能为空且唯一"); return } if (r.prevFocusId = r.focusId, r.focusId = e.id, ct = s.windows[e.id], ct) { if (ct.status === "min" && s.restore(ct.id), ct.existFlicker === !0 && s.flicker(e.id), i.isFunction(e.event.onexist)) e.event.onexist(ct.layxWindow, ct); return ai = setInterval(function () { e.id !== r.focusId ? s.updateZIndex(e.id) : clearInterval(ai) }, 0), ct } if (i.isArray(e.frames)) for (c = 0; c < e.frames.length; c++)if (e.frames[c] = layxDeepClone({}, s.defaultFrames, e.frames[c]), !e.frames[c].id) { console.error("窗口组窗口id不能为空且窗口组内唯一"); return } if (i.isArray(e.buttons)) for (c = 0; c < e.buttons.length; c++)e.buttons[c] = layxDeepClone({}, s.defaultButtons, e.buttons[c]); if ((e.shadable === !0 || /^(0(\.[0-9])?$)|(1)$/.test(e.shadable)) && (lt = document.createElement("div"), lt.setAttribute("id", "layx-" + e.id + "-shade"), lt.classList.add("layx-shade"), lt.style.zIndex = e.alwaysOnTop === !0 ? ++s.stickZIndex : ++s.zIndex, /^(0(\.[0-9])?$)|(1)$/.test(e.shadable) && (lt.style.backgroundColor = "rgba(0,0,0," + e.shadable + ")"), lt.oncontextmenu = function (n) { return n = n || window.event, n.returnValue = !1, !1 }, lt.onclick = function (n) { n = n || window.event; e.shadeDestroy === !0 ? s.destroy(e.id, null, !0) : e.existFlicker === !0 && s.flicker(e.id); n.stopPropagation() }, document.body.appendChild(lt)), e.style && (at = document.getElementById("layx-style"), at ? at.innerHTML += e.style : (at = document.createElement("style"), at.setAttribute("id", "layx-style"), at.type = "text/css", at.innerHTML = e.style, document.getElementsByTagName("HEAD").item(0).appendChild(at))), h = document.createElement("div"), h.setAttribute("id", "layx-" + e.id), h.classList.add("layx-window"), h.classList.add("layx-flexbox"), h.classList.add("layx-skin-" + e.skin), e.shadow === !0 && (h.style.setProperty("box-shadow", "1px 1px 24px rgba(0, 0, 0, .3)"), h.style.setProperty("-moz-box-shadow", "1px 1px 24px rgba(0, 0, 0, .3)"), h.style.setProperty("-webkit-box-shadow", "1px 1px 24px rgba(0, 0, 0, .3)")), vi = i.compileLayxWidthOrHeight("width", e.minWidth, s.defaults.minWidth), yi = i.compileLayxWidthOrHeight("height", e.minHeight, s.defaults.minHeight), d = i.compileLayxWidthOrHeight("width", e.width, s.defaults.width), rt = i.compileLayxWidthOrHeight("height", e.height, s.defaults.height), d = Math.max(d, vi), rt = Math.max(rt, yi), ki = i.compileLayxPosition(d, rt, e.position), ut = ki.top, ft = ki.left, ut = Math.max(ut, 0), ut = Math.min(t.innerHeight - 15, ut), ft = Math.max(ft, -(d - 15)), ft = Math.min(ft, t.innerWidth - 15), e.storeStatus === !0 && e.floatTarget === !1 ? (yt = s.getStoreWindowAreaInfo(e.id), yt ? (d = yt.width, rt = yt.height, ut = yt.top, ft = yt.left) : s.storeWindowAreaInfo(e.id, { width: d, height: rt, top: ut, left: ft })) : s.removeStoreWindowAreaInfo(e.id), i.isDom(e.floatTarget) && (h.classList.add("layx-bubble-type"), oi = document.createElement("div"), oi.classList.add("layx-bubble"), oi.classList.add("layx-bubble-" + e.floatDirection), h.appendChild(oi), pi = document.createElement("div"), pi.classList.add("layx-bubble-inlay"), pi.classList.add("layx-bubble-inlay-" + e.floatDirection), oi.appendChild(pi)), h.style.zIndex = e.alwaysOnTop === !0 ? ++s.stickZIndex : ++s.zIndex, h.style.width = d + "px", h.style.height = rt + "px", h.style.minWidth = vi + "px", h.style.minHeight = yi + "px", h.style.top = ut + "px", h.style.left = ft + "px", h.style.setProperty("border", i.isBoolean(e.border) ? e.skin === "default" && e.border === !0 ? "" : "none" : e.border), h.style.backgroundColor = e.bgColor, h.style.setProperty("border-radius", e.borderRadius), h.style.setProperty("-moz-border-radius", e.borderRadius), h.style.setProperty("-webkit-border-radius", e.borderRadius), h.style.opacity = /^(0(\.[0-9])?$)|(1)$/.test(e.opacity) ? e.opacity : 1, e.focusable === !0 && (h.onclick = function (n) { if (n = n || window.event, i.isFunction(e.event.onfocus)) { var t = i.isFunction(e.event.onfocus); if (t === !1) return; e.event.onfocus(h, o) } s.updateZIndex(e.id) }), document.body.appendChild(h), l = h.currentStyle ? h.currentStyle : t.getComputedStyle(h, null), o.id = e.id, o.title = e.title, o.layxWindowId = h.getAttribute("id"), o.layxWindow = h, o.createDate = new Date, o.status = "normal", o.type = e.type, o.buttons = e.buttons, o.frames = e.frames, o.useFrameTitle = e.useFrameTitle, o.cloneElementContent = e.cloneElementContent, o.storeStatus = e.storeStatus, o.url = e.url, o.content = e.content, o.escKey = e.escKey, o.focusToReveal = e.focusToReveal, o.dialogType = e.dialogType, o.enableDomainFocus = e.enableDomainFocus, o.buttonKey = e.buttonKey, o.existFlicker = e.existFlicker, o.groupCurrentId = i.isArray(e.frames) && e.frames.length > 0 && e.frames[e.frameIndex] ? e.frames[e.frameIndex].id : null, o.area = { width: d, height: rt, minWidth: vi, minHeight: yi, top: ut, left: ft }, o.border = e.border, o.control = e.control, o.isFloatTarget = i.isDom(e.floatTarget), o.floatTarget = e.floatTarget, o.floatDirection = e.floatDirection, o.loadingText = e.loadingText, o.focusable = e.focusable, o.isStick = e.alwaysOnTop === !0, o.zIndex = e.alwaysOnTop === !0 ? s.stickZIndex : s.zIndex, o.movable = e.movable, o.moveLimit = e.moveLimit, o.resizable = e.resizable, o.resizeLimit = e.resizeLimit, o.stickable = e.stickable, o.minable = e.minable, o.maxable = e.maxable, o.restorable = e.restorable, o.closable = e.closable, o.skin = e.skin, o.event = e.event, o.dragInTopToMax = e.dragInTopToMax, s.windows[e.id] = o, e.control === !0) { if (p = document.createElement("div"), p.classList.add("layx-control-bar"), p.classList.add("layx-flexbox"), p.style.setProperty("border-radius", l.borderRadius + " " + l.borderRadius + " 0 0"), p.style.setProperty("-moz-border-radius", l.borderRadius + " " + l.borderRadius + " 0 0"), p.style.setProperty("-webkit-border-radius", l.borderRadius + " " + l.borderRadius + " 0 0"), e.controlStyle && p.setAttribute("style", e.controlStyle), e.type === "group" && e.mergeTitle === !0 && p.classList.add("layx-type-group"), h.appendChild(p), e.icon !== !1 && (pt = document.createElement("div"), pt.classList.add("layx-left-bar"), pt.classList.add("layx-flexbox"), pt.classList.add("layx-flex-vertical"), p.appendChild(pt), wt = document.createElement("div"), wt.classList.add("layx-icon"), wt.classList.add("layx-window-icon"), wt.innerHTML = e.icon === !0 ? '
' + t + "<\/pre><\/div><\/div>", shadable: !0, debugMenu: !1, minMenu: !1, minable: !1, position: [h.offsetTop + 10, h.offsetLeft + 10], storeStatus: !1 }) }, et.appendChild(ot)), (e.stickMenu === !0 || e.alwaysOnTop === !0 && e.stickMenu) && (k = document.createElement("div"), k.classList.add("layx-icon"), k.classList.add("layx-flexbox"), k.classList.add("layx-flex-center"), k.classList.add("layx-stick-menu"), e.alwaysOnTop === !0 ? k.setAttribute("title", "取消置顶") : k.setAttribute("title", "置顶"), e.alwaysOnTop === !0 && k.setAttribute("data-enable", "1"), k.innerHTML = '