 
 $ = (id) -> document.getElementById id
 bgExclusions = chrome.extension.getBackgroundPage().Exclusions
-restoreSettingsVersion = null
 
 # 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

#
# Backup and restore. "?" is for the tests."
DomUtils?.documentReady ->
  populateBackupLinkUrl = ->
    backup = settingsVersion: bgSettings.get "settingsVersion"
    for option in Option.all

            option.populateElement backup[option.field]
            option.onUpdated()

  Option.onSave ->
    # If we're restoring a backup, then restore the backed up settingsVersion.
    if restoreSettingsVersion?
      bgSettings.set "settingsVersion", restoreSettingsVersion
      restoreSettingsVersion = null
    # Reset the restore-backup input.
    $("chooseFile").value = ""
    # We need to apply migrations in case we are restoring an old backup.
    bgSettings.applyMigrations()

# Exported for tests.
root = exports ? window
extend root, {Options, isVimiumOptionsPage: true}
