diff options
| -rw-r--r-- | background_scripts/settings.coffee | 9 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 4 | ||||
| -rw-r--r-- | options/options.coffee | 13 | ||||
| -rw-r--r-- | options/options.html | 2 | ||||
| -rw-r--r-- | tests/unit_tests/settings_test.coffee | 2 |
5 files changed, 18 insertions, 12 deletions
diff --git a/background_scripts/settings.coffee b/background_scripts/settings.coffee index fc78d48f..2eb7c1d6 100644 --- a/background_scripts/settings.coffee +++ b/background_scripts/settings.coffee @@ -21,7 +21,7 @@ root.Settings = Settings = # options/options.(coffee|html) only handle booleans and strings; therefore # all defaults must be booleans or strings defaults: - scrollStepSize: "60" + scrollStepSize: 60 linkHintCharacters: "sadfjklewcmpgh" linkHintNumbers: "0123456789" filterLinkHints: false @@ -62,6 +62,9 @@ root.Settings = Settings = # default/fall back search engine searchUrl: "http://www.google.com/search?q=" -# Initialization code. -# We use this parameter to coordinate any necessary schema changes. + settingsVersion: Utils.getCurrentVersion() + +# We use settingsVersion to coordinate any necessary schema changes. +if Utils.compareVersions("1.41", Settings.get("settingsVersion")) != -1 + Settings.set("scrollStepSize", parseFloat Settings.get("scrollStepSize")) Settings.set("settingsVersion", Utils.getCurrentVersion()) diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index e7ced988..026b0c15 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -221,13 +221,13 @@ extend window, scrollToLeft: -> Scroller.scrollTo "x", 0 scrollToRight: -> Scroller.scrollTo "x", "max" scrollUp: -> Scroller.scrollBy "y", -1 * settings.get("scrollStepSize") - scrollDown: -> Scroller.scrollBy "y", parseFloat(settings.get("scrollStepSize")) + scrollDown: -> Scroller.scrollBy "y", settings.get("scrollStepSize") scrollPageUp: -> Scroller.scrollBy "y", "viewSize", -1/2 scrollPageDown: -> Scroller.scrollBy "y", "viewSize", 1/2 scrollFullPageUp: -> Scroller.scrollBy "y", "viewSize", -1 scrollFullPageDown: -> Scroller.scrollBy "y", "viewSize" scrollLeft: -> Scroller.scrollBy "x", -1 * settings.get("scrollStepSize") - scrollRight: -> Scroller.scrollBy "x", parseFloat(settings.get("scrollStepSize")) + scrollRight: -> Scroller.scrollBy "x", settings.get("scrollStepSize") extend window, reload: -> window.location.reload() diff --git a/options/options.coffee b/options/options.coffee index 6dc2c8dd..abe3fee7 100644 --- a/options/options.coffee +++ b/options/options.coffee @@ -56,11 +56,14 @@ saveOptions = -> # the freedom to change the defaults in the future. for fieldName in editableFields field = $(fieldName) - if field.getAttribute("type") is "checkbox" - fieldValue = field.checked - else - fieldValue = field.value.trim() - field.value = fieldValue + switch field.getAttribute("type") + when "checkbox" + fieldValue = field.checked + when "number" + fieldValue = parseFloat field.value + else + fieldValue = field.value.trim() + field.value = fieldValue # If it's empty and not a field that we allow to be empty, restore to the default value if not fieldValue and canBeEmptyFields.indexOf(fieldName) is -1 diff --git a/options/options.html b/options/options.html index d5f836e7..f6059618 100644 --- a/options/options.html +++ b/options/options.html @@ -188,7 +188,7 @@ <tr> <td class="caption">Scroll step size</td> <td> - <input id="scrollStepSize" type="text" />px + <input id="scrollStepSize" type="number" />px </td> </tr> <tr> diff --git a/tests/unit_tests/settings_test.coffee b/tests/unit_tests/settings_test.coffee index f86d63dc..4599ff03 100644 --- a/tests/unit_tests/settings_test.coffee +++ b/tests/unit_tests/settings_test.coffee @@ -1,7 +1,7 @@ require "./test_helper.js" {Utils} = require "../../lib/utils.js" -Utils.getCurrentVersion = -> '1.39' +Utils.getCurrentVersion = -> '1.42' global.localStorage = {} {Settings} = require "../../background_scripts/settings.js" |
