layui-js/dist/layui.js

1 line
277 KiB
JavaScript
Raw Normal View History

/** 2.6.13 | MIT Licensed */;!function(f){"use strict";function r(){this.v="2.6.13"}function d(t,e){e=e||"log",f.console&&console[e]&&console[e]("layui error hint: "+t)}var t,h=f.document,m={modules:{},status:{},timeout:10,event:{}},e=f.LAYUI_GLOBAL||{},v=(t=h.currentScript?h.currentScript.src:function(){for(var t,e=h.scripts,o=e.length-1,r=o;0<r;r--)if("interactive"===e[r].readyState){t=e[r].src;break}return t||e[o].src}(),m.dir=e.dir||t.substring(0,t.lastIndexOf("/")+1)),g="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),b=m.builtin={lay:"lay",layer:"layer",laydate:"laydate",laypage:"laypage",laytpl:"laytpl",layedit:"layedit",form:"form",upload:"upload",dropdown:"dropdown",transfer:"transfer",tree:"tree",table:"table",element:"element",rate:"rate",colorpicker:"colorpicker",slider:"slider",carousel:"carousel",flow:"flow",util:"util",code:"code",jquery:"jquery",all:"all","layui.all":"layui.all"},s=(r.prototype.cache=m,r.prototype.define=function(t,r){return"function"==typeof t&&(r=t,t=[]),this.use(t,function(){function o(t,e){layui[t]=e,m.status[t]=!0}return"function"==typeof r&&r(function(t,e){o(t,e),m.callback[t]=function(){r(o)}}),this},null,"define"),this},r.prototype.use=function(o,t,e,r){var n=this,i=m.dir=m.dir||v,a=h.getElementsByTagName("head")[0],u=(o="string"==typeof o?[o]:"function"==typeof o?(t=o,["all"]):o,f.jQuery&&jQuery.fn.on&&(n.each(o,function(t,e){"jquery"===e&&o.splice(t,1)}),layui.jquery=layui.$=jQuery),o[0]),l=0;function s(t,e){var o="PLaySTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/;"load"!==t.type&&!o.test((t.currentTarget||t.srcElement).readyState)||(m.modules[u]=e,a.removeChild(p),function t(){return++l>1e3*m.timeout/4?d(u+" is not a valid module","error"):void(m.status[u]?c():setTimeout(t,4))}())}function c(){e.push(layui[u]),1<o.length?n.use(o.slice(1),t,e,r):"function"==typeof t&&(layui.jquery&&"function"==typeof layui.jquery&&"define"!==r?layui.jquery(function(){t.apply(layui,e)}):t.apply(layui,e))}if(e=e||[],m.host=m.host||(i.match(/\/\/([\s\S]+?)\//)||["//"+location.host+"/"])[0],0===o.length||layui["layui.all"]&&b[u])return c(),n;var p,y=(y=(b[u]?i+"modules/":!/^\{\/\}/.test(n.modules[u])&&m.base||"")+(n.modules[u]||u)+".js").replace(/^\{\/\}/,"");return!m.modules[u]&&layui[u]&&(m.modules[u]=y),m.modules[u]?function t(){return++l>1e3*m.timeout/4?d(u+" is not a valid module","error"):void("string"==typeof m.modules[u]&&m.status[u]?c():setTimeout(t,4))}():((p=h.createElement("script")).async=!0,p.charset="utf-8",p.src=y+((i=!0===m.version?m.v||(new Date).getTime():m.version||"")?"?v="+i:""),a.appendChild(p),!p.attachEvent||p.attachEvent.toString&&p.attachEvent.toString().indexOf("[native code")<0||g?p.addEventListener("load",function(t){s(t,y)},!1):p.attachEvent("onreadystatechange",function(t){s(t,y)}),m.modules[u]=y),n},r.prototype.getStyle=function(t,e){t=t.currentStyle||f.getComputedStyle(t,null);return t[t.getPropertyValue?"getPropertyValue":"getAttribute"](e)},r.prototype.link=function(r,n,t){var i=this,e=h.getElementsByTagName("head")[0],o=h.createElement("link"),t=((t="string"==typeof n?n:t)||r).replace(/\.|\//g,""),a=o.id="layuicss-"+t,u="creating",l=0;return o.rel="stylesheet",o.href=r+(m.debug?"?v="+(new Date).getTime():""),o.media="all",h.getElementById(a)||e.appendChild(o),"function"!=typeof n||function t(e){var o=h.getElementById(a);return++l>1e3*m.timeout/100?d(r+" timeout"):void(1989===parseInt(i.getStyle(o,"width"))?(e===u&&o.removeAttribute("lay-status"),o.getAttribute("lay-status")===u?setTimeout(t,100):n()):(o.setAttribute("lay-status",u),setTimeout(function(){t(u)},100)))}(),i},r.prototype.addcss=function(t,e,o){return layui.link(m.dir+"css/"+t,e,o)},m.callback={},r.prototype.factory=function(t){if(layui[t])return"function"==typeof m.callback[t]?m.callback[t]:null},r.prototype.img=function(t,e,o){var r=new Image;if(r.src=t,r.complete)return e(r);r.onload=function(){r.onload=null,"function"==typeof e&&e(r)},r.onerror=function(t){r.onerror=null,"function"==typeof o&&o(t)}},r.prototype.config=function(t){for(var e in t=t||{})m[e]=t[e];r