layer-compiled.js 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  2. /*! layer mobile-v2.0.0 Web弹层组件 MIT License http://layer.layui.com/mobile By 贤心 */
  3. ;!function (e) {
  4. "use strict";
  5. var t = document,
  6. n = "querySelectorAll",
  7. i = "getElementsByClassName",
  8. a = function a(e) {
  9. return t[n](e);
  10. },
  11. s = { type: 0, shade: !0, shadeClose: !0, fixed: !0, anim: "scale" },
  12. l = { extend: function extend(e) {
  13. var t = JSON.parse(JSON.stringify(s));for (var n in e) {
  14. t[n] = e[n];
  15. }return t;
  16. }, timer: {}, end: {} };l.touch = function (e, t) {
  17. e.addEventListener("click", function (e) {
  18. t.call(this, e);
  19. }, !1);
  20. };var r = 0,
  21. o = ["layui-m-layer"],
  22. c = function c(e) {
  23. var t = this;t.config = l.extend(e), t.view();
  24. };c.prototype.view = function () {
  25. var e = this,
  26. n = e.config,
  27. s = t.createElement("div");e.id = s.id = o[0] + r, s.setAttribute("class", o[0] + " " + o[0] + (n.type || 0)), s.setAttribute("index", r);var l = function () {
  28. var e = "object" == _typeof(n.title);return n.title ? '<h3 style="' + (e ? n.title[1] : "") + '">' + (e ? n.title[0] : n.title) + "</h3>" : "";
  29. }(),
  30. c = function () {
  31. "string" == typeof n.btn && (n.btn = [n.btn]);var e,
  32. t = (n.btn || []).length;return 0 !== t && n.btn ? (e = '<span yes type="1">' + n.btn[0] + "</span>", 2 === t && (e = '<span no type="0">' + n.btn[1] + "</span>" + e), '<div class="layui-m-layerbtn">' + e + "</div>") : "";
  33. }();if (n.fixed || (n.top = n.hasOwnProperty("top") ? n.top : 100, n.style = n.style || "", n.style += " top:" + (t.body.scrollTop + n.top) + "px"), 2 === n.type && (n.content = '<i></i><i class="layui-m-layerload"></i><i></i><p>' + (n.content || "") + "</p>"), n.skin && (n.anim = "up"), "msg" === n.skin && (n.shade = !1), s.innerHTML = (n.shade ? "<div " + ("string" == typeof n.shade ? 'style="' + n.shade + '"' : "") + ' class="layui-m-layershade"></div>' : "") + '<div class="layui-m-layermain" ' + (n.fixed ? "" : 'style="position:static;"') + '><div class="layui-m-layersection"><div class="layui-m-layerchild ' + (n.skin ? "layui-m-layer-" + n.skin + " " : "") + (n.className ? n.className : "") + " " + (n.anim ? "layui-m-anim-" + n.anim : "") + '" ' + (n.style ? 'style="' + n.style + '"' : "") + ">" + l + '<div class="layui-m-layercont">' + n.content + "</div>" + c + "</div></div></div>", !n.type || 2 === n.type) {
  34. var d = t[i](o[0] + n.type),
  35. y = d.length;y >= 1 && layer.close(d[0].getAttribute("index"));
  36. }document.body.appendChild(s);var u = e.elem = a("#" + e.id)[0];n.success && n.success(u), e.index = r++, e.action(n, u);
  37. }, c.prototype.action = function (e, t) {
  38. var n = this;e.time && (l.timer[n.index] = setTimeout(function () {
  39. layer.close(n.index);
  40. }, 1e3 * e.time));var a = function a() {
  41. var t = this.getAttribute("type");0 == t ? (e.no && e.no(), layer.close(n.index)) : e.yes ? e.yes(n.index) : layer.close(n.index);
  42. };if (e.btn) for (var s = t[i]("layui-m-layerbtn")[0].children, r = s.length, o = 0; o < r; o++) {
  43. l.touch(s[o], a);
  44. }if (e.shade && e.shadeClose) {
  45. var c = t[i]("layui-m-layershade")[0];l.touch(c, function () {
  46. layer.close(n.index, e.end);
  47. });
  48. }e.end && (l.end[n.index] = e.end);
  49. }, e.layer = { v: "2.0", index: r, open: function open(e) {
  50. var t = new c(e || {});return t.index;
  51. }, close: function close(e) {
  52. var n = a("#" + o[0] + e)[0];n && (n.innerHTML = "", t.body.removeChild(n), clearTimeout(l.timer[e]), delete l.timer[e], "function" == typeof l.end[e] && l.end[e](), delete l.end[e]);
  53. }, closeAll: function closeAll() {
  54. for (var e = t[i](o[0]), n = 0, a = e.length; n < a; n++) {
  55. layer.close(0 | e[0].getAttribute("index"));
  56. }
  57. } }, "function" == typeof define ? define(function () {
  58. return layer;
  59. }) : function () {
  60. var e = document.scripts,
  61. n = e[e.length - 1],
  62. i = n.src,
  63. a = i.substring(0, i.lastIndexOf("/") + 1);n.getAttribute("merge") || document.head.appendChild(function () {
  64. var e = t.createElement("link");return e.href = a + "need/layer.css?2.0", e.type = "text/css", e.rel = "styleSheet", e.id = "layermcss", e;
  65. }());
  66. }();
  67. }(window);
  68. //# sourceMappingURL=layer-compiled.js.map