dialog.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. ; !
  2. function (a, b) {
  3. "use strict";
  4. var c,
  5. d,
  6. e = {
  7. getPath: function () {
  8. var a = document.scripts,
  9. b = a[a.length - 1],
  10. c = b.src;
  11. if (!b.getAttribute("merge")) return c.substring(0, c.lastIndexOf("/") + 1)
  12. }(),
  13. config: {},
  14. end: {},
  15. btn: ["确定", "取消"],
  16. type: ["dialog", "page", "iframe", "loading", "tips"]
  17. };
  18. a.layer = {
  19. v: "1.9.3",
  20. ie6: !!a.ActiveXObject && !a.XMLHttpRequest,
  21. index: 0,
  22. path: e.getPath,
  23. config: function (a, b) {
  24. var d = 0;
  25. return a = a || {},
  26. layer.cache = e.config = c.extend(e.config, a),
  27. layer.path = e.config.path || layer.path,
  28. "string" == typeof a.extend && (a.extend = [a.extend]),
  29. layer.use("skin/dialog.css", a.extend && a.extend.length > 0 ?
  30. function f() {
  31. var c = a.extend;
  32. layer.use(c[c[d] ? d : d - 1], d < c.length ?
  33. function () {
  34. return ++d,
  35. f
  36. }() : b)
  37. }() : b),
  38. this
  39. },
  40. use: function (a, b, d) {
  41. var e = c("head")[0],
  42. a = a.replace(/\s/g, ""),
  43. f = /\.css$/.test(a),
  44. g = document.createElement(f ? "link" : "script"),
  45. h = "layui_layer_" + a.replace(/\.|\//g, "");
  46. return layer.path ? (f && (g.rel = "stylesheet"), g[f ? "href" : "src"] = /^http:\/\//.test(a) ? a : layer.path + a, g.id = h, c("#" + h)[0] || e.appendChild(g),
  47. function i() {
  48. (f ? 1989 === parseInt(c("#" + h).css("width")) : layer[d || h]) ?
  49. function () {
  50. b && b();
  51. try {
  52. f || e.removeChild(g)
  53. } catch (a) { }
  54. }() : setTimeout(i, 100)
  55. }(), this) : void 0
  56. },
  57. ready: function (a, b) {
  58. var d = "function" == typeof a;
  59. return d && (b = a),
  60. layer.config(c.extend(e.config,
  61. function () {
  62. return d ? {} : {
  63. path: a
  64. }
  65. }()), b),
  66. this
  67. },
  68. alert: function (a, b, d) {
  69. var e = "function" == typeof b;
  70. return e && (d = b),
  71. layer.open(c.extend({
  72. content: a,
  73. yes: d
  74. },
  75. e ? {} : b))
  76. },
  77. confirm: function (a, b, d, f) {
  78. var g = "function" == typeof b;
  79. return g && (f = d, d = b),
  80. layer.open(c.extend({
  81. content: a,
  82. btn: e.btn,
  83. yes: d,
  84. cancel: f
  85. },
  86. g ? {} : b))
  87. },
  88. msg: function (a, d, f) {
  89. var h = "function" == typeof d,
  90. i = e.config.skin,
  91. j = (i ? i + " " + i + "-msg" : "") || "layui-layer-msg",
  92. k = g.anim.length - 1;
  93. return h && (f = d),
  94. layer.open(c.extend({
  95. content: a,
  96. time: 3e3,
  97. shade: !1,
  98. skin: j,
  99. title: !1,
  100. closeBtn: !1,
  101. btn: !1,
  102. end: f
  103. },
  104. h && !e.config.skin ? {
  105. skin: j + " layui-layer-hui",
  106. shift: k
  107. } : function () {
  108. return d = d || {},
  109. (-1 === d.icon || d.icon === b && !e.config.skin) && (d.skin = j + " " + (d.skin || "layui-layer-hui")),
  110. d
  111. }()))
  112. },
  113. load: function (a, b) {
  114. return layer.open(c.extend({
  115. type: 3,
  116. icon: a || 0,
  117. shade: .01
  118. },
  119. b))
  120. },
  121. tips: function (a, b, d) {
  122. return layer.open(c.extend({
  123. type: 4,
  124. content: [a, b],
  125. closeBtn: !1,
  126. time: 3e3,
  127. maxWidth: 210
  128. },
  129. d))
  130. }
  131. };
  132. var f = function (a) {
  133. var b = this;
  134. b.index = ++layer.index,
  135. b.config = c.extend({},
  136. b.config, e.config, a),
  137. b.creat()
  138. };
  139. f.pt = f.prototype;
  140. var g = ["layui-layer", ".layui-layer-title", ".layui-layer-main", ".layui-layer-dialog", "layui-layer-iframe", "layui-layer-content", "layui-layer-btn", "layui-layer-close"];
  141. g.anim = ["layui-anim", "layui-anim-01", "layui-anim-02", "layui-anim-03", "layui-anim-04", "layui-anim-05", "layui-anim-06"],
  142. f.pt.config = {
  143. type: 0,
  144. shade: .3,
  145. fix: !0,
  146. move: g[1],
  147. title: "",
  148. offset: "auto",
  149. area: "auto",
  150. closeBtn: 1,
  151. time: 0,
  152. zIndex: 2900,
  153. maxWidth: "auto",
  154. shift: -1,
  155. icon: -1,
  156. scrollbar: !0,
  157. tips: 2
  158. },
  159. f.pt.vessel = function (a, b) {
  160. var c = this,
  161. d = c.index,
  162. f = c.config,
  163. h = f.zIndex + d,
  164. i = "object" == typeof f.title,
  165. j = f.maxmin && (1 === f.type || 2 === f.type),
  166. k = f.title ? '<div class="layui-layer-title" style="' + (i ? f.title[1] : "") + '">' + (i ? f.title[0] : f.title) + "</div>" : "";
  167. var _length = top.$(".layui-layer-shade").length;
  168. var _opacity = (f.shade[0] || f.shade);
  169. if (_length > 0) {
  170. //_opacity = 0;
  171. }
  172. return f.zIndex = h,
  173. b([f.shade ? '<div class="layui-layer-shade" id="layui-layer-shade' + d + '" times="' + d + '" style="' + ("z-index:" + (h - 1) + "; background-color:" + (f.shade[1] || "#000") + "; opacity:" + _opacity + "; filter:alpha(opacity=" + (100 * f.shade[0] || 100 * f.shade) + ");") + '"></div>' : "", '<div class="' + g[0] + " " + (g.anim[f.shift] || "") + (" layui-layer-" + e.type[f.type]) + (0 != f.type && 2 != f.type || f.shade ? "" : " layui-layer-border") + " " + (f.skin || "") + '" id="' + g[0] + d + '" type="' + e.type[f.type] + '" times="' + d + '" showtime="' + f.time + '" conType="' + (a ? "object" : "string") + '" style="z-index: ' + h + "; width:" + f.area[0] + ";height:" + f.area[1] + (f.fix ? "" : ";position:absolute;") + '">' + (a && 2 != f.type ? "" : k) + '<div class="layui-layer-content' + (0 == f.type && -1 !== f.icon ? " layui-layer-padding" : "") + (3 == f.type ? " layui-layer-loading" + f.icon : "") + '">' + (0 == f.type && -1 !== f.icon ? '<i class="layui-layer-ico layui-layer-ico' + f.icon + '"></i>' : "") + (1 == f.type && a ? "" : f.content || "") + '</div><span class="layui-layer-setwin">' +
  174. function () {
  175. var a = j ? '<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>' : "";
  176. return f.closeBtn && (a += '<a class="' + g[7] + " " + g[7] + (f.title ? f.closeBtn : 4 == f.type ? "1" : "2") + '" href="javascript:;">×</a>'),
  177. a
  178. }() + "</span>" + (f.btn ?
  179. function () {
  180. var a = "";
  181. "string" == typeof f.btn && (f.btn = [f.btn]);
  182. for (var b = 0, c = f.btn.length; c > b; b++) a += '<a class="' + g[6] + b + '">' + f.btn[b] + "</a>";
  183. var Content_IsClose = '';
  184. if (e.type[f.type] == "iframe") {
  185. Content_IsClose = '<div style="float: left;padding-top:5px;padding-left:15px;-moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;user-select: none;"><input checked="checked" type="checkbox" id="IsdialogClose" style="vertical-align: middle;margin-bottom:2px;" /><label style=";padding-left:5px;cursor:pointer" for="IsdialogClose">确认并关闭窗口</label></div>';
  186. }
  187. return '<div class="' + g[6] + '">' + a + Content_IsClose + '</div>';
  188. }() : "") + "</div>"], k),
  189. c
  190. },
  191. f.pt.creat = function () {
  192. var a = this,
  193. b = a.config,
  194. f = a.index,
  195. h = b.content,
  196. i = "object" == typeof h;
  197. switch ("string" == typeof b.area && (b.area = "auto" === b.area ? ["", ""] : [b.area, ""]), b.type) {
  198. case 0:
  199. b.btn = "btn" in b ? b.btn : e.btn[0],
  200. layer.closeAll("dialog");
  201. break;
  202. case 2:
  203. var h = b.content = i ? b.content : [b.content || "", "auto"];
  204. var ajaxloader = '<div class="ajax-loader" style="cursor: progress; position: absolute; width: 100%; height: 100%; background: #fff; z-index: 100; overflow: hidden;"></div>';
  205. b.content = ajaxloader + '<iframe scrolling="' + (b.content[1] || "auto") + '" allowtransparency="true" id="' + b.id + '" name="' + b.id + '" onload="Loading(false);" frameborder="0" src="' + b.content[0] + '"></iframe>';
  206. break;
  207. case 3:
  208. b.title = !1,
  209. b.closeBtn = !1,
  210. -1 === b.icon && 0 === b.icon,
  211. layer.closeAll("loading");
  212. break;
  213. case 4:
  214. i || (b.content = [b.content, "body"]),
  215. b.follow = b.content[1],
  216. b.content = b.content[0] + '<i class="layui-layer-TipsG"></i>',
  217. b.title = !1,
  218. b.shade = !1,
  219. b.fix = !1,
  220. b.tips = "object" == typeof b.tips ? b.tips : [b.tips, !0],
  221. b.tipsMore || layer.closeAll("tips")
  222. }
  223. a.vessel(i,
  224. function (d, e) {
  225. c("body").append(d[0]),
  226. i ?
  227. function () {
  228. 2 == b.type || 4 == b.type ?
  229. function () {
  230. c("body").append(d[1])
  231. }() : function () {
  232. h.parents("." + g[0])[0] || (h.show().addClass("layui-layer-wrap").wrap(d[1]), c("#" + g[0] + f).find("." + g[5]).before(e))
  233. }()
  234. }() : c("body").append(d[1]),
  235. a.layero = c("#" + g[0] + f),
  236. b.scrollbar || g.html.css("overflow", "hidden").attr("layer-full", f)
  237. }).auto(f),
  238. 2 == b.type && layer.ie6 && a.layero.find("iframe").attr("src", h[0]),
  239. 4 == b.type ? a.tips() : a.offset(),
  240. b.fix && d.on("resize",
  241. function () {
  242. a.offset(),
  243. (/^\d+%$/.test(b.area[0]) || /^\d+%$/.test(b.area[1])) && a.auto(f),
  244. 4 == b.type && a.tips()
  245. }),
  246. b.time <= 0 || setTimeout(function () {
  247. layer.close(a.index)
  248. },
  249. b.time),
  250. a.move().callback()
  251. },
  252. f.pt.auto = function (a) {
  253. function b(a) {
  254. a = h.find(a),
  255. a.height(i[1] - j - k - 2 * (0 | parseFloat(a.css("padding"))))
  256. }
  257. var e = this,
  258. f = e.config,
  259. h = c("#" + g[0] + a);
  260. "" === f.area[0] && f.maxWidth > 0 && (/MSIE 7/.test(navigator.userAgent) && f.btn && h.width(h.innerWidth()), h.outerWidth() > f.maxWidth && h.width(f.maxWidth));
  261. var i = [h.innerWidth(), h.innerHeight()],
  262. j = h.find(g[1]).outerHeight() || 0,
  263. k = h.find("." + g[6]).outerHeight() || 0;
  264. switch (f.type) {
  265. case 2:
  266. b("iframe");
  267. break;
  268. default:
  269. "" === f.area[1] ? f.fix && i[1] > d.height() && (i[1] = d.height(), b("." + g[5])) : b("." + g[5])
  270. }
  271. return e
  272. },
  273. f.pt.offset = function () {
  274. var a = this,
  275. b = a.config,
  276. c = a.layero,
  277. e = [c.outerWidth(), c.outerHeight()],
  278. f = "object" == typeof b.offset;
  279. a.offsetTop = (d.height() - e[1]) / 2,
  280. a.offsetLeft = (d.width() - e[0]) / 2,
  281. f ? (a.offsetTop = b.offset[0], a.offsetLeft = b.offset[1] || a.offsetLeft) : "auto" !== b.offset && (a.offsetTop = b.offset, "rb" === b.offset && (a.offsetTop = d.height() - e[1], a.offsetLeft = d.width() - e[0])),
  282. b.fix || (a.offsetTop = /%$/.test(a.offsetTop) ? d.height() * parseFloat(a.offsetTop) / 100 : parseFloat(a.offsetTop), a.offsetLeft = /%$/.test(a.offsetLeft) ? d.width() * parseFloat(a.offsetLeft) / 100 : parseFloat(a.offsetLeft), a.offsetTop += d.scrollTop(), a.offsetLeft += d.scrollLeft()),
  283. c.css({
  284. top: a.offsetTop,
  285. left: a.offsetLeft
  286. })
  287. },
  288. f.pt.tips = function () {
  289. var a = this,
  290. b = a.config,
  291. e = a.layero,
  292. f = [e.outerWidth(), e.outerHeight()],
  293. h = c(b.follow);
  294. h[0] || (h = c("body"));
  295. var i = {
  296. width: h.outerWidth(),
  297. height: h.outerHeight(),
  298. top: h.offset().top,
  299. left: h.offset().left
  300. },
  301. j = e.find(".layui-layer-TipsG"),
  302. k = b.tips[0];
  303. b.tips[1] || j.remove(),
  304. i.autoLeft = function () {
  305. i.left + f[0] - d.width() > 0 ? (i.tipLeft = i.left + i.width - f[0], j.css({
  306. right: 12,
  307. left: "auto"
  308. })) : i.tipLeft = i.left
  309. },
  310. i.where = [function () {
  311. i.autoLeft(),
  312. i.tipTop = i.top - f[1] - 10,
  313. j.removeClass("layui-layer-TipsB").addClass("layui-layer-TipsT").css("border-right-color", b.tips[1])
  314. },
  315. function () {
  316. i.tipLeft = i.left + i.width + 10,
  317. i.tipTop = i.top,
  318. j.removeClass("layui-layer-TipsL").addClass("layui-layer-TipsR").css("border-bottom-color", b.tips[1])
  319. },
  320. function () {
  321. i.autoLeft(),
  322. i.tipTop = i.top + i.height + 10,
  323. j.removeClass("layui-layer-TipsT").addClass("layui-layer-TipsB").css("border-right-color", b.tips[1])
  324. },
  325. function () {
  326. i.tipLeft = i.left - f[0] - 10,
  327. i.tipTop = i.top,
  328. j.removeClass("layui-layer-TipsR").addClass("layui-layer-TipsL").css("border-bottom-color", b.tips[1])
  329. }],
  330. i.where[k - 1](),
  331. 1 === k ? i.top - (d.scrollTop() + f[1] + 16) < 0 && i.where[2]() : 2 === k ? d.width() - (i.left + i.width + f[0] + 16) > 0 || i.where[3]() : 3 === k ? i.top - d.scrollTop() + i.height + f[1] + 16 - d.height() > 0 && i.where[0]() : 4 === k && f[0] + 16 - i.left > 0 && i.where[1](),
  332. e.find("." + g[5]).css({
  333. "background-color": b.tips[1],
  334. "padding-right": b.closeBtn ? "30px" : ""
  335. }),
  336. e.css({
  337. left: i.tipLeft,
  338. top: i.tipTop
  339. })
  340. },
  341. f.pt.move = function () {
  342. var a = this,
  343. b = a.config,
  344. e = {
  345. setY: 0,
  346. moveLayer: function () {
  347. var a = e.layero,
  348. b = parseInt(a.css("margin-left")),
  349. c = parseInt(e.move.css("left"));
  350. 0 === b || (c -= b),
  351. "fixed" !== a.css("position") && (c -= a.parent().offset().left, e.setY = 0),
  352. a.css({
  353. left: c,
  354. top: parseInt(e.move.css("top")) - e.setY
  355. })
  356. }
  357. },
  358. f = a.layero.find(b.move);
  359. return b.move && f.attr("move", "ok"),
  360. f.css({
  361. cursor: b.move ? "move" : "auto"
  362. }),
  363. c(b.move).on("mousedown",
  364. function (a) {
  365. if (a.preventDefault(), "ok" === c(this).attr("move")) {
  366. e.ismove = !0,
  367. e.layero = c(this).parents("." + g[0]);
  368. var f = e.layero.offset().left,
  369. h = e.layero.offset().top,
  370. i = e.layero.outerWidth() - 6,
  371. j = e.layero.outerHeight() - 6;
  372. c("#layui-layer-moves")[0] || c("body").append('<div id="layui-layer-moves" class="layui-layer-moves" style="left:' + f + "px; top:" + h + "px; width:" + i + "px; height:" + j + 'px; z-index:2147483584"></div>'),
  373. e.move = c("#layui-layer-moves"),
  374. b.moveType && e.move.css({
  375. visibility: "hidden"
  376. }),
  377. e.moveX = a.pageX - e.move.position().left,
  378. e.moveY = a.pageY - e.move.position().top,
  379. "fixed" !== e.layero.css("position") || (e.setY = d.scrollTop())
  380. }
  381. }),
  382. c(document).mousemove(function (a) {
  383. if (e.ismove) {
  384. var c = a.pageX - e.moveX,
  385. f = a.pageY - e.moveY;
  386. if (a.preventDefault(), !b.moveOut) {
  387. e.setY = d.scrollTop();
  388. var g = d.width() - e.move.outerWidth(),
  389. h = e.setY;
  390. 0 > c && (c = 0),
  391. c > g && (c = g),
  392. h > f && (f = h),
  393. f > d.height() - e.move.outerHeight() + e.setY && (f = d.height() - e.move.outerHeight() + e.setY)
  394. }
  395. e.move.css({
  396. left: c,
  397. top: f
  398. }),
  399. b.moveType && e.moveLayer(),
  400. c = f = g = h = null
  401. }
  402. }).mouseup(function () {
  403. try {
  404. e.ismove && (e.moveLayer(), e.move.remove()),
  405. e.ismove = !1
  406. } catch (a) {
  407. e.ismove = !1
  408. }
  409. b.moveEnd && b.moveEnd()
  410. }),
  411. a
  412. },
  413. f.pt.callback = function () {
  414. function a() {
  415. var a = f.cancel && f.cancel(b.index);
  416. a === !1 || layer.close(b.index)
  417. }
  418. var b = this,
  419. d = b.layero,
  420. f = b.config;
  421. b.openLayer(),
  422. f.success && (2 == f.type ? d.find("iframe")[0].onload = function () {
  423. this.className = "",
  424. f.success(d, b.index)
  425. } : f.success(d, b.index)),
  426. layer.ie6 && b.IE6(d),
  427. d.find("." + g[6]).children("a").on("click",
  428. function () {
  429. var e = c(this).index();
  430. 0 === e ? f.yes ? f.yes(b.index, d) : layer.close(b.index) : 1 === e ? a() : f["btn" + (e + 1)] ? f["btn" + (e + 1)](b.index, d) : layer.close(b.index)
  431. }),
  432. d.find("." + g[7]).on("click", a),
  433. f.shadeClose && c("#layui-layer-shade" + b.index).on("click",
  434. function () {
  435. layer.close(b.index)
  436. }),
  437. d.find(".layui-layer-min").on("click",
  438. function () {
  439. layer.min(b.index, f),
  440. f.min && f.min(d)
  441. }),
  442. d.find(".layui-layer-max").on("click",
  443. function () {
  444. c(this).hasClass("layui-layer-maxmin") ? (layer.restore(b.index), f.restore && f.restore(d)) : (layer.full(b.index, f), f.full && f.full(d))
  445. }),
  446. f.end && (e.end[b.index] = f.end)
  447. },
  448. e.reselect = function () {
  449. c.each(c("select"),
  450. function (a, b) {
  451. var d = c(this);
  452. d.parents("." + g[0])[0] || 1 == d.attr("layer") && c("." + g[0]).length < 1 && d.removeAttr("layer").show(),
  453. d = null
  454. })
  455. },
  456. f.pt.IE6 = function (a) {
  457. function b() {
  458. a.css({
  459. top: f + (e.config.fix ? d.scrollTop() : 0)
  460. })
  461. }
  462. var e = this,
  463. f = a.offset().top;
  464. b(),
  465. d.scroll(b),
  466. c("select").each(function (a, b) {
  467. var d = c(this);
  468. d.parents("." + g[0])[0] || "none" === d.css("display") || d.attr({
  469. layer: "1"
  470. }).hide(),
  471. d = null
  472. })
  473. },
  474. f.pt.openLayer = function () {
  475. var a = this;
  476. layer.zIndex = a.config.zIndex,
  477. layer.setTop = function (a) {
  478. var b = function () {
  479. layer.zIndex++,
  480. a.css("z-index", layer.zIndex + 1)
  481. };
  482. return layer.zIndex = parseInt(a[0].style.zIndex),
  483. a.on("mousedown", b),
  484. layer.zIndex
  485. }
  486. },
  487. e.record = function (a) {
  488. var b = [a.outerWidth(), a.outerHeight(), a.position().top, a.position().left + parseFloat(a.css("margin-left"))];
  489. a.find(".layui-layer-max").addClass("layui-layer-maxmin"),
  490. a.attr({
  491. area: b
  492. })
  493. },
  494. e.rescollbar = function (a) {
  495. g.html.attr("layer-full") == a && (g.html[0].style.removeProperty ? g.html[0].style.removeProperty("overflow") : g.html[0].style.removeAttribute("overflow"), g.html.removeAttr("layer-full"))
  496. },
  497. layer.getChildFrame = function (a, b) {
  498. return b = b || c("." + g[4]).attr("times"),
  499. c("#" + g[0] + b).find("iframe").contents().find(a)
  500. },
  501. layer.getFrameIndex = function (a) {
  502. return c("#" + a).parents("." + g[4]).attr("times")
  503. },
  504. layer.iframeAuto = function (a) {
  505. if (a) {
  506. var b = layer.getChildFrame("body", a).outerHeight(),
  507. d = c("#" + g[0] + a),
  508. e = d.find(g[1]).outerHeight() || 0,
  509. f = d.find("." + g[6]).outerHeight() || 0;
  510. d.css({
  511. height: b + e + f
  512. }),
  513. d.find("iframe").css({
  514. height: b
  515. })
  516. }
  517. },
  518. layer.iframeSrc = function (a, b) {
  519. c("#" + g[0] + a).find("iframe").attr("src", b)
  520. },
  521. layer.style = function (a, b) {
  522. var d = c("#" + g[0] + a),
  523. f = d.attr("type"),
  524. h = d.find(g[1]).outerHeight() || 0,
  525. i = d.find("." + g[6]).outerHeight() || 0; (f === e.type[1] || f === e.type[2]) && (d.css(b), f === e.type[2] && d.find("iframe").css({
  526. height: parseFloat(b.height) - h - i
  527. }))
  528. },
  529. layer.min = function (a, b) {
  530. var d = c("#" + g[0] + a),
  531. f = d.find(g[1]).outerHeight() || 0;
  532. e.record(d),
  533. layer.style(a, {
  534. width: 180,
  535. height: f,
  536. overflow: "hidden"
  537. }),
  538. d.find(".layui-layer-min").hide(),
  539. "page" === d.attr("type") && d.find(g[4]).hide(),
  540. e.rescollbar(a)
  541. },
  542. layer.restore = function (a) {
  543. var b = c("#" + g[0] + a),
  544. d = b.attr("area").split(",");
  545. b.attr("type");
  546. layer.style(a, {
  547. width: parseFloat(d[0]),
  548. height: parseFloat(d[1]),
  549. top: parseFloat(d[2]),
  550. left: parseFloat(d[3]),
  551. overflow: "visible"
  552. }),
  553. b.find(".layui-layer-max").removeClass("layui-layer-maxmin"),
  554. b.find(".layui-layer-min").show(),
  555. "page" === b.attr("type") && b.find(g[4]).show(),
  556. e.rescollbar(a)
  557. },
  558. layer.full = function (a) {
  559. var b,
  560. f = c("#" + g[0] + a);
  561. e.record(f),
  562. g.html.attr("layer-full") || g.html.css("overflow", "hidden").attr("layer-full", a),
  563. clearTimeout(b),
  564. b = setTimeout(function () {
  565. var b = "fixed" === f.css("position");
  566. layer.style(a, {
  567. top: b ? 0 : d.scrollTop(),
  568. left: b ? 0 : d.scrollLeft(),
  569. width: d.width(),
  570. height: d.height() - 14
  571. }),
  572. f.find(".layui-layer-min").hide()
  573. },
  574. 100)
  575. },
  576. layer.title = function (a, b) {
  577. var d = c("#" + g[0] + (b || layer.index)).find(g[1]);
  578. d.html(a)
  579. },
  580. layer.close = function (a) {
  581. var b = c("#" + g[0] + a),
  582. d = b.attr("type");
  583. if (b[0]) {
  584. if (d === e.type[1] && "object" === b.attr("conType")) {
  585. b.children(":not(." + g[5] + ")").remove();
  586. for (var f = 0; 2 > f; f++) b.find(".layui-layer-wrap").unwrap().hide()
  587. } else {
  588. if (d === e.type[2]) try {
  589. var h = c("#" + g[4] + a)[0];
  590. h.contentWindow.document.write(""),
  591. h.contentWindow.close(),
  592. b.find("." + g[5])[0].removeChild(h)
  593. } catch (i) { }
  594. b[0].innerHTML = "",
  595. b.remove()
  596. }
  597. c("#layui-layer-moves, #layui-layer-shade" + a).remove(),
  598. layer.ie6 && e.reselect(),
  599. e.rescollbar(a),
  600. "function" == typeof e.end[a] && e.end[a](),
  601. delete e.end[a]
  602. }
  603. },
  604. layer.closeAll = function (a) {
  605. c.each(c("." + g[0]),
  606. function () {
  607. var b = c(this),
  608. d = a ? b.attr("type") === a : 1;
  609. d && layer.close(b.attr("times")),
  610. d = null
  611. })
  612. },
  613. e.run = function () {
  614. c = jQuery,
  615. d = c(a),
  616. g.html = c("html"),
  617. layer.open = function (a) {
  618. var b = new f(a);
  619. return b.index
  620. }
  621. },
  622. "function" == typeof define ? define(function () {
  623. return e.run(),
  624. layer
  625. }) : function () {
  626. e.run(),
  627. layer.use("dialog.css")
  628. }()
  629. }(window);