aboutsummaryrefslogtreecommitdiffstats
path: root/pages/options.coffee
diff options
context:
space:
mode:
authorStephen Blott2014-11-15 17:14:30 +0000
committerStephen Blott2014-11-16 14:45:06 +0000
commit6230dec9d051306201af7cff7b530814e2da5275 (patch)
tree7c6f6f3082e9597ac8b8675d018743e4ce8816fd /pages/options.coffee
parent7b9c1017d8742b280774184e99743f4ae15e2777 (diff)
downloadvimium-6230dec9d051306201af7cff7b530814e2da5275.tar.bz2
Options; reworked, with fixed footer.
Changes: - Added caption "Miscellaneous toggles" to visually separate the link-hints checkbox from the others. - Made the text for the two link-hint character sets the same. - The "Show advanced options" link now spans two columns, so it does not affect its column's width, so the layout doesn't change when the options below the fold are expanded. - Added a fixed footer containing the help text and the save button. - The text of the save button now changes when it is enabled. (I sometimes find it hard to tell whether its been activated or not.) - Control-Enter anywhere on the page saves all options. - Aligned the entire options table left, instead of centered. This is the chrome style. However, it also makes it easier to get the alignment right between main table and the footer. - Change width of main wrapper such that it actually matches the table's width. This aligns the right edge of the bar under the title with the right edge of the second column of the table.
Diffstat (limited to 'pages/options.coffee')
-rw-r--r--pages/options.coffee29
1 files changed, 6 insertions, 23 deletions
diff --git a/pages/options.coffee b/pages/options.coffee
index f5968eb9..aaa4d9b4 100644
--- a/pages/options.coffee
+++ b/pages/options.coffee
@@ -42,13 +42,7 @@ class Option
@saveOptions: ->
Option.all.map (option) -> option.save()
$("saveOptions").disabled = true
-
- # Used by text options. <ctrl-Enter> saves all options.
- activateCtrlEnterListener: (element) ->
- element.addEventListener "keyup", (event) ->
- if event.ctrlKey and event.keyCode == 13
- element.blur()
- Option.saveOptions()
+ $("saveOptions").innerHTML = "No Changes"
# Abstract method; only implemented in sub-classes.
# Populate the option's DOM element (@element) with the setting's current value.
@@ -66,7 +60,6 @@ class TextOption extends Option
constructor: (field,enableSaveButton) ->
super(field,enableSaveButton)
@element.addEventListener "input", enableSaveButton
- @activateCtrlEnterListener @element
populateElement: (value) -> @element.value = value
readValueFromElement: -> @element.value.trim()
@@ -74,7 +67,6 @@ class NonEmptyTextOption extends Option
constructor: (field,enableSaveButton) ->
super(field,enableSaveButton)
@element.addEventListener "input", enableSaveButton
- @activateCtrlEnterListener @element
populateElement: (value) -> @element.value = value
# If the new value is not empty, then return it. Otherwise, restore the default value.
@@ -89,7 +81,6 @@ class ExclusionRulesOption extends Option
super(args...)
$("exclusionAddButton").addEventListener "click", (event) =>
@appendRule { pattern: "", passKeys: "" }
- @maintainExclusionMargin()
# Focus the pattern element in the new rule.
@element.children[@element.children.length-1].children[0].children[0].focus()
# Scroll the new rule into view.
@@ -101,7 +92,6 @@ class ExclusionRulesOption extends Option
@element.removeChild @element.firstChild
for rule in rules
@appendRule rule
- @maintainExclusionMargin()
# Append a row for a new rule.
appendRule: (rule) ->
@@ -111,7 +101,6 @@ class ExclusionRulesOption extends Option
for field in ["pattern", "passKeys"]
element = row.querySelector ".#{field}"
element.value = rule[field]
- @activateCtrlEnterListener element
for event in [ "input", "change" ]
element.addEventListener event, enableSaveButton
@@ -120,7 +109,6 @@ class ExclusionRulesOption extends Option
row = event.target.parentNode.parentNode
row.parentNode.removeChild row
enableSaveButton()
- @maintainExclusionMargin()
@element.appendChild row
@@ -138,20 +126,11 @@ class ExclusionRulesOption extends Option
flatten = (rule) -> if rule and rule.pattern then rule.pattern + "\n" + rule.passKeys else ""
a.map(flatten).join("\n") == b.map(flatten).join("\n")
- # Hack. There has to be a better way than...
- # The y-axis scrollbar for "exclusionRules" is only displayed if it is needed. When visible, it appears on
- # top of the enclosed content (partially obscuring it). Here, we adjust the margin of the "Remove" button to
- # compensate.
- maintainExclusionMargin: ->
- scrollBox = $("exclusionScrollBox")
- margin = if scrollBox.clientHeight < scrollBox.scrollHeight then "16px" else "0px"
- for element in scrollBox.getElementsByClassName "exclusionRemoveButton"
- element.style["margin-right"] = margin
-
#
# Operations for page elements.
enableSaveButton = ->
$("saveOptions").removeAttribute "disabled"
+ $("saveOptions").innerHTML = "Save Changes"
# Display either "linkHintNumbers" or "linkHintCharacters", depending upon "filterLinkHints".
maintainLinkHintsView = ->
@@ -213,3 +192,7 @@ document.addEventListener "DOMContentLoaded", ->
maintainLinkHintsView()
window.onbeforeunload = -> "You have unsaved changes to options." unless $("saveOptions").disabled
+ document.addEventListener "keyup", (event) ->
+ if event.ctrlKey and event.keyCode == 13
+ Option.saveOptions()
+