kis-js/kis-min.js

23 lines
9.4 KiB
JavaScript

(function(){if(document.querySelectorAll){var c,e,g,a;e=function(b,d){var a;if(typeof b!=="string"||typeof b==="undefined")return b;a=typeof d==="object"&&d.nodeType===1?d:document;if(b.match(/^#([\w\-]+$)/))return document.getElementById(b.split("#")[1]);else a=a.querySelectorAll(b);return a.length===1?a[0]:a};c=function(b){a=typeof b==="undefined"?typeof c.el!=="undefined"?c.el:document.documentElement:typeof b!=="object"?e(b):b;c.prototype.el=a;var b=g(c),d;for(d in b)if(typeof b[d]==="object")b[d].el=
a;b.el=a;return b};g=function(a){var d;if(typeof a!=="undefined"){if(typeof Object.create!=="undefined")return Object.create(a);d=typeof a;if(!(d!=="object"&&d!=="function"))return d=function(){},d.prototype=a,new d}};c.ext=function(b,d){d.el=a;c[b]=d};c.ext("each",function(b){if(typeof a.length!=="undefined"&&a!==window){var d=a.length;if(d!==0)for(var f,h=0;h<d;h++)f=a.item(h)?a.item(h):a[h],b(f)}else b(a)});c.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()};c=window.$_=window.$_||c;c.$=e;if(typeof window.console==="undefined")window.console={log:function(){}};if(typeof String.prototype.trim==="undefined")String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}}})();
typeof document!=="undefined"&&!("classList"in document.createElement("a"))&&function(c){var c=(c.HTMLElement||c.Element).prototype,e=Object,g=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},a=Array.prototype.indexOf||function(a){for(var d=0,b=this.length;d<b;d++)if(d in this&&this[d]===a)return d;return-1},b=function(a,d){this.name=a;this.code=DOMException[a];this.message=d},d=function(d,f){if(f==="")throw new b("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(f))throw new b("INVALID_CHARACTER_ERR",
"String contains an invalid character");return a.call(d,f)},f=function(a){for(var d=g.call(a.className),d=d?d.split(/\s+/):[],b=0,f=d.length;b<f;b++)this.push(d[b]);this._updateClassName=function(){a.className=this.toString()}},h=f.prototype=[],j=function(){return new f(this)};b.prototype=Error.prototype;h.item=function(a){return this[a]||null};h.contains=function(a){a+="";return d(this,a)!==-1};h.add=function(a){a+="";d(this,a)===-1&&(this.push(a),this._updateClassName())};h.remove=function(a){a+=
"";a=d(this,a);a!==-1&&(this.splice(a,1),this._updateClassName())};h.toggle=function(a){a+="";d(this,a)===-1?this.add(a):this.remove(a)};h.toString=function(){return this.join(" ")};if(e.defineProperty){h={get:j,enumerable:true,configurable:true};try{e.defineProperty(c,"classList",h)}catch(i){if(i.number===-2146823252)h.enumerable=false,e.defineProperty(c,"classList",h)}}else e.prototype.__defineGetter__&&c.__defineGetter__("classList",j)}(self);
(function(){function c(a,b,d){var f,h;if(typeof a.hasAttribute!=="undefined")a.hasAttribute(b)&&(f=a.getAttribute(b)),h=true;else if(typeof a[b]!=="undefined")f=a[b],h=false;else if(b==="class"&&typeof a.className!=="undefined")b="className",f=a.className,h=false;if(typeof f==="undefined"&&(typeof d==="undefined"||d===null))console.log(d),console.log(a),console.log("Element does not have the selected attribute");else{if(typeof d==="undefined")return f;typeof d!=="undefined"&&d!==null?h===true?a.setAttribute(b,
d):a[b]=d:d===null&&(h===true?a.removeAttribute(b):delete a[b]);return typeof d!=="undefined"?d:f}}function e(a){return a.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function g(a,b,d){var f,b=e(b);f={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if(typeof d==="undefined"&&a.style[b]!=="undefined")return a.style[b];else if(typeof d==="undefined"&&a.style[f[b]]!=="undefined")return a.style[f[b]];typeof a.style[b]!=="undefined"?a.style[b]=d:a.style[f[b]]?
a.style[f[b]]=d:console.log("Property "+b+" nor an equivalent seems to exist")}$_.ext("dom",{addClass:function(a){$_.each(function(b){b.classList.add(a)})},removeClass:function(a){$_.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 d=this.el;if(d.length>1&&typeof b==="undefined")console.log(d),console.log("Must be a singular element");else if(d.length>1&&typeof b!==
"undefined")$_.each(function(d){return c(d,a,b)});else return c(d,a,b)},text:function(a){var b,d,f;f=this.el;d=typeof f.innerText!=="undefined"?"innerText":typeof f.textContent!=="undefined"?"textContent":"innerHTML";b=f[d];return typeof a!=="undefined"?f[d]=a:b},css:function(a,b){if(typeof b==="undefined")return g(this.el,a);$_.each(function(d){g(d,a,b)})}})})();
(function(){$_.ext("store",{get:function(c){return JSON.parse(localStorage.getItem(c))},set:function(c,e){typeof e!=="string"&&(e=JSON.stringify(e));localStorage.setItem(c,e)},remove:function(c){localStorage.removeItem(c)},getAll:function(){var c,e,g;e=localStorage.length;g={};for(c=0;c<e;c++){var a=localStorage.key(c),b=localStorage.getItem(a);g[a]=b}return g}})})();
(function(){$_.hb=history.pushState?false:true;$_.ext("qs",{parse:function(c){var c=c||$_.hb,e,g,a,b;a={};if(c===true)c=location.hash.split("#!/"),c=c.length>1?c[1]:"";else if(c===false||c===void 0)c=window.location.search.substring(1);else return false;e=c.split("&");g=e.length;for(c=0;c<g;c++){b=e[c].split("=");if(b.length<2)break;a[b[0]]=b[1]}return a},set:function(c,e,g){var g=g||$_.hb,a=this.parse(g);c!==void 0&&e!==void 0&&(a[c]=e);var c=[],b;for(b in a)a.hasOwnProperty(b)&&c.push(b+"="+a[b]);
a=c.join("&");if(g===true)a="!/"+a,location.hash=a;return a},get:function(c,e){var e=e||$_.hb,g=this.parse(e);return g[c]?g[c]:""}})})();
(function(){var c={_do:function(c,g,a,b){typeof a==="undefined"&&(a=function(){});var d=typeof window.XMLHttpRequest!=="undefined"?new XMLHttpRequest:false,b=b?"POST":"GET";c+=b==="GET"?"?"+this._serialize(g):"";d.open(b,c);d.onreadystatechange=function(){d.readyState===4&&a(d.responseText)};b==="POST"?(d.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),d.send(this._serialize(g))):d.send(null)},_serialize:function(c){var g=[],a;for(a in c)if(c.hasOwnProperty(a)&&typeof c[a]!==
"function"){var b=c[a].toString();a=encodeURIComponent(a);b=encodeURIComponent(b);g.push(a+"="+b)}return g.join("&")}};$_.ext("get",function(e,g,a){c._do(e,g,a,false)});$_.ext("post",function(e,g,a){c._do(e,g,a,true)})})();
(function(){var c=function(c){var a=[],b=0,d={},f,a=e.object_keys(c);a.sort(function(a,d){var b=parseFloat(d),f=parseFloat(a),c=b+""===d,g=f+""===a;if(c&&g)return b>f?1:b<f?-1:0;else if(c&&!g)return 1;else if(!c&&g)return-1;return d>a?1:d<a?-1:0});b=a.length;for(f=0;f<b;f++)d[a[f]]=c[a[f]];return d},e={object_keys:function(c){var a=[],b;for(b in c)c.hasOwnProperty(b)&&a.push(b);return a},object_values:function(c){var a=[],b;for(b in c)a.push(c[b]);return a},array_combine:function(c,a){var b={},d,
f=0;$_.type(c)!=="array"&&(c=this.object_values(c));$_.type(a)!=="array"&&(a=this.object_values(a));d=c.length;if(d!==a.length)return console.log("Object combine requires two arrays of the same size"),false;for(f=0;f<d;f++)b[c[f]]=a[f];return b},object_merge:function(){var c=Array.prototype.slice.call(arguments),a=c.length,b={},d,f=0,h,e,i;d=true;for(h=0;h<a;h++)if($_.type(c[h])!=="array"){d=false;break}if(d){b=[];for(h=0;h<a;h++)b=b.contact(c[h]);return b}for(h=0,i=0;h<a;h++)if(d=c[h],$_.type(d)==
"array")for(e=0,f=d.length;e<f;e++)b[i++]=d[e];else for(e in d)d.hasOwnProperty(e)&&(parseInt(e,10)+""===e?b[i++]=d[e]:b[e]=d[e]);return b},str_trans:function(e,a,b){var d=[],f=[],h=false,j=0,i=0,l="",k="",n="",o="",m;if(typeof a==="object"){a=c(a);for(m in a)a.hasOwnProperty(m)&&(d.push(m),f.push(a[m]));a=d;b=f}i=e.length;j=a.length;l=typeof b==="string";k=typeof a==="string";for(d=0;d<i;d++){h=false;if(k){e.charAt(d-1);n=e.charAt(d);e.charAt(d+1);for(f=0;f<j;f++)if(n==a.charAt(f)){h=true;break}}else for(f=
0;f<j;f++)if(e.substr(d,a[f].length)==a[f]){h=true;d=d+a[f].length-1;break}o+=h?l?b.charAt(f):b[f]:e.charAt(d)}return o}};$_.ext("util",e)})();
(function(){var c,e,g,a,b;typeof document.addEventListener!=="undefined"?(c=function(a,b,c){typeof a.addEventListener!=="undefined"&&a.addEventListener(b,c,false)},e=function(a,b,c){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(b,c,false)}):typeof document.attachEvent!=="undefined"&&(c=function(a,b,c){var d;function g(){c.apply(arguments)}typeof a.attachEvent!=="undefined"?(e(b,c),a.attachEvent("on"+b,g),d=a.KIS_0_3_0=a.KIS_0_3_0||{},a=d,a.listeners=a.listeners||{},a.listeners[b]=
a.listeners[b]||[],a.listeners[b].push({callback:c,listener:g})):console.log("Failed to attach event:"+b+" on "+a)},e=function(a,b,c){if(typeof a.detachEvent!=="undefined"){var e=a.KIS_0_3_0;if(e&&e.listeners&&e.listeners[b])for(var g=e.listeners[b],l=g.length,k=0;k<l;k++)if(g[k].callback===c){a.detachEvent("on"+b,g[k].listener);g.splice(k,1);g.length===0&&delete e.listeners[b];break}}});g=function(a,b,h,j){var i,l;if(typeof a==="undefined")return console.log(arguments),console.log(b),false;if(b.match(/^([\w\-]+)$/))j===
true?c(a,b,h):e(a,b,h);else{b=b.split(" ");l=b.length;for(i=0;i<l;i++)g(a,b[i],h,j)}};a=function(a,b,c){g(a,c,function(){a=$_.$(a)},true)};b=function(b,c,e){a(document.documentElement,b,c,e)};$_.ext("event",{add:function(a,b){$_.each(function(c){g(c,a,b,true)})},remove:function(a,b){$_.each(function(c){g(c,a,b,false)})},live:function(a,c){$_.each(function(e){b(e,a,c)})},delegate:function(b,c,e){$_.each(function(g){a(g,b,c,e)})}})})();