Added object_merge function

This commit is contained in:
Timothy Warren 2011-10-24 12:35:48 -04:00
parent b43960338a
commit f1bd4d92ee
2 changed files with 957 additions and 861 deletions

1801
kis-all.js

File diff suppressed because it is too large Load Diff

17
kis-min.js vendored
View File

@ -2,19 +2,20 @@
c;a.el=c;return a};f=function(a){var d;if(typeof a!=="undefined"){if(typeof Object.create!=="undefined")return Object.create(a);d=typeof a;if(!(d!=="object"&&d!=="function"))return d=function(){},d.prototype=a,new d}};b.ext=function(a,d){d.el=c;b[a]=d};b.ext("each",function(a){if(typeof c.length!=="undefined"&&c!==window){var d=c.length;if(d!==0)for(var b,e=0;e<d;e++)b=c.item(e)?c.item(e):c[e],a(b)}else a(c)});b.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()};b=window.$_=window.$_||b;b.$=e;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(b){var b=(b.HTMLElement||b.Element).prototype,e=Object,f=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array.prototype.indexOf||function(a){for(var d=0,c=this.length;d<c;d++)if(d in this&&this[d]===a)return d;return-1},a=function(a,d){this.name=a;this.code=DOMException[a];this.message=d},d=function(d,b){if(b==="")throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(b))throw new a("INVALID_CHARACTER_ERR",
"String contains an invalid character");return c.call(d,b)},l=function(a){for(var d=f.call(a.className),d=d?d.split(/\s+/):[],c=0,b=d.length;c<b;c++)this.push(d[c]);this._updateClassName=function(){a.className=this.toString()}},g=l.prototype=[],j=function(){return new l(this)};a.prototype=Error.prototype;g.item=function(a){return this[a]||null};g.contains=function(a){a+="";return d(this,a)!==-1};g.add=function(a){a+="";d(this,a)===-1&&(this.push(a),this._updateClassName())};g.remove=function(a){a+=
"";a=d(this,a);a!==-1&&(this.splice(a,1),this._updateClassName())};g.toggle=function(a){a+="";d(this,a)===-1?this.add(a):this.remove(a)};g.toString=function(){return this.join(" ")};if(e.defineProperty){g={get:j,enumerable:true,configurable:true};try{e.defineProperty(b,"classList",g)}catch(h){if(h.number===-2146823252)g.enumerable=false,e.defineProperty(b,"classList",g)}}else e.prototype.__defineGetter__&&b.__defineGetter__("classList",j)}(self);
"String contains an invalid character");return c.call(d,b)},h=function(a){for(var d=f.call(a.className),d=d?d.split(/\s+/):[],c=0,b=d.length;c<b;c++)this.push(d[c]);this._updateClassName=function(){a.className=this.toString()}},g=h.prototype=[],l=function(){return new h(this)};a.prototype=Error.prototype;g.item=function(d){return this[d]||null};g.contains=function(a){a+="";return d(this,a)!==-1};g.add=function(a){a+="";d(this,a)===-1&&(this.push(a),this._updateClassName())};g.remove=function(a){a+=
"";a=d(this,a);a!==-1&&(this.splice(a,1),this._updateClassName())};g.toggle=function(a){a+="";d(this,a)===-1?this.add(a):this.remove(a)};g.toString=function(){return this.join(" ")};if(e.defineProperty){g={get:l,enumerable:true,configurable:true};try{e.defineProperty(b,"classList",g)}catch(j){if(j.number===-2146823252)g.enumerable=false,e.defineProperty(b,"classList",g)}}else e.prototype.__defineGetter__&&b.__defineGetter__("classList",l)}(self);
(function(){function b(c,a,d){var b,e;if(typeof c.hasAttribute!=="undefined")c.hasAttribute(a)&&(b=c.getAttribute(a)),e=true;else if(typeof c[a]!=="undefined")b=c[a],e=false;else if(a==="class"&&typeof c.className!=="undefined")a="className",b=c.className,e=false;if(typeof b==="undefined"&&(typeof d==="undefined"||d===null))console.log(d),console.log(c),console.log("Element does not have the selected attribute");else{if(typeof d==="undefined")return b;typeof d!=="undefined"&&d!==null?e===true?c.setAttribute(a,
d):c[a]=d:d===null&&(e===true?c.removeAttribute(a):delete c[a]);return typeof d!=="undefined"?d:b}}function e(c){return c.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function f(c,a,d){var b,a=e(a);b={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if(typeof d==="undefined"&&c.style[a]!=="undefined")return c.style[a];else if(typeof d==="undefined"&&c.style[b[a]]!=="undefined")return c.style[b[a]];typeof c.style[a]!=="undefined"?c.style[a]=d:c.style[b[a]]?
c.style[b[a]]=d:console.log("Property "+a+" nor an equivalent seems to exist")}$_.ext("dom",{addClass:function(c){$_.each(function(a){a.classList.add(c)})},removeClass:function(c){$_.each(function(a){a.classList.remove(c)})},hide:function(){this.css("display","none")},show:function(c){typeof c==="undefined"&&(c="block");this.css("display",c)},attr:function(c,a){var d=this.el;if(d.length>1&&typeof a==="undefined")console.log(d),console.log("Must be a singular element");else if(d.length>1&&typeof a!==
"undefined")$_.each(function(d){return b(d,c,a)});else return b(d,c,a)},text:function(c){var a,d,b;b=this.el;d=typeof b.innerText!=="undefined"?"innerText":typeof b.textContent!=="undefined"?"textContent":"innerHTML";a=b[d];return typeof c!=="undefined"?b[d]=c:a},css:function(b,a){if(typeof a==="undefined")return f(this.el,b);$_.each(function(d){f(d,b,a)})}})})();
"undefined")$_.each(function(d){return b(d,c,a)});else return b(d,c,a)},text:function(c){var a,d,b;b=this.el;d=typeof b.innerText!=="undefined"?"innerText":typeof b.textContent!=="undefined"?"textContent":"innerHTML";a=b[d];return typeof c!=="undefined"?b[d]=c:a},css:function(c,a){if(typeof a==="undefined")return f(this.el,c);$_.each(function(d){f(d,c,a)})}})})();
(function(){$_.ext("store",{get:function(b){return JSON.parse(localStorage.getItem(b))},set:function(b,e){typeof e!=="string"&&(e=JSON.stringify(e));localStorage.setItem(b,e)},remove:function(b){localStorage.removeItem(b)},getAll:function(){var b,e,f;e=localStorage.length;f={};for(b=0;b<e;b++){var c=localStorage.key(b),a=localStorage.getItem(c);f[c]=a}return f}})})();
(function(){$_.hb=history.pushState?false:true;$_.ext("qs",{parse:function(b){var b=b||$_.hb,e,f,c,a;c={};if(b===true)b=location.hash.split("#!/"),b=b.length>1?b[1]:"";else if(b===false||b===void 0)b=window.location.search.substring(1);else return false;e=b.split("&");f=e.length;for(b=0;b<f;b++){a=e[b].split("=");if(a.length<2)break;c[a[0]]=a[1]}return c},set:function(b,e,f){var f=f||$_.hb,c=this.parse(f);b!==void 0&&e!==void 0&&(c[b]=e);var b=[],a;for(a in c)c.hasOwnProperty(a)&&b.push(a+"="+c[a]);
c=b.join("&");if(f===true)c="!/"+c,location.hash=c;return c},get:function(b,e){var e=e||$_.hb,f=this.parse(e);return f[b]?f[b]:""}})})();var $_=$_||window.$_;
c=b.join("&");if(f===true)c="!/"+c,location.hash=c;return c},get:function(b,e){var e=e||$_.hb,f=this.parse(e);return f[b]?f[b]:""}})})();
(function(){var b={_do:function(b,f,c,a){typeof c==="undefined"&&(c=function(){});var d=typeof window.XMLHttpRequest!=="undefined"?new XMLHttpRequest:false,a=a?"POST":"GET";b+=a==="GET"?"?"+this._serialize(f):"";d.open(a,b);d.onreadystatechange=function(){d.readyState===4&&c(d.responseText)};a==="POST"?(d.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),d.send(this._serialize(f))):d.send(null)},_serialize:function(b){var f=[],c;for(c in b)if(b.hasOwnProperty(c)&&typeof b[c]!==
"function"){var a=b[c].toString();c=encodeURIComponent(c);a=encodeURIComponent(a);f.push(c+"="+a)}return f.join("&")}};$_.ext("get",function(e,f,c){b._do(e,f,c,false)});$_.ext("post",function(e,f,c){b._do(e,f,c,true)})})();
(function(){$_.ext("util",{object_keys:function(b){var e=[],f;for(f in b)b.hasOwnProperty(f)&&e.push(f);return e},object_values:function(b){var e=[],f;for(f in b)e.push(b[f]);return e},object_merge:function(){},reverse_key_sort:function(b){var e=[],f=0,c={},a,d,e=this.object_keys(b);e.sort(function(a,d){var b=parseFloat(d),c=parseFloat(a),e=b+""===d,f=c+""===a;if(e&&f)return b>c?1:b<c?-1:0;else if(e&&!f)return 1;else if(!e&&f)return-1;return d>a?1:d<a?-1:0});f=e.length;for(a=0;a<f;a++)d=e[a],c[d]=
b[d];return c},str_trans:function(){}})})();
(function(){$_.ext("util",{reverse_key_sort:function(b){var e=[],f=0,c={},a,e=this.object_keys(b);e.sort(function(a,b){var c=parseFloat(b),e=parseFloat(a),f=c+""===b,i=e+""===a;if(f&&i)return c>e?1:c<e?-1:0;else if(f&&!i)return 1;else if(!f&&i)return-1;return b>a?1:b<a?-1:0});f=e.length;for(a=0;a<f;a++)c[e[a]]=b[e[a]];return c},object_keys:function(b){var e=[],f;for(f in b)b.hasOwnProperty(f)&&e.push(f);return e},object_values:function(b){var e=[],f;for(f in b)e.push(b[f]);return e},array_combine:function(b,
e){var f={},c,a=0;$_.type(b)!=="array"&&(b=this.object_values(b));$_.type(e)!=="array"&&(e=this.object_values(e));c=b.length;if(c!==e.length)return console.log("Object combine requires two arrays of the same size"),false;for(a=0;a<c;a++)f[b[a]]=e[a];return f},object_merge:function(){var b=Array.prototype.slice.call(arguments),e=b.length,f={},c,a=0,d,h,g;c=true;for(d=0;d<e;d++)if($_.type(b[d])!=="array"){c=false;break}if(c){f=[];for(d=0;d<e;d++)f=f.contact(b[d]);return f}for(d=0,g=0;d<e;d++)if(c=b[d],
$_.type(c)=="array")for(h=0,a=c.length;h<a;h++)f[g++]=c[h];else for(h in c)c.hasOwnProperty(h)&&(parseInt(h,10)+""===h?f[g++]=c[h]:f[h]=c[h]);return f},str_trans:function(){},str_replace:function(){}})})();
(function(){var b,e,f,c,a;typeof document.addEventListener!=="undefined"?(b=function(a,b,c){typeof a.addEventListener!=="undefined"&&a.addEventListener(b,c,false)},e=function(a,b,c){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(b,c,false)}):typeof document.attachEvent!=="undefined"&&(b=function(a,b,c){var d;function f(){c.apply(arguments)}typeof a.attachEvent!=="undefined"?(e(b,c),a.attachEvent("on"+b,f),d=a.KIS_0_3_0=a.KIS_0_3_0||{},a=d,a.listeners=a.listeners||{},a.listeners[b]=
a.listeners[b]||[],a.listeners[b].push({callback:c,listener:f})):console.log("Failed to attach event:"+b+" on "+a)},e=function(a,b,c){if(typeof a.detachEvent!=="undefined"){var e=a.KIS_0_3_0;if(e&&e.listeners&&e.listeners[b])for(var f=e.listeners[b],k=f.length,i=0;i<k;i++)if(f[i].callback===c){a.detachEvent("on"+b,f[i].listener);f.splice(i,1);f.length===0&&delete e.listeners[b];break}}});f=function(a,c,g,j){var h,k;if(typeof a==="undefined")return console.log(arguments),console.log(c),false;if(c.match(/^([\w\-]+)$/))j===
true?b(a,c,g):e(a,c,g);else{c=c.split(" ");k=c.length;for(h=0;h<k;h++)f(a,c[h],g,j)}};c=function(a,b,c){f(a,c,function(){a=$_.$(a)},true)};a=function(a,b,e){c(document.documentElement,a,b,e)};$_.ext("event",{add:function(a,b){$_.each(function(c){f(c,a,b,true)})},remove:function(a,b){$_.each(function(c){f(c,a,b,false)})},live:function(b,c){$_.each(function(e){a(e,b,c)})},delegate:function(a,b,e){$_.each(function(f){c(f,a,b,e)})}})})();
a.listeners[b]||[],a.listeners[b].push({callback:c,listener:f})):console.log("Failed to attach event:"+b+" on "+a)},e=function(a,b,c){if(typeof a.detachEvent!=="undefined"){var e=a.KIS_0_3_0;if(e&&e.listeners&&e.listeners[b])for(var f=e.listeners[b],i=f.length,k=0;k<i;k++)if(f[k].callback===c){a.detachEvent("on"+b,f[k].listener);f.splice(k,1);f.length===0&&delete e.listeners[b];break}}});f=function(a,c,g,l){var j,i;if(typeof a==="undefined")return console.log(arguments),console.log(c),false;if(c.match(/^([\w\-]+)$/))l===
true?b(a,c,g):e(a,c,g);else{c=c.split(" ");i=c.length;for(j=0;j<i;j++)f(a,c[j],g,l)}};c=function(a,b,c){f(a,c,function(){a=$_.$(a)},true)};a=function(a,b,e){c(document.documentElement,a,b,e)};$_.ext("event",{add:function(a,b){$_.each(function(c){f(c,a,b,true)})},remove:function(a,b){$_.each(function(c){f(c,a,b,false)})},live:function(b,c){$_.each(function(e){a(e,b,c)})},delegate:function(a,b,e){$_.each(function(f){c(f,a,b,e)})}})})();