diff options
| author | Stephen Blott | 2015-06-01 14:56:08 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2015-06-01 14:56:08 +0100 | 
| commit | 35c52143d82c8b2bc3e07832e8f6cdb089453baf (patch) | |
| tree | 9e38267f3cc8e0d82331a52373ad8f212f0ce3e0 /pages/options.coffee | |
| parent | f44ca0ff0b7f17a280e30348fdb68daa606b1b9f (diff) | |
| parent | 34f0f90debf0050ece9bd847993f281c1e64be59 (diff) | |
| download | vimium-35c52143d82c8b2bc3e07832e8f6cdb089453baf.tar.bz2 | |
Merge branch 'unified-settings-implementation'
Diffstat (limited to 'pages/options.coffee')
| -rw-r--r-- | pages/options.coffee | 13 | 
1 files changed, 9 insertions, 4 deletions
diff --git a/pages/options.coffee b/pages/options.coffee index 5521cc55..93b0be11 100644 --- a/pages/options.coffee +++ b/pages/options.coffee @@ -1,8 +1,13 @@  $ = (id) -> document.getElementById id -Settings.init()  bgExclusions = chrome.extension.getBackgroundPage().Exclusions +# We have to use Settings from the background page here (not Settings, directly) to avoid a race condition for +# the page popup.  Specifically, we must ensure that the settings have been updated on the background page +# *before* the popup closes.  This ensures that any exclusion-rule changes are in place before the page +# regains the focus. +bgSettings = chrome.extension.getBackgroundPage().Settings +  #  # Class hierarchy for various types of option.  class Option @@ -21,20 +26,20 @@ class Option    # Fetch a setting from localStorage, remember the @previous value and populate the DOM element.    # Return the fetched value.    fetch: -> -    @populateElement @previous = Settings.get @field +    @populateElement @previous = bgSettings.get @field      @previous    # Write this option's new value back to localStorage, if necessary.    save: ->      value = @readValueFromElement()      if not @areEqual value, @previous -      Settings.set @field, @previous = value +      bgSettings.set @field, @previous = value    # Compare values; this is overridden by sub-classes.    areEqual: (a,b) -> a == b    restoreToDefault: -> -    Settings.clear @field +    bgSettings.clear @field      @fetch()    # Static method.  | 
