kis-js/kis-lite-min.js

7 lines
2.4 KiB
JavaScript
Executable File

(function(e){var b,f,c;b=function(a){c=a===e?b.el!==e?b.el:document.documentElement:f(a);b.prototype.el=c;a=Object.create(b);for(var d in a)"object"===typeof a[d]&&(a[d].el=c);a.el=c;return a};f=function(a,c){var b;if("string"!=typeof a||a===e)return a;b=null!=c&&1===c.nodeType?c:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);b=b.querySelectorAll(a);return 1===b.length?b[0]:b};b.ext=function(a,d){d.el=c;b[a]=d};b.ext("each",function(a){c.length!==e&&c!==window?
[].forEach.call(c,a):a.call(c,c)});b.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};b=window.$_=window.$_||b;b.$=f})();Promise.prototype.done||(Promise.prototype.done=function(e,b){this.then(e,b).then(null,function(b){setTimeout(function(){throw b;},0)})});
(function(e){var b={_do:function(b,c,a,d,h){var g=new XMLHttpRequest;a===e&&(a=function(){});h=h?"POST":"GET";"GET"===h&&(b+=b.match(/\?/)?this._serialize(c):"?"+this._serialize(c));g.open(h,b);g.onreadystatechange=function(){4===g.readyState&&(200===g.status?a.call(g.responseText,g.responseText):d!==e&&d.call(g.status,g.status))};"POST"===h?(g.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),g.send(this._serialize(c))):g.send(null)},_serialize:function(b){var c,a,d=[];for(c in b)b.hasOwnProperty(c)&&
"function"!==$_.type(b[c])&&(a=b[c].toString(),c=encodeURIComponent(c),a=encodeURIComponent(a),d.push(c+"="+a));return d.join("&")}};$_.ext("get",function(f,c,a,d){b._do(f,c,a,d,!1)});$_.ext("post",function(f,c,a,d){b._do(f,c,a,d,!0)})})();
(function(e){var b,f;b=function(c,a,d,h){var g,f;if(a.match(/^([\w\-]+)$/))!0===h?c.addEventListener(a,d,!1):c.removeEventListener(a,d,!1);else for(a=a.split(" "),f=a.length,g=0;g<f;g++)b(c,a[g],d,h)};f=function(c,a,d,f){b(c,d,function(b){var d,e;e=$_.$(a,c);for(d in e)b.target==e[d]&&(f.call(e[d],b),b.stopPropagation())},!0)};$_.ext("event",{create:function(c,a){if(/MSIE|Trident/i.test(navigator.userAgent)){var b=document.createEvent("CustomEvent");b.initCustomEvent(c,!0,!0,a);return b}return new CustomEvent(c,
a)},add:function(c,a){$_.each(function(d){b(d,c,a,!0)})},remove:function(c,a){$_.each(function(d){b(d,c,a,!1)})},live:function(c,a,b){f(document.documentElement,c,a,b)},delegate:function(b,a,d){$_.each(function(e){f(e,b,a,d)})},trigger:function(b){return this.el.dispatchEvent(b)}})})();