kis-js/kis-lite-dom-min.js

18 lines
7.6 KiB
JavaScript
Executable File

(function(){if("undefined"!==typeof document.querySelector){var c,g,e,a;c=function(b){a="undefined"===typeof b?"undefined"!==typeof c.el?c.el:document.documentElement:"object"!==typeof b?g(b):b;c.prototype.el=a;var b=e(c),f;for(f in b)"object"===typeof b[f]&&(b[f].el=a);b.el=a;return b};g=function(b,f){var a;if("string"!=typeof b||"undefined"===typeof b)return b;a=null!=f&&1===f.nodeType?f:document;if(b.match(/^#([\w\-]+$)/))return document.getElementById(b.split("#")[1]);a=a.querySelectorAll(b);
return 1===a.length?a[0]:a};e=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}};c.ext=function(b,f){f.el=a;c[b]=f};c.ext("each",function(b){if("undefined"!==typeof a.length&&a!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(a,b);else{var f=a.length;if(0!==f)for(var d,h=0;h<f;h++)d=a.item(h)?a.item(h):a[h],b.call(d,d)}else b.call(a,
a)});c.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()};c=window.$_=window.$_||c;c.$=g}})();"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 Array.isArray&&(Array.isArray=function(c){return Object.prototype.toString.apply(c)==="[object Array]"});
(function(){if(typeof window.XMLHttpRequest!=="undefined"){var c={_do:function(c,e,a,b,f){var d=new XMLHttpRequest;typeof a==="undefined"&&(a=function(){});f=f?"POST":"GET";c=c+(f==="GET"?"?"+this._serialize(e):"");d.open(f,c);d.onreadystatechange=function(){d.readyState===4&&(d.status===200?a.call(d.responseText,d.responseText):typeof b!=="undefined"&&b.call(d.status,d.status))};if(f==="POST"){d.setRequestHeader("Content-Type","application/x-www-form-urlencoded");d.send(this._serialize(e))}else d.send(null)},
_serialize:function(c){var e,a,b=[];for(e in c)if(c.hasOwnProperty(e)&&typeof c[e]!=="function"){a=c[e].toString();e=encodeURIComponent(e);a=encodeURIComponent(a);b.push(e+"="+a)}return b.join("&")}};$_.ext("get",function(g,e,a,b){c._do(g,e,a,b,false)});$_.ext("post",function(g,e,a,b){c._do(g,e,a,b,true)});$_.ext("sse",function(c,e){var a;if(typeof EventSource!=="undefined"){a=new EventSource(c);a.onmessage=function(b){e.call(b.data,b.data)}}})}})();
(function(){var c,g,e,a;if(typeof document.addEventListener!=="undefined"){c=function(b,a,d){typeof b.addEventListener!=="undefined"&&b.addEventListener(a,d,false)};g=function(b,a,d){typeof b.removeEventListener!=="undefined"&&b.removeEventListener(a,d,false)}}else if(typeof document.attachEvent!=="undefined"){c=function(b,a,d){function c(b){d.apply(b)}if(typeof b.attachEvent!=="undefined"){g(a,d);b.attachEvent("on"+a,c);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:d,_listener:c})}};g=function(b,a,d){if(typeof b.detachEvent!=="undefined"){var c=b.KIS_0_6_0;if(c&&c.listeners&&c.listeners[a])for(var e=c.listeners[a],g=e.length,i=0;i<g;i++)if(e[i].callback===d){b.detachEvent("on"+a,e[i]._listener);e.splice(i,1);e.length===0&&delete c.listeners[a];break}}}}e=function(b,a,d,h){var j,k;if(typeof b==="undefined")return null;if(a.match(/^([\w\-]+)$/))h===true?c(b,a,d):g(b,a,d);else{a=a.split(" ");k=a.length;for(j=0;j<k;j++)e(b,a[j],
d,h)}};a=function(b,a,d,c){e(b,d,function(d){var e,i,g,d=d||window.event;i=$_.$(a,b);for(e in i){g=d.target||d.srcElement;if(g==i[e]){c.call(i[e],d);d.stopPropagation()}}},true)};$_.ext("event",{add:function(b,a){$_.each(function(d){e(d,b,a,true)})},remove:function(b,a){$_.each(function(d){e(d,b,a,false)})},live:function(b,f,d){a(document.documentElement,b,f,d)},delegate:function(b,f,d){$_.each(function(c){a(c,b,f,d)})}})})();
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(c){var c=(c.HTMLElement||c.Element).prototype,g=Object,e=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},a=Array.prototype.indexOf||function(b){for(var a=0,d=this.length;a<d;a++)if(a in this&&this[a]===b)return a;return-1},b=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},f=function(d,c){if(c==="")throw new b("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(c))throw new b("INVALID_CHARACTER_ERR",
"String contains an invalid character");return a.call(d,c)},d=function(a){for(var b=e.call(a.className),b=b?b.split(/\s+/):[],d=0,c=b.length;d<c;d++)this.push(b[d]);this._updateClassName=function(){a.className=this.toString()}},h=d.prototype=[],j=function(){return new d(this)};b.prototype=Error.prototype;h.item=function(a){return this[a]||null};h.contains=function(a){return f(this,a+"")!==-1};h.add=function(a){a=a+"";if(f(this,a)===-1){this.push(a);this._updateClassName()}};h.remove=function(a){a=
f(this,a+"");if(a!==-1){this.splice(a,1);this._updateClassName()}};h.toggle=function(a){a=a+"";f(this,a)===-1?this.add(a):this.remove(a)};h.toString=function(){return this.join(" ")};if(g.defineProperty){h={get:j,enumerable:true,configurable:true};try{g.defineProperty(c,"classList",h)}catch(k){if(k.number===-2146823252){h.enumerable=false;g.defineProperty(c,"classList",h)}}}else g.prototype.__defineGetter__&&c.__defineGetter__("classList",j)}(self);
(function(){function c(a,b,c){var d,e;if(typeof a.hasAttribute!=="undefined"){a.hasAttribute(b)&&(d=a.getAttribute(b));e=true}else if(typeof a[b]!=="undefined"){d=a[b];e=false}else if(b==="class"&&typeof a.className!=="undefined"){b="className";d=a.className;e=false}if(typeof d==="undefined"&&(typeof c==="undefined"||c===null))return null;if(typeof c==="undefined")return d;typeof c!=="undefined"&&c!==null?e===true?a.setAttribute(b,c):a[b]=c:c===null&&(e===true?a.removeAttribute(b):delete a[b]);return typeof c!==
"undefined"?c:d}function g(a){return a.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function e(a,b,c){var d,b=g(b);d={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if(typeof c==="undefined"&&a.style[b]!=="undefined")return a.style[b];if(typeof c==="undefined"&&a.style[d[b]]!=="undefined")return a.style[d[b]];if(typeof a.style[b]!=="undefined"){a.style[b]=c;return null}if(a.style[d[b]]){a.style[d[b]]=c;return null}}$_.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 e=this.el;if(e.length>1&&typeof b==="undefined")return null;if(e.length>1&&typeof b!=="undefined")$_.each(function(d){return c(d,a,b)});else return c(e,a,b)},text:function(a){var b,c,d;d=this.el;c=typeof d.textContent!=="undefined"?"textContent":typeof d.innerText!=="undefined"?"innerText":
"innerHTML";b=d[c];if(typeof a!=="undefined")return d[c]=a;return b},css:function(a,b){if(typeof b==="undefined")return e(this.el,a);$_.each(function(c){e(c,a,b)})},append:function(a){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("beforeend",a):this.el.innerHTML=this.el.innerHTML+a},prepend:function(a){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("afterbegin",a):this.el.innerHTML=a+this.el.innerHTML},html:function(a){if(typeof a!=="undefined")this.el.innerHTML=
a;return this.el.innerHTML}})})();