Mike Alsup wrote: > I just updated blockUI and added better event handling. Mouse and key > events are now discarded only if they are targeted for elements > outside of the blocking message (or dialog). I also added the feature > of focusing the first visible input (if any) in the message/dialog. > For modal dialogs it's still not a very A11y-friendly solution, but > it's a little better than it was before. > > Mike > Mike,
Nice improvements :) It looks like your overlay captures most of the mouse clicks. I have been *struggling* to implement similar functionality to jqModal, as I've come across a strange bug/miscode on my part. jqModal supports disabling of the overlay so that users can still interact with the background page. If 'focus' is passed as a parameter, however, all interaction is forced to the modal window, and clicks/keypresses outside of the window ignored. To accomplish this I've bound a function to the keypress, keydown, and mousedown events [as per block UI]. The function returns false if the event target is outside the focused modal window, or true if it's inside [now, also as per block UI -- although jqModal *may* have a faster means for determining if event target is within modal]. The strange this is that I *thought* returning false would terminate the event chain/bubbling. It doesn't appear so, and the target's event is executed regardless of returning true or false. More strange is that if an alert() is added to the 'capturing' function, the function terminates the event chain as expected. I have tried issuing e.preventDefault() and e.stopPropagation() in the capturing function. A pre-release version of jqModal is available to demonstrate this issue; http://dev.iceburg.net/jquery/jqModal/pre/ The demo on this page calls a modal window w/ a disabled overlay & focus ("true modal") enabled. In the 'capturing' function, I've left the firebug caller ("debugger;") for quick reference. (( offtopic; You'll notice that $.jqm() is now anchored to the dialog element (vs. the trigger(s) ) as in traditional models... not only did this result in a smaller codebase, but the removal of the "header" parameters allows window styling to be easier & more flexible. )) Here's a related code overview; 1) Bind 'capturing' function to all clicks/keypresses if it has not yet been initialized, and only if focus is passed. --- if(c.focus) { if(typeof($.jqm.focus) == 'undefined') { var m = $.jqm.modal; $().bind('keypress',m).bind('keydown',m).bind('mousedown',m); } $.jqm['focus'] = serial; // TODO: UNBIND TOOOO!!!!! } ... 2) 'capturing' function; return true if event target is within the focused modal window; --- modal: function(e) { return ($(e.target).parents('#jqmID'+$.jqm.focus).length == 0) ? false : true; }, ... Any ideas? Thanks! ~ Brice _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/