diff options
| author | Jez Ng | 2012-10-29 17:56:32 -0400 |
|---|---|---|
| committer | Jez Ng | 2012-10-29 18:28:33 -0400 |
| commit | 76622cd99cf671531cfa21c5d6243f3e4e185116 (patch) | |
| tree | bf0e1922a7f872ea044d3828f3b9e1fdcd67c1c8 /options | |
| parent | c0af54eac713be14d1e3eceeca23139455abb408 (diff) | |
| download | vimium-76622cd99cf671531cfa21c5d6243f3e4e185116.tar.bz2 | |
Convert strings to numbers when saving options page.
This avoids the need to continually re-parse the strings each time we
load the option value.
Diffstat (limited to 'options')
| -rw-r--r-- | options/options.coffee | 13 | ||||
| -rw-r--r-- | options/options.html | 2 |
2 files changed, 9 insertions, 6 deletions
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> |
