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

15 lines
6.4 KiB
JavaScript
Executable File

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