element.dev.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. "use strict";
  2. /** layui-v2.5.6 MIT License By https://www.layui.com */
  3. ;
  4. layui.define("jquery", function (t) {
  5. "use strict";
  6. var a = layui.$,
  7. i = (layui.hint(), layui.device()),
  8. e = "element",
  9. l = "layui-this",
  10. n = "layui-show",
  11. s = function s() {
  12. this.config = {};
  13. };
  14. s.prototype.set = function (t) {
  15. var i = this;
  16. return a.extend(!0, i.config, t), i;
  17. }, s.prototype.on = function (t, a) {
  18. return layui.onevent.call(this, e, t, a);
  19. }, s.prototype.tabAdd = function (t, i) {
  20. var e = ".layui-tab-title",
  21. l = a(".layui-tab[lay-filter=" + t + "]"),
  22. n = l.children(e),
  23. s = n.children(".layui-tab-bar"),
  24. o = l.children(".layui-tab-content"),
  25. r = '<li lay-id="' + (i.id || "") + '"' + (i.attr ? ' lay-attr="' + i.attr + '"' : "") + ">" + (i.title || "unnaming") + "</li>";
  26. return s[0] ? s.before(r) : n.append(r), o.append('<div class="layui-tab-item">' + (i.content || "") + "</div>"), f.hideTabMore(!0), f.tabAuto(), this;
  27. }, s.prototype.tabDelete = function (t, i) {
  28. var e = ".layui-tab-title",
  29. l = a(".layui-tab[lay-filter=" + t + "]"),
  30. n = l.children(e),
  31. s = n.find('>li[lay-id="' + i + '"]');
  32. return f.tabDelete(null, s), this;
  33. }, s.prototype.tabChange = function (t, i) {
  34. var e = ".layui-tab-title",
  35. l = a(".layui-tab[lay-filter=" + t + "]"),
  36. n = l.children(e),
  37. s = n.find('>li[lay-id="' + i + '"]');
  38. return f.tabClick.call(s[0], null, null, s), this;
  39. }, s.prototype.tab = function (t) {
  40. t = t || {}, b.on("click", t.headerElem, function (i) {
  41. var e = a(this).index();
  42. f.tabClick.call(this, i, e, null, t);
  43. });
  44. }, s.prototype.progress = function (t, i) {
  45. var e = "layui-progress",
  46. l = a("." + e + "[lay-filter=" + t + "]"),
  47. n = l.find("." + e + "-bar"),
  48. s = n.find("." + e + "-text");
  49. return n.css("width", i), s.text(i), this;
  50. };
  51. var o = ".layui-nav",
  52. r = "layui-nav-item",
  53. c = "layui-nav-bar",
  54. u = "layui-nav-tree",
  55. d = "layui-nav-child",
  56. y = "layui-nav-more",
  57. h = "layui-anim layui-anim-upbit",
  58. f = {
  59. tabClick: function tabClick(t, i, s, o) {
  60. o = o || {};
  61. var r = s || a(this),
  62. i = i || r.parent().children("li").index(r),
  63. c = o.headerElem ? r.parent() : r.parents(".layui-tab").eq(0),
  64. u = o.bodyElem ? a(o.bodyElem) : c.children(".layui-tab-content").children(".layui-tab-item"),
  65. d = r.find("a"),
  66. y = c.attr("lay-filter");
  67. "javascript:;" !== d.attr("href") && "_blank" === d.attr("target") || (r.addClass(l).siblings().removeClass(l), u.eq(i).addClass(n).siblings().removeClass(n)), layui.event.call(this, e, "tab(" + y + ")", {
  68. elem: c,
  69. index: i
  70. });
  71. },
  72. tabDelete: function tabDelete(t, i) {
  73. var n = i || a(this).parent(),
  74. s = n.index(),
  75. o = n.parents(".layui-tab").eq(0),
  76. r = o.children(".layui-tab-content").children(".layui-tab-item"),
  77. c = o.attr("lay-filter");
  78. n.hasClass(l) && (n.next()[0] ? f.tabClick.call(n.next()[0], null, s + 1) : n.prev()[0] && f.tabClick.call(n.prev()[0], null, s - 1)), n.remove(), r.eq(s).remove(), setTimeout(function () {
  79. f.tabAuto();
  80. }, 50), layui.event.call(this, e, "tabDelete(" + c + ")", {
  81. elem: o,
  82. index: s
  83. });
  84. },
  85. tabAuto: function tabAuto() {
  86. var t = "layui-tab-more",
  87. e = "layui-tab-bar",
  88. l = "layui-tab-close",
  89. n = this;
  90. a(".layui-tab").each(function () {
  91. var s = a(this),
  92. o = s.children(".layui-tab-title"),
  93. r = (s.children(".layui-tab-content").children(".layui-tab-item"), 'lay-stope="tabmore"'),
  94. c = a('<span class="layui-unselect layui-tab-bar" ' + r + "><i " + r + ' class="layui-icon">&#xe61a;</i></span>');
  95. if (n === window && 8 != i.ie && f.hideTabMore(!0), s.attr("lay-allowClose") && o.find("li").each(function () {
  96. var t = a(this);
  97. if (!t.find("." + l)[0]) {
  98. var i = a('<i class="layui-icon layui-unselect ' + l + '">&#x1006;</i>');
  99. i.on("click", f.tabDelete), t.append(i);
  100. }
  101. }), "string" != typeof s.attr("lay-unauto")) if (o.prop("scrollWidth") > o.outerWidth() + 1) {
  102. if (o.find("." + e)[0]) return;
  103. o.append(c), s.attr("overflow", ""), c.on("click", function (a) {
  104. o[this.title ? "removeClass" : "addClass"](t), this.title = this.title ? "" : "收缩";
  105. });
  106. } else o.find("." + e).remove(), s.removeAttr("overflow");
  107. });
  108. },
  109. hideTabMore: function hideTabMore(t) {
  110. var i = a(".layui-tab-title");
  111. t !== !0 && "tabmore" === a(t.target).attr("lay-stope") || (i.removeClass("layui-tab-more"), i.find(".layui-tab-bar").attr("title", ""));
  112. },
  113. clickThis: function clickThis() {
  114. var t = a(this),
  115. i = t.parents(o),
  116. n = i.attr("lay-filter"),
  117. s = t.parent(),
  118. c = t.siblings("." + d),
  119. y = "string" == typeof s.attr("lay-unselect");
  120. "javascript:;" !== t.attr("href") && "_blank" === t.attr("target") || y || c[0] || (i.find("." + l).removeClass(l), s.addClass(l)), i.hasClass(u) && (c.removeClass(h), c[0] && (s["none" === c.css("display") ? "addClass" : "removeClass"](r + "ed"), "all" === i.attr("lay-shrink") && s.siblings().removeClass(r + "ed"))), layui.event.call(this, e, "nav(" + n + ")", t);
  121. },
  122. collapse: function collapse() {
  123. var t = a(this),
  124. i = t.find(".layui-colla-icon"),
  125. l = t.siblings(".layui-colla-content"),
  126. s = t.parents(".layui-collapse").eq(0),
  127. o = s.attr("lay-filter"),
  128. r = "none" === l.css("display");
  129. if ("string" == typeof s.attr("lay-accordion")) {
  130. var c = s.children(".layui-colla-item").children("." + n);
  131. c.siblings(".layui-colla-title").children(".layui-colla-icon").html("&#xe602;"), c.removeClass(n);
  132. }
  133. l[r ? "addClass" : "removeClass"](n), i.html(r ? "&#xe61a;" : "&#xe602;"), layui.event.call(this, e, "collapse(" + o + ")", {
  134. title: t,
  135. content: l,
  136. show: r
  137. });
  138. }
  139. };
  140. s.prototype.init = function (t, e) {
  141. var l = function () {
  142. return e ? '[lay-filter="' + e + '"]' : "";
  143. }(),
  144. s = {
  145. tab: function tab() {
  146. f.tabAuto.call({});
  147. },
  148. nav: function nav() {
  149. var t = 200,
  150. e = {},
  151. s = {},
  152. p = {},
  153. b = function b(l, o, r) {
  154. var c = a(this),
  155. f = c.find("." + d);
  156. o.hasClass(u) ? l.css({
  157. top: c.position().top,
  158. height: c.children("a").outerHeight(),
  159. opacity: 1
  160. }) : (f.addClass(h), l.css({
  161. left: c.position().left + parseFloat(c.css("marginLeft")),
  162. top: c.position().top + c.height() - l.height()
  163. }), e[r] = setTimeout(function () {
  164. l.css({
  165. width: c.width(),
  166. opacity: 1
  167. });
  168. }, i.ie && i.ie < 10 ? 0 : t), clearTimeout(p[r]), "block" === f.css("display") && clearTimeout(s[r]), s[r] = setTimeout(function () {
  169. f.addClass(n), c.find("." + y).addClass(y + "d");
  170. }, 300));
  171. };
  172. a(o + l).each(function (i) {
  173. var l = a(this),
  174. o = a('<span class="' + c + '"></span>'),
  175. h = l.find("." + r);
  176. l.find("." + c)[0] || (l.append(o), h.on("mouseenter", function () {
  177. b.call(this, o, l, i);
  178. }).on("mouseleave", function () {
  179. l.hasClass(u) || (clearTimeout(s[i]), s[i] = setTimeout(function () {
  180. l.find("." + d).removeClass(n), l.find("." + y).removeClass(y + "d");
  181. }, 300));
  182. }), l.on("mouseleave", function () {
  183. clearTimeout(e[i]), p[i] = setTimeout(function () {
  184. l.hasClass(u) ? o.css({
  185. height: 0,
  186. top: o.position().top + o.height() / 2,
  187. opacity: 0
  188. }) : o.css({
  189. width: 0,
  190. left: o.position().left + o.width() / 2,
  191. opacity: 0
  192. });
  193. }, t);
  194. })), h.find("a").each(function () {
  195. var t = a(this),
  196. i = (t.parent(), t.siblings("." + d));
  197. i[0] && !t.children("." + y)[0] && t.append('<span class="' + y + '"></span>'), t.off("click", f.clickThis).on("click", f.clickThis);
  198. });
  199. });
  200. },
  201. breadcrumb: function breadcrumb() {
  202. var t = ".layui-breadcrumb";
  203. a(t + l).each(function () {
  204. var t = a(this),
  205. i = "lay-separator",
  206. e = t.attr(i) || "/",
  207. l = t.find("a");
  208. l.next("span[" + i + "]")[0] || (l.each(function (t) {
  209. t !== l.length - 1 && a(this).after("<span " + i + ">" + e + "</span>");
  210. }), t.css("visibility", "visible"));
  211. });
  212. },
  213. progress: function progress() {
  214. var t = "layui-progress";
  215. a("." + t + l).each(function () {
  216. var i = a(this),
  217. e = i.find(".layui-progress-bar"),
  218. l = e.attr("lay-percent");
  219. e.css("width", function () {
  220. return /^.+\/.+$/.test(l) ? 100 * new Function("return " + l)() + "%" : l;
  221. }()), i.attr("lay-showPercent") && setTimeout(function () {
  222. e.html('<span class="' + t + '-text">' + l + "</span>");
  223. }, 350);
  224. });
  225. },
  226. collapse: function collapse() {
  227. var t = "layui-collapse";
  228. a("." + t + l).each(function () {
  229. var t = a(this).find(".layui-colla-item");
  230. t.each(function () {
  231. var t = a(this),
  232. i = t.find(".layui-colla-title"),
  233. e = t.find(".layui-colla-content"),
  234. l = "none" === e.css("display");
  235. i.find(".layui-colla-icon").remove(), i.append('<i class="layui-icon layui-colla-icon">' + (l ? "&#xe602;" : "&#xe61a;") + "</i>"), i.off("click", f.collapse).on("click", f.collapse);
  236. });
  237. });
  238. }
  239. };
  240. return s[t] ? s[t]() : layui.each(s, function (t, a) {
  241. a();
  242. });
  243. }, s.prototype.render = s.prototype.init;
  244. var p = new s(),
  245. b = a(document);
  246. p.render();
  247. var v = ".layui-tab-title li";
  248. b.on("click", v, f.tabClick), b.on("click", f.hideTabMore), a(window).on("resize", f.tabAuto), t(e, p);
  249. });