diff --git a/docs/files.html b/docs/files.html index 0d8cb6c..327bd02 100644 --- a/docs/files.html +++ b/docs/files.html @@ -120,7 +120,7 @@
- Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 18:52:39 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 20:13:40 GMT-0400 (EDT)
diff --git a/docs/index.html b/docs/index.html index c85bbb0..7932ff5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -138,7 +138,7 @@
- Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 18:52:39 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 20:13:40 GMT-0400 (EDT)
diff --git a/docs/symbols/$_.dom.html b/docs/symbols/$_.dom.html index d25a03d..6465059 100644 --- a/docs/symbols/$_.dom.html +++ b/docs/symbols/$_.dom.html @@ -459,7 +459,7 @@ current selector.
- Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 18:52:39 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 20:13:40 GMT-0400 (EDT)
diff --git a/docs/symbols/$_.event.html b/docs/symbols/$_.event.html index b1e6f71..22529ac 100644 --- a/docs/symbols/$_.event.html +++ b/docs/symbols/$_.event.html @@ -451,7 +451,7 @@ event and selector
- Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 18:52:39 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 20:13:40 GMT-0400 (EDT)
diff --git a/docs/symbols/$_.store.html b/docs/symbols/$_.store.html index b7cc2f9..bf46ca0 100644 --- a/docs/symbols/$_.store.html +++ b/docs/symbols/$_.store.html @@ -338,7 +338,7 @@ and JSON-encodes the value if not a string
- Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 18:52:39 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 20:13:40 GMT-0400 (EDT)
diff --git a/docs/symbols/$_.util.html b/docs/symbols/$_.util.html index de2de00..f267829 100644 --- a/docs/symbols/$_.util.html +++ b/docs/symbols/$_.util.html @@ -658,7 +658,7 @@ from => to replacements as key/value pairs
- Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 18:52:39 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 20:13:40 GMT-0400 (EDT)
diff --git a/docs/symbols/_global_.html b/docs/symbols/_global_.html index a3528c5..77b5fe3 100644 --- a/docs/symbols/_global_.html +++ b/docs/symbols/_global_.html @@ -105,7 +105,7 @@
- Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 18:52:39 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Tue Nov 01 2011 20:13:40 GMT-0400 (EDT)
diff --git a/docs/symbols/src/kis-js_src_modules_DOM.js.html b/docs/symbols/src/kis-js_src_modules_DOM.js.html index 43e8928..273d138 100755 --- a/docs/symbols/src/kis-js_src_modules_DOM.js.html +++ b/docs/symbols/src/kis-js_src_modules_DOM.js.html @@ -174,312 +174,315 @@ 167 // -------------------------------------------------------------------------- 168 169 (function (){ -170 var d, tag_reg, class_reg; -171 -172 tag_reg = /^([\w\-]+)$/; -173 class_reg = /\.([\w\-]+)$/; +170 +171 "use strict"; +172 +173 var d, tag_reg, class_reg; 174 -175 -176 //Private function for getting/setting attributes -177 function _attr(sel, name, value) -178 { -179 var oldVal, doAttr; -180 -181 //Get the value of the attribute, if it exists -182 if (typeof sel.hasAttribute !== "undefined") -183 { -184 if (sel.hasAttribute(name)) -185 { -186 oldVal = sel.getAttribute(name); -187 } -188 -189 doAttr = true; -190 } -191 else if (typeof sel[name] !== "undefined") -192 { -193 oldVal = sel[name]; -194 doAttr = false; -195 } -196 else if (name === "class" && typeof sel.className !== "undefined") //className attribute -197 { -198 name = "className"; -199 oldVal = sel.className; -200 doAttr = false; -201 } -202 -203 //Well, I guess that attribute doesn't exist -204 if (typeof oldVal === "undefined" && (typeof value === "undefined" || value === null)) -205 { -206 console.log(value); -207 console.log(sel); -208 console.log("Element does not have the selected attribute"); -209 return; -210 } -211 -212 //No value to set? Return the current value -213 if (typeof value === "undefined") -214 { -215 return oldVal; -216 } -217 -218 //Determine what to do with the attribute -219 if (typeof value !== "undefined" && value !== null) -220 { -221 if(doAttr === true) -222 { -223 sel.setAttribute(name, value); -224 } -225 else -226 { -227 sel[name] = value; -228 } -229 } -230 else if (value === null) -231 { -232 if(doAttr === true) -233 { -234 sel.removeAttribute(name); -235 } -236 else -237 { -238 delete sel[name]; -239 } -240 } -241 -242 return (typeof value !== "undefined") ? value : oldVal; -243 } -244 -245 function _toCamel(s) -246 { -247 return s.replace(/(\-[a-z])/g, function($1){ -248 return $1.toUpperCase().replace('-',''); -249 }); -250 } -251 -252 function _css(sel, prop, val) -253 { -254 var equi; -255 -256 //Camel-case -257 prop = _toCamel(prop); -258 -259 //Equivalent properties for 'special' browsers -260 equi = { -261 outerHeight: "offsetHeight", -262 outerWidth: "offsetWidth", -263 top: "posTop" -264 }; -265 -266 -267 //If you don't define a value, try returning the existing value -268 if(typeof val === "undefined" && sel.style[prop] !== "undefined") -269 { -270 return sel.style[prop]; -271 } -272 else if(typeof val === "undefined" && sel.style[equi[prop]] !== "undefined") -273 { -274 return sel.style[equi[prop]]; -275 } -276 -277 //Let's try the easy way first -278 if(typeof sel.style[prop] !== "undefined") -279 { -280 sel.style[prop] = val; -281 -282 //Short circuit -283 return; -284 } -285 else if(sel.style[equi[prop]]) -286 { -287 sel.style[equi[prop]] = val; -288 return; -289 } -290 -291 //No matches? Well, lets log it for now -292 console.log("Property " + prop + " nor an equivalent seems to exist"); -293 } -294 -295 // -------------------------------------------------------------------------- -296 -297 /** -298 * DOM -299 * -300 * Dom manipulation module -301 * @namespace -302 * @memberOf $_ -303 * @name dom -304 */ -305 d = { -306 /** -307 * Adds a class to the element(s) specified by the current -308 * selector -309 * -310 * @name addClass -311 * @memberOf $_.dom -312 * @function -313 * @param string class -314 * @return void -315 */ -316 addClass: function (c) -317 { -318 $_.each(function (e){ -319 e.classList.add(c); -320 }); -321 }, -322 /** -323 * Removes a class from the element(s) specified by the current -324 * selector -325 * -326 * @name removeClass -327 * @memberOf $_.dom -328 * @function -329 * @param string class -330 * @return void -331 */ -332 removeClass: function (c) -333 { -334 $_.each(function (e){ -335 e.classList.remove(c); -336 }); -337 }, -338 /** -339 * Hides the element(s) specified by the current selector -340 * -341 * @name hide -342 * @memberOf $_.dom -343 * @function -344 * @return void -345 */ -346 hide: function () -347 { -348 this.css('display', 'none'); -349 }, -350 /** -351 * Shows the element(s) specified by the current selector. -352 * if type is specified, the element will have it's style -353 * property set to "display:[your type]". If type is not -354 * specified, the element is set to "display:block". -355 * -356 * @name show -357 * @memberOf $_.dom -358 * @function -359 * @param [string] type -360 * @return void -361 */ -362 show: function (type) -363 { -364 if (typeof type === "undefined") -365 { -366 type = "block"; -367 } -368 -369 this.css("display", type); -370 }, -371 /** -372 * Sets attributes on element(s) specified by the current -373 * selector, or, if name is not specified, returns the -374 * value of the attribute of the element specified by the -375 * current selector. -376 * -377 * @name attr -378 * @memberOf $_.dom -379 * @function -380 * @param string name -381 * @param string value -382 * @return string -383 * @type string -384 */ -385 attr: function (name, value) -386 { -387 var sel = this.el; -388 -389 //Make sure you don't try to get a bunch of elements -390 if (sel.length > 1 && typeof value === "undefined") -391 { -392 console.log(sel); -393 console.log("Must be a singular element"); -394 return; -395 } -396 else if (sel.length > 1 && typeof value !== "undefined") //You can set a bunch, though -397 { -398 $_.each(function (e){ -399 return _attr(e, name, value); -400 }); -401 } -402 else //Normal behavior -403 { -404 return _attr(sel, name, value); -405 } -406 }, -407 /** -408 * Sets or retrieves the text content of the element -409 * specified by the current selector. If a value is -410 * passed, it will set that value on the current element, -411 * otherwise it will return the value of the current element -412 * -413 * @name text -414 * @memberOf $_.util -415 * @function -416 * @param [string] value -417 * @returns string -418 * @type string -419 */ -420 text: function (value) -421 { -422 var oldValue, set, type, sel; -423 -424 sel = this.el; -425 -426 set = (typeof value !== "undefined") ? true : false; -427 -428 type = (typeof sel.innerText !== "undefined") -429 ? "innerText" -430 : (typeof sel.textContent !== "undefined") -431 ? "textContent" -432 : "innerHTML"; -433 -434 oldValue = sel[type]; -435 -436 if(set) -437 { -438 sel[type] = value; -439 return value; -440 } -441 else -442 { -443 return oldValue; -444 } -445 }, -446 /** -447 * Sets or retrieves a css property of the element -448 * specified by the current selector. If a value is -449 * passed, it will set that value on the current element, -450 * otherwise it will return the value of the css property -451 * on the current element -452 * -453 * @name css -454 * @memberOf $_.util -455 * @function -456 * @param string property -457 * @param [string] value -458 * @returns string -459 * @type string -460 */ -461 css: function (prop, val) -462 { -463 //Return the current value if a value is not set -464 if(typeof val === "undefined") -465 { -466 return _css(this.el, prop); -467 } -468 -469 $_.each(function (e){ -470 _css(e, prop, val); -471 }); -472 } -473 }; -474 -475 $_.ext('dom', d); -476 -477 }()); -478 \ No newline at end of file +175 tag_reg = /^([\w\-]+)$/; +176 class_reg = /\.([\w\-]+)$/; +177 +178 +179 //Private function for getting/setting attributes +180 function _attr(sel, name, value) +181 { +182 var oldVal, doAttr; +183 +184 //Get the value of the attribute, if it exists +185 if (typeof sel.hasAttribute !== "undefined") +186 { +187 if (sel.hasAttribute(name)) +188 { +189 oldVal = sel.getAttribute(name); +190 } +191 +192 doAttr = true; +193 } +194 else if (typeof sel[name] !== "undefined") +195 { +196 oldVal = sel[name]; +197 doAttr = false; +198 } +199 else if (name === "class" && typeof sel.className !== "undefined") //className attribute +200 { +201 name = "className"; +202 oldVal = sel.className; +203 doAttr = false; +204 } +205 +206 //Well, I guess that attribute doesn't exist +207 if (typeof oldVal === "undefined" && (typeof value === "undefined" || value === null)) +208 { +209 console.log(value); +210 console.log(sel); +211 console.log("Element does not have the selected attribute"); +212 return; +213 } +214 +215 //No value to set? Return the current value +216 if (typeof value === "undefined") +217 { +218 return oldVal; +219 } +220 +221 //Determine what to do with the attribute +222 if (typeof value !== "undefined" && value !== null) +223 { +224 if(doAttr === true) +225 { +226 sel.setAttribute(name, value); +227 } +228 else +229 { +230 sel[name] = value; +231 } +232 } +233 else if (value === null) +234 { +235 if(doAttr === true) +236 { +237 sel.removeAttribute(name); +238 } +239 else +240 { +241 delete sel[name]; +242 } +243 } +244 +245 return (typeof value !== "undefined") ? value : oldVal; +246 } +247 +248 function _toCamel(s) +249 { +250 return s.replace(/(\-[a-z])/g, function($1){ +251 return $1.toUpperCase().replace('-',''); +252 }); +253 } +254 +255 function _css(sel, prop, val) +256 { +257 var equi; +258 +259 //Camel-case +260 prop = _toCamel(prop); +261 +262 //Equivalent properties for 'special' browsers +263 equi = { +264 outerHeight: "offsetHeight", +265 outerWidth: "offsetWidth", +266 top: "posTop" +267 }; +268 +269 +270 //If you don't define a value, try returning the existing value +271 if(typeof val === "undefined" && sel.style[prop] !== "undefined") +272 { +273 return sel.style[prop]; +274 } +275 else if(typeof val === "undefined" && sel.style[equi[prop]] !== "undefined") +276 { +277 return sel.style[equi[prop]]; +278 } +279 +280 //Let's try the easy way first +281 if(typeof sel.style[prop] !== "undefined") +282 { +283 sel.style[prop] = val; +284 +285 //Short circuit +286 return; +287 } +288 else if(sel.style[equi[prop]]) +289 { +290 sel.style[equi[prop]] = val; +291 return; +292 } +293 +294 //No matches? Well, lets log it for now +295 console.log("Property " + prop + " nor an equivalent seems to exist"); +296 } +297 +298 // -------------------------------------------------------------------------- +299 +300 /** +301 * DOM +302 * +303 * Dom manipulation module +304 * @namespace +305 * @memberOf $_ +306 * @name dom +307 */ +308 d = { +309 /** +310 * Adds a class to the element(s) specified by the current +311 * selector +312 * +313 * @name addClass +314 * @memberOf $_.dom +315 * @function +316 * @param string class +317 * @return void +318 */ +319 addClass: function (c) +320 { +321 $_.each(function (e){ +322 e.classList.add(c); +323 }); +324 }, +325 /** +326 * Removes a class from the element(s) specified by the current +327 * selector +328 * +329 * @name removeClass +330 * @memberOf $_.dom +331 * @function +332 * @param string class +333 * @return void +334 */ +335 removeClass: function (c) +336 { +337 $_.each(function (e){ +338 e.classList.remove(c); +339 }); +340 }, +341 /** +342 * Hides the element(s) specified by the current selector +343 * +344 * @name hide +345 * @memberOf $_.dom +346 * @function +347 * @return void +348 */ +349 hide: function () +350 { +351 this.css('display', 'none'); +352 }, +353 /** +354 * Shows the element(s) specified by the current selector. +355 * if type is specified, the element will have it's style +356 * property set to "display:[your type]". If type is not +357 * specified, the element is set to "display:block". +358 * +359 * @name show +360 * @memberOf $_.dom +361 * @function +362 * @param [string] type +363 * @return void +364 */ +365 show: function (type) +366 { +367 if (typeof type === "undefined") +368 { +369 type = "block"; +370 } +371 +372 this.css("display", type); +373 }, +374 /** +375 * Sets attributes on element(s) specified by the current +376 * selector, or, if name is not specified, returns the +377 * value of the attribute of the element specified by the +378 * current selector. +379 * +380 * @name attr +381 * @memberOf $_.dom +382 * @function +383 * @param string name +384 * @param string value +385 * @return string +386 * @type string +387 */ +388 attr: function (name, value) +389 { +390 var sel = this.el; +391 +392 //Make sure you don't try to get a bunch of elements +393 if (sel.length > 1 && typeof value === "undefined") +394 { +395 console.log(sel); +396 console.log("Must be a singular element"); +397 return; +398 } +399 else if (sel.length > 1 && typeof value !== "undefined") //You can set a bunch, though +400 { +401 $_.each(function (e){ +402 return _attr(e, name, value); +403 }); +404 } +405 else //Normal behavior +406 { +407 return _attr(sel, name, value); +408 } +409 }, +410 /** +411 * Sets or retrieves the text content of the element +412 * specified by the current selector. If a value is +413 * passed, it will set that value on the current element, +414 * otherwise it will return the value of the current element +415 * +416 * @name text +417 * @memberOf $_.util +418 * @function +419 * @param [string] value +420 * @returns string +421 * @type string +422 */ +423 text: function (value) +424 { +425 var oldValue, set, type, sel; +426 +427 sel = this.el; +428 +429 set = (typeof value !== "undefined") ? true : false; +430 +431 type = (typeof sel.innerText !== "undefined") +432 ? "innerText" +433 : (typeof sel.textContent !== "undefined") +434 ? "textContent" +435 : "innerHTML"; +436 +437 oldValue = sel[type]; +438 +439 if(set) +440 { +441 sel[type] = value; +442 return value; +443 } +444 else +445 { +446 return oldValue; +447 } +448 }, +449 /** +450 * Sets or retrieves a css property of the element +451 * specified by the current selector. If a value is +452 * passed, it will set that value on the current element, +453 * otherwise it will return the value of the css property +454 * on the current element +455 * +456 * @name css +457 * @memberOf $_.util +458 * @function +459 * @param string property +460 * @param [string] value +461 * @returns string +462 * @type string +463 */ +464 css: function (prop, val) +465 { +466 //Return the current value if a value is not set +467 if(typeof val === "undefined") +468 { +469 return _css(this.el, prop); +470 } +471 +472 $_.each(function (e){ +473 _css(e, prop, val); +474 }); +475 } +476 }; +477 +478 $_.ext('dom', d); +479 +480 }()); +481 \ No newline at end of file diff --git a/docs/symbols/src/kis-js_src_modules_ajax.js.html b/docs/symbols/src/kis-js_src_modules_ajax.js.html index 957a9d8..45d0608 100755 --- a/docs/symbols/src/kis-js_src_modules_ajax.js.html +++ b/docs/symbols/src/kis-js_src_modules_ajax.js.html @@ -12,99 +12,101 @@ 5 */ 6 (function (){ 7 - 8 var ajax = { - 9 _do: function (url, data, callback, isPost) - 10 { - 11 if (typeof callback === "undefined") - 12 { - 13 /** - 14 * @private - 15 */ - 16 callback = function (){}; - 17 } - 18 - 19 var request = (typeof window.XMLHttpRequest !== "undefined") - 20 ? new XMLHttpRequest() - 21 : false; - 22 - 23 var type = (isPost) ? "POST" : "GET"; + 8 "use strict"; + 9 + 10 var ajax = { + 11 _do: function (url, data, callback, isPost) + 12 { + 13 if (typeof callback === "undefined") + 14 { + 15 /** + 16 * @private + 17 */ + 18 callback = function (){}; + 19 } + 20 + 21 var request = (typeof window.XMLHttpRequest !== "undefined") + 22 ? new XMLHttpRequest() + 23 : false; 24 - 25 url += (type === "GET") ? "?"+this._serialize(data) : ''; - 26 - 27 request.open(type, url); - 28 - 29 request.onreadystatechange = function () - 30 { - 31 if (request.readyState === 4) - 32 { - 33 callback(request.responseText); - 34 } - 35 }; - 36 - 37 if (type === "POST") - 38 { - 39 request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - 40 request.send(this._serialize(data)); - 41 } - 42 else - 43 { - 44 request.send(null); - 45 } - 46 }, - 47 _serialize: function (data) - 48 { - 49 var pairs = []; - 50 - 51 for (var name in data) - 52 { - 53 if (!data.hasOwnProperty(name)) - 54 { - 55 continue; - 56 } - 57 if (typeof data[name] === "function") - 58 { - 59 continue; - 60 } - 61 - 62 var value = data[name].toString(); + 25 var type = (isPost) ? "POST" : "GET"; + 26 + 27 url += (type === "GET") ? "?"+this._serialize(data) : ''; + 28 + 29 request.open(type, url); + 30 + 31 request.onreadystatechange = function () + 32 { + 33 if (request.readyState === 4) + 34 { + 35 callback(request.responseText); + 36 } + 37 }; + 38 + 39 if (type === "POST") + 40 { + 41 request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + 42 request.send(this._serialize(data)); + 43 } + 44 else + 45 { + 46 request.send(null); + 47 } + 48 }, + 49 _serialize: function (data) + 50 { + 51 var pairs = []; + 52 + 53 for (var name in data) + 54 { + 55 if (!data.hasOwnProperty(name)) + 56 { + 57 continue; + 58 } + 59 if (typeof data[name] === "function") + 60 { + 61 continue; + 62 } 63 - 64 name = encodeURIComponent(name); - 65 value = encodeURIComponent(value); - 66 - 67 pairs.push(name + "=" + value); - 68 } - 69 - 70 return pairs.join("&"); - 71 } - 72 }; - 73 - 74 /** - 75 * Sends a GET type ajax request - 76 * - 77 * @name get - 78 * @function - 79 * @memberOf $_ - 80 * @param string url - 81 * @param object data - 82 * @param function callback - 83 * @return void - 84 */ - 85 $_.ext('get', function (url, data, callback){ - 86 ajax._do(url, data, callback, false); - 87 }); - 88 - 89 /** - 90 * Sends a POST type ajax request - 91 * - 92 * @name post - 93 * @function - 94 * @memberOf $_ - 95 * @param string url - 96 * @param object data - 97 * @param function callback - 98 * @return void - 99 */ -100 $_.ext('post', function (url, data, callback){ -101 ajax._do(url, data, callback, true); -102 }); -103 }()); \ No newline at end of file + 64 var value = data[name].toString(); + 65 + 66 name = encodeURIComponent(name); + 67 value = encodeURIComponent(value); + 68 + 69 pairs.push(name + "=" + value); + 70 } + 71 + 72 return pairs.join("&"); + 73 } + 74 }; + 75 + 76 /** + 77 * Sends a GET type ajax request + 78 * + 79 * @name get + 80 * @function + 81 * @memberOf $_ + 82 * @param string url + 83 * @param object data + 84 * @param function callback + 85 * @return void + 86 */ + 87 $_.ext('get', function (url, data, callback){ + 88 ajax._do(url, data, callback, false); + 89 }); + 90 + 91 /** + 92 * Sends a POST type ajax request + 93 * + 94 * @name post + 95 * @function + 96 * @memberOf $_ + 97 * @param string url + 98 * @param object data + 99 * @param function callback +100 * @return void +101 */ +102 $_.ext('post', function (url, data, callback){ +103 ajax._do(url, data, callback, true); +104 }); +105 }()); \ No newline at end of file diff --git a/docs/symbols/src/kis-js_src_modules_event.js.html b/docs/symbols/src/kis-js_src_modules_event.js.html index bbbba2e..bdd11d7 100755 --- a/docs/symbols/src/kis-js_src_modules_event.js.html +++ b/docs/symbols/src/kis-js_src_modules_event.js.html @@ -45,7 +45,7 @@ 38 } 39 }; 40 } - 41 //typeof function doesn't work in IE where _attachEvent is available: brute force it + 41 //typeof function doesn't work in IE where attachEvent is available: brute force it 42 else if(typeof document.attachEvent !== "undefined") 43 { 44 /** @@ -64,7 +64,7 @@ 57 _remove(event, callback); // Make sure we don't have duplicate listeners 58 59 sel.attachEvent("on" + event, listener); - 60 // Store our listener so we can _remove it later + 60 // Store our listener so we can remove it later 61 var expando = sel[kis_expando] = sel[kis_expando] || {}; 62 expando.listeners = expando.listeners || {}; 63 expando.listeners[event] = expando.listeners[event] || []; @@ -149,115 +149,112 @@ 142 _attach_delegate = function(sel, target, event, callback) 143 { 144 //_attach the listener to the parent object -145 _add_remove(target, event, function(e){ +145 _add_remove(sel, event, function(e){ 146 -147 var i, t; +147 var elem, t; 148 149 //Get the live version of the target selector 150 t = $_.$(target); 151 -152 console.log(t); -153 -154 //Check each element to see if it matches the target -155 for(i in t) -156 { -157 if(t.hasOwnProperty(i)) -158 { -159 //Fire target callback when event bubbles from target -160 if(e.target == i) -161 { -162 //Trigger the event callback -163 callback.call(i, e); -164 -165 //Stop event propegation -166 e.stopPropagation(); -167 } -168 } -169 } -170 -171 -172 }, true); -173 }; -174 -175 // -------------------------------------------------------------------------- -176 -177 /** -178 * @namespace -179 * @name event -180 * @memberOf $_ -181 */ -182 e = { -183 /** -184 * Adds an event that returns a callback when triggered on the selected -185 * event and selector -186 * -187 * @memberOf $_.event -188 * @name add -189 * @function -190 * @example Eg. $_("#selector").event.add("click", do_something()); -191 * @param string event -192 * @param function callback -193 * @return void -194 */ -195 add: function (event, callback) -196 { -197 $_.each(function(e){ -198 _add_remove(e, event, callback, true); -199 }); -200 }, -201 /** -202 * Removes an event bound the the specified selector, event type, and callback -203 * -204 * @memberOf $_.event -205 * @name remove -206 * @function -207 * @example Eg. $_("#selector").event.remove("click", do_something()); -208 * @param string event -209 * @param string callback -210 * @return void -211 */ -212 remove: function (event, callback) -213 { -214 $_.each(function(e){ -215 _add_remove(e, event, callback, false); -216 }); -217 }, -218 /** -219 * Binds a persistent, delegated event -220 * -221 * @memberOf $_.event -222 * @name live -223 * @function -224 * @example Eg. $_.event.live(".button", "click", do_something()); -225 * @param string target -226 * @param string event -227 * @param function callback -228 * @return void -229 */ -230 live: function (target, event, callback) -231 { -232 _attach_delegate(document.documentElement, target, event, callback); -233 }, -234 /** -235 * Binds an event to a parent object -236 * -237 * @memberOf $_.event -238 * @name delegate -239 * @function -240 * @example Eg. $_("#parent").delegate(".button", "click", do_something()); -241 * @param string target -242 * @param string event_type -243 * @parma function callback -244 * @return void -245 */ -246 delegate: function(target, event, callback) -247 { -248 $_.each(function(e){ -249 _attach_delegate(e, target, event, callback); -250 }); -251 } -252 }; -253 -254 $_.ext('event', e); -255 -256 }()); \ No newline at end of file +152 //Check each element to see if it matches the target +153 for(elem in t) +154 { +155 //Fire target callback when event bubbles from target +156 if(e.target == t[elem]) +157 { +158 //Trigger the event callback +159 callback.call(t[elem], e); +160 +161 //Stop event propegation +162 e.stopPropagation(); +163 } +164 } +165 +166 +167 }, true); +168 }; +169 +170 +171 +172 // -------------------------------------------------------------------------- +173 +174 /** +175 * @namespace +176 * @name event +177 * @memberOf $_ +178 */ +179 e = { +180 /** +181 * Adds an event that returns a callback when triggered on the selected +182 * event and selector +183 * +184 * @memberOf $_.event +185 * @name add +186 * @function +187 * @example Eg. $_("#selector").event.add("click", do_something()); +188 * @param string event +189 * @param function callback +190 * @return void +191 */ +192 add: function (event, callback) +193 { +194 $_.each(function(e){ +195 _add_remove(e, event, callback, true); +196 }); +197 }, +198 /** +199 * Removes an event bound the the specified selector, event type, and callback +200 * +201 * @memberOf $_.event +202 * @name remove +203 * @function +204 * @example Eg. $_("#selector").event.remove("click", do_something()); +205 * @param string event +206 * @param string callback +207 * @return void +208 */ +209 remove: function (event, callback) +210 { +211 $_.each(function(e){ +212 _add_remove(e, event, callback, false); +213 }); +214 }, +215 /** +216 * Binds a persistent, delegated event +217 * +218 * @memberOf $_.event +219 * @name live +220 * @function +221 * @example Eg. $_.event.live(".button", "click", do_something()); +222 * @param string target +223 * @param string event +224 * @param function callback +225 * @return void +226 */ +227 live: function (target, event, callback) +228 { +229 _attach_delegate(document.documentElement, target, event, callback); +230 }, +231 /** +232 * Binds an event to a parent object +233 * +234 * @memberOf $_.event +235 * @name delegate +236 * @function +237 * @example Eg. $_("#parent").delegate(".button", "click", do_something()); +238 * @param string target +239 * @param string event_type +240 * @parma function callback +241 * @return void +242 */ +243 delegate: function(target, event, callback) +244 { +245 $_.each(function(e){ +246 _attach_delegate(e, target, event, callback); +247 }); +248 } +249 }; +250 +251 $_.ext('event', e); +252 +253 }()); \ No newline at end of file diff --git a/kis-all.js b/kis-all.js index e748e92..ea7401a 100644 --- a/kis-all.js +++ b/kis-all.js @@ -399,6 +399,9 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" // -------------------------------------------------------------------------- (function (){ + + "use strict"; + var d, tag_reg, class_reg; tag_reg = /^([\w\-]+)$/; @@ -807,6 +810,8 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" */ (function (){ + "use strict"; + var ajax = { _do: function (url, data, callback, isPost) { @@ -1310,7 +1315,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" } }; } - //typeof function doesn't work in IE where _attachEvent is available: brute force it + //typeof function doesn't work in IE where attachEvent is available: brute force it else if(typeof document.attachEvent !== "undefined") { /** @@ -1329,7 +1334,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" _remove(event, callback); // Make sure we don't have duplicate listeners sel.attachEvent("on" + event, listener); - // Store our listener so we can _remove it later + // Store our listener so we can remove it later var expando = sel[kis_expando] = sel[kis_expando] || {}; expando.listeners = expando.listeners || {}; expando.listeners[event] = expando.listeners[event] || []; @@ -1414,29 +1419,24 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" _attach_delegate = function(sel, target, event, callback) { //_attach the listener to the parent object - _add_remove(target, event, function(e){ + _add_remove(sel, event, function(e){ - var i, t; + var elem, t; //Get the live version of the target selector t = $_.$(target); - console.log(t); - //Check each element to see if it matches the target - for(i in t) + for(elem in t) { - if(t.hasOwnProperty(i)) + //Fire target callback when event bubbles from target + if(e.target == t[elem]) { - //Fire target callback when event bubbles from target - if(e.target == i) - { - //Trigger the event callback - callback.call(i, e); - - //Stop event propegation - e.stopPropagation(); - } + //Trigger the event callback + callback.call(t[elem], e); + + //Stop event propegation + e.stopPropagation(); } } @@ -1444,6 +1444,8 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" }, true); }; + + // -------------------------------------------------------------------------- /** diff --git a/kis-min.js b/kis-min.js index 681177e..632ad6e 100644 --- a/kis-min.js +++ b/kis-min.js @@ -17,4 +17,4 @@ e=0;$_.type(f)!=="array"&&(f=this.object_values(f));$_.type(b)!=="array"&&(b=thi 0;e