layer.js 28 KB

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