kis-js/kis-min.js

25 lines
10 KiB
JavaScript
Executable File

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