layui.dev.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. "use strict";
  2. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3. /** layui-v2.5.6 MIT License By https://www.layui.com */
  4. ;
  5. !function (e) {
  6. "use strict";
  7. var t = document,
  8. n = {
  9. modules: {},
  10. status: {},
  11. timeout: 10,
  12. event: {}
  13. },
  14. r = function r() {
  15. this.v = "2.5.6";
  16. },
  17. o = function () {
  18. var e = t.currentScript ? t.currentScript.src : function () {
  19. for (var e, n = t.scripts, r = n.length - 1, o = r; o > 0; o--) {
  20. if ("interactive" === n[o].readyState) {
  21. e = n[o].src;
  22. break;
  23. }
  24. }
  25. return e || n[r].src;
  26. }();
  27. return e.substring(0, e.lastIndexOf("/") + 1);
  28. }(),
  29. a = function a(t) {
  30. e.console && console.error && console.error("Layui hint: " + t);
  31. },
  32. i = "undefined" != typeof opera && "[object Opera]" === opera.toString(),
  33. u = {
  34. layer: "modules/layer",
  35. laydate: "modules/laydate",
  36. laypage: "modules/laypage",
  37. laytpl: "modules/laytpl",
  38. layim: "modules/layim",
  39. layedit: "modules/layedit",
  40. form: "modules/form",
  41. upload: "modules/upload",
  42. transfer: "modules/transfer",
  43. tree: "modules/tree",
  44. table: "modules/table",
  45. element: "modules/element",
  46. rate: "modules/rate",
  47. colorpicker: "modules/colorpicker",
  48. slider: "modules/slider",
  49. carousel: "modules/carousel",
  50. flow: "modules/flow",
  51. util: "modules/util",
  52. code: "modules/code",
  53. jquery: "modules/jquery",
  54. mobile: "modules/mobile",
  55. "layui.all": "../layui.all"
  56. };
  57. r.prototype.cache = n, r.prototype.define = function (e, t) {
  58. var r = this,
  59. o = "function" == typeof e,
  60. a = function a() {
  61. var e = function e(_e, t) {
  62. layui[_e] = t, n.status[_e] = !0;
  63. };
  64. return "function" == typeof t && t(function (r, o) {
  65. e(r, o), n.callback[r] = function () {
  66. t(e);
  67. };
  68. }), this;
  69. };
  70. return o && (t = e, e = []), !layui["layui.all"] && layui["layui.mobile"] ? a.call(r) : (r.use(e, a), r);
  71. }, r.prototype.use = function (e, r, l) {
  72. function c(e, t) {
  73. var r = "PLaySTATION 3" === navigator.platform ? /^complete$/ : /^(complete|loaded)$/;
  74. ("load" === e.type || r.test((e.currentTarget || e.srcElement).readyState)) && (n.modules[d] = t, y.removeChild(h), function o() {
  75. return ++m > 1e3 * n.timeout / 4 ? a(d + " is not a valid module") : void (n.status[d] ? s() : setTimeout(o, 4));
  76. }());
  77. }
  78. function s() {
  79. l.push(layui[d]), e.length > 1 ? p.use(e.slice(1), r, l) : "function" == typeof r && r.apply(layui, l);
  80. }
  81. var p = this,
  82. f = n.dir = n.dir ? n.dir : o,
  83. y = t.getElementsByTagName("head")[0];
  84. e = "string" == typeof e ? [e] : e, window.jQuery && jQuery.fn.on && (p.each(e, function (t, n) {
  85. "jquery" === n && e.splice(t, 1);
  86. }), layui.jquery = layui.$ = jQuery);
  87. var d = e[0],
  88. m = 0;
  89. if (l = l || [], n.host = n.host || (f.match(/\/\/([\s\S]+?)\//) || ["//" + location.host + "/"])[0], 0 === e.length || layui["layui.all"] && u[d] || !layui["layui.all"] && layui["layui.mobile"] && u[d]) return s(), p;
  90. var v = (u[d] ? f + "lay/" : /^\{\/\}/.test(p.modules[d]) ? "" : n.base || "") + (p.modules[d] || d) + ".js";
  91. if (v = v.replace(/^\{\/\}/, ""), !n.modules[d] && layui[d] && (n.modules[d] = v), n.modules[d]) !function g() {
  92. return ++m > 1e3 * n.timeout / 4 ? a(d + " is not a valid module") : void ("string" == typeof n.modules[d] && n.status[d] ? s() : setTimeout(g, 4));
  93. }();else {
  94. var h = t.createElement("script");
  95. h.async = !0, h.charset = "utf-8", h.src = v + function () {
  96. var e = n.version === !0 ? n.v || new Date().getTime() : n.version || "";
  97. return e ? "?v=" + e : "";
  98. }(), y.appendChild(h), !h.attachEvent || h.attachEvent.toString && h.attachEvent.toString().indexOf("[native code") < 0 || i ? h.addEventListener("load", function (e) {
  99. c(e, v);
  100. }, !1) : h.attachEvent("onreadystatechange", function (e) {
  101. c(e, v);
  102. }), n.modules[d] = v;
  103. }
  104. return p;
  105. }, r.prototype.getStyle = function (t, n) {
  106. var r = t.currentStyle ? t.currentStyle : e.getComputedStyle(t, null);
  107. return r[r.getPropertyValue ? "getPropertyValue" : "getAttribute"](n);
  108. }, r.prototype.link = function (e, r, o) {
  109. var i = this,
  110. u = t.createElement("link"),
  111. l = t.getElementsByTagName("head")[0];
  112. "string" == typeof r && (o = r);
  113. var c = (o || e).replace(/\.|\//g, ""),
  114. s = u.id = "layuicss-" + c,
  115. p = 0;
  116. return u.rel = "stylesheet", u.href = e + (n.debug ? "?v=" + new Date().getTime() : ""), u.media = "all", t.getElementById(s) || l.appendChild(u), "function" != typeof r ? i : (function f() {
  117. return ++p > 1e3 * n.timeout / 100 ? a(e + " timeout") : void (1989 === parseInt(i.getStyle(t.getElementById(s), "width")) ? function () {
  118. r();
  119. }() : setTimeout(f, 100));
  120. }(), i);
  121. }, n.callback = {}, r.prototype.factory = function (e) {
  122. if (layui[e]) return "function" == typeof n.callback[e] ? n.callback[e] : null;
  123. }, r.prototype.addcss = function (e, t, r) {
  124. return layui.link(n.dir + "css/" + e, t, r);
  125. }, r.prototype.img = function (e, t, n) {
  126. var r = new Image();
  127. return r.src = e, r.complete ? t(r) : (r.onload = function () {
  128. r.onload = null, "function" == typeof t && t(r);
  129. }, void (r.onerror = function (e) {
  130. r.onerror = null, "function" == typeof n && n(e);
  131. }));
  132. }, r.prototype.config = function (e) {
  133. e = e || {};
  134. for (var t in e) {
  135. n[t] = e[t];
  136. }
  137. return this;
  138. }, r.prototype.modules = function () {
  139. var e = {};
  140. for (var t in u) {
  141. e[t] = u[t];
  142. }
  143. return e;
  144. }(), r.prototype.extend = function (e) {
  145. var t = this;
  146. e = e || {};
  147. for (var n in e) {
  148. t[n] || t.modules[n] ? a("模块名 " + n + " 已被占用") : t.modules[n] = e[n];
  149. }
  150. return t;
  151. }, r.prototype.router = function (e) {
  152. var t = this,
  153. e = e || location.hash,
  154. n = {
  155. path: [],
  156. search: {},
  157. hash: (e.match(/[^#](#.*$)/) || [])[1] || ""
  158. };
  159. return /^#\//.test(e) ? (e = e.replace(/^#\//, ""), n.href = "/" + e, e = e.replace(/([^#])(#.*$)/, "$1").split("/") || [], t.each(e, function (e, t) {
  160. /^\w+=/.test(t) ? function () {
  161. t = t.split("="), n.search[t[0]] = t[1];
  162. }() : n.path.push(t);
  163. }), n) : n;
  164. }, r.prototype.url = function (e) {
  165. var t = this,
  166. n = {
  167. pathname: function () {
  168. var t = e ? function () {
  169. var t = (e.match(/\.[^.]+?\/.+/) || [])[0] || "";
  170. return t.replace(/^[^\/]+/, "").replace(/\?.+/, "");
  171. }() : location.pathname;
  172. return t.replace(/^\//, "").split("/");
  173. }(),
  174. search: function () {
  175. var n = {},
  176. r = (e ? function () {
  177. var t = (e.match(/\?.+/) || [])[0] || "";
  178. return t.replace(/\#.+/, "");
  179. }() : location.search).replace(/^\?+/, "").split("&");
  180. return t.each(r, function (e, t) {
  181. var r = t.indexOf("="),
  182. o = function () {
  183. return r < 0 ? t.substr(0, t.length) : 0 !== r && t.substr(0, r);
  184. }();
  185. o && (n[o] = r > 0 ? t.substr(r + 1) : null);
  186. }), n;
  187. }(),
  188. hash: t.router(function () {
  189. return e ? (e.match(/#.+/) || [])[0] || "" : location.hash;
  190. }())
  191. };
  192. return n;
  193. }, r.prototype.data = function (t, n, r) {
  194. if (t = t || "layui", r = r || localStorage, e.JSON && e.JSON.parse) {
  195. if (null === n) return delete r[t];
  196. n = "object" == _typeof(n) ? n : {
  197. key: n
  198. };
  199. try {
  200. var o = JSON.parse(r[t]);
  201. } catch (a) {
  202. var o = {};
  203. }
  204. return "value" in n && (o[n.key] = n.value), n.remove && delete o[n.key], r[t] = JSON.stringify(o), n.key ? o[n.key] : o;
  205. }
  206. }, r.prototype.sessionData = function (e, t) {
  207. return this.data(e, t, sessionStorage);
  208. }, r.prototype.device = function (t) {
  209. var n = navigator.userAgent.toLowerCase(),
  210. r = function r(e) {
  211. var t = new RegExp(e + "/([^\\s\\_\\-]+)");
  212. return e = (n.match(t) || [])[1], e || !1;
  213. },
  214. o = {
  215. os: function () {
  216. return /windows/.test(n) ? "windows" : /linux/.test(n) ? "linux" : /iphone|ipod|ipad|ios/.test(n) ? "ios" : /mac/.test(n) ? "mac" : void 0;
  217. }(),
  218. ie: function () {
  219. return !!(e.ActiveXObject || "ActiveXObject" in e) && ((n.match(/msie\s(\d+)/) || [])[1] || "11");
  220. }(),
  221. weixin: r("micromessenger")
  222. };
  223. return t && !o[t] && (o[t] = r(t)), o.android = /android/.test(n), o.ios = "ios" === o.os, o.mobile = !(!o.android && !o.ios), o;
  224. }, r.prototype.hint = function () {
  225. return {
  226. error: a
  227. };
  228. }, r.prototype.each = function (e, t) {
  229. var n,
  230. r = this;
  231. if ("function" != typeof t) return r;
  232. if (e = e || [], e.constructor === Object) {
  233. for (n in e) {
  234. if (t.call(e[n], n, e[n])) break;
  235. }
  236. } else for (n = 0; n < e.length && !t.call(e[n], n, e[n]); n++) {
  237. ;
  238. }
  239. return r;
  240. }, r.prototype.sort = function (e, t, n) {
  241. var r = JSON.parse(JSON.stringify(e || []));
  242. return t ? (r.sort(function (e, n) {
  243. var r = /^-?\d+$/,
  244. o = e[t],
  245. a = n[t];
  246. return r.test(o) && (o = parseFloat(o)), r.test(a) && (a = parseFloat(a)), o && !a ? 1 : !o && a ? -1 : o > a ? 1 : o < a ? -1 : 0;
  247. }), n && r.reverse(), r) : r;
  248. }, r.prototype.stope = function (t) {
  249. t = t || e.event;
  250. try {
  251. t.stopPropagation();
  252. } catch (n) {
  253. t.cancelBubble = !0;
  254. }
  255. }, r.prototype.onevent = function (e, t, n) {
  256. return "string" != typeof e || "function" != typeof n ? this : r.event(e, t, null, n);
  257. }, r.prototype.event = r.event = function (e, t, r, o) {
  258. var a = this,
  259. i = null,
  260. u = t.match(/\((.*)\)$/) || [],
  261. l = (e + "." + t).replace(u[0], ""),
  262. c = u[1] || "",
  263. s = function s(e, t) {
  264. var n = t && t.call(a, r);
  265. n === !1 && null === i && (i = !1);
  266. };
  267. return o ? (n.event[l] = n.event[l] || {}, n.event[l][c] = [o], this) : (layui.each(n.event[l], function (e, t) {
  268. return "{*}" === c ? void layui.each(t, s) : ("" === e && layui.each(t, s), void (c && e === c && layui.each(t, s)));
  269. }), i);
  270. }, e.layui = new r();
  271. }(window);