kis-js/kis-min.js

1 line
8.9 KiB
JavaScript
Raw Normal View History

2011-11-02 19:12:58 -04:00
(function(){if(typeof document.querySelector!=="undefined"){var d,h,f,b;d=function(a){b=typeof a==="undefined"?typeof d.el!=="undefined"?d.el:document.documentElement:typeof a!=="object"?h(a):a;d.prototype.el=b;var a=f(d),c;for(c in a)if(typeof a[c]==="object")a[c].el=b;a.el=b;return a};h=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};f=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}};d.ext=function(a,c){c.el=b;d[a]=c};d.ext("each",function(a){if(typeof b.length!=="undefined"&&b!==window){var c=b.length;if(c!==0)for(var e,g=0;g<c;g++)e=b.item(g)?b.item(g):b[g],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.$=h}})();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(d){var d=(d.HTMLElement||d.Element).prototype,h=Object,f=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=f.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()}},g=e.prototype=[],j=function(){return new e(this)};a.prototype=Error.prototype;g.item=function(a){return this[a]||null};g.contains=function(a){a+="";return c(this,a)!==-1};g.add=function(a){a+="";c(this,a)===-1&&(this.push(a),this._updateClassName())};g.remove=function(a){a+= "";a=c(this,a);a!==-1&&(this.splice(a,1),this._updateClassName())};g.toggle=function(a){a+="";c(this,a)===-1?this.add(a):this.remove(a)};g.toString=function(){return this.join(" ")};if(h.defineProperty){g={get:j,enumerable:true,configurable:true};try{h.defineProperty(d,"classList",g)}catch(k){if(k.number===-2146823252)g.enumerable=false,h.defineProperty(d,"classList",g)}}else h.prototype.__defineGetter__&&d.__defineGetter__("classList",j)}(self); (function(){function d(b,a,c){var e,g;if(typeof b.hasAttribute!=="undefined")b.hasAttribute(a)&&(e=b.getAttribute(a)),g=true;else if(typeof b[a]!=="undefined")e=b[a],g=false;else if(a==="class"&&typeof b.className!=="undefined")a="className",e=b.className,g=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?g===true?b.setAttribute(a, c):b[a]=c:c===null&&(g===true?b.removeAttribute(a):delete b[a]);return typeof c!=="undefined"?c:e}}function h(b){return b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function f(b,a,c){var e,a=h(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()