kis-js/kis-min.js

18 lines
7.9 KiB
JavaScript

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