kis-js/kis-min.js

21 lines
9.5 KiB
JavaScript
Executable File

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