Нет описания

layer.js 27KB

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