kis-js/kis-min.js

23 lines
9.1 KiB
JavaScript

(function(){if(document.querySelectorAll){var c,f,g,a;f=function(b,a){var e;if(typeof b!="string"||typeof b==="undefined")return b;e=a!=null&&a.nodeType===1?a:document;if(b.match(/^#([\w\-]+$)/))return document.getElementById(b.split("#")[1]);else e=e.querySelectorAll(b);return e.length===1?e[0]:e};c=function(b){a=typeof b==="undefined"?typeof c.el!=="undefined"?c.el:document.documentElement:typeof b!=="object"?f(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 e,c=0;c<d;c++)e=a.item(c)?a.item(c):a[c],b(e)}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.$=f;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,f=Object,g=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},a=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},b=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},d=function(d,e){if(e==="")throw new b("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new b("INVALID_CHARACTER_ERR",
"String contains an invalid character");return a.call(d,e)},e=function(a){for(var b=g.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()}},i=e.prototype=[],h=function(){return new e(this)};b.prototype=Error.prototype;i.item=function(a){return this[a]||null};i.contains=function(a){a+="";return d(this,a)!==-1};i.add=function(a){a+="";d(this,a)===-1&&(this.push(a),this._updateClassName())};i.remove=function(a){a+=
"";a=d(this,a);a!==-1&&(this.splice(a,1),this._updateClassName())};i.toggle=function(a){a+="";d(this,a)===-1?this.add(a):this.remove(a)};i.toString=function(){return this.join(" ")};if(f.defineProperty){i={get:h,enumerable:true,configurable:true};try{f.defineProperty(c,"classList",i)}catch(j){if(j.number===-2146823252)i.enumerable=false,f.defineProperty(c,"classList",i)}}else f.prototype.__defineGetter__&&c.__defineGetter__("classList",h)}(self);
(function(){function c(a,b,d){var e,c;if(typeof a.hasAttribute!=="undefined")a.hasAttribute(b)&&(e=a.getAttribute(b)),c=true;else if(typeof a[b]!=="undefined")e=a[b],c=false;else if(b==="class"&&typeof a.className!=="undefined")b="className",e=a.className,c=false;if(typeof e==="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 e;typeof d!=="undefined"&&d!==null?c===true?a.setAttribute(b,
d):a[b]=d:d===null&&(c===true?a.removeAttribute(b):delete a[b]);return typeof d!=="undefined"?d:e}}function f(a){return a.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function g(a,b,d){var e,b=f(b);e={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[e[b]]!=="undefined")return a.style[e[b]];typeof a.style[b]!=="undefined"?a.style[b]=d:a.style[e[b]]?
a.style[e[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,c;c=this.el;d=typeof c.innerText!=="undefined"?"innerText":typeof c.textContent!=="undefined"?"textContent":"innerHTML";b=c[d];return typeof a!=="undefined"?c[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,f){typeof f!=="string"&&(f=JSON.stringify(f));localStorage.setItem(c,f)},remove:function(c){localStorage.removeItem(c)},getAll:function(){var c,f,g;f=localStorage.length;g={};for(c=0;c<f;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,f,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;f=c.split("&");g=f.length;for(c=0;c<g;c++){b=f[c].split("=");if(b.length<2)break;a[b[0]]=b[1]}return a},set:function(c,f,g){var g=g||$_.hb,a=this.parse(g);c!==void 0&&f!==void 0&&(a[c]=f);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,f){var f=f||$_.hb,g=this.parse(f);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(f,g,a){c._do(f,g,a,false)});$_.ext("post",function(f,g,a){c._do(f,g,a,true)})})();
(function(){var c=function(c){var a=[],b=0,d={},e,a=f.object_keys(c);a.sort(function(a,b){var d=parseFloat(b),c=parseFloat(a),e=d+""===b,g=c+""===a;if(e&&g)return d>c?1:d<c?-1:0;else if(e&&!g)return 1;else if(!e&&g)return-1;return b>a?1:b<a?-1:0});b=a.length;for(e=0;e<b;e++)d[a[e]]=c[a[e]];return d},f={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,
e=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(e=0;e<d;e++)b[c[e]]=a[e];return b},object_merge:function(){var c=Array.prototype.slice.call(arguments),a=c.length,b={},d,e=0,f,h,j;d=true;for(f=0;f<a;f++)if($_.type(c[f])!=="array"){d=false;break}if(d){b=[];for(f=0;f<a;f++)b=b.contact(c[f]);return b}for(f=0,j=0;f<a;f++)if(d=c[f],$_.type(d)==
"array")for(h=0,e=d.length;h<e;h++)b[j++]=d[h];else for(h in d)d.hasOwnProperty(h)&&(parseInt(h,10)+""===h?b[j++]=d[h]:b[h]=d[h]);return b},str_trans:function(f,a,b){var d=[],e=[],i=false,h=0,j=0,l="",m="",n="",o="",k;if(typeof a==="object"){a=c(a);for(k in a)a.hasOwnProperty(k)&&(d.push(k),e.push(a[k]));a=d;b=e}j=f.length;h=a.length;l=typeof b==="string";m=typeof a==="string";for(d=0;d<j;d++){i=false;if(m){f.charAt(d-1);n=f.charAt(d);f.charAt(d+1);for(e=0;e<h;e++)if(n==a.charAt(e)){i=true;break}}else for(e=
0;e<h;e++)if(f.substr(d,a[e].length)==a[e]){i=true;d=d+a[e].length-1;break}o+=i?l?b.charAt(e):b[e]:f.charAt(d)}return o}};$_.ext("util",f)})();
(function(){var c,f,g;typeof document.addEventListener!=="undefined"?(c=function(a,b,d){a.removeEventListener(b,d,false);a.addEventListener(b,d,false)},f=function(a,b,d){a.removeEventListener(b,d,false)}):typeof document.attachEvent!=="undefined"&&(c=function(a,b,d){var e;function c(a){d.apply(a)}typeof a.attachEvent!=="undefined"?(f(b,d),a.attachEvent("on"+b,c),e=a.KIS_0_3_0=a.KIS_0_3_0||{},a=e,a.listeners=a.listeners||{},a.listeners[b]=a.listeners[b]||[],a.listeners[b].push({callback:d,listener:c})):
console.log("Failed to attach event:"+b+" on "+a)},f=function(a,b,d){if(typeof a.detachEvent!=="undefined"){var c=a.KIS_0_3_0;if(c&&c.listeners&&c.listeners[b])for(var f=c.listeners[b],g=f.length,j=0;j<g;j++)if(f[j].callback===d){a.detachEvent("on"+b,f[j].listener);f.splice(j,1);f.length===0&&delete c.listeners[b];break}}});g=function(a,b,d,e){var i,h;if(typeof a==="undefined")return console.log(arguments),console.log(b),false;if(b.match(/^([\w\-]+)$/))e===true?c(a,b,d):f(a,b,d);else{b=b.split(" ");
h=b.length;for(i=0;i<h;i++)g(a,b[i],d,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)})}})})();