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 5ef1aa4..bb47c5f 100644 --- a/docs/symbols/src/kis-js_src_modules_event.js.html +++ b/docs/symbols/src/kis-js_src_modules_event.js.html @@ -30,7 +30,7 @@ 23 { 24 if(typeof sel.addEventListener !== "undefined") 25 { - 26 //Duplicated events are dropped, per the specification + 26 // Duplicated events are dropped, per the specification 27 sel.addEventListener(event, callback, false); 28 } 29 }; @@ -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 /** @@ -120,7 +120,7 @@ 113 return false; 114 } 115 -116 //Multiple events? Run recursively! +116 // Multiple events? Run recursively! 117 if (!event.match(/^([\w\-]+)$/)) 118 { 119 event = event.split(" "); @@ -148,30 +148,30 @@ 141 142 _attach_delegate = function(sel, target, event, callback) 143 { -144 //_attach the _listener to the parent object +144 // attach the listener to the parent object 145 _add_remove(sel, event, function(e){ 146 147 var elem, t, tar; 148 -149 //IE 8 doesn't have event bound to element +149 // IE 8 doesn't have event bound to element 150 e = e || window.event; 151 -152 //Get the live version of the target selector +152 // Get the live version of the target selector 153 t = $_.$(target); 154 -155 //Check each element to see if it matches the target +155 // Check each element to see if it matches the target 156 for(elem in t) 157 { -158 //IE 8 doesn't have target in the event object +158 // IE 8 doesn't have target in the event object 159 tar = e.target || e.srcElement; 160 -161 //Fire target callback when event bubbles from target +161 // Fire target callback when event bubbles from target 162 if(tar == t[elem]) 163 { -164 //Trigger the event callback +164 // Trigger the event callback 165 callback.call(t[elem], e); 166 -167 //Stop event propegation +167 // Stop event propegation 168 e.stopPropagation(); 169 } 170 } @@ -250,7 +250,7 @@ 243 * @param string event_type 244 * @param function callback 245 */ -246 delegate: function(target, event, callback) +246 delegate: function (target, event, callback) 247 { 248 $_.each(function(e){ 249 _attach_delegate(e, target, event, callback); 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 7ddaa97..ee6389c 100644 --- a/docs/symbols/src/kis-js_src_modules_util.js.html +++ b/docs/symbols/src/kis-js_src_modules_util.js.html @@ -50,10 +50,10 @@ 43 return a > b ? 1 : a < b ? -1 : 0; 44 }); 45 - 46 //cache object/array size + 46 // cache object/array size 47 num_keys = keys.length; 48 - 49 //Recreate the object/array + 49 // Recreate the object/array 50 for(i=0; i < num_keys; i++) 51 { 52 new_o[keys[i]] = o[keys[i]]; @@ -138,7 +138,7 @@ 131 num_keys, 132 i = 0; 133 -134 //Extract the keys or values if needed +134 // Extract the keys or values if needed 135 if($_.type(keys) !== "array") 136 { 137 keys = this.object_values(keys); @@ -148,7 +148,7 @@ 141 vals = this.object_values(vals); 142 } 143 -144 //cache the number of keys +144 // cache the number of keys 145 num_keys = keys.length; 146 147 if(num_keys !== vals.length) @@ -157,7 +157,7 @@ 150 return false; 151 } 152 -153 //Create and return the new object +153 // Create and return the new object 154 for(i = 0; i < num_keys; i++) 155 { 156 new_object[keys[i]] = vals[i]; @@ -191,7 +191,7 @@ 184 x, 185 is_array = true; 186 -187 //Check for an array in the arguments +187 // Check for an array in the arguments 188 for(i=0; i < arg_len; i++) 189 { 190 if($_.type(args[i]) !== "array") @@ -201,21 +201,21 @@ 194 } 195 } 196 -197 //If all the arguments are javascript arrays +197 // If all the arguments are javascript arrays 198 if(is_array) 199 { 200 new_obj = []; -201 //Let javascript do all the work! +201 // Let javascript do all the work! 202 for(i=0; i< arg_len; i++) 203 { 204 new_obj = new_obj.contact(args[i]); 205 } 206 -207 //Return early +207 // Return early 208 return new_obj; 209 } 210 -211 //No, there's at least one object +211 // No, there's at least one object 212 for(i=0, x=0; i < arg_len; i++) 213 { 214 arg = args[i]; @@ -360,10 +360,11 @@ 353 return new_str; 354 355 } -356 }; -357 -358 //Add it to the $_ object -359 $_.ext('util', u); -360 }()); -361 -362 \ No newline at end of file +356 +357 }; +358 +359 //Add it to the $_ object +360 $_.ext('util', u); +361 }()); +362 +363 \ No newline at end of file diff --git a/kis-all.js b/kis-all.js index f888a7e..0545bf7 100644 --- a/kis-all.js +++ b/kis-all.js @@ -411,6 +411,25 @@ }(self)); } + + // -------------------------------------------------------------------------- + + /** + * event.preventDefault/e.stopPropagation polyfill + * @private + */ + if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined") + { + Event.prototype.preventDefault = function() + { + window.event.stop(); + }, + Event.prototype.stopPropagation = function() + { + window.event.returnValue = false; + } + } + }()); // -------------------------------------------------------------------------- @@ -1028,10 +1047,10 @@ return a > b ? 1 : a < b ? -1 : 0; }); - //cache object/array size + // cache object/array size num_keys = keys.length; - //Recreate the object/array + // Recreate the object/array for(i=0; i < num_keys; i++) { new_o[keys[i]] = o[keys[i]]; @@ -1116,7 +1135,7 @@ num_keys, i = 0; - //Extract the keys or values if needed + // Extract the keys or values if needed if($_.type(keys) !== "array") { keys = this.object_values(keys); @@ -1126,7 +1145,7 @@ vals = this.object_values(vals); } - //cache the number of keys + // cache the number of keys num_keys = keys.length; if(num_keys !== vals.length) @@ -1135,7 +1154,7 @@ return false; } - //Create and return the new object + // Create and return the new object for(i = 0; i < num_keys; i++) { new_object[keys[i]] = vals[i]; @@ -1169,7 +1188,7 @@ x, is_array = true; - //Check for an array in the arguments + // Check for an array in the arguments for(i=0; i < arg_len; i++) { if($_.type(args[i]) !== "array") @@ -1179,21 +1198,21 @@ } } - //If all the arguments are javascript arrays + // If all the arguments are javascript arrays if(is_array) { new_obj = []; - //Let javascript do all the work! + // Let javascript do all the work! for(i=0; i< arg_len; i++) { new_obj = new_obj.contact(args[i]); } - //Return early + // Return early return new_obj; } - //No, there's at least one object + // No, there's at least one object for(i=0, x=0; i < arg_len; i++) { arg = args[i]; @@ -1338,6 +1357,7 @@ return new_str; } + }; //Add it to the $_ object @@ -1372,7 +1392,7 @@ { if(typeof sel.addEventListener !== "undefined") { - //Duplicated events are dropped, per the specification + // Duplicated events are dropped, per the specification sel.addEventListener(event, callback, false); } }; @@ -1387,7 +1407,7 @@ } }; } - //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") { /** @@ -1462,7 +1482,7 @@ return false; } - //Multiple events? Run recursively! + // Multiple events? Run recursively! if (!event.match(/^([\w\-]+)$/)) { event = event.split(" "); @@ -1490,30 +1510,30 @@ _attach_delegate = function(sel, target, event, callback) { - //_attach the _listener to the parent object + // attach the listener to the parent object _add_remove(sel, event, function(e){ var elem, t, tar; - //IE 8 doesn't have event bound to element + // IE 8 doesn't have event bound to element e = e || window.event; - //Get the live version of the target selector + // Get the live version of the target selector t = $_.$(target); - //Check each element to see if it matches the target + // Check each element to see if it matches the target for(elem in t) { - //IE 8 doesn't have target in the event object + // IE 8 doesn't have target in the event object tar = e.target || e.srcElement; - //Fire target callback when event bubbles from target + // Fire target callback when event bubbles from target if(tar == t[elem]) { - //Trigger the event callback + // Trigger the event callback callback.call(t[elem], e); - //Stop event propegation + // Stop event propegation e.stopPropagation(); } } @@ -1592,7 +1612,7 @@ * @param string event_type * @param function callback */ - delegate: function(target, event, callback) + delegate: function (target, event, callback) { $_.each(function(e){ _attach_delegate(e, target, event, callback); diff --git a/kis-min.js b/kis-min.js index 70f3853..1024b50 100644 --- a/kis-min.js +++ b/kis-min.js @@ -4,7 +4,7 @@ return b.length===1?b[0]:b};d=function(a){var c;if(typeof a!=="undefined"){if(ty (function(){if(typeof window.console==="undefined")window.console={log:function(){}};if(typeof String.prototype.trim==="undefined")String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")};typeof document!=="undefined"&&!("classList"in document.createElement("a"))&&function(f){var f=(f.HTMLElement||f.Element).prototype,g=Object,d=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},b=Array.prototype.indexOf||function(a){for(var c=0,b=this.length;c1&&typeof a==="undefined")console.log(c),console.log("Must be a singular element");else if(c.length>1&&typeof a!== diff --git a/src/modules/event.js b/src/modules/event.js index 9bbdd91..3389a7a 100644 --- a/src/modules/event.js +++ b/src/modules/event.js @@ -23,7 +23,7 @@ { if(typeof sel.addEventListener !== "undefined") { - //Duplicated events are dropped, per the specification + // Duplicated events are dropped, per the specification sel.addEventListener(event, callback, false); } }; @@ -38,7 +38,7 @@ } }; } - //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") { /** @@ -113,7 +113,7 @@ return false; } - //Multiple events? Run recursively! + // Multiple events? Run recursively! if (!event.match(/^([\w\-]+)$/)) { event = event.split(" "); @@ -141,30 +141,30 @@ _attach_delegate = function(sel, target, event, callback) { - //_attach the _listener to the parent object + // attach the listener to the parent object _add_remove(sel, event, function(e){ var elem, t, tar; - //IE 8 doesn't have event bound to element + // IE 8 doesn't have event bound to element e = e || window.event; - //Get the live version of the target selector + // Get the live version of the target selector t = $_.$(target); - //Check each element to see if it matches the target + // Check each element to see if it matches the target for(elem in t) { - //IE 8 doesn't have target in the event object + // IE 8 doesn't have target in the event object tar = e.target || e.srcElement; - //Fire target callback when event bubbles from target + // Fire target callback when event bubbles from target if(tar == t[elem]) { - //Trigger the event callback + // Trigger the event callback callback.call(t[elem], e); - //Stop event propegation + // Stop event propegation e.stopPropagation(); } } @@ -243,7 +243,7 @@ * @param string event_type * @param function callback */ - delegate: function(target, event, callback) + delegate: function (target, event, callback) { $_.each(function(e){ _attach_delegate(e, target, event, callback); diff --git a/src/modules/util.js b/src/modules/util.js index bf95870..aa31294 100644 --- a/src/modules/util.js +++ b/src/modules/util.js @@ -43,10 +43,10 @@ return a > b ? 1 : a < b ? -1 : 0; }); - //cache object/array size + // cache object/array size num_keys = keys.length; - //Recreate the object/array + // Recreate the object/array for(i=0; i < num_keys; i++) { new_o[keys[i]] = o[keys[i]]; @@ -131,7 +131,7 @@ num_keys, i = 0; - //Extract the keys or values if needed + // Extract the keys or values if needed if($_.type(keys) !== "array") { keys = this.object_values(keys); @@ -141,7 +141,7 @@ vals = this.object_values(vals); } - //cache the number of keys + // cache the number of keys num_keys = keys.length; if(num_keys !== vals.length) @@ -150,7 +150,7 @@ return false; } - //Create and return the new object + // Create and return the new object for(i = 0; i < num_keys; i++) { new_object[keys[i]] = vals[i]; @@ -184,7 +184,7 @@ x, is_array = true; - //Check for an array in the arguments + // Check for an array in the arguments for(i=0; i < arg_len; i++) { if($_.type(args[i]) !== "array") @@ -194,21 +194,21 @@ } } - //If all the arguments are javascript arrays + // If all the arguments are javascript arrays if(is_array) { new_obj = []; - //Let javascript do all the work! + // Let javascript do all the work! for(i=0; i< arg_len; i++) { new_obj = new_obj.contact(args[i]); } - //Return early + // Return early return new_obj; } - //No, there's at least one object + // No, there's at least one object for(i=0, x=0; i < arg_len; i++) { arg = args[i]; @@ -353,6 +353,7 @@ return new_str; } + }; //Add it to the $_ object diff --git a/src/polyfill.js b/src/polyfill.js index b45a5af..0560ebe 100644 --- a/src/polyfill.js +++ b/src/polyfill.js @@ -198,4 +198,23 @@ }(self)); } + + // -------------------------------------------------------------------------- + + /** + * event.preventDefault/e.stopPropagation polyfill + * @private + */ + if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined") + { + Event.prototype.preventDefault = function() + { + window.event.stop(); + }, + Event.prototype.stopPropagation = function() + { + window.event.returnValue = false; + } + } + }()); \ No newline at end of file