kis-js/kis-min.js

22 lines
9.3 KiB
JavaScript

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