kis-js/kis-min.js

18 lines
7.9 KiB
JavaScript
Executable File

(function(g){if(document.querySelector!==g){var c,n,r,f;c=function(k){f=k===g?c.el!==g?c.el:document.documentElement:n(k);c.prototype.el=f;k=r(c);for(var j in k)"object"===typeof k[j]&&(k[j].el=f);k.el=f;return k};n=function(c,j){var f;if("string"!=typeof c||c===g)return c;f=null!=j&&1===j.nodeType?j:document;if(c.match(/^#([\w\-]+$)/))return document.getElementById(c.split("#")[1]);f=f.querySelectorAll(c);return 1===f.length?f[0]:f};r=function(c){var f;if(c!==g){if(Object.create!==g)return Object.create(c);
f=typeof c;if(!("object"!==f&&"function"!==f))return f=function(){},f.prototype=c,new f}};c.ext=function(g,j){j.el=f;c[g]=j};c.ext("each",function(c){if(f.length!==g&&f!==window)if(Array.prototype.forEach!==g)[].forEach.call(f,c);else{var j=f.length;if(0!==j)for(var n,m=0;m<j;m++)n=f.item(m)?f.item(m):f[m],c.call(n,n)}else c.call(f,f)});c.type=function(c){return function(){return c&&c!==this}.call(c)?(typeof c).toLowerCase():{}.toString.call(c).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};c=window.$_=
window.$_||c;c.$=n}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Array.isArray&&(Array.isArray=function(g){return"[object Array]"===Object.prototype.toString.apply(g)});
(function(g,c){function n(a,b,d){var e,l;a.hasAttribute!==c?(a.hasAttribute(b)&&(e=a.getAttribute(b)),l=!0):a[b]!==c?(e=a[b],l=!1):"class"===b&&a.className!==c&&(b="className",e=a.className,l=!1);if(e===c&&(d===c||null===d))return null;if(d===c)return e;d!==c&&null!==d?!0===l?a.setAttribute(b,d):a[b]=d:null===d&&(!0===l?a.removeAttribute(b):delete a[b]);return d!==c?d:e}function r(a,b,d){var e;b=b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")});e={outerHeight:"offsetHeight",
outerWidth:"offsetWidth",top:"posTop"};if(d===c&&a.style[b]!==c)return a.style[b];if(d===c&&a.style[e[b]]!==c)return a.style[e[b]];if(a.style[b]!==c)return a.style[b]=d,null;if(a.style[e[b]])return a.style[e[b]]=d,null}if("undefined"!==typeof document&&!("classList"in document.createElement("a"))&&("HTMLElement"in self||"Element"in self)){var f=(self.HTMLElement||self.Element).prototype,k=Object,j=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},B=Array.prototype.indexOf||function(a){for(var b=
0,d=this.length;b<d;b++)if(b in this&&this[b]===a)return b;return-1},m=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},v=function(a,b){if(""===b)throw new m("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(b))throw new m("INVALID_CHARACTER_ERR","String contains an invalid character");return B.call(a,b)},x=function(a){for(var b=j.call(a.className),b=b?b.split(/\s+/):[],d=0,e=b.length;d<e;d++)this.push(b[d]);this._updateClassName=function(){a.className=this.toString()}},
p=x.prototype=[],y=function(){return new x(this)};m.prototype=Error.prototype;p.item=function(a){return this[a]||null};p.contains=function(a){return-1!==v(this,a+"")};p.add=function(){var a=arguments,b=0,d=a.length,e,c=!1;do e=a[b]+"",-1===v(this,e)&&(this.push(e),c=!0);while(++b<d);c&&this._updateClassName()};p.remove=function(){var a=arguments,b=0,d=a.length,e,c=!1;do e=a[b]+"",e=v(this,e),-1!==e&&(this.splice(e,1),c=!0);while(++b<d);c&&this._updateClassName()};p.toggle=function(a,b){a+="";var d=
this.contains(a),e=d?!0!==b&&"remove":!1!==b&&"add";if(e)this[e](a);return!d};p.toString=function(){return this.join(" ")};if(k.defineProperty){p={get:y,enumerable:!0,configurable:!0};try{k.defineProperty(f,"classList",p)}catch(C){-2146823252===C.number&&(p.enumerable=!1,k.defineProperty(f,"classList",p))}}else k.prototype.__defineGetter__&&f.__defineGetter__("classList",y)}g.ext("dom",{addClass:function(a){g.each(function(){this.classList.add(a)})},removeClass:function(a){g.each(function(b){b.classList.remove(a)})},
hide:function(){this.css("display","none")},show:function(a){a===c&&(a="block");this.css("display",a)},attr:function(a,b){var d=this.el;if(1<d.length&&b===c)return null;if(1<d.length&&b!==c)g.each(function(d){return n(d,a,b)});else return n(d,a,b)},text:function(a){var b,d,e;e=this.el;d=a!==c?!0:!1;b=e.textContent;return d?e.textContent=a:b},css:function(a,b){if(b===c)return r(this.el,a);g.each(function(d){r(d,a,b)})},append:function(a){document.insertAdjacentHTML!==c?this.el.insertAdjacentHTML("beforeend",
a):this.el.innerHTML+=a},prepend:function(a){document.insertAdjacentHTML!==c?this.el.insertAdjacentHTML("afterbegin",a):this.el.innerHTML=a+this.el.innerHTML},html:function(a){a!==c&&(this.el.innerHTML=a);return this.el.innerHTML}});if(window.XMLHttpRequest!==c){var z={_do:function(a,b,d,e,l){var h=new XMLHttpRequest;d===c&&(d=function(){});l=l?"POST":"GET";"GET"===l&&(a+=a.match(/\?/)?this._serialize(b):"?"+this._serialize(b));h.open(l,a);h.onreadystatechange=function(){4===h.readyState&&(200===
h.status?d.call(h.responseText,h.responseText):e!==c&&e.call(h.status,h.status))};"POST"===l?(h.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),h.send(this._serialize(b))):h.send(null)},_serialize:function(a){var b,d,e=[];for(b in a)a.hasOwnProperty(b)&&"function"!==typeof a[b]&&(d=a[b].toString(),b=encodeURIComponent(b),d=encodeURIComponent(d),e.push(b+"="+d));return e.join("&")}};g.ext("get",function(a,b,d,e){z._do(a,b,d,e,!1)});g.ext("post",function(a,b,d,e){z._do(a,b,d,e,
!0)});g.ext("sse",function(a,b){var d;EventSource!==c&&(d=new EventSource(a),d.onmessage=function(a){b.call(a.data,a.data)})});var s,w;if(document.addEventListener===c)return!1;s=function(a,b,d,e){var l,h;if(a===c)return null;if(b.match(/^([\w\-]+)$/))!0===e?a.addEventListener(b,d,!1):a.removeEventListener(b,d,!1);else{b=b.split(" ");h=b.length;for(l=0;l<h;l++)s(a,b[l],d,e)}};w=function(a,b,d,e){s(a,d,function(d){var c,f;f=g.$(b,a);for(c in f)d.target==f[c]&&(e.call(f[c],d),d.stopPropagation())},
!0)};g.ext("event",{add:function(a,b){g.each(function(d){s(d,a,b,!0)})},remove:function(a,b){g.each(function(d){s(d,a,b,!1)})},live:function(a,b,d){w(document.documentElement,a,b,d)},delegate:function(a,b,d){g.each(function(e){w(e,a,b,d)})}});if(localStorage===c||JSON===c)return null;var t=localStorage,u=sessionStorage;g.ext("store",{get:function(a,b){var d=b?u.getItem(a):t.getItem(a);return JSON.parse(d)},set:function(a,b,d){b=JSON.stringify(b);d?u.setItem(a,b):t.setItem(a,b)},remove:function(a,
b){b?u.removeItem(a):t.removeItem(a)},getAll:function(a){var b,d={},e,c;c=a?t:u;b=c.length;for(a=0;a<b;a++)e=c.key(a),d[e]=c.getItem(e);return d},clear:function(a){a?u.clear():t.clear()}});var A={object_keys:function(a){var b=[],d;for(d in a)a.hasOwnProperty(d)&&b.push(d);return b},object_values:function(a){var b=[],d;for(d in a)b.push(a[d]);return b},array_combine:function(a,b){var d={},e,c=0;"array"!==g.type(a)&&(a=this.object_values(a));"array"!==g.type(b)&&(b=this.object_values(b));e=a.length;
if(e!==b.length)return!1;for(c=0;c<e;c++)d[a[c]]=b[c];return d},object_merge:function(){var a=Array.prototype.slice.call(arguments),b=a.length,d={},c,f=0,h,q,j;c=!0;for(h=0;h<b;h++)if("array"!==g.type(a[h])){c=!1;break}if(c){d=[];for(h=0;h<b;h++)d=d.contact(a[h]);return d}for(j=h=0;h<b;h++)if(c=a[h],"array"==g.type(c)){q=0;for(f=c.length;q<f;q++)d[j++]=c[q]}else for(q in c)c.hasOwnProperty(q)&&(parseInt(q,10)+""===q?d[j++]=c[q]:d[q]=c[q]);return d},str_trans:function(a,b,d){var c=[],f=[],h=!1,g=0,
j=0,k="",n="",p="",m="",r;if("object"===typeof b){d=[];h=0;g={};d=A.object_keys(b);d.sort(function(a,b){var c=parseFloat(b),d=parseFloat(a),e=c+""===b,f=d+""===a;return e&&f?c>d?1:c<d?-1:0:e&&!f?1:!e&&f?-1:b>a?1:b<a?-1:0});h=d.length;for(j=0;j<h;j++)g[d[j]]=b[d[j]];b=g;for(r in b)b.hasOwnProperty(r)&&(c.push(r),f.push(b[r]));b=c;d=f}j=a.length;g=b.length;k="string"===typeof d;n="string"===typeof b;for(c=0;c<j;c++){h=!1;if(n){a.charAt(c-1);p=a.charAt(c);a.charAt(c+1);for(f=0;f<g;f++)if(p==b.charAt(f)){h=
!0;break}}else for(f=0;f<g;f++)if(a.substr(c,b[f].length)==b[f]){h=!0;c=c+b[f].length-1;break}m=h?m+(k?d.charAt(f):d[f]):m+a.charAt(c)}return m}};g.ext("util",A)}})($_);