layer.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922
  1. /*! layer-v3.0.2 Web弹层组件 MIT License http://layer.layui.com/ By 贤心 */
  2. ;!function(e, t) {
  3. "use strict";
  4. var i, n, a = e.layui && layui.define, o = {
  5. getPath: function() {
  6. var e = document.scripts
  7. , t = e[e.length - 1]
  8. , i = t.src;
  9. if (!t.getAttribute("merge"))
  10. 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. }, r = {
  19. v: "3.0.2",
  20. ie: function() {
  21. var t = navigator.userAgent.toLowerCase();
  22. return !!(e.ActiveXObject || "ActiveXObject"in e) && ((t.match(/msie\s(\d+)/) || [])[1] || "11")
  23. }(),
  24. index: e.layer && e.layer.v ? 1e5 : 0,
  25. path: o.getPath,
  26. config: function(e, t) {
  27. return e = e || {},
  28. r.cache = o.config = i.extend({}, o.config, e),
  29. r.path = o.config.path || r.path,
  30. "string" == typeof e.extend && (e.extend = [e.extend]),
  31. o.config.path && r.ready(),
  32. e.extend ? (a ? layui.addcss("modules/layer/" + e.extend) : r.link("skin/" + e.extend),
  33. this) : this
  34. },
  35. link: function(t, n, a) {
  36. if (r.path) {
  37. var o = i("head")[0]
  38. , s = document.createElement("link");
  39. "string" == typeof n && (a = n);
  40. var l = (a || t).replace(/\.|\//g, "")
  41. , f = "layuicss-" + l
  42. , c = 0;
  43. s.rel = "stylesheet",
  44. s.href = r.path + t,
  45. s.id = f,
  46. i("#" + f)[0] || o.appendChild(s),
  47. "function" == typeof n && !function u() {
  48. return ++c > 80 ? e.console && console.error("layer.css: Invalid") : void (1989 === parseInt(i("#" + f).css("width")) ? n() : setTimeout(u, 100))
  49. }()
  50. }
  51. },
  52. ready: function(e) {
  53. var t = "skinlayercss"
  54. , i = "302";
  55. 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),
  56. this
  57. },
  58. alert: function(e, t, n) {
  59. var a = "function" == typeof t;
  60. return a && (n = t),
  61. r.open(i.extend({
  62. content: e,
  63. yes: n
  64. }, a ? {} : t))
  65. },
  66. confirm: function(e, t, n, a) {
  67. var s = "function" == typeof t;
  68. return s && (a = n,
  69. n = t),
  70. 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),
  83. r.open(i.extend({
  84. content: e,
  85. time: 3e3,
  86. shade: !1,
  87. skin: c,
  88. title: !1,
  89. closeBtn: !1,
  90. btn: !1,
  91. resize: !1,
  92. end: a
  93. }, s && !o.config.skin ? {
  94. skin: c + " layui-layer-hui",
  95. anim: u
  96. } : function() {
  97. return n = n || {},
  98. (n.icon === -1 || n.icon === t && !o.config.skin) && (n.skin = c + " " + (n.skin || "layui-layer-hui")),
  99. n
  100. }()))
  101. },
  102. load: function(e, t) {
  103. return r.open(i.extend({
  104. type: 3,
  105. icon: e || 0,
  106. resize: !1,
  107. shade: .01
  108. }, t))
  109. },
  110. tips: function(e, t, n) {
  111. return r.open(i.extend({
  112. type: 4,
  113. content: [e, t],
  114. closeBtn: !1,
  115. time: 3e3,
  116. shade: !1,
  117. resize: !1,
  118. fixed: !1,
  119. maxWidth: 210
  120. }, n))
  121. }
  122. }, s = function(e) {
  123. var t = this;
  124. t.index = ++r.index,
  125. t.config = i.extend({}, t.config, o.config, e),
  126. r.ready(function() {
  127. document.body ? t.creat() : setTimeout(function() {
  128. t.creat()
  129. }, 50)
  130. })
  131. };
  132. s.pt = s.prototype;
  133. 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"];
  134. l.anim = ["layer-anim", "layer-anim-01", "layer-anim-02", "layer-anim-03", "layer-anim-04", "layer-anim-05", "layer-anim-06"],
  135. s.pt.config = {
  136. type: 0,
  137. shade: .3,
  138. fixed: !0,
  139. move: l[1],
  140. title: "信息",
  141. offset: "auto",
  142. area: "auto",
  143. closeBtn: 1,
  144. time: 0,
  145. zIndex: 19891014,
  146. maxWidth: 360,
  147. anim: 0,
  148. icon: -1,
  149. moveType: 1,
  150. resize: !0,
  151. scrollbar: !0,
  152. tips: 2
  153. },
  154. s.pt.vessel = function(e, t) {
  155. var n = this
  156. , a = n.index
  157. , r = n.config
  158. , s = r.zIndex + a
  159. , f = "object" == typeof r.title
  160. , c = r.maxmin && (1 === r.type || 2 === r.type)
  161. , u = r.title ? '<div class="layui-layer-title" style="' + (f ? r.title[1] : "") + '">' + (f ? r.title[0] : r.title) + "</div>" : "";
  162. return r.zIndex = s,
  163. 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() {
  164. var e = c ? '<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>' : "";
  165. 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>'),
  166. e
  167. }() + "</span>" + (r.btn ? function() {
  168. var e = "";
  169. "string" == typeof r.btn && (r.btn = [r.btn]);
  170. for (var t = 0, i = r.btn.length; t < i; t++)
  171. e += '<a class="' + l[6] + t + '">' + r.btn[t] + "</a>";
  172. return '<div class="' + l[6] + " layui-layer-btn-" + (r.btnAlign || "") + '">' + e + "</div>"
  173. }() : "") + (r.resize ? '<span class="layui-layer-resize"></span>' : "") + "</div>"], u, i('<div class="layui-layer-move"></div>')),
  174. n
  175. }
  176. ,
  177. s.pt.creat = function() {
  178. var e = this
  179. , t = e.config
  180. , a = e.index
  181. , s = t.content
  182. , f = "object" == typeof s
  183. , c = i("body");
  184. if (!t.id || !i("#" + t.id)[0]) {
  185. switch ("string" == typeof t.area && (t.area = "auto" === t.area ? ["", ""] : [t.area, ""]),
  186. t.shift && (t.anim = t.shift),
  187. 6 == r.ie && (t.fixed = !1),
  188. t.type) {
  189. case 0:
  190. t.btn = "btn"in t ? t.btn : o.btn[0],
  191. r.closeAll("dialog");
  192. break;
  193. case 2:
  194. var s = t.content = f ? t.content : [t.content || "http://layer.layui.com", "auto"];
  195. 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>';
  196. break;
  197. case 3:
  198. delete t.title,
  199. delete t.closeBtn,
  200. t.icon === -1 && 0 === t.icon,
  201. r.closeAll("loading");
  202. break;
  203. case 4:
  204. f || (t.content = [t.content, "body"]),
  205. t.follow = t.content[1],
  206. t.content = t.content[0] + '<i class="layui-layer-TipsG"></i>',
  207. delete t.title,
  208. t.tips = "object" == typeof t.tips ? t.tips : [t.tips, !0],
  209. t.tipsMore || r.closeAll("tips")
  210. }
  211. e.vessel(f, function(n, r, u) {
  212. c.append(n[0]),
  213. f ? function() {
  214. 2 == t.type || 4 == t.type ? function() {
  215. i("body").append(n[1])
  216. }() : function() {
  217. s.parents("." + l[0])[0] || (s.data("display", s.css("display")).show().addClass("layui-layer-wrap").wrap(n[1]),
  218. i("#" + l[0] + a).find("." + l[5]).before(r))
  219. }()
  220. }() : c.append(n[1]),
  221. i(".layui-layer-move")[0] || c.append(o.moveElem = u),
  222. e.layero = i("#" + l[0] + a),
  223. t.scrollbar || l.html.css("overflow", "hidden").attr("layer-full", a)
  224. }).auto(a),
  225. 2 == t.type && 6 == r.ie && e.layero.find("iframe").attr("src", s[0]),
  226. 4 == t.type ? e.tips() : e.offset(),
  227. t.fixed && n.on("resize", function() {
  228. e.offset(),
  229. (/^\d+%$/.test(t.area[0]) || /^\d+%$/.test(t.area[1])) && e.auto(a),
  230. 4 == t.type && e.tips()
  231. }),
  232. t.time <= 0 || setTimeout(function() {
  233. r.close(e.index)
  234. }, t.time),
  235. e.move().callback(),
  236. l.anim[t.anim] && e.layero.addClass(l.anim[t.anim]).data("anim", !0)
  237. }
  238. }
  239. ,
  240. s.pt.auto = function(e) {
  241. function t(e) {
  242. e = s.find(e),
  243. e.height(f[1] - c - u - 2 * (0 | parseFloat(e.css("padding"))))
  244. }
  245. var a = this
  246. , o = a.config
  247. , s = i("#" + l[0] + e);
  248. "" === o.area[0] && o.maxWidth > 0 && (r.ie && r.ie < 8 && o.btn && s.width(s.innerWidth()),
  249. s.outerWidth() > o.maxWidth && s.width(o.maxWidth));
  250. var f = [s.innerWidth(), s.innerHeight()]
  251. , c = s.find(l[1]).outerHeight() || 0
  252. , u = s.find("." + l[6]).outerHeight() || 0;
  253. switch (o.type) {
  254. case 2:
  255. t("iframe");
  256. break;
  257. default:
  258. "" === o.area[1] ? o.fixed && f[1] >= n.height() && (f[1] = n.height(),
  259. t("." + l[5])) : t("." + l[5])
  260. }
  261. return a
  262. }
  263. ,
  264. s.pt.offset = function() {
  265. var e = this
  266. , t = e.config
  267. , i = e.layero
  268. , a = [i.outerWidth(), i.outerHeight()]
  269. , o = "object" == typeof t.offset;
  270. e.offsetTop = (n.height() - a[1]) / 2,
  271. e.offsetLeft = (n.width() - a[0]) / 2,
  272. o ? (e.offsetTop = t.offset[0],
  273. 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,
  274. e.offsetLeft = 0) : "lb" === t.offset ? (e.offsetTop = n.height() - a[1],
  275. e.offsetLeft = 0) : "rt" === t.offset ? (e.offsetTop = 0,
  276. e.offsetLeft = n.width() - a[0]) : "rb" === t.offset ? (e.offsetTop = n.height() - a[1],
  277. e.offsetLeft = n.width() - a[0]) : e.offsetTop = t.offset),
  278. t.fixed || (e.offsetTop = /%$/.test(e.offsetTop) ? n.height() * parseFloat(e.offsetTop) / 100 : parseFloat(e.offsetTop),
  279. e.offsetLeft = /%$/.test(e.offsetLeft) ? n.width() * parseFloat(e.offsetLeft) / 100 : parseFloat(e.offsetLeft),
  280. e.offsetTop += n.scrollTop(),
  281. e.offsetLeft += n.scrollLeft()),
  282. i.attr("minLeft") && (e.offsetTop = n.height() - (i.find(l[1]).outerHeight() || 0),
  283. e.offsetLeft = i.css("left")),
  284. i.css({
  285. top: e.offsetTop,
  286. left: e.offsetLeft
  287. })
  288. }
  289. ,
  290. s.pt.tips = function() {
  291. var e = this
  292. , t = e.config
  293. , a = e.layero
  294. , o = [a.outerWidth(), a.outerHeight()]
  295. , r = i(t.follow);
  296. r[0] || (r = i("body"));
  297. var s = {
  298. width: r.outerWidth(),
  299. height: r.outerHeight(),
  300. top: r.offset().top,
  301. left: r.offset().left
  302. }
  303. , f = a.find(".layui-layer-TipsG")
  304. , c = t.tips[0];
  305. t.tips[1] || f.remove(),
  306. s.autoLeft = function() {
  307. s.left + o[0] - n.width() > 0 ? (s.tipLeft = s.left + s.width - o[0],
  308. f.css({
  309. right: 12,
  310. left: "auto"
  311. })) : s.tipLeft = s.left
  312. }
  313. ,
  314. s.where = [function() {
  315. s.autoLeft(),
  316. s.tipTop = s.top - o[1] - 10,
  317. f.removeClass("layui-layer-TipsB").addClass("layui-layer-TipsT").css("border-right-color", t.tips[1])
  318. }
  319. , function() {
  320. s.tipLeft = s.left + s.width + 10,
  321. s.tipTop = s.top,
  322. f.removeClass("layui-layer-TipsL").addClass("layui-layer-TipsR").css("border-bottom-color", t.tips[1])
  323. }
  324. , function() {
  325. s.autoLeft(),
  326. s.tipTop = s.top + s.height + 10,
  327. f.removeClass("layui-layer-TipsT").addClass("layui-layer-TipsB").css("border-right-color", t.tips[1])
  328. }
  329. , function() {
  330. s.tipLeft = s.left - o[0] - 10,
  331. s.tipTop = s.top,
  332. f.removeClass("layui-layer-TipsR").addClass("layui-layer-TipsL").css("border-bottom-color", t.tips[1])
  333. }
  334. ],
  335. s.where[c - 1](),
  336. 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](),
  337. a.find("." + l[5]).css({
  338. "background-color": t.tips[1],
  339. "padding-right": t.closeBtn ? "30px" : ""
  340. }),
  341. a.css({
  342. left: s.tipLeft - (t.fixed ? n.scrollLeft() : 0),
  343. top: s.tipTop - (t.fixed ? n.scrollTop() : 0)
  344. })
  345. }
  346. ,
  347. s.pt.move = function() {
  348. var e = this
  349. , t = e.config
  350. , a = i(document)
  351. , s = e.layero
  352. , l = s.find(t.move)
  353. , f = s.find(".layui-layer-resize")
  354. , c = {};
  355. return t.move && l.css("cursor", "move"),
  356. l.on("mousedown", function(e) {
  357. e.preventDefault(),
  358. t.move && (c.moveStart = !0,
  359. c.offset = [e.clientX - parseFloat(s.css("left")), e.clientY - parseFloat(s.css("top"))],
  360. o.moveElem.css("cursor", "move").show())
  361. }),
  362. f.on("mousedown", function(e) {
  363. e.preventDefault(),
  364. c.resizeStart = !0,
  365. c.offset = [e.clientX, e.clientY],
  366. c.area = [s.outerWidth(), s.outerHeight()],
  367. o.moveElem.css("cursor", "se-resize").show()
  368. }),
  369. a.on("mousemove", function(i) {
  370. if (c.moveStart) {
  371. var a = i.clientX - c.offset[0]
  372. , o = i.clientY - c.offset[1]
  373. , l = "fixed" === s.css("position");
  374. if (i.preventDefault(),
  375. c.stX = l ? 0 : n.scrollLeft(),
  376. c.stY = l ? 0 : n.scrollTop(),
  377. !t.moveOut) {
  378. var f = n.width() - s.outerWidth() + c.stX
  379. , u = n.height() - s.outerHeight() + c.stY;
  380. a < c.stX && (a = c.stX),
  381. a > f && (a = f),
  382. o < c.stY && (o = c.stY),
  383. o > u && (o = u)
  384. }
  385. s.css({
  386. left: a,
  387. top: o
  388. })
  389. }
  390. if (t.resize && c.resizeStart) {
  391. var a = i.clientX - c.offset[0]
  392. , o = i.clientY - c.offset[1];
  393. i.preventDefault(),
  394. r.style(e.index, {
  395. width: c.area[0] + a,
  396. height: c.area[1] + o
  397. }),
  398. c.isResize = !0,
  399. t.resizing && t.resizing(s)
  400. }
  401. }).on("mouseup", function(e) {
  402. c.moveStart && (delete c.moveStart,
  403. o.moveElem.hide(),
  404. t.moveEnd && t.moveEnd(s)),
  405. c.resizeStart && (delete c.resizeStart,
  406. o.moveElem.hide())
  407. }),
  408. e
  409. }
  410. ,
  411. s.pt.callback = function() {
  412. function e() {
  413. var e = a.cancel && a.cancel(t.index, n);
  414. e === !1 || r.close(t.index)
  415. }
  416. var t = this
  417. , n = t.layero
  418. , a = t.config;
  419. t.openLayer(),
  420. a.success && (2 == a.type ? n.find("iframe").on("load", function() {
  421. a.success(n, t.index)
  422. }) : a.success(n, t.index)),
  423. 6 == r.ie && t.IE6(n),
  424. n.find("." + l[6]).children("a").on("click", function() {
  425. var e = i(this).index();
  426. if (0 === e)
  427. a.yes ? a.yes(t.index, n) : a.btn1 ? a.btn1(t.index, n) : r.close(t.index);
  428. else {
  429. var o = a["btn" + (e + 1)] && a["btn" + (e + 1)](t.index, n);
  430. o === !1 || r.close(t.index)
  431. }
  432. }),
  433. n.find("." + l[7]).on("click", e),
  434. a.shadeClose && i("#layui-layer-shade" + t.index).on("click", function() {
  435. r.close(t.index)
  436. }),
  437. n.find(".layui-layer-min").on("click", function() {
  438. var e = a.min && a.min(n);
  439. e === !1 || r.min(t.index, a)
  440. }),
  441. n.find(".layui-layer-max").on("click", function() {
  442. i(this).hasClass("layui-layer-maxmin") ? (r.restore(t.index),
  443. a.restore && a.restore(n)) : (r.full(t.index, a),
  444. setTimeout(function() {
  445. a.full && a.full(n)
  446. }, 100))
  447. }),
  448. a.end && (o.end[t.index] = a.end)
  449. }
  450. ,
  451. o.reselect = function() {
  452. i.each(i("select"), function(e, t) {
  453. var n = i(this);
  454. n.parents("." + l[0])[0] || 1 == n.attr("layer") && i("." + l[0]).length < 1 && n.removeAttr("layer").show(),
  455. n = null
  456. })
  457. }
  458. ,
  459. s.pt.IE6 = function(e) {
  460. i("select").each(function(e, t) {
  461. var n = i(this);
  462. n.parents("." + l[0])[0] || "none" === n.css("display") || n.attr({
  463. layer: "1"
  464. }).hide(),
  465. n = null
  466. })
  467. }
  468. ,
  469. s.pt.openLayer = function() {
  470. var e = this;
  471. r.zIndex = e.config.zIndex,
  472. r.setTop = function(e) {
  473. var t = function() {
  474. r.zIndex++,
  475. e.css("z-index", r.zIndex + 1)
  476. };
  477. return r.zIndex = parseInt(e[0].style.zIndex),
  478. e.on("mousedown", t),
  479. r.zIndex
  480. }
  481. }
  482. ,
  483. o.record = function(e) {
  484. var t = [e.width(), e.height(), e.position().top, e.position().left + parseFloat(e.css("margin-left"))];
  485. e.find(".layui-layer-max").addClass("layui-layer-maxmin"),
  486. e.attr({
  487. area: t
  488. })
  489. }
  490. ,
  491. o.rescollbar = function(e) {
  492. l.html.attr("layer-full") == e && (l.html[0].style.removeProperty ? l.html[0].style.removeProperty("overflow") : l.html[0].style.removeAttribute("overflow"),
  493. l.html.removeAttr("layer-full"))
  494. }
  495. ,
  496. e.layer = r,
  497. r.getChildFrame = function(e, t) {
  498. return t = t || i("." + l[4]).attr("times"),
  499. i("#" + l[0] + t).find("iframe").contents().find(e)
  500. }
  501. ,
  502. r.getFrameIndex = function(e) {
  503. return i("#" + e).parents("." + l[4]).attr("times")
  504. }
  505. ,
  506. r.iframeAuto = function(e) {
  507. if (e) {
  508. var t = r.getChildFrame("html", e).outerHeight()
  509. , n = i("#" + l[0] + e)
  510. , a = n.find(l[1]).outerHeight() || 0
  511. , o = n.find("." + l[6]).outerHeight() || 0;
  512. n.css({
  513. height: t + a + o
  514. }),
  515. n.find("iframe").css({
  516. height: t
  517. })
  518. }
  519. }
  520. ,
  521. r.iframeSrc = function(e, t) {
  522. i("#" + l[0] + e).find("iframe").attr("src", t)
  523. }
  524. ,
  525. r.style = function(e, t, n) {
  526. var a = i("#" + l[0] + e)
  527. , r = a.find(".layui-layer-content")
  528. , s = a.attr("type")
  529. , f = a.find(l[1]).outerHeight() || 0
  530. , c = a.find("." + l[6]).outerHeight() || 0;
  531. a.attr("minLeft");
  532. s !== o.type[3] && s !== o.type[4] && (n || (parseFloat(t.width) <= 260 && (t.width = 260),
  533. parseFloat(t.height) - f - c <= 64 && (t.height = 64 + f + c)),
  534. a.css(t),
  535. c = a.find("." + l[6]).outerHeight(),
  536. s === o.type[2] ? a.find("iframe").css({
  537. height: parseFloat(t.height) - f - c
  538. }) : r.css({
  539. height: parseFloat(t.height) - f - c - parseFloat(r.css("padding-top")) - parseFloat(r.css("padding-bottom"))
  540. }))
  541. }
  542. ,
  543. r.min = function(e, t) {
  544. var a = i("#" + l[0] + e)
  545. , s = a.find(l[1]).outerHeight() || 0
  546. , f = a.attr("minLeft") || 181 * o.minIndex + "px"
  547. , c = a.css("position");
  548. o.record(a),
  549. o.minLeft[0] && (f = o.minLeft[0],
  550. o.minLeft.shift()),
  551. a.attr("position", c),
  552. r.style(e, {
  553. width: 180,
  554. height: s,
  555. left: f,
  556. top: n.height() - s,
  557. position: "fixed",
  558. overflow: "hidden"
  559. }, !0),
  560. a.find(".layui-layer-min").hide(),
  561. "page" === a.attr("type") && a.find(l[4]).hide(),
  562. o.rescollbar(e),
  563. a.attr("minLeft") || o.minIndex++,
  564. a.attr("minLeft", f)
  565. }
  566. ,
  567. r.restore = function(e) {
  568. var t = i("#" + l[0] + e)
  569. , n = t.attr("area").split(",");
  570. t.attr("type");
  571. r.style(e, {
  572. width: parseFloat(n[0]),
  573. height: parseFloat(n[1]),
  574. top: parseFloat(n[2]),
  575. left: parseFloat(n[3]),
  576. position: t.attr("position"),
  577. overflow: "visible"
  578. }, !0),
  579. t.find(".layui-layer-max").removeClass("layui-layer-maxmin"),
  580. t.find(".layui-layer-min").show(),
  581. "page" === t.attr("type") && t.find(l[4]).show(),
  582. o.rescollbar(e)
  583. }
  584. ,
  585. r.full = function(e) {
  586. var t, a = i("#" + l[0] + e);
  587. o.record(a),
  588. l.html.attr("layer-full") || l.html.css("overflow", "hidden").attr("layer-full", e),
  589. clearTimeout(t),
  590. t = setTimeout(function() {
  591. var t = "fixed" === a.css("position");
  592. r.style(e, {
  593. top: t ? 0 : n.scrollTop(),
  594. left: t ? 0 : n.scrollLeft(),
  595. width: n.width(),
  596. height: n.height()
  597. }, !0),
  598. a.find(".layui-layer-min").hide()
  599. }, 100)
  600. }
  601. ,
  602. r.title = function(e, t) {
  603. var n = i("#" + l[0] + (t || r.index)).find(l[1]);
  604. n.html(e)
  605. }
  606. ,
  607. r.close = function(e) {
  608. var t = i("#" + l[0] + e)
  609. , n = t.attr("type")
  610. , a = "layer-anim-close";
  611. if (t[0]) {
  612. var s = "layui-layer-wrap"
  613. , f = function() {
  614. if (n === o.type[1] && "object" === t.attr("conType")) {
  615. t.children(":not(." + l[5] + ")").remove();
  616. for (var a = t.find("." + s), r = 0; r < 2; r++)
  617. a.unwrap();
  618. a.css("display", a.data("display")).removeClass(s)
  619. } else {
  620. if (n === o.type[2])
  621. try {
  622. var f = i("#" + l[4] + e)[0];
  623. f.contentWindow.document.write(""),
  624. f.contentWindow.close(),
  625. t.find("." + l[5])[0].removeChild(f)
  626. } catch (c) {}
  627. t[0].innerHTML = "",
  628. t.remove()
  629. }
  630. "function" == typeof o.end[e] && o.end[e](),
  631. delete o.end[e]
  632. };
  633. t.data("anim") && t.addClass(a),
  634. i("#layui-layer-moves, #layui-layer-shade" + e).remove(),
  635. 6 == r.ie && o.reselect(),
  636. o.rescollbar(e),
  637. t.attr("minLeft") && (o.minIndex--,
  638. o.minLeft.push(t.attr("minLeft"))),
  639. setTimeout(function() {
  640. f()
  641. }, r.ie && r.ie < 10 || !t.data("anim") ? 0 : 200)
  642. }
  643. }
  644. ,
  645. r.closeAll = function(e) {
  646. i.each(i("." + l[0]), function() {
  647. var t = i(this)
  648. , n = e ? t.attr("type") === e : 1;
  649. n && r.close(t.attr("times")),
  650. n = null
  651. })
  652. }
  653. ;
  654. var f = r.cache || {}
  655. , c = function(e) {
  656. return f.skin ? " " + f.skin + " " + f.skin + "-" + e : ""
  657. };
  658. r.prompt = function(e, t) {
  659. var a = "";
  660. if (e = e || {},
  661. "function" == typeof e && (t = e),
  662. e.area) {
  663. var o = e.area;
  664. a = 'style="width: ' + o[0] + "; height: " + o[1] + ';"',
  665. delete e.area
  666. }
  667. var s, l = 2 == e.formType ? '<textarea class="layui-layer-input"' + a + ">" + (e.value || "") + "</textarea>" : function() {
  668. return '<input type="' + (1 == e.formType ? "password" : "text") + '" class="layui-layer-input" value="' + (e.value || "") + '">'
  669. }(), f = e.success;
  670. return delete e.success,
  671. r.open(i.extend({
  672. type: 1,
  673. btn: ["&#x786E;&#x5B9A;", "&#x53D6;&#x6D88;"],
  674. content: l,
  675. skin: "layui-layer-prompt" + c("prompt"),
  676. maxWidth: n.width(),
  677. success: function(e) {
  678. s = e.find(".layui-layer-input"),
  679. s.focus(),
  680. "function" == typeof f && f(e)
  681. },
  682. resize: !1,
  683. yes: function(i) {
  684. var n = s.val();
  685. "" === n ? s.focus() : n.length > (e.maxlength || 500) ? r.tips("&#x6700;&#x591A;&#x8F93;&#x5165;" + (e.maxlength || 500) + "&#x4E2A;&#x5B57;&#x6570;", s, {
  686. tips: 1
  687. }) : t && t(n, i, s)
  688. }
  689. }, e))
  690. }
  691. ,
  692. r.tab = function(e) {
  693. e = e || {};
  694. var t = e.tab || {}
  695. , n = e.success;
  696. return delete e.success,
  697. r.open(i.extend({
  698. type: 1,
  699. skin: "layui-layer-tab" + c("tab"),
  700. resize: !1,
  701. title: function() {
  702. var e = t.length
  703. , i = 1
  704. , n = "";
  705. if (e > 0)
  706. for (n = '<span class="layui-layer-tabnow">' + t[0].title + "</span>"; i < e; i++)
  707. n += "<span>" + t[i].title + "</span>";
  708. return n
  709. }(),
  710. content: '<ul class="layui-layer-tabmain">' + function() {
  711. var e = t.length
  712. , i = 1
  713. , n = "";
  714. if (e > 0)
  715. for (n = '<li class="layui-layer-tabli xubox_tab_layer">' + (t[0].content || "no content") + "</li>"; i < e; i++)
  716. n += '<li class="layui-layer-tabli">' + (t[i].content || "no content") + "</li>";
  717. return n
  718. }() + "</ul>",
  719. success: function(t) {
  720. var a = t.find(".layui-layer-title").children()
  721. , o = t.find(".layui-layer-tabmain").children();
  722. a.on("mousedown", function(t) {
  723. t.stopPropagation ? t.stopPropagation() : t.cancelBubble = !0;
  724. var n = i(this)
  725. , a = n.index();
  726. n.addClass("layui-layer-tabnow").siblings().removeClass("layui-layer-tabnow"),
  727. o.eq(a).show().siblings().hide(),
  728. "function" == typeof e.change && e.change(a)
  729. }),
  730. "function" == typeof n && n(t)
  731. }
  732. }, e))
  733. }
  734. ,
  735. r.photos = function(t, n, a) {
  736. function o(e, t, i) {
  737. var n = new Image;
  738. return n.src = e,
  739. n.complete ? t(n) : (n.onload = function() {
  740. n.onload = null,
  741. t(n)
  742. }
  743. ,
  744. void (n.onerror = function(e) {
  745. n.onerror = null,
  746. i(e)
  747. }
  748. ))
  749. }
  750. var s = {};
  751. if (t = t || {},
  752. t.photos) {
  753. var l = t.photos.constructor === Object
  754. , f = l ? t.photos : {}
  755. , u = f.data || []
  756. , d = f.start || 0;
  757. s.imgIndex = (0 | d) + 1,
  758. t.img = t.img || "img";
  759. var y = t.success;
  760. if (delete t.success,
  761. l) {
  762. if (0 === u.length)
  763. return r.msg("&#x6CA1;&#x6709;&#x56FE;&#x7247;")
  764. } else {
  765. var p = i(t.photos)
  766. , h = function() {
  767. u = [],
  768. p.find(t.img).each(function(e) {
  769. var t = i(this);
  770. t.attr("layer-index", e),
  771. u.push({
  772. alt: t.attr("alt"),
  773. pid: t.attr("layer-pid"),
  774. src: t.attr("layer-src") || t.attr("src"),
  775. thumb: t.attr("src")
  776. })
  777. })
  778. };
  779. if (h(),
  780. 0 === u.length)
  781. return;
  782. if (n || p.on("click", t.img, function() {
  783. var e = i(this)
  784. , n = e.attr("layer-index");
  785. r.photos(i.extend(t, {
  786. photos: {
  787. start: n,
  788. data: u,
  789. tab: t.tab
  790. },
  791. full: t.full
  792. }), !0),
  793. h()
  794. }),
  795. !n)
  796. return
  797. }
  798. s.imgprev = function(e) {
  799. s.imgIndex--,
  800. s.imgIndex < 1 && (s.imgIndex = u.length),
  801. s.tabimg(e)
  802. }
  803. ,
  804. s.imgnext = function(e, t) {
  805. s.imgIndex++,
  806. s.imgIndex > u.length && (s.imgIndex = 1,
  807. t) || s.tabimg(e)
  808. }
  809. ,
  810. s.keyup = function(e) {
  811. if (!s.end) {
  812. var t = e.keyCode;
  813. e.preventDefault(),
  814. 37 === t ? s.imgprev(!0) : 39 === t ? s.imgnext(!0) : 27 === t && r.close(s.index)
  815. }
  816. }
  817. ,
  818. s.tabimg = function(e) {
  819. u.length <= 1 || (f.start = s.imgIndex - 1,
  820. r.close(s.index),
  821. setTimeout(function() {
  822. r.photos(t, !0, e)
  823. }, 200))
  824. }
  825. ,
  826. s.event = function() {
  827. s.bigimg.hover(function() {
  828. s.imgsee.show()
  829. }, function() {
  830. s.imgsee.hide()
  831. }),
  832. s.bigimg.find(".layui-layer-imgprev").on("click", function(e) {
  833. e.preventDefault(),
  834. s.imgprev()
  835. }),
  836. s.bigimg.find(".layui-layer-imgnext").on("click", function(e) {
  837. e.preventDefault(),
  838. s.imgnext()
  839. }),
  840. i(document).on("keyup", s.keyup)
  841. }
  842. ,
  843. s.loadi = r.load(1, {
  844. shade: !("shade"in t) && .9,
  845. scrollbar: !1
  846. }),
  847. o(u[d].src, function(n) {
  848. r.close(s.loadi),
  849. s.index = r.open(i.extend({
  850. type: 1,
  851. id: "layui-layer-photos",
  852. area: function() {
  853. var a = [n.width, n.height]
  854. , o = [i(e).width() - 100, i(e).height() - 100];
  855. if (!t.full && (a[0] > o[0] || a[1] > o[1])) {
  856. var r = [a[0] / o[0], a[1] / o[1]];
  857. r[0] > r[1] ? (a[0] = a[0] / r[0],
  858. a[1] = a[1] / r[0]) : r[0] < r[1] && (a[0] = a[0] / r[1],
  859. a[1] = a[1] / r[1])
  860. }
  861. return [a[0] + "px", a[1] + "px"]
  862. }(),
  863. title: !1,
  864. shade: .9,
  865. shadeClose: !0,
  866. closeBtn: !1,
  867. move: ".layui-layer-phimg img",
  868. moveType: 1,
  869. scrollbar: !1,
  870. moveOut: !0,
  871. anim: 5 * Math.random() | 0,
  872. skin: "layui-layer-photos" + c("photos"),
  873. 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>",
  874. success: function(e, i) {
  875. s.bigimg = e.find(".layui-layer-phimg"),
  876. s.imgsee = e.find(".layui-layer-imguide,.layui-layer-imgbar"),
  877. s.event(e),
  878. t.tab && t.tab(u[d], e),
  879. "function" == typeof y && y(e)
  880. },
  881. end: function() {
  882. s.end = !0,
  883. i(document).off("keyup", s.keyup)
  884. }
  885. }, t))
  886. }, function() {
  887. r.close(s.loadi),
  888. r.msg("&#x5F53;&#x524D;&#x56FE;&#x7247;&#x5730;&#x5740;&#x5F02;&#x5E38;<br>&#x662F;&#x5426;&#x7EE7;&#x7EED;&#x67E5;&#x770B;&#x4E0B;&#x4E00;&#x5F20;&#xFF1F;", {
  889. time: 3e4,
  890. btn: ["&#x4E0B;&#x4E00;&#x5F20;", "&#x4E0D;&#x770B;&#x4E86;"],
  891. yes: function() {
  892. u.length > 1 && s.imgnext(!0, !0)
  893. }
  894. })
  895. })
  896. }
  897. }
  898. ,
  899. o.run = function(t) {
  900. i = t,
  901. n = i(e),
  902. l.html = i("html"),
  903. r.open = function(e) {
  904. var t = new s(e);
  905. return t.index
  906. }
  907. }
  908. ,
  909. e.layui && layui.define ? (r.ready(),
  910. layui.define("jquery", function(t) {
  911. r.path = layui.cache.dir,
  912. o.run(layui.jquery),
  913. e.layer = r,
  914. t("layer", r)
  915. })) : "function" == typeof define && define.amd ? define(["jquery"], function() {
  916. return o.run(e.jQuery),
  917. r
  918. }) : function() {
  919. o.run(e.jQuery),
  920. r.ready()
  921. }()
  922. }(window);