Skip to content

Commit 20eff4c

Browse files
committed
Merge pull request philc#1211 from mrmr1993/blur-embeds-with-options
Allow blur of embedded objects (e.g. flash) and add an option to enable/disable it Conflicts: content_scripts/vimium_frontend.coffee
2 parents a912676 + babddda commit 20eff4c

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

background_scripts/settings.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ root.Settings = Settings =
6666
linkHintNumbers: "0123456789"
6767
filterLinkHints: false
6868
hideHud: false
69+
enableBlurEmbeds: false
6970
userDefinedLinkHintCss:
7071
"""
7172
div > .vimiumHintMarker {

content_scripts/vimium_frontend.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ settings =
5151
loadedValues: 0
5252
valuesToLoad: ["scrollStepSize", "linkHintCharacters", "linkHintNumbers", "filterLinkHints", "hideHud",
5353
"previousPatterns", "nextPatterns", "findModeRawQuery", "regexFindMode", "userDefinedLinkHintCss",
54-
"helpDialog_showAdvancedCommands"]
54+
"helpDialog_showAdvancedCommands", "enableBlurEmbeds"]
5555
isLoaded: false
5656
eventListeners: {}
5757

@@ -423,11 +423,11 @@ onKeydown = (event) ->
423423

424424
if (isInsertMode() and
425425
(insertExitKeys.indexOf(rawKeyChar) != -1 or isInsertExitPassKey))
426-
# We don't want to programmatically blur out of Flash embeds from Javascript.
427-
if (!isEmbed(event.srcElement))
426+
# Blurring out of embeds could be dangerous, do nothing unless the user explicitly enables it.
427+
if (!isEmbed(event.srcElement) or settings.get "enableBlurEmbeds")
428428
# Remove focus so the user can't just get himself back into insert mode by typing in the same input
429429
# box.
430-
if (isEditable(event.srcElement))
430+
if (isEditable(event.srcElement) or isEmbed(event.srcElement))
431431
event.srcElement.blur()
432432
exitInsertMode()
433433
unless isInsertExitPassKey

pages/options.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ document.addEventListener "DOMContentLoaded", ->
194194
newTabUrl: NonEmptyTextOption
195195
nextPatterns: NonEmptyTextOption
196196
previousPatterns: NonEmptyTextOption
197+
enableBlurEmbeds: CheckBoxOption
197198
regexFindMode: CheckBoxOption
198199
scrollStepSize: NumberOption
199200
searchEngines: TextOption

pages/options.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,20 @@
345345
</label>
346346
</td>
347347
</tr>
348+
<tr>
349+
<td class="caption"></td>
350+
<td verticalAlign="top" class="booleanOption">
351+
<div class="help">
352+
<div class="example">
353+
This is an experimental option, and could break embeds that expect to handle the escape key.
354+
</div>
355+
</div>
356+
<label>
357+
<input id="enableBlurEmbeds" type="checkbox"/>
358+
Enable blurring embed elements to exit insert mode.
359+
</label>
360+
</td>
361+
</tr>
348362
<tr>
349363
<td class="caption"></td>
350364
<td verticalAlign="top" class="booleanOption">

0 commit comments

Comments
 (0)