From 9205532e79ffc025a1bc7aaf47d2c261c34e96e2 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 4 Nov 2011 16:42:07 -0400 Subject: [PATCH] Fixed deferred events in IE8 --- .../src/kis-js_src_modules_event.js.html | 211 +++++++++--------- kis-all.js | 11 +- kis-min.js | 2 +- src/modules/event.js | 11 +- 4 files changed, 125 insertions(+), 110 deletions(-) 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 d64d07e..5ef1aa4 100644 --- a/docs/symbols/src/kis-js_src_modules_event.js.html +++ b/docs/symbols/src/kis-js_src_modules_event.js.html @@ -151,108 +151,113 @@ 144 //_attach the _listener to the parent object 145 _add_remove(sel, event, function(e){ 146 -147 var elem, t; +147 var elem, t, tar; 148 -149 //Get the live version of the target selector -150 t = $_.$(target); +149 //IE 8 doesn't have event bound to element +150 e = e || window.event; 151 -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 * Event Listener module -176 * -177 * @namespace -178 * @name event -179 * @memberOf $_ -180 */ -181 e = { -182 /** -183 * Adds an event that returns a callback when triggered on the selected -184 * event and selector -185 * -186 * @memberOf $_.event -187 * @name add -188 * @function -189 * @example Eg. $_("#selector").event.add("click", do_something()); -190 * @param string event -191 * @param function callback -192 */ -193 add: function (event, callback) -194 { -195 $_.each(function(e){ -196 _add_remove(e, event, callback, true); -197 }); -198 }, -199 /** -200 * Removes an event bound the the specified selector, event type, and callback -201 * -202 * @memberOf $_.event -203 * @name remove -204 * @function -205 * @example Eg. $_("#selector").event.remove("click", do_something()); -206 * @param string event -207 * @param string callback -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 event to the document -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 */ -226 live: function (target, event, callback) -227 { -228 _attach_delegate(document.documentElement, target, event, callback); -229 }, -230 /** -231 * Binds an event to a parent object -232 * -233 * @memberOf $_.event -234 * @name delegate -235 * @function -236 * @example Eg. $_("#parent").delegate(".button", "click", do_something()); -237 * @param string target -238 * @param string event_type -239 * @param function callback -240 */ -241 delegate: function(target, event, callback) -242 { -243 $_.each(function(e){ -244 _attach_delegate(e, target, event, callback); -245 }); -246 } -247 }; -248 -249 $_.ext('event', e); -250 -251 }()); \ No newline at end of file +152 //Get the live version of the target selector +153 t = $_.$(target); +154 +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 +159 tar = e.target || e.srcElement; +160 +161 //Fire target callback when event bubbles from target +162 if(tar == t[elem]) +163 { +164 //Trigger the event callback +165 callback.call(t[elem], e); +166 +167 //Stop event propegation +168 e.stopPropagation(); +169 } +170 } +171 +172 }, true); +173 }; +174 +175 +176 +177 // -------------------------------------------------------------------------- +178 +179 /** +180 * Event Listener module +181 * +182 * @namespace +183 * @name event +184 * @memberOf $_ +185 */ +186 e = { +187 /** +188 * Adds an event that returns a callback when triggered on the selected +189 * event and selector +190 * +191 * @memberOf $_.event +192 * @name add +193 * @function +194 * @example Eg. $_("#selector").event.add("click", do_something()); +195 * @param string event +196 * @param function callback +197 */ +198 add: function (event, callback) +199 { +200 $_.each(function(e){ +201 _add_remove(e, event, callback, true); +202 }); +203 }, +204 /** +205 * Removes an event bound the the specified selector, event type, and callback +206 * +207 * @memberOf $_.event +208 * @name remove +209 * @function +210 * @example Eg. $_("#selector").event.remove("click", do_something()); +211 * @param string event +212 * @param string callback +213 */ +214 remove: function (event, callback) +215 { +216 $_.each(function(e){ +217 _add_remove(e, event, callback, false); +218 }); +219 }, +220 /** +221 * Binds a persistent event to the document +222 * +223 * @memberOf $_.event +224 * @name live +225 * @function +226 * @example Eg. $_.event.live(".button", "click", do_something()); +227 * @param string target +228 * @param string event +229 * @param function callback +230 */ +231 live: function (target, event, callback) +232 { +233 _attach_delegate(document.documentElement, target, event, callback); +234 }, +235 /** +236 * Binds an event to a parent object +237 * +238 * @memberOf $_.event +239 * @name delegate +240 * @function +241 * @example Eg. $_("#parent").delegate(".button", "click", do_something()); +242 * @param string target +243 * @param string event_type +244 * @param function callback +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 diff --git a/kis-all.js b/kis-all.js index 1e32b88..f888a7e 100644 --- a/kis-all.js +++ b/kis-all.js @@ -1493,7 +1493,10 @@ //_attach the _listener to the parent object _add_remove(sel, event, function(e){ - var elem, t; + var elem, t, tar; + + //IE 8 doesn't have event bound to element + e = e || window.event; //Get the live version of the target selector t = $_.$(target); @@ -1501,8 +1504,11 @@ //Check each element to see if it matches the target for(elem in t) { + //IE 8 doesn't have target in the event object + tar = e.target || e.srcElement; + //Fire target callback when event bubbles from target - if(e.target == t[elem]) + if(tar == t[elem]) { //Trigger the event callback callback.call(t[elem], e); @@ -1512,7 +1518,6 @@ } } - }, true); }; diff --git a/kis-min.js b/kis-min.js index bfb1b91..70f3853 100644 --- a/kis-min.js +++ b/kis-min.js @@ -18,4 +18,4 @@ e=0;$_.type(d)!=="array"&&(d=this.object_values(d));$_.type(b)!=="array"&&(b=thi 0;e