diff options
| author | Stephen Blott | 2014-11-02 08:56:15 +0000 |
|---|---|---|
| committer | Stephen Blott | 2014-11-02 08:56:15 +0000 |
| commit | 3bae8f0f8fc012720001caced69999160d9005fa (patch) | |
| tree | 896f52810677beac492d8d24759dc3b31e93f351 | |
| parent | 28e9c8374bfc7a4fd479dbb958a4a87331fb0857 (diff) | |
| download | vimium-3bae8f0f8fc012720001caced69999160d9005fa.tar.bz2 | |
Centralize handling of event propagation.
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 6 | ||||
| -rw-r--r-- | content_scripts/vomnibar.coffee | 2 | ||||
| -rw-r--r-- | lib/dom_utils.coffee | 5 |
3 files changed, 8 insertions, 5 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 93d0bcd2..8f4c0f2a 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -438,7 +438,7 @@ onKeydown = (event) -> handledKeydownEvents.push event else if (!modifiers) - event.stopImmediatePropagation() + DomUtils.suppressPropagation(event) handledKeydownEvents.push event else if (isShowingHelpDialog && KeyboardUtils.isEscape(event)) @@ -470,7 +470,7 @@ onKeydown = (event) -> if (keyChar == "" && !isInsertMode() && (currentCompletionKeys.indexOf(KeyboardUtils.getKeyChar(event)) != -1 || isValidFirstKey(KeyboardUtils.getKeyChar(event)))) - event.stopImmediatePropagation() + DomUtils.suppressPropagation(event) handledKeydownEvents.push event onKeyup = (event) -> @@ -486,7 +486,7 @@ onKeyup = (event) -> event.keyCode == keydown.keyCode handledKeydownEvents.splice i, 1 - event.stopImmediatePropagation() + DomUtils.suppressPropagation(event) break checkIfEnabledForUrl = -> diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee index 8c6b2059..f1d2ccc5 100644 --- a/content_scripts/vomnibar.coffee +++ b/content_scripts/vomnibar.coffee @@ -139,7 +139,7 @@ class VomnibarUI @hide() # It seems like we have to manually suppress the event here and still return true. - event.stopImmediatePropagation() + DomUtils.suppressPropagation(event) event.preventDefault() true diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 8c0445c5..62e655e7 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -127,9 +127,12 @@ DomUtils = document.documentElement.appendChild(flashEl) setTimeout((-> DomUtils.removeElement flashEl), 400) + suppressPropagation: (event) -> + event.stopImmediatePropagation() + suppressEvent: (event) -> event.preventDefault() - event.stopImmediatePropagation() + @suppressPropagation(event) root = exports ? window root.DomUtils = DomUtils |
