kis-js/kis-min.js

25 lines
10 KiB
JavaScript

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