From 5dc517f24efa632af0bb6ad5bcf25657e857b53b Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 24 May 2012 09:56:39 -0400 Subject: [PATCH] Removed console.log statement from util module --- .gitignore | 1 - .../src/kis-js_src_modules_DOM.js.html | 1049 ++++++++--------- .../src/kis-js_src_modules_ajax.js.html | 2 +- .../src/kis-js_src_modules_util.js.html | 427 ++++--- kis-all.js | 5 +- kis-lite-dom.js | 3 +- kis-lite.js | 2 +- kis-min.js | 6 +- src/modules/DOM.js | 1 - src/modules/ajax.js | 2 +- src/modules/event.js | 0 src/modules/util.js | 4 +- 12 files changed, 745 insertions(+), 757 deletions(-) mode change 100755 => 100644 src/modules/DOM.js mode change 100755 => 100644 src/modules/ajax.js mode change 100755 => 100644 src/modules/event.js mode change 100755 => 100644 src/modules/util.js diff --git a/.gitignore b/.gitignore index af79749..bc88642 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ kis-custom.js kis-custom-min.js combine-build.php test.html -index.php .* \ No newline at end of file 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 6c5d06f..b8c3b2b 100755 --- a/docs/symbols/src/kis-js_src_modules_DOM.js.html +++ b/docs/symbols/src/kis-js_src_modules_DOM.js.html @@ -14,529 +14,528 @@ 7 * Public Domain. 8 * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. 9 */ - 10 - 11 if (typeof document !== "undefined" && !("classList" in document.createElement("a"))) - 12 { - 13 (function (view){ - 14 - 15 var classListProp = "classList", - 16 protoProp = "prototype", - 17 elemCtrProto = (view.HTMLElement || view.Element)[protoProp], - 18 objCtr = Object, - 19 strTrim = String[protoProp].trim || - 20 function () - 21 { - 22 return this.replace(/^\s+|\s+$/g, ""); - 23 }, - 24 arrIndexOf = Array[protoProp].indexOf || - 25 function (item) - 26 { - 27 var - 28 i = 0, - 29 len = this.length; - 30 for (; i < len; i++) - 31 { - 32 if (i in this && this[i] === item) - 33 { - 34 return i; - 35 } - 36 } - 37 return -1; - 38 } - 39 // Vendors: please allow content code to instantiate DOMExceptions - 40 , - 41 /** - 42 * @private - 43 */ - 44 DOMEx = function (type, message) - 45 { - 46 this.name = type; - 47 this.code = DOMException[type]; - 48 this.message = message; - 49 }, - 50 /** - 51 * @private - 52 */ - 53 checkTokenAndGetIndex = function (classList, token) - 54 { - 55 if (token === "") - 56 { - 57 throw new DOMEx("SYNTAX_ERR", "An invalid or illegal string was specified"); - 58 } - 59 if (/\s/.test(token)) - 60 { - 61 throw new DOMEx("INVALID_CHARACTER_ERR", "String contains an invalid character"); - 62 } - 63 return arrIndexOf.call(classList, token); - 64 }, - 65 /** - 66 * @private - 67 */ - 68 ClassList = function (elem) - 69 { - 70 var - 71 trimmedClasses = strTrim.call(elem.className), - 72 classes = trimmedClasses ? trimmedClasses.split(/\s+/) : [], - 73 i = 0, - 74 len = classes.length; - 75 for (; i < len; i++) - 76 { - 77 this.push(classes[i]); - 78 } - 79 this._updateClassName = function () - 80 { - 81 elem.className = this.toString(); - 82 }; - 83 }, - 84 classListProto = ClassList[protoProp] = [], - 85 /** - 86 * @private - 87 */ - 88 classListGetter = function () - 89 { - 90 return new ClassList(this); - 91 }; - 92 // Most DOMException implementations don't allow calling DOMException's toString() - 93 // on non-DOMExceptions. Error's toString() is sufficient here. - 94 DOMEx[protoProp] = Error[protoProp]; - 95 classListProto.item = function (i) - 96 { - 97 return this[i] || null; - 98 }; - 99 classListProto.contains = function (token) -100 { -101 token += ""; -102 return checkTokenAndGetIndex(this, token) !== -1; -103 }; -104 classListProto.add = function (token) -105 { -106 token += ""; -107 if (checkTokenAndGetIndex(this, token) === -1) -108 { -109 this.push(token); -110 this._updateClassName(); -111 } -112 }; -113 classListProto.remove = function (token) -114 { -115 token += ""; -116 var index = checkTokenAndGetIndex(this, token); -117 if (index !== -1) -118 { -119 this.splice(index, 1); -120 this._updateClassName(); -121 } -122 }; -123 classListProto.toggle = function (token) -124 { -125 token += ""; -126 if (checkTokenAndGetIndex(this, token) === -1) -127 { -128 this.add(token); -129 } -130 else -131 { -132 this.remove(token); -133 } -134 }; -135 classListProto.toString = function () -136 { -137 return this.join(" "); -138 }; -139 -140 if (objCtr.defineProperty) -141 { -142 var classListPropDesc = { -143 get: classListGetter, -144 enumerable: true, -145 configurable: true -146 }; -147 try -148 { -149 objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); -150 } -151 catch (ex) -152 { // IE 8 doesn't support enumerable:true -153 if (ex.number === -0x7FF5EC54) -154 { -155 classListPropDesc.enumerable = false; -156 objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); -157 } -158 } -159 } -160 else if (objCtr[protoProp].__defineGetter__) -161 { -162 elemCtrProto.__defineGetter__(classListProp, classListGetter); -163 } -164 -165 }(self)); -166 } -167 -168 /** -169 * DOM -170 * -171 * Dom manipulation module -172 */ -173 (function (){ -174 -175 "use strict"; -176 -177 var d; -178 -179 //Private function for getting/setting attributes/properties -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 null; -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 /** -249 * Change css property name to it's -250 * javascript camel case equivalent -251 */ -252 function _toCamel(s) -253 { -254 return s.replace(/(\-[a-z])/g, function($1){ -255 return $1.toUpperCase().replace('-',''); -256 }); -257 } -258 -259 function _css(sel, prop, val) -260 { -261 var equi; -262 -263 //Camel-case -264 prop = _toCamel(prop); -265 -266 //Equivalent properties for 'special' browsers -267 equi = { -268 outerHeight: "offsetHeight", -269 outerWidth: "offsetWidth", -270 top: "posTop" -271 }; + 10 if (typeof document !== "undefined" && !("classList" in document.createElement("a"))) + 11 { + 12 (function (view){ + 13 + 14 var classListProp = "classList", + 15 protoProp = "prototype", + 16 elemCtrProto = (view.HTMLElement || view.Element)[protoProp], + 17 objCtr = Object, + 18 strTrim = String[protoProp].trim || + 19 function () + 20 { + 21 return this.replace(/^\s+|\s+$/g, ""); + 22 }, + 23 arrIndexOf = Array[protoProp].indexOf || + 24 function (item) + 25 { + 26 var + 27 i = 0, + 28 len = this.length; + 29 for (; i < len; i++) + 30 { + 31 if (i in this && this[i] === item) + 32 { + 33 return i; + 34 } + 35 } + 36 return -1; + 37 } + 38 // Vendors: please allow content code to instantiate DOMExceptions + 39 , + 40 /** + 41 * @private + 42 */ + 43 DOMEx = function (type, message) + 44 { + 45 this.name = type; + 46 this.code = DOMException[type]; + 47 this.message = message; + 48 }, + 49 /** + 50 * @private + 51 */ + 52 checkTokenAndGetIndex = function (classList, token) + 53 { + 54 if (token === "") + 55 { + 56 throw new DOMEx("SYNTAX_ERR", "An invalid or illegal string was specified"); + 57 } + 58 if (/\s/.test(token)) + 59 { + 60 throw new DOMEx("INVALID_CHARACTER_ERR", "String contains an invalid character"); + 61 } + 62 return arrIndexOf.call(classList, token); + 63 }, + 64 /** + 65 * @private + 66 */ + 67 ClassList = function (elem) + 68 { + 69 var + 70 trimmedClasses = strTrim.call(elem.className), + 71 classes = trimmedClasses ? trimmedClasses.split(/\s+/) : [], + 72 i = 0, + 73 len = classes.length; + 74 for (; i < len; i++) + 75 { + 76 this.push(classes[i]); + 77 } + 78 this._updateClassName = function () + 79 { + 80 elem.className = this.toString(); + 81 }; + 82 }, + 83 classListProto = ClassList[protoProp] = [], + 84 /** + 85 * @private + 86 */ + 87 classListGetter = function () + 88 { + 89 return new ClassList(this); + 90 }; + 91 // Most DOMException implementations don't allow calling DOMException's toString() + 92 // on non-DOMExceptions. Error's toString() is sufficient here. + 93 DOMEx[protoProp] = Error[protoProp]; + 94 classListProto.item = function (i) + 95 { + 96 return this[i] || null; + 97 }; + 98 classListProto.contains = function (token) + 99 { +100 token += ""; +101 return checkTokenAndGetIndex(this, token) !== -1; +102 }; +103 classListProto.add = function (token) +104 { +105 token += ""; +106 if (checkTokenAndGetIndex(this, token) === -1) +107 { +108 this.push(token); +109 this._updateClassName(); +110 } +111 }; +112 classListProto.remove = function (token) +113 { +114 token += ""; +115 var index = checkTokenAndGetIndex(this, token); +116 if (index !== -1) +117 { +118 this.splice(index, 1); +119 this._updateClassName(); +120 } +121 }; +122 classListProto.toggle = function (token) +123 { +124 token += ""; +125 if (checkTokenAndGetIndex(this, token) === -1) +126 { +127 this.add(token); +128 } +129 else +130 { +131 this.remove(token); +132 } +133 }; +134 classListProto.toString = function () +135 { +136 return this.join(" "); +137 }; +138 +139 if (objCtr.defineProperty) +140 { +141 var classListPropDesc = { +142 get: classListGetter, +143 enumerable: true, +144 configurable: true +145 }; +146 try +147 { +148 objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); +149 } +150 catch (ex) +151 { // IE 8 doesn't support enumerable:true +152 if (ex.number === -0x7FF5EC54) +153 { +154 classListPropDesc.enumerable = false; +155 objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); +156 } +157 } +158 } +159 else if (objCtr[protoProp].__defineGetter__) +160 { +161 elemCtrProto.__defineGetter__(classListProp, classListGetter); +162 } +163 +164 }(self)); +165 } +166 +167 /** +168 * DOM +169 * +170 * Dom manipulation module +171 */ +172 (function (){ +173 +174 "use strict"; +175 +176 var d; +177 +178 //Private function for getting/setting attributes/properties +179 function _attr(sel, name, value) +180 { +181 var oldVal, doAttr; +182 +183 //Get the value of the attribute, if it exists +184 if (typeof sel.hasAttribute !== "undefined") +185 { +186 if (sel.hasAttribute(name)) +187 { +188 oldVal = sel.getAttribute(name); +189 } +190 +191 doAttr = true; +192 } +193 else if (typeof sel[name] !== "undefined") +194 { +195 oldVal = sel[name]; +196 doAttr = false; +197 } +198 else if (name === "class" && typeof sel.className !== "undefined") //className attribute +199 { +200 name = "className"; +201 oldVal = sel.className; +202 doAttr = false; +203 } +204 +205 //Well, I guess that attribute doesn't exist +206 if (typeof oldVal === "undefined" && (typeof value === "undefined" || value === null)) +207 { +208 /*console.log(value); +209 console.log(sel); +210 console.log("Element does not have the selected attribute");*/ +211 return null; +212 } +213 +214 //No value to set? Return the current value +215 if (typeof value === "undefined") +216 { +217 return oldVal; +218 } +219 +220 //Determine what to do with the attribute +221 if (typeof value !== "undefined" && value !== null) +222 { +223 if(doAttr === true) +224 { +225 sel.setAttribute(name, value); +226 } +227 else +228 { +229 sel[name] = value; +230 } +231 } +232 else if (value === null) +233 { +234 if(doAttr === true) +235 { +236 sel.removeAttribute(name); +237 } +238 else +239 { +240 delete sel[name]; +241 } +242 } +243 +244 return (typeof value !== "undefined") ? value : oldVal; +245 } +246 +247 /** +248 * Change css property name to it's +249 * javascript camel case equivalent +250 */ +251 function _toCamel(s) +252 { +253 return s.replace(/(\-[a-z])/g, function($1){ +254 return $1.toUpperCase().replace('-',''); +255 }); +256 } +257 +258 function _css(sel, prop, val) +259 { +260 var equi; +261 +262 //Camel-case +263 prop = _toCamel(prop); +264 +265 //Equivalent properties for 'special' browsers +266 equi = { +267 outerHeight: "offsetHeight", +268 outerWidth: "offsetWidth", +269 top: "posTop" +270 }; +271 272 -273 -274 //If you don't define a value, try returning the existing value -275 if(typeof val === "undefined" && sel.style[prop] !== "undefined") -276 { -277 return sel.style[prop]; -278 } -279 else if(typeof val === "undefined" && sel.style[equi[prop]] !== "undefined") -280 { -281 return sel.style[equi[prop]]; -282 } -283 -284 //Let's try the easy way first -285 if(typeof sel.style[prop] !== "undefined") -286 { -287 sel.style[prop] = val; -288 -289 //Short circuit -290 return null; -291 } -292 else if(sel.style[equi[prop]]) -293 { -294 sel.style[equi[prop]] = val; -295 return null; -296 } -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 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 the parameter is undefined, just return the current value -529 return this.el.innerHTML; -530 } -531 }; -532 -533 $_.ext('dom', d); -534 -535 }()); \ No newline at end of file +273 //If you don't define a value, try returning the existing value +274 if(typeof val === "undefined" && sel.style[prop] !== "undefined") +275 { +276 return sel.style[prop]; +277 } +278 else if(typeof val === "undefined" && sel.style[equi[prop]] !== "undefined") +279 { +280 return sel.style[equi[prop]]; +281 } +282 +283 //Let's try the easy way first +284 if(typeof sel.style[prop] !== "undefined") +285 { +286 sel.style[prop] = val; +287 +288 //Short circuit +289 return null; +290 } +291 else if(sel.style[equi[prop]]) +292 { +293 sel.style[equi[prop]] = val; +294 return null; +295 } +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 */ +318 addClass: function (c) +319 { +320 $_.each(function (e){ +321 e.classList.add(c); +322 }); +323 }, +324 /** +325 * Removes a class from the element(s) specified by the current +326 * selector +327 * +328 * @name removeClass +329 * @memberOf $_.dom +330 * @function +331 * @param string class +332 */ +333 removeClass: function (c) +334 { +335 $_.each(function (e){ +336 e.classList.remove(c); +337 }); +338 }, +339 /** +340 * Hides the element(s) specified by the current selector +341 * +342 * @name hide +343 * @memberOf $_.dom +344 * @function +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 */ +361 show: function (type) +362 { +363 if (typeof type === "undefined") +364 { +365 type = "block"; +366 } +367 +368 this.css("display", type); +369 }, +370 /** +371 * Sets attributes on element(s) specified by the current +372 * selector, or, if name is not specified, returns the +373 * value of the attribute of the element specified by the +374 * current selector. +375 * +376 * @name attr +377 * @memberOf $_.dom +378 * @function +379 * @param string name +380 * @param [string] value +381 * @return string +382 * @type string +383 */ +384 attr: function (name, value) +385 { +386 var sel = this.el; +387 +388 //Make sure you don't try to get a bunch of elements +389 if (sel.length > 1 && typeof value === "undefined") +390 { +391 return null; +392 } +393 else if (sel.length > 1 && typeof value !== "undefined") //You can set a bunch, though +394 { +395 $_.each(function (e){ +396 return _attr(e, name, value); +397 }); +398 } +399 else //Normal behavior +400 { +401 return _attr(sel, name, value); +402 } +403 }, +404 /** +405 * Sets or retrieves the text content of the element +406 * specified by the current selector. If a value is +407 * passed, it will set that value on the current element, +408 * otherwise it will return the value of the current element +409 * +410 * @name text +411 * @memberOf $_.dom +412 * @function +413 * @param [string] value +414 * @return string +415 * @type string +416 */ +417 text: function (value) +418 { +419 var oldValue, set, type, sel; +420 +421 sel = this.el; +422 +423 set = (typeof value !== "undefined") ? true : false; +424 +425 type = (typeof sel.textContent !== "undefined") +426 ? "textContent" +427 : (typeof sel.innerText !== "undefined") +428 ? "innerText" +429 : "innerHTML"; +430 +431 oldValue = sel[type]; +432 +433 if(set) +434 { +435 sel[type] = value; +436 return value; +437 } +438 else +439 { +440 return oldValue; +441 } +442 }, +443 /** +444 * Sets or retrieves a css property of the element +445 * specified by the current selector. If a value is +446 * passed, it will set that value on the current element, +447 * otherwise it will return the value of the css property +448 * on the current element +449 * +450 * @name css +451 * @memberOf $_.dom +452 * @function +453 * @param string property +454 * @param [string] value +455 * @return string +456 * @type string +457 */ +458 css: function (prop, val) +459 { +460 //Return the current value if a value is not set +461 if(typeof val === "undefined") +462 { +463 return _css(this.el, prop); +464 } +465 +466 $_.each(function (e){ +467 _css(e, prop, val); +468 }); +469 }, +470 /** +471 * Adds to the innerHTML of the current element, after the last child. +472 * +473 * @example $_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element +474 * @name append +475 * @memberOf $_.dom +476 * @function +477 * @param string htm +478 */ +479 append: function(htm) +480 { +481 if(typeof document.insertAdjacentHTML !== "undefined") +482 { +483 this.el.insertAdjacentHTML('beforeend', htm); +484 } +485 else +486 { +487 this.el.innerHTML += htm; +488 } +489 }, +490 /** +491 * Adds to the innerHTML of the selected element, before the current children +492 * +493 * @name prepend +494 * @memberOf $_.dom +495 * @function +496 * @param string htm +497 */ +498 prepend: function(htm) +499 { +500 if(typeof document.insertAdjacentHTML !== "undefined") +501 { +502 this.el.insertAdjacentHTML('afterbegin', htm); +503 } +504 else +505 { +506 this.el.innerHTML = htm + this.el.innerHTML; +507 } +508 }, +509 /** +510 * Sets or gets the innerHTML propery of the element(s) passed +511 * +512 * @name html +513 * @memberOf $_.dom +514 * @function +515 * @param [string] htm +516 * @return string +517 * @type string +518 */ +519 html: function(htm) +520 { +521 +522 if(typeof htm !== "undefined") +523 { +524 this.el.innerHTML = htm; +525 } +526 +527 //If the parameter is undefined, just return the current value +528 return this.el.innerHTML; +529 } +530 }; +531 +532 $_.ext('dom', d); +533 +534 }()); \ 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 10a5f8f..19a7765 100755 --- a/docs/symbols/src/kis-js_src_modules_ajax.js.html +++ b/docs/symbols/src/kis-js_src_modules_ajax.js.html @@ -36,7 +36,7 @@ 29 30 type = (isPost) ? "POST" : "GET"; 31 - 32 url += (type === "GET") ? "?"+this._serialize(data) : ''; + 32 url += (type === "GET") ? "?" + this._serialize(data) : ''; 33 34 request.open(type, url); 35 diff --git a/docs/symbols/src/kis-js_src_modules_util.js.html b/docs/symbols/src/kis-js_src_modules_util.js.html index 7658d09..b79f0b5 100755 --- a/docs/symbols/src/kis-js_src_modules_util.js.html +++ b/docs/symbols/src/kis-js_src_modules_util.js.html @@ -152,218 +152,215 @@ 145 146 if(num_keys !== vals.length) 147 { -148 console.log("Object combine requires two arrays of the same size"); -149 return false; -150 } -151 -152 // Create and return the new object -153 for(i = 0; i < num_keys; i++) -154 { -155 new_object[keys[i]] = vals[i]; -156 } -157 -158 return new_object; -159 }, -160 /** -161 * Combines two or more objects/arrays. If the keys are numeric, the outputted -162 * object will have re-indexed keys. If a key/value pair exists in both objects, -163 * indentical values will be droped, but if a key exists with a different value, -164 * with the same key, the value in the second array will replace the value in the -165 * first -166 * -167 * @name object_merge -168 * @memberOf $_.util -169 * @function -170 * @param object [as many as you wish to combine] -171 * @type object -172 * @return object -173 */ -174 object_merge: function() -175 { -176 var args = Array.prototype.slice.call(arguments), -177 arg_len = args.length, -178 new_obj = {}, -179 arg, -180 iarg_len = 0, -181 i, -182 j, -183 x, -184 is_array = true; -185 -186 // Check for an array in the arguments -187 for(i=0; i < arg_len; i++) -188 { -189 if($_.type(args[i]) !== "array") -190 { -191 is_array = false; -192 break; -193 } -194 } -195 -196 // If all the arguments are javascript arrays -197 if(is_array) -198 { -199 new_obj = []; -200 // Let javascript do all the work! -201 for(i=0; i< arg_len; i++) -202 { -203 new_obj = new_obj.contact(args[i]); -204 } -205 -206 // Return early -207 return new_obj; -208 } -209 -210 // No, there's at least one object -211 for(i=0, x=0; i < arg_len; i++) -212 { -213 arg = args[i]; -214 -215 // If the argument is an array, add the array items as -216 // numeric object properties -217 if ($_.type(arg) == "array") -218 { -219 for (j=0, iarg_len= arg.length; j < iarg_len; j++) -220 { -221 new_obj[x++] = arg[j]; -222 } -223 } -224 else -225 { -226 for (j in arg) -227 { -228 if(arg.hasOwnProperty(j)) -229 { -230 // If the key is numeric, add the property with -231 // a numeric key -232 if(parseInt(j, 10) + '' === j) -233 { -234 new_obj[x++] = arg[j]; -235 } -236 else -237 { -238 new_obj[j] = arg[j]; -239 } -240 } -241 } -242 } -243 } -244 -245 return new_obj; -246 }, -247 /** -248 * Replaces sections of strings in a greedy fashion, -249 * starting with the longest replace pairs first. Accepts -250 * one replace pair as two parameters, or an object, with -251 * from => to replacements as key/value pairs -252 * -253 * @name str_trans -254 * @memberOf $_.util -255 * @function -256 * @param string input_string -257 * @param mixed from (string)/replace pairs (object) -258 * @param [string] -259 * @return string -260 * @type string -261 */ -262 str_trans: function(str, from, to) -263 { -264 var froms = [], -265 tos = [], -266 ret = '', -267 match = false, -268 from_len = 0, -269 str_len = 0, -270 to_len = 0, -271 to_is_str = '', -272 from_is_str = '', -273 strx = '', -274 strw = '', -275 stry = '', -276 from_strx = '', -277 new_str = '', -278 f, -279 i, -280 j; -281 -282 //Replace pairs? add them to the internal arrays -283 if(typeof from === 'object') -284 { -285 // Sort the keys in descending order for better -286 // replacement functionality -287 from = reverse_key_sort(from); -288 -289 for(f in from) -290 { -291 if(from.hasOwnProperty(f)) -292 { -293 froms.push(f); -294 tos.push(from[f]); -295 } -296 } -297 -298 from = froms; -299 to = tos; -300 } -301 -302 //Go through the string, and replace characters as needed -303 str_len = str.length; -304 from_len = from.length; -305 to_len = to.length; -306 to_is_str = typeof to === 'string'; -307 from_is_str = typeof from === 'string'; -308 -309 for(i=0; i < str_len; i++) -310 { -311 match = false; -312 if(from_is_str) -313 { -314 strw = str.charAt(i-1); -315 strx = str.charAt(i); -316 stry = str.charAt(i+1); -317 for(j=0; j < from_len; j++) -318 { -319 if(strx == from.charAt(j)) -320 { -321 match = true; -322 break; -323 } -324 } -325 } -326 else -327 { -328 for(j=0; j < from_len; j++) -329 { -330 if(str.substr(i, from[j].length) == from[j]) -331 { -332 match = true; -333 -334 //Go past the current match -335 i = (i + from[j].length) -1; -336 break; -337 -338 } -339 } -340 } -341 -342 if(match) -343 { -344 new_str += (to_is_str) ? to.charAt(j) : to[j]; -345 } -346 else -347 { -348 new_str += str.charAt(i); -349 } -350 } -351 -352 return new_str; -353 -354 } -355 -356 }; -357 -358 //Add it to the $_ object -359 $_.ext('util', u); -360 }()); -361 -362 \ No newline at end of file +148 return false; +149 } +150 +151 // Create and return the new object +152 for(i = 0; i < num_keys; i++) +153 { +154 new_object[keys[i]] = vals[i]; +155 } +156 +157 return new_object; +158 }, +159 /** +160 * Combines two or more objects/arrays. If the keys are numeric, the outputted +161 * object will have re-indexed keys. If a key/value pair exists in both objects, +162 * indentical values will be droped, but if a key exists with a different value, +163 * with the same key, the value in the second array will replace the value in the +164 * first +165 * +166 * @name object_merge +167 * @memberOf $_.util +168 * @function +169 * @param object [as many as you wish to combine] +170 * @type object +171 * @return object +172 */ +173 object_merge: function() +174 { +175 var args = Array.prototype.slice.call(arguments), +176 arg_len = args.length, +177 new_obj = {}, +178 arg, +179 iarg_len = 0, +180 i, +181 j, +182 x, +183 is_array = true; +184 +185 // Check for an array in the arguments +186 for(i=0; i < arg_len; i++) +187 { +188 if($_.type(args[i]) !== "array") +189 { +190 is_array = false; +191 break; +192 } +193 } +194 +195 // If all the arguments are javascript arrays +196 if(is_array) +197 { +198 new_obj = []; +199 // Let javascript do all the work! +200 for(i=0; i< arg_len; i++) +201 { +202 new_obj = new_obj.contact(args[i]); +203 } +204 +205 // Return early +206 return new_obj; +207 } +208 +209 // No, there's at least one object +210 for(i=0, x=0; i < arg_len; i++) +211 { +212 arg = args[i]; +213 +214 // If the argument is an array, add the array items as +215 // numeric object properties +216 if ($_.type(arg) == "array") +217 { +218 for (j=0, iarg_len= arg.length; j < iarg_len; j++) +219 { +220 new_obj[x++] = arg[j]; +221 } +222 } +223 else +224 { +225 for (j in arg) +226 { +227 if(arg.hasOwnProperty(j)) +228 { +229 // If the key is numeric, add the property with +230 // a numeric key +231 if(parseInt(j, 10) + '' === j) +232 { +233 new_obj[x++] = arg[j]; +234 } +235 else +236 { +237 new_obj[j] = arg[j]; +238 } +239 } +240 } +241 } +242 } +243 +244 return new_obj; +245 }, +246 /** +247 * Replaces sections of strings in a greedy fashion, +248 * starting with the longest replace pairs first. Accepts +249 * one replace pair as two parameters, or an object, with +250 * from => to replacements as key/value pairs +251 * +252 * @name str_trans +253 * @memberOf $_.util +254 * @function +255 * @param string input_string +256 * @param mixed from (string)/replace pairs (object) +257 * @param [string] +258 * @return string +259 * @type string +260 */ +261 str_trans: function(str, from, to) +262 { +263 var froms = [], +264 tos = [], +265 ret = '', +266 match = false, +267 from_len = 0, +268 str_len = 0, +269 to_len = 0, +270 to_is_str = '', +271 from_is_str = '', +272 strx = '', +273 strw = '', +274 stry = '', +275 from_strx = '', +276 new_str = '', +277 f, +278 i, +279 j; +280 +281 //Replace pairs? add them to the internal arrays +282 if(typeof from === 'object') +283 { +284 // Sort the keys in descending order for better +285 // replacement functionality +286 from = reverse_key_sort(from); +287 +288 for(f in from) +289 { +290 if(from.hasOwnProperty(f)) +291 { +292 froms.push(f); +293 tos.push(from[f]); +294 } +295 } +296 +297 from = froms; +298 to = tos; +299 } +300 +301 //Go through the string, and replace characters as needed +302 str_len = str.length; +303 from_len = from.length; +304 to_len = to.length; +305 to_is_str = typeof to === 'string'; +306 from_is_str = typeof from === 'string'; +307 +308 for(i=0; i < str_len; i++) +309 { +310 match = false; +311 if(from_is_str) +312 { +313 strw = str.charAt(i-1); +314 strx = str.charAt(i); +315 stry = str.charAt(i+1); +316 for(j=0; j < from_len; j++) +317 { +318 if(strx == from.charAt(j)) +319 { +320 match = true; +321 break; +322 } +323 } +324 } +325 else +326 { +327 for(j=0; j < from_len; j++) +328 { +329 if(str.substr(i, from[j].length) == from[j]) +330 { +331 match = true; +332 +333 //Go past the current match +334 i = (i + from[j].length) -1; +335 break; +336 +337 } +338 } +339 } +340 +341 if(match) +342 { +343 new_str += (to_is_str) ? to.charAt(j) : to[j]; +344 } +345 else +346 { +347 new_str += str.charAt(i); +348 } +349 } +350 +351 return new_str; +352 +353 } +354 +355 }; +356 +357 //Add it to the $_ object +358 $_.ext('util', u); +359 }()); \ No newline at end of file diff --git a/kis-all.js b/kis-all.js index e473a4d..a0c0705 100755 --- a/kis-all.js +++ b/kis-all.js @@ -288,7 +288,6 @@ if (typeof Array.isArray === "undefined") * Public Domain. * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. */ - if (typeof document !== "undefined" && !("classList" in document.createElement("a"))) { (function (view){ @@ -844,7 +843,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" type = (isPost) ? "POST" : "GET"; - url += (type === "GET") ? "?"+this._serialize(data) : ''; + url += (type === "GET") ? "?" + this._serialize(data) : ''; request.open(type, url); @@ -1486,7 +1485,6 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" if(num_keys !== vals.length) { - console.log("Object combine requires two arrays of the same size"); return false; } @@ -1699,5 +1697,4 @@ if (typeof document !== "undefined" && !("classList" in document.createElement(" //Add it to the $_ object $_.ext('util', u); - }($_)); \ No newline at end of file diff --git a/kis-lite-dom.js b/kis-lite-dom.js index 9382348..108b381 100755 --- a/kis-lite-dom.js +++ b/kis-lite-dom.js @@ -302,7 +302,7 @@ if (typeof Array.isArray === "undefined") type = (isPost) ? "POST" : "GET"; - url += (type === "GET") ? "?"+this._serialize(data) : ''; + url += (type === "GET") ? "?" + this._serialize(data) : ''; request.open(type, url); @@ -684,7 +684,6 @@ if (typeof Array.isArray === "undefined") * Public Domain. * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. */ - if (typeof document !== "undefined" && !("classList" in document.createElement("a"))) { (function (view){ diff --git a/kis-lite.js b/kis-lite.js index 11ce10b..2693cda 100755 --- a/kis-lite.js +++ b/kis-lite.js @@ -302,7 +302,7 @@ if (typeof Array.isArray === "undefined") type = (isPost) ? "POST" : "GET"; - url += (type === "GET") ? "?"+this._serialize(data) : ''; + url += (type === "GET") ? "?" + this._serialize(data) : ''; request.open(type, url); diff --git a/kis-min.js b/kis-min.js index ba0a184..720ed05 100755 --- a/kis-min.js +++ b/kis-min.js @@ -15,6 +15,6 @@ function(a,b,c){typeof a.addEventListener!=="undefined"&&a.addEventListener(b,c, b,c){if(typeof a.detachEvent!=="undefined"){var f=a.KIS_0_6_0;if(f&&f.listeners&&f.listeners[b])for(var d=f.listeners[b],e=d.length,h=0;hd?1:ca?1:ba?1:b