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

View File

@ -185,10 +185,7 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/*
// --------------------------------------------------------------------------
/*
* classList.js: Cross-browser full element.classList implementation. * classList.js: Cross-browser full element.classList implementation.
* 2011-06-15 * 2011-06-15
* *
@ -197,8 +194,8 @@
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/ */
if (typeof document !== "undefined" && !("classList" in document.createElement("a"))) if (typeof document !== "undefined" && !("classList" in document.createElement("a")))
{ {
(function (view){ (function (view){
var classListProp = "classList", var classListProp = "classList",
@ -340,15 +337,15 @@
} }
}(self)); }(self));
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Dom manipulation object * Dom manipulation object
* *
*/ */
(function (){ (function (){
var d, tag_reg, class_reg; var d, tag_reg, class_reg;
tag_reg = /^([\w\-]+)$/; tag_reg = /^([\w\-]+)$/;
@ -566,16 +563,16 @@
$_.ext('dom', d); $_.ext('dom', d);
}()); }());
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Store object * Store object
* *
* Wrapper for localstorage data serialization * Wrapper for localstorage data serialization
*/ */
(function (){ (function (){
var store = { var store = {
get: function (key) get: function (key)
{ {
@ -613,16 +610,16 @@
}; };
$_.ext('store', store); $_.ext('store', store);
}()); }());
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Qs * Qs
* *
* Object for encoding and decoding querystrings and hashbang strings * Object for encoding and decoding querystrings and hashbang strings
*/ */
(function (){ (function (){
$_.hb = (history.pushState) ? false : true; $_.hb = (history.pushState) ? false : true;
@ -707,21 +704,16 @@
$_.ext('qs', qs); $_.ext('qs', qs);
}()); }());
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
//Fix $_ is not defined errors /**
var $_ = $_ || window.$_;
// --------------------------------------------------------------------------
/**
* Ajax * Ajax
* *
* Object for making ajax requests * Object for making ajax requests
*/ */
(function (){ (function (){
var ajax = { var ajax = {
_do: function (url, data, callback, isPost) _do: function (url, data, callback, isPost)
@ -793,65 +785,33 @@
$_.ext('post', function (url, data, callback){ $_.ext('post', function (url, data, callback){
ajax._do(url, data, callback, true); ajax._do(url, data, callback, true);
}); });
}()); }());
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Util Object * Util Object
* *
* Various object and string manipulation functions * Various object and string manipulation functions
*/ */
(function(){ (function(){
"use strict";
var u = { var u = {
object_keys: function(o)
{
var keys = [],
k;
for(k in o)
{
if(o.hasOwnProperty(k))
{
keys.push(k);
}
}
return keys;
},
object_values: function(o)
{
var vals = [],
prop;
for(prop in o)
{
vals.push(o[prop]);
}
return vals;
},
object_merge: function()
{
},
reverse_key_sort: function(o) reverse_key_sort: function(o)
{ {
//Define some variables //Define some variables
var keys = [], var keys = [],
num_keys = 0, num_keys = 0,
new_o = {}, new_o = {},
i, i;
k,
x;
//Extract the keys //Extract the keys
keys = this.object_keys(o); keys = this.object_keys(o);
//Sort the keys //Sort the keys
keys.sort(function (b, a) { keys.sort(function (b, a) {
var aFloat = parseFloat(a), var aFloat = parseFloat(a),
bFloat = parseFloat(b), bFloat = parseFloat(b),
aNumeric = aFloat + '' === a, aNumeric = aFloat + '' === a,
@ -879,30 +839,165 @@
//Recreate the object/array //Recreate the object/array
for(i=0; i < num_keys; i++) for(i=0; i < num_keys; i++)
{ {
k = keys[i]; new_o[keys[i]] = o[keys[i]];
new_o[k] = o[k];
} }
return new_o; return new_o;
}, },
object_keys: function(o)
{
var keys = [],
k;
for(k in o)
{
if(o.hasOwnProperty(k))
{
keys.push(k);
}
}
return keys;
},
object_values: function(o)
{
var vals = [],
prop;
for(prop in o)
{
vals.push(o[prop]);
}
return vals;
},
array_combine: function(keys, vals)
{
var new_object = {},
num_keys,
i = 0;
//Extract the keys or values if needed
if($_.type(keys) !== "array")
{
keys = this.object_values(keys);
}
if($_.type(vals) !== "array")
{
vals = this.object_values(vals);
}
//cache the number of keys
num_keys = keys.length;
if(num_keys !== vals.length)
{
console.log("Object combine requires two arrays of the same size");
return false;
}
//Create and return the new object
for(i = 0; i < num_keys; i++)
{
new_object[keys[i]] = vals[i];
}
return new_object;
},
object_merge: function()
{
var args = Array.prototype.slice.call(arguments),
arg_len = args.length,
new_obj = {},
arg,
iarg_len = 0,
i,
j,
x,
is_array = true;
//Check for an array in the arguments
for(i=0; i < arg_len; i++)
{
if($_.type(args[i]) !== "array")
{
is_array = false;
break;
}
}
//If all the arguments are javascript arrays
if(is_array)
{
new_obj = [];
//Let javascript do all the work!
for(i=0; i< arg_len; i++)
{
new_obj = new_obj.contact(args[i]);
}
//Return early
return new_obj;
}
//No, there's at least one object
for(i=0, x=0; i < arg_len; i++)
{
arg = args[i];
// If the argument is an array, add the array items as
// numeric object properties
if ($_.type(arg) == "array")
{
for (j=0, iarg_len= arg.length; j < iarg_len; j++)
{
new_obj[x++] = arg[j];
}
}
else
{
for (j in arg)
{
if(arg.hasOwnProperty(j))
{
// If the key is numeric, add the property with
// a numeric key
if(parseInt(j, 10) + '' === j)
{
new_obj[x++] = arg[j];
}
else
{
new_obj[j] = arg[j];
}
}
}
}
}
return new_obj;
},
str_trans: function(string, from, to) str_trans: function(string, from, to)
{ {
},
str_replace: function(from, to, string)
{
} }
}; };
//Add it to the $_ object //Add it to the $_ object
$_.ext('util', u); $_.ext('util', u);
}()); }());
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Event object * Event object
* *
* Event api wrapper * Event api wrapper
*/ */
(function (){ (function (){
// Property name for expandos on DOM objects // Property name for expandos on DOM objects
var kis_expando = "KIS_0_3_0"; var kis_expando = "KIS_0_3_0";
@ -1073,4 +1168,4 @@
$_.ext('event', e); $_.ext('event', e);
}()); }());

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(): 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,"")}}})(); {}.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", 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+= "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: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); "";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, (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]]? 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!== 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(){$_.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]); (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 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"){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]= (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,
b[d];return c},str_trans:function(){}})})(); 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]= (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=== 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(" ");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)})}})})(); 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)})}})})();