zurb/foundation — pull request #4151 by btsai (2014-01-15 08:07:23+00:00)
Title: Fix issue #4150: Reveal: escape key press event capturing does not work consistently

hi zurbists,

thanks again for your great framework.

i noticed this functionality problem while trying to implement some stuff.

i broke this into three separate commits so you can pick and choose what you want to use.
1. your `$('body').on('keyup.fndtn.reveal')` was firing between 4 to 7 times for each key press, once a reveal window was displayed.
2. because of the multiple triggered events when the escape key was pressed, the reveal window did not close properly and remained in a locked state, so it would not open again.
3. you had the keyup event mapped from the time the reveal library was initialized, and it was always on. i would recommend that you actually have the keyup event captured only when you need it, ie. when there is a reveal modal open.

in its current implementation, once you opened a reveal modal, typing on the page would trigger this block of code 4 to 7 times each time you typed a single letter:
```
var open_modal = $('[data-reveal].open'),
settings = open_modal.data('reveal-init');
```

i've tested this with both an in-page reveal dialog and an ajax-based reveal dialog, as well as with one modal having a link to a second modal, and both work.

good luck,

brian