layer.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /** layui-v2.4.3 MIT License By https://www.layui.com */ ;
  2. ! function(e, t) {
  3. "use strict";
  4. var i, n, a = e.layui && layui.define,
  5. o = {
  6. getPath: function() {
  7. var e = document.currentScript ? document.currentScript.src : function() {
  8. for (var e, t = document.scripts, i = t.length - 1, n = i; n > 0; n--)
  9. if ("interactive" === t[n].readyState) {
  10. e = t[n].src;
  11. break
  12. }
  13. return e || t[i].src
  14. }();
  15. return e.substring(0, e.lastIndexOf("/") + 1)
  16. }(),
  17. config: {},
  18. end: {},
  19. minIndex: 0,
  20. minLeft: [],
  21. btn: ["确定", "取消"],
  22. type: ["dialog", "page", "iframe", "loading", "tips"],
  23. getStyle: function(t, i) {
  24. var n = t.currentStyle ? t.currentStyle : e.getComputedStyle(t, null);
  25. return n[n.getPropertyValue ? "getPropertyValue" : "getAttribute"](i)
  26. },
  27. link: function(t, i, n) {
  28. if (r.path) {
  29. var a = document.getElementsByTagName("head")[0],
  30. s = document.createElement("link");
  31. "string" == typeof i && (n = i);
  32. var l = (n || t).replace(/\.|\//g, ""),
  33. f = "layuicss-" + l,
  34. c = 0;
  35. s.rel = "stylesheet", s.href = r.path + t, s.id = f, document.getElementById(f) || a.appendChild(s), "function" == typeof i && ! function u() {
  36. return ++c > 80 ? e.console && console.error("layer.css: Invalid") : void(1989 === parseInt(o.getStyle(document.getElementById(f), "width")) ? i() : setTimeout(u, 100))
  37. }()
  38. }
  39. }
  40. },
  41. r = {
  42. v: "3.1.1",
  43. ie: function() {
  44. var t = navigator.userAgent.toLowerCase();
  45. return !!(e.ActiveXObject || "ActiveXObject" in e) && ((t.match(/msie\s(\d+)/) || [])[1] || "11")
  46. }(),
  47. index: e.layer && e.layer.v ? 1e5 : 0,
  48. path: o.getPath,
  49. config: function(e, t) {
  50. return e = e || {}, r.cache = o.config = i.extend({}, o.config, e), r.path = o.config.path || r.path, "string" == typeof e.extend && (e.extend = [e.extend]), o.config.path && r.ready(), e.extend ? (a ? layui.addcss("modules/layer/" + e.extend) : o.link("theme/" + e.extend), this) : this
  51. },
  52. ready: function(e) {
  53. var t = "layer",
  54. i = "",
  55. n = (a ? "modules/layer/" : "theme/") + "default/layer.css?v=" + r.v + i;
  56. return a ? layui.addcss(n, e, t) : o.link(n, e, t), this
  57. },
  58. alert: function(e, t, n) {
  59. var a = "function" == typeof t;
  60. return a && (n = t), r.open(i.extend({
  61. content: e,
  62. yes: n
  63. }, a ? {} : t))
  64. },
  65. confirm: function(e, t, n, a) {
  66. var s = "function" == typeof t;
  67. return s && (a = n, n = t), r.open(i.extend({
  68. content: e,
  69. btn: o.btn,
  70. yes: n,
  71. btn2: a
  72. }, s ? {} : t))
  73. },
  74. msg: function(e, n, a) {
  75. var s = "function" == typeof n,
  76. f = o.config.skin,
  77. c = (f ? f + " " + f + "-msg" : "") || "layui-layer-msg",
  78. u = l.anim.length - 1;
  79. return s && (a = n), r.open(i.extend({
  80. content: e,
  81. time: 3e3,
  82. shade: !1,
  83. skin: c,
  84. title: !1,
  85. closeBtn: !1,
  86. btn: !1,
  87. resize: !1,
  88. end: a
  89. }, s && !o.config.skin ? {
  90. skin: c + " layui-layer-hui",
  91. anim: u
  92. } : function() {
  93. return n = n || {}, (n.icon === -1 || n.icon === t && !o.config.skin) && (n.skin = c + " " + (n.skin || "layui-layer-hui")), n
  94. }()))
  95. },
  96. load: function(e, t) {
  97. return r.open(i.extend({
  98. type: 3,
  99. icon: e || 0,
  100. resize: !1,
  101. shade: .01
  102. }, t))
  103. },
  104. tips: function(e, t, n) {
  105. return r.open(i.extend({
  106. type: 4,
  107. content: [e, t],
  108. closeBtn: !1,
  109. time: 3e3,
  110. shade: !1,
  111. resize: !1,
  112. fixed: !1,
  113. maxWidth: 210
  114. }, n))
  115. }
  116. },
  117. s = function(e) {
  118. var t = this;
  119. t.index = ++r.index, t.config = i.extend({}, t.config, o.config, e), document.body ? t.creat() : setTimeout(function() {
  120. t.creat()
  121. }, 30)
  122. };
  123. s.pt = s.prototype;
  124. var l = ["layui-layer", ".layui-layer-title", ".layui-layer-main", ".layui-layer-dialog", "layui-layer-iframe", "layui-layer-content", "layui-layer-btn", "layui-layer-close"];
  125. l.anim = ["layer-anim-00", "layer-anim-01", "layer-anim-02", "layer-anim-03", "layer-anim-04", "layer-anim-05", "layer-anim-06"], s.pt.config = {
  126. type: 0,
  127. shade: .3,
  128. fixed: !0,
  129. move: l[1],
  130. title: "信息",
  131. offset: "auto",
  132. area: "auto",
  133. closeBtn: 1,
  134. time: 0,
  135. zIndex: 19891014,
  136. maxWidth: 360,
  137. anim: 0,
  138. isOutAnim: !0,
  139. icon: -1,
  140. moveType: 1,
  141. resize: !0,
  142. scrollbar: !0,
  143. tips: 2
  144. }, s.pt.vessel = function(e, t) {
  145. var n = this,
  146. a = n.index,
  147. r = n.config,
  148. s = r.zIndex + a,
  149. f = "object" == typeof r.title,
  150. c = r.maxmin && (1 === r.type || 2 === r.type),
  151. u = r.title ? '<div class="layui-layer-title" style="' + (f ? r.title[1] : "") + '">' + (f ? r.title[0] : r.title) + "</div>" : "";
  152. return r.zIndex = s, t([r.shade ? '<div class="layui-layer-shade" id="layui-layer-shade' + a + '" times="' + a + '" style="' + ("z-index:" + (s - 1) + "; ") + '"></div>' : "", '<div class="' + l[0] + (" layui-layer-" + o.type[r.type]) + (0 != r.type && 2 != r.type || r.shade ? "" : " layui-layer-border") + " " + (r.skin || "") + '" id="' + l[0] + a + '" type="' + o.type[r.type] + '" times="' + a + '" showtime="' + r.time + '" conType="' + (e ? "object" : "string") + '" style="z-index: ' + s + "; width:" + r.area[0] + ";height:" + r.area[1] + (r.fixed ? "" : ";position:absolute;") + '">' + (e && 2 != r.type ? "" : u) + '<div id="' + (r.id || "") + '" class="layui-layer-content' + (0 == r.type && r.icon !== -1 ? " layui-layer-padding" : "") + (3 == r.type ? " layui-layer-loading" + r.icon : "") + '">' + (0 == r.type && r.icon !== -1 ? '<i class="layui-layer-ico layui-layer-ico' + r.icon + '"></i>' : "") + (1 == r.type && e ? "" : r.content || "") + '</div><span class="layui-layer-setwin">' + function() {
  153. var e = c ? '<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>' : "";
  154. return r.closeBtn && (e += '<a class="layui-layer-ico ' + l[7] + " " + l[7] + (r.title ? r.closeBtn : 4 == r.type ? "1" : "2") + '" href="javascript:;"></a>'), e
  155. }() + "</span>" + (r.btn ? function() {
  156. var e = "";
  157. "string" == typeof r.btn && (r.btn = [r.btn]);
  158. for (var t = 0, i = r.btn.length; t < i; t++) e += '<a class="' + l[6] + t + '">' + r.btn[t] + "</a>";
  159. return '<div class="' + l[6] + " layui-layer-btn-" + (r.btnAlign || "") + '">' + e + "</div>"
  160. }() : "") + (r.resize ? '<span class="layui-layer-resize"></span>' : "") + "</div>"], u, i('<div class="layui-layer-move"></div>')), n
  161. }, s.pt.creat = function() {
  162. var e = this,
  163. t = e.config,
  164. a = e.index,
  165. s = t.content,
  166. f = "object" == typeof s,
  167. c = i("body");
  168. if (!t.id || !i("#" + t.id)[0]) {
  169. switch ("string" == typeof t.area && (t.area = "auto" === t.area ? ["", ""] : [t.area, ""]), t.shift && (t.anim = t.shift), 6 == r.ie && (t.fixed = !1), t.type) {
  170. case 0:
  171. t.btn = "btn" in t ? t.btn : o.btn[0], r.closeAll("dialog");
  172. break;
  173. case 2:
  174. var s = t.content = f ? t.content : [t.content || "", "auto"];
  175. t.content = '<iframe scrolling="' + (t.content[1] || "auto") + '" allowtransparency="true" id="' + l[4] + a + '" name="' + l[4] + a + '" onload="this.className=\'\';" class="layui-layer-load" frameborder="0" src="' + t.content[0] + '"></iframe>';
  176. break;
  177. case 3:
  178. delete t.title, delete t.closeBtn, t.icon === -1 && 0 === t.icon, r.closeAll("loading");
  179. break;
  180. case 4:
  181. f || (t.content = [t.content, "body"]), t.follow = t.content[1], t.content = t.content[0] + '<i class="layui-layer-TipsG"></i>', delete t.title, t.tips = "object" == typeof t.tips ? t.tips : [t.tips, !0], t.tipsMore || r.closeAll("tips")
  182. }
  183. if (e.vessel(f, function(n, r, u) {
  184. c.append(n[0]), f ? function() {
  185. 2 == t.type || 4 == t.type ? function() {
  186. i("body").append(n[1])
  187. }() : function() {
  188. s.parents("." + l[0])[0] || (s.data("display", s.css("display")).show().addClass("layui-layer-wrap").wrap(n[1]), i("#" + l[0] + a).find("." + l[5]).before(r))
  189. }()
  190. }() : c.append(n[1]), i(".layui-layer-move")[0] || c.append(o.moveElem = u), e.layero = i("#" + l[0] + a), t.scrollbar || l.html.css("overflow", "hidden").attr("layer-full", a)
  191. }).auto(a), i("#layui-layer-shade" + e.index).css({
  192. "background-color": t.shade[1] || "#000",
  193. opacity: t.shade[0] || t.shade
  194. }), 2 == t.type && 6 == r.ie && e.layero.find("iframe").attr("src", s[0]), 4 == t.type ? e.tips() : e.offset(), t.fixed && n.on("resize", function() {
  195. e.offset(), (/^\d+%$/.test(t.area[0]) || /^\d+%$/.test(t.area[1])) && e.auto(a), 4 == t.type && e.tips()
  196. }), t.time <= 0 || setTimeout(function() {
  197. r.close(e.index)
  198. }, t.time), e.move().callback(), l.anim[t.anim]) {
  199. var u = "layer-anim " + l.anim[t.anim];
  200. e.layero.addClass(u).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function() {
  201. i(this).removeClass(u)
  202. })
  203. }
  204. t.isOutAnim && e.layero.data("isOutAnim", !0)
  205. }
  206. }, s.pt.auto = function(e) {
  207. var t = this,
  208. a = t.config,
  209. o = i("#" + l[0] + e);
  210. "" === a.area[0] && a.maxWidth > 0 && (r.ie && r.ie < 8 && a.btn && o.width(o.innerWidth()), o.outerWidth() > a.maxWidth && o.width(a.maxWidth));
  211. var s = [o.innerWidth(), o.innerHeight()],
  212. f = o.find(l[1]).outerHeight() || 0,
  213. c = o.find("." + l[6]).outerHeight() || 0,
  214. u = function(e) {
  215. e = o.find(e), e.height(s[1] - f - c - 2 * (0 | parseFloat(e.css("padding-top"))))
  216. };
  217. switch (a.type) {
  218. case 2:
  219. u("iframe");
  220. break;
  221. default:
  222. "" === a.area[1] ? a.maxHeight > 0 && o.outerHeight() > a.maxHeight ? (s[1] = a.maxHeight, u("." + l[5])) : a.fixed && s[1] >= n.height() && (s[1] = n.height(), u("." + l[5])) : u("." + l[5])
  223. }
  224. return t
  225. }, s.pt.offset = function() {
  226. var e = this,
  227. t = e.config,
  228. i = e.layero,
  229. a = [i.outerWidth(), i.outerHeight()],
  230. o = "object" == typeof t.offset;
  231. e.offsetTop = (n.height() - a[1]) / 2, e.offsetLeft = (n.width() - a[0]) / 2, o ? (e.offsetTop = t.offset[0], e.offsetLeft = t.offset[1] || e.offsetLeft) : "auto" !== t.offset && ("t" === t.offset ? e.offsetTop = 0 : "r" === t.offset ? e.offsetLeft = n.width() - a[0] : "b" === t.offset ? e.offsetTop = n.height() - a[1] : "l" === t.offset ? e.offsetLeft = 0 : "lt" === t.offset ? (e.offsetTop = 0, e.offsetLeft = 0) : "lb" === t.offset ? (e.offsetTop = n.height() - a[1], e.offsetLeft = 0) : "rt" === t.offset ? (e.offsetTop = 0, e.offsetLeft = n.width() - a[0]) : "rb" === t.offset ? (e.offsetTop = n.height() - a[1], e.offsetLeft = n.width() - a[0]) : e.offsetTop = t.offset), t.fixed || (e.offsetTop = /%$/.test(e.offsetTop) ? n.height() * parseFloat(e.offsetTop) / 100 : parseFloat(e.offsetTop), e.offsetLeft = /%$/.test(e.offsetLeft) ? n.width() * parseFloat(e.offsetLeft) / 100 : parseFloat(e.offsetLeft), e.offsetTop += n.scrollTop(), e.offsetLeft += n.scrollLeft()), i.attr("minLeft") && (e.offsetTop = n.height() - (i.find(l[1]).outerHeight() || 0), e.offsetLeft = i.css("left")), i.css({
  232. top: e.offsetTop,
  233. left: e.offsetLeft
  234. })
  235. }, s.pt.tips = function() {
  236. var e = this,
  237. t = e.config,
  238. a = e.layero,
  239. o = [a.outerWidth(), a.outerHeight()],
  240. r = i(t.follow);
  241. r[0] || (r = i("body"));
  242. var s = {
  243. width: r.outerWidth(),
  244. height: r.outerHeight(),
  245. top: r.offset().top,
  246. left: r.offset().left
  247. },
  248. f = a.find(".layui-layer-TipsG"),
  249. c = t.tips[0];
  250. t.tips[1] || f.remove(), s.autoLeft = function() {
  251. s.left + o[0] - n.width() > 0 ? (s.tipLeft = s.left + s.width - o[0], f.css({
  252. right: 12,
  253. left: "auto"
  254. })) : s.tipLeft = s.left
  255. }, s.where = [
  256. function() {
  257. s.autoLeft(), s.tipTop = s.top - o[1] - 10, f.removeClass("layui-layer-TipsB").addClass("layui-layer-TipsT").css("border-right-color", t.tips[1])
  258. },
  259. function() {
  260. s.tipLeft = s.left + s.width + 10, s.tipTop = s.top, f.removeClass("layui-layer-TipsL").addClass("layui-layer-TipsR").css("border-bottom-color", t.tips[1])
  261. },
  262. function() {
  263. s.autoLeft(), s.tipTop = s.top + s.height + 10, f.removeClass("layui-layer-TipsT").addClass("layui-layer-TipsB").css("border-right-color", t.tips[1])
  264. },
  265. function() {
  266. s.tipLeft = s.left - o[0] - 10, s.tipTop = s.top, f.removeClass("layui-layer-TipsR").addClass("layui-layer-TipsL").css("border-bottom-color", t.tips[1])
  267. }
  268. ], s.where[c - 1](), 1 === c ? s.top - (n.scrollTop() + o[1] + 16) < 0 && s.where[2]() : 2 === c ? n.width() - (s.left + s.width + o[0] + 16) > 0 || s.where[3]() : 3 === c ? s.top - n.scrollTop() + s.height + o[1] + 16 - n.height() > 0 && s.where[0]() : 4 === c && o[0] + 16 - s.left > 0 && s.where[1](), a.find("." + l[5]).css({
  269. "background-color": t.tips[1],
  270. "padding-right": t.closeBtn ? "30px" : ""
  271. }), a.css({
  272. left: s.tipLeft - (t.fixed ? n.scrollLeft() : 0),
  273. top: s.tipTop - (t.fixed ? n.scrollTop() : 0)
  274. })
  275. }, s.pt.move = function() {
  276. var e = this,
  277. t = e.config,
  278. a = i(document),
  279. s = e.layero,
  280. l = s.find(t.move),
  281. f = s.find(".layui-layer-resize"),
  282. c = {};
  283. return t.move && l.css("cursor", "move"), l.on("mousedown", function(e) {
  284. e.preventDefault(), t.move && (c.moveStart = !0, c.offset = [e.clientX - parseFloat(s.css("left")), e.clientY - parseFloat(s.css("top"))], o.moveElem.css("cursor", "move").show())
  285. }), f.on("mousedown", function(e) {
  286. e.preventDefault(), c.resizeStart = !0, c.offset = [e.clientX, e.clientY], c.area = [s.outerWidth(), s.outerHeight()], o.moveElem.css("cursor", "se-resize").show()
  287. }), a.on("mousemove", function(i) {
  288. if (c.moveStart) {
  289. var a = i.clientX - c.offset[0],
  290. o = i.clientY - c.offset[1],
  291. l = "fixed" === s.css("position");
  292. if (i.preventDefault(), c.stX = l ? 0 : n.scrollLeft(), c.stY = l ? 0 : n.scrollTop(), !t.moveOut) {
  293. var f = n.width() - s.outerWidth() + c.stX,
  294. u = n.height() - s.outerHeight() + c.stY;
  295. a < c.stX && (a = c.stX), a > f && (a = f), o < c.stY && (o = c.stY), o > u && (o = u)
  296. }
  297. s.css({
  298. left: a,
  299. top: o
  300. })
  301. }
  302. if (t.resize && c.resizeStart) {
  303. var a = i.clientX - c.offset[0],
  304. o = i.clientY - c.offset[1];
  305. i.preventDefault(), r.style(e.index, {
  306. width: c.area[0] + a,
  307. height: c.area[1] + o
  308. }), c.isResize = !0, t.resizing && t.resizing(s)
  309. }
  310. }).on("mouseup", function(e) {
  311. c.moveStart && (delete c.moveStart, o.moveElem.hide(), t.moveEnd && t.moveEnd(s)), c.resizeStart && (delete c.resizeStart, o.moveElem.hide())
  312. }), e
  313. }, s.pt.callback = function() {
  314. function e() {
  315. var e = a.cancel && a.cancel(t.index, n);
  316. e === !1 || r.close(t.index)
  317. }
  318. var t = this,
  319. n = t.layero,
  320. a = t.config;
  321. t.openLayer(), a.success && (2 == a.type ? n.find("iframe").on("load", function() {
  322. a.success(n, t.index)
  323. }) : a.success(n, t.index)), 6 == r.ie && t.IE6(n), n.find("." + l[6]).children("a").on("click", function() {
  324. var e = i(this).index();
  325. if (0 === e) a.yes ? a.yes(t.index, n) : a.btn1 ? a.btn1(t.index, n) : r.close(t.index);
  326. else {
  327. var o = a["btn" + (e + 1)] && a["btn" + (e + 1)](t.index, n);
  328. o === !1 || r.close(t.index)
  329. }
  330. }), n.find("." + l[7]).on("click", e), a.shadeClose && i("#layui-layer-shade" + t.index).on("click", function() {
  331. r.close(t.index)
  332. }), n.find(".layui-layer-min").on("click", function() {
  333. var e = a.min && a.min(n);
  334. e === !1 || r.min(t.index, a)
  335. }), n.find(".layui-layer-max").on("click", function() {
  336. i(this).hasClass("layui-layer-maxmin") ? (r.restore(t.index), a.restore && a.restore(n)) : (r.full(t.index, a), setTimeout(function() {
  337. a.full && a.full(n)
  338. }, 100))
  339. }), a.end && (o.end[t.index] = a.end)
  340. }, o.reselect = function() {
  341. i.each(i("select"), function(e, t) {
  342. var n = i(this);
  343. n.parents("." + l[0])[0] || 1 == n.attr("layer") && i("." + l[0]).length < 1 && n.removeAttr("layer").show(), n = null
  344. })
  345. }, s.pt.IE6 = function(e) {
  346. i("select").each(function(e, t) {
  347. var n = i(this);
  348. n.parents("." + l[0])[0] || "none" === n.css("display") || n.attr({
  349. layer: "1"
  350. }).hide(), n = null
  351. })
  352. }, s.pt.openLayer = function() {
  353. var e = this;
  354. r.zIndex = e.config.zIndex, r.setTop = function(e) {
  355. var t = function() {
  356. r.zIndex++, e.css("z-index", r.zIndex + 1)
  357. };
  358. return r.zIndex = parseInt(e[0].style.zIndex), e.on("mousedown", t), r.zIndex
  359. }
  360. }, o.record = function(e) {
  361. var t = [e.width(), e.height(), e.position().top, e.position().left + parseFloat(e.css("margin-left"))];
  362. e.find(".layui-layer-max").addClass("layui-layer-maxmin"), e.attr({
  363. area: t
  364. })
  365. }, o.rescollbar = function(e) {
  366. l.html.attr("layer-full") == e && (l.html[0].style.removeProperty ? l.html[0].style.removeProperty("overflow") : l.html[0].style.removeAttribute("overflow"), l.html.removeAttr("layer-full"))
  367. }, e.layer = r, r.getChildFrame = function(e, t) {
  368. return t = t || i("." + l[4]).attr("times"), i("#" + l[0] + t).find("iframe").contents().find(e)
  369. }, r.getFrameIndex = function(e) {
  370. return i("#" + e).parents("." + l[4]).attr("times")
  371. }, r.iframeAuto = function(e) {
  372. if (e) {
  373. var t = r.getChildFrame("html", e).outerHeight(),
  374. n = i("#" + l[0] + e),
  375. a = n.find(l[1]).outerHeight() || 0,
  376. o = n.find("." + l[6]).outerHeight() || 0;
  377. n.css({
  378. height: t + a + o
  379. }), n.find("iframe").css({
  380. height: t
  381. })
  382. }
  383. }, r.iframeSrc = function(e, t) {
  384. i("#" + l[0] + e).find("iframe").attr("src", t)
  385. }, r.style = function(e, t, n) {
  386. var a = i("#" + l[0] + e),
  387. r = a.find(".layui-layer-content"),
  388. s = a.attr("type"),
  389. f = a.find(l[1]).outerHeight() || 0,
  390. c = a.find("." + l[6]).outerHeight() || 0;
  391. a.attr("minLeft");
  392. s !== o.type[3] && s !== o.type[4] && (n || (parseFloat(t.width) <= 260 && (t.width = 260), parseFloat(t.height) - f - c <= 64 && (t.height = 64 + f + c)), a.css(t), c = a.find("." + l[6]).outerHeight(), s === o.type[2] ? a.find("iframe").css({
  393. height: parseFloat(t.height) - f - c
  394. }) : r.css({
  395. height: parseFloat(t.height) - f - c - parseFloat(r.css("padding-top")) - parseFloat(r.css("padding-bottom"))
  396. }))
  397. }, r.min = function(e, t) {
  398. var a = i("#" + l[0] + e),
  399. s = a.find(l[1]).outerHeight() || 0,
  400. f = a.attr("minLeft") || 181 * o.minIndex + "px",
  401. c = a.css("position");
  402. o.record(a), o.minLeft[0] && (f = o.minLeft[0], o.minLeft.shift()), a.attr("position", c), r.style(e, {
  403. width: 180,
  404. height: s,
  405. left: f,
  406. top: n.height() - s,
  407. position: "fixed",
  408. overflow: "hidden"
  409. }, !0), a.find(".layui-layer-min").hide(), "page" === a.attr("type") && a.find(l[4]).hide(), o.rescollbar(e), a.attr("minLeft") || o.minIndex++, a.attr("minLeft", f)
  410. }, r.restore = function(e) {
  411. var t = i("#" + l[0] + e),
  412. n = t.attr("area").split(",");
  413. t.attr("type");
  414. r.style(e, {
  415. width: parseFloat(n[0]),
  416. height: parseFloat(n[1]),
  417. top: parseFloat(n[2]),
  418. left: parseFloat(n[3]),
  419. position: t.attr("position"),
  420. overflow: "visible"
  421. }, !0), t.find(".layui-layer-max").removeClass("layui-layer-maxmin"), t.find(".layui-layer-min").show(), "page" === t.attr("type") && t.find(l[4]).show(), o.rescollbar(e)
  422. }, r.full = function(e) {
  423. var t, a = i("#" + l[0] + e);
  424. o.record(a), l.html.attr("layer-full") || l.html.css("overflow", "hidden").attr("layer-full", e), clearTimeout(t), t = setTimeout(function() {
  425. var t = "fixed" === a.css("position");
  426. r.style(e, {
  427. top: t ? 0 : n.scrollTop(),
  428. left: t ? 0 : n.scrollLeft(),
  429. width: n.width(),
  430. height: n.height()
  431. }, !0), a.find(".layui-layer-min").hide()
  432. }, 100)
  433. }, r.title = function(e, t) {
  434. var n = i("#" + l[0] + (t || r.index)).find(l[1]);
  435. n.html(e)
  436. }, r.close = function(e) {
  437. var t = i("#" + l[0] + e),
  438. n = t.attr("type"),
  439. a = "layer-anim-close";
  440. if (t[0]) {
  441. var s = "layui-layer-wrap",
  442. f = function() {
  443. if (n === o.type[1] && "object" === t.attr("conType")) {
  444. t.children(":not(." + l[5] + ")").remove();
  445. for (var a = t.find("." + s), r = 0; r < 2; r++) a.unwrap();
  446. a.css("display", a.data("display")).removeClass(s)
  447. } else {
  448. if (n === o.type[2]) try {
  449. var f = i("#" + l[4] + e)[0];
  450. f.contentWindow.document.write(""), f.contentWindow.close(), t.find("." + l[5])[0].removeChild(f)
  451. } catch (c) {}
  452. t[0].innerHTML = "", t.remove()
  453. }
  454. "function" == typeof o.end[e] && o.end[e](), delete o.end[e]
  455. };
  456. t.data("isOutAnim") && t.addClass("layer-anim " + a), i("#layui-layer-moves, #layui-layer-shade" + e).remove(), 6 == r.ie && o.reselect(), o.rescollbar(e), t.attr("minLeft") && (o.minIndex--, o.minLeft.push(t.attr("minLeft"))), r.ie && r.ie < 10 || !t.data("isOutAnim") ? f() : setTimeout(function() {
  457. f()
  458. }, 200)
  459. }
  460. }, r.closeAll = function(e) {
  461. i.each(i("." + l[0]), function() {
  462. var t = i(this),
  463. n = e ? t.attr("type") === e : 1;
  464. n && r.close(t.attr("times")), n = null
  465. })
  466. };
  467. var f = r.cache || {},
  468. c = function(e) {
  469. return f.skin ? " " + f.skin + " " + f.skin + "-" + e : ""
  470. };
  471. r.prompt = function(e, t) {
  472. var a = "";
  473. if (e = e || {}, "function" == typeof e && (t = e), e.area) {
  474. var o = e.area;
  475. a = 'style="width: ' + o[0] + "; height: " + o[1] + ';"', delete e.area
  476. }
  477. var s, l = 2 == e.formType ? '<textarea class="layui-layer-input"' + a + "></textarea>" : function() {
  478. return '<input type="' + (1 == e.formType ? "password" : "text") + '" class="layui-layer-input">'
  479. }(),
  480. f = e.success;
  481. return delete e.success, r.open(i.extend({
  482. type: 1,
  483. btn: ["&#x786E;&#x5B9A;", "&#x53D6;&#x6D88;"],
  484. content: l,
  485. skin: "layui-layer-prompt" + c("prompt"),
  486. maxWidth: n.width(),
  487. success: function(t) {
  488. s = t.find(".layui-layer-input"), s.val(e.value || "").focus(), "function" == typeof f && f(t)
  489. },
  490. resize: !1,
  491. yes: function(i) {
  492. var n = s.val();
  493. "" === n ? s.focus() : n.length > (e.maxlength || 500) ? r.tips("&#x6700;&#x591A;&#x8F93;&#x5165;" + (e.maxlength || 500) + "&#x4E2A;&#x5B57;&#x6570;", s, {
  494. tips: 1
  495. }) : t && t(n, i, s)
  496. }
  497. }, e))
  498. }, r.tab = function(e) {
  499. e = e || {};
  500. var t = e.tab || {},
  501. n = "layui-this",
  502. a = e.success;
  503. return delete e.success, r.open(i.extend({
  504. type: 1,
  505. skin: "layui-layer-tab" + c("tab"),
  506. resize: !1,
  507. title: function() {
  508. var e = t.length,
  509. i = 1,
  510. a = "";
  511. if (e > 0)
  512. for (a = '<span class="' + n + '">' + t[0].title + "</span>"; i < e; i++) a += "<span>" + t[i].title + "</span>";
  513. return a
  514. }(),
  515. content: '<ul class="layui-layer-tabmain">' + function() {
  516. var e = t.length,
  517. i = 1,
  518. a = "";
  519. if (e > 0)
  520. for (a = '<li class="layui-layer-tabli ' + n + '">' + (t[0].content || "no content") + "</li>"; i < e; i++) a += '<li class="layui-layer-tabli">' + (t[i].content || "no content") + "</li>";
  521. return a
  522. }() + "</ul>",
  523. success: function(t) {
  524. var o = t.find(".layui-layer-title").children(),
  525. r = t.find(".layui-layer-tabmain").children();
  526. o.on("mousedown", function(t) {
  527. t.stopPropagation ? t.stopPropagation() : t.cancelBubble = !0;
  528. var a = i(this),
  529. o = a.index();
  530. a.addClass(n).siblings().removeClass(n), r.eq(o).show().siblings().hide(), "function" == typeof e.change && e.change(o)
  531. }), "function" == typeof a && a(t)
  532. }
  533. }, e))
  534. }, r.photos = function(t, n, a) {
  535. function o(e, t, i) {
  536. var n = new Image;
  537. return n.src = e, n.complete ? t(n) : (n.onload = function() {
  538. n.onload = null, t(n)
  539. }, void(n.onerror = function(e) {
  540. n.onerror = null, i(e)
  541. }))
  542. }
  543. var s = {};
  544. if (t = t || {}, t.photos) {
  545. var l = t.photos.constructor === Object,
  546. f = l ? t.photos : {},
  547. u = f.data || [],
  548. d = f.start || 0;
  549. s.imgIndex = (0 | d) + 1, t.img = t.img || "img";
  550. var y = t.success;
  551. if (delete t.success, l) {
  552. if (0 === u.length) return r.msg("&#x6CA1;&#x6709;&#x56FE;&#x7247;")
  553. } else {
  554. var p = i(t.photos),
  555. h = function() {
  556. u = [], p.find(t.img).each(function(e) {
  557. var t = i(this);
  558. t.attr("layer-index", e), u.push({
  559. alt: t.attr("alt"),
  560. pid: t.attr("layer-pid"),
  561. src: t.attr("layer-src") || t.attr("src"),
  562. thumb: t.attr("src")
  563. })
  564. })
  565. };
  566. if (h(), 0 === u.length) return;
  567. if (n || p.on("click", t.img, function() {
  568. var e = i(this),
  569. n = e.attr("layer-index");
  570. r.photos(i.extend(t, {
  571. photos: {
  572. start: n,
  573. data: u,
  574. tab: t.tab
  575. },
  576. full: t.full
  577. }), !0), h()
  578. }), !n) return
  579. }
  580. s.imgprev = function(e) {
  581. s.imgIndex--, s.imgIndex < 1 && (s.imgIndex = u.length), s.tabimg(e)
  582. }, s.imgnext = function(e, t) {
  583. s.imgIndex++, s.imgIndex > u.length && (s.imgIndex = 1, t) || s.tabimg(e)
  584. }, s.keyup = function(e) {
  585. if (!s.end) {
  586. var t = e.keyCode;
  587. e.preventDefault(), 37 === t ? s.imgprev(!0) : 39 === t ? s.imgnext(!0) : 27 === t && r.close(s.index)
  588. }
  589. }, s.tabimg = function(e) {
  590. if (!(u.length <= 1)) return f.start = s.imgIndex - 1, r.close(s.index), r.photos(t, !0, e)
  591. }, s.event = function() {
  592. s.bigimg.hover(function() {
  593. s.imgsee.show()
  594. }, function() {
  595. s.imgsee.hide()
  596. }), s.bigimg.find(".layui-layer-imgprev").on("click", function(e) {
  597. e.preventDefault(), s.imgprev()
  598. }), s.bigimg.find(".layui-layer-imgnext").on("click", function(e) {
  599. e.preventDefault(), s.imgnext()
  600. }), i(document).on("keyup", s.keyup)
  601. }, s.loadi = r.load(1, {
  602. shade: !("shade" in t) && .9,
  603. scrollbar: !1
  604. }), o(u[d].src, function(n) {
  605. r.close(s.loadi), s.index = r.open(i.extend({
  606. type: 1,
  607. id: "layui-layer-photos",
  608. area: function() {
  609. var a = [n.width, n.height],
  610. o = [i(e).width() - 100, i(e).height() - 100];
  611. if (!t.full && (a[0] > o[0] || a[1] > o[1])) {
  612. var r = [a[0] / o[0], a[1] / o[1]];
  613. r[0] > r[1] ? (a[0] = a[0] / r[0], a[1] = a[1] / r[0]) : r[0] < r[1] && (a[0] = a[0] / r[1], a[1] = a[1] / r[1])
  614. }
  615. return [a[0] + "px", a[1] + "px"]
  616. }(),
  617. title: !1,
  618. shade: .9,
  619. shadeClose: !0,
  620. closeBtn: !1,
  621. move: ".layui-layer-phimg img",
  622. moveType: 1,
  623. scrollbar: !1,
  624. moveOut: !0,
  625. isOutAnim: !1,
  626. skin: "layui-layer-photos" + c("photos"),
  627. content: '<div class="layui-layer-phimg"><img src="' + u[d].src + '" alt="' + (u[d].alt || "") + '" layer-pid="' + u[d].pid + '"><div class="layui-layer-imgsee">' + (u.length > 1 ? '<span class="layui-layer-imguide"><a href="javascript:;" class="layui-layer-iconext layui-layer-imgprev"></a><a href="javascript:;" class="layui-layer-iconext layui-layer-imgnext"></a></span>' : "") + '<div class="layui-layer-imgbar" style="display:' + (a ? "block" : "") + '"><span class="layui-layer-imgtit"><a href="javascript:;">' + (u[d].alt || "") + "</a><em>" + s.imgIndex + "/" + u.length + "</em></span></div></div></div>",
  628. success: function(e, i) {
  629. s.bigimg = e.find(".layui-layer-phimg"), s.imgsee = e.find(".layui-layer-imguide,.layui-layer-imgbar"), s.event(e), t.tab && t.tab(u[d], e), "function" == typeof y && y(e)
  630. },
  631. end: function() {
  632. s.end = !0, i(document).off("keyup", s.keyup)
  633. }
  634. }, t))
  635. }, function() {
  636. r.close(s.loadi), r.msg("&#x5F53;&#x524D;&#x56FE;&#x7247;&#x5730;&#x5740;&#x5F02;&#x5E38;<br>&#x662F;&#x5426;&#x7EE7;&#x7EED;&#x67E5;&#x770B;&#x4E0B;&#x4E00;&#x5F20;&#xFF1F;", {
  637. time: 3e4,
  638. btn: ["&#x4E0B;&#x4E00;&#x5F20;", "&#x4E0D;&#x770B;&#x4E86;"],
  639. yes: function() {
  640. u.length > 1 && s.imgnext(!0, !0)
  641. }
  642. })
  643. })
  644. }
  645. }, o.run = function(t) {
  646. i = t, n = i(e), l.html = i("html"), r.open = function(e) {
  647. var t = new s(e);
  648. return t.index
  649. }
  650. }, e.layui && layui.define ? (r.ready(), layui.define("jquery", function(t) {
  651. r.path = layui.cache.dir, o.run(layui.$), e.layer = r, t("layer", r)
  652. })) : "function" == typeof define && define.amd ? define(["jquery"], function() {
  653. return o.run(e.jQuery), r
  654. }) : function() {
  655. o.run(e.jQuery), r.ready()
  656. }()
  657. }(window);