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 4e0d4ee..6c5d06f 100755 --- a/docs/symbols/src/kis-js_src_modules_DOM.js.html +++ b/docs/symbols/src/kis-js_src_modules_DOM.js.html @@ -5,7 +5,7 @@ .STRN {color: #393;} .REGX {color: #339;} .line {border-right: 1px dotted #666; color: #666; font-style: normal;} -
1 //This is used so IE 8 can use the classList api +1 //This is used so IE can use the classList api 2 /* 3 * classList.js: Cross-browser full element.classList implementation. 4 * 2011-06-15 @@ -213,9 +213,9 @@ 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"); +209 /*console.log(value); +210 console.log(sel); +211 console.log("Element does not have the selected attribute");*/ 212 return null; 213 } 214 @@ -301,247 +301,242 @@ 294 sel.style[equi[prop]] = val; 295 return null; 296 } -297 -298 //No matches? Well, lets log it for now -299 console.log("Property " + prop + " nor an equivalent seems to exist"); -300 } -301 -302 // -------------------------------------------------------------------------- -303 -304 /** -305 * DOM -306 * -307 * Dom manipulation module -308 * @namespace -309 * @memberOf $_ -310 * @name dom -311 */ -312 d = { -313 /** -314 * Adds a class to the element(s) specified by the current -315 * selector -316 * -317 * @name addClass -318 * @memberOf $_.dom -319 * @function -320 * @param string class -321 */ -322 addClass: function (c) -323 { -324 $_.each(function (e){ -325 e.classList.add(c); -326 }); -327 }, -328 /** -329 * Removes a class from the element(s) specified by the current -330 * selector -331 * -332 * @name removeClass -333 * @memberOf $_.dom -334 * @function -335 * @param string class -336 */ -337 removeClass: function (c) -338 { -339 $_.each(function (e){ -340 e.classList.remove(c); -341 }); -342 }, -343 /** -344 * Hides the element(s) specified by the current selector -345 * -346 * @name hide -347 * @memberOf $_.dom -348 * @function -349 */ -350 hide: function () -351 { -352 this.css('display', 'none'); -353 }, -354 /** -355 * Shows the element(s) specified by the current selector. -356 * if type is specified, the element will have it's style -357 * property set to "display:[your type]". If type is not -358 * specified, the element is set to "display:block". -359 * -360 * @name show -361 * @memberOf $_.dom -362 * @function -363 * @param [string] type -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 $_.dom -418 * @function -419 * @param [string] value -420 * @return 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.textContent !== "undefined") -432 ? "textContent" -433 : (typeof sel.innerText !== "undefined") -434 ? "innerText" -435 : "innerHTML"; -436 -437 oldValue = sel[type]; -438 -439 if(set) +297 } +298 +299 // -------------------------------------------------------------------------- +300 +301 /** +302 * DOM +303 * +304 * Dom manipulation module +305 * @namespace +306 * @memberOf $_ +307 * @name dom +308 */ +309 d = { +310 /** +311 * Adds a class to the element(s) specified by the current +312 * selector +313 * +314 * @name addClass +315 * @memberOf $_.dom +316 * @function +317 * @param string class +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 */ +334 removeClass: function (c) +335 { +336 $_.each(function (e){ +337 e.classList.remove(c); +338 }); +339 }, +340 /** +341 * Hides the element(s) specified by the current selector +342 * +343 * @name hide +344 * @memberOf $_.dom +345 * @function +346 */ +347 hide: function () +348 { +349 this.css('display', 'none'); +350 }, +351 /** +352 * Shows the element(s) specified by the current selector. +353 * if type is specified, the element will have it's style +354 * property set to "display:[your type]". If type is not +355 * specified, the element is set to "display:block". +356 * +357 * @name show +358 * @memberOf $_.dom +359 * @function +360 * @param [string] type +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 return null; +393 } +394 else if (sel.length > 1 && typeof value !== "undefined") //You can set a bunch, though +395 { +396 $_.each(function (e){ +397 return _attr(e, name, value); +398 }); +399 } +400 else //Normal behavior +401 { +402 return _attr(sel, name, value); +403 } +404 }, +405 /** +406 * Sets or retrieves the text content of the element +407 * specified by the current selector. If a value is +408 * passed, it will set that value on the current element, +409 * otherwise it will return the value of the current element +410 * +411 * @name text +412 * @memberOf $_.dom +413 * @function +414 * @param [string] value +415 * @return string +416 * @type string +417 */ +418 text: function (value) +419 { +420 var oldValue, set, type, sel; +421 +422 sel = this.el; +423 +424 set = (typeof value !== "undefined") ? true : false; +425 +426 type = (typeof sel.textContent !== "undefined") +427 ? "textContent" +428 : (typeof sel.innerText !== "undefined") +429 ? "innerText" +430 : "innerHTML"; +431 +432 oldValue = sel[type]; +433 +434 if(set) +435 { +436 sel[type] = value; +437 return value; +438 } +439 else 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 $_.dom -458 * @function -459 * @param string property -460 * @param [string] value -461 * @return 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 * Adds to the innerHTML of the current element, after the last child. -478 * -479 * @example $_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element -480 * @name append -481 * @memberOf $_.dom -482 * @function -483 * @param string htm -484 */ -485 append: function(htm) -486 { -487 if(typeof document.insertAdjacentHTML !== "undefined") -488 { -489 this.el.insertAdjacentHTML('beforeend', htm); -490 } -491 else -492 { -493 this.el.innerHTML += htm; -494 } -495 }, -496 /** -497 * Adds to the innerHTML of the selected element, before the current children -498 * -499 * @name prepend -500 * @memberOf $_.dom -501 * @function -502 * @param string htm -503 */ -504 prepend: function(htm) -505 { -506 if(typeof document.insertAdjacentHTML !== "undefined") -507 { -508 this.el.insertAdjacentHTML('afterbegin', htm); -509 } -510 else -511 { -512 this.el.innerHTML = htm + this.el.innerHTML; -513 } -514 }, -515 /** -516 * Sets or gets the innerHTML propery of the element(s) passed -517 * -518 * @name html -519 * @memberOf $_.dom -520 * @function -521 * @param [string] htm -522 * @return string -523 * @type string -524 */ -525 html: function(htm) -526 { +441 return oldValue; +442 } +443 }, +444 /** +445 * Sets or retrieves a css property of the element +446 * specified by the current selector. If a value is +447 * passed, it will set that value on the current element, +448 * otherwise it will return the value of the css property +449 * on the current element +450 * +451 * @name css +452 * @memberOf $_.dom +453 * @function +454 * @param string property +455 * @param [string] value +456 * @return string +457 * @type string +458 */ +459 css: function (prop, val) +460 { +461 //Return the current value if a value is not set +462 if(typeof val === "undefined") +463 { +464 return _css(this.el, prop); +465 } +466 +467 $_.each(function (e){ +468 _css(e, prop, val); +469 }); +470 }, +471 /** +472 * Adds to the innerHTML of the current element, after the last child. +473 * +474 * @example $_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element +475 * @name append +476 * @memberOf $_.dom +477 * @function +478 * @param string htm +479 */ +480 append: function(htm) +481 { +482 if(typeof document.insertAdjacentHTML !== "undefined") +483 { +484 this.el.insertAdjacentHTML('beforeend', htm); +485 } +486 else +487 { +488 this.el.innerHTML += htm; +489 } +490 }, +491 /** +492 * Adds to the innerHTML of the selected element, before the current children +493 * +494 * @name prepend +495 * @memberOf $_.dom +496 * @function +497 * @param string htm +498 */ +499 prepend: function(htm) +500 { +501 if(typeof document.insertAdjacentHTML !== "undefined") +502 { +503 this.el.insertAdjacentHTML('afterbegin', htm); +504 } +505 else +506 { +507 this.el.innerHTML = htm + this.el.innerHTML; +508 } +509 }, +510 /** +511 * Sets or gets the innerHTML propery of the element(s) passed +512 * +513 * @name html +514 * @memberOf $_.dom +515 * @function +516 * @param [string] htm +517 * @return string +518 * @type string +519 */ +520 html: function(htm) +521 { +522 +523 if(typeof htm !== "undefined") +524 { +525 this.el.innerHTML = htm; +526 } 527 -528 if(typeof htm !== "undefined") -529 { -530 this.el.innerHTML = htm; -531 } +528 //If the parameter is undefined, just return the current value +529 return this.el.innerHTML; +530 } +531 }; 532 -533 //If the parameter is undefined, just return the current value -534 return this.el.innerHTML; -535 } -536 }; -537 -538 $_.ext('dom', d); -539 -540 }());