kis-js/kis-lite-min.js

7 lines
2.3 KiB
JavaScript
Executable File

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