forked from mozilla/KitchenSink
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* settings.js stores settings in localStorage
* settings object emits an event when any key changes * hide/showCertified moved from settings.js to ui.js
- Loading branch information
Showing
4 changed files
with
96 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
define(function(require) { | ||
var prime = require('prime'); | ||
var Emitter = require('prime/emitter'); | ||
|
||
var Settings = prime({ | ||
inherits: Emitter, | ||
|
||
options: { | ||
'certifiedVisible': false | ||
}, | ||
|
||
constructor: function() { | ||
// update settings from localStorage | ||
var localSettings = JSON.parse(localStorage.settings || '{}'); | ||
for (var key in localSettings) { | ||
this.options[key] = localSettings[key]; | ||
} | ||
this.store(); | ||
}, | ||
|
||
get: function(key) { | ||
return this.options[key]; | ||
}, | ||
|
||
set: function(key, value) { | ||
this.options[key] = value; | ||
this.store(); | ||
this.emit(key); | ||
}, | ||
|
||
store: function() { | ||
localStorage.settings = JSON.stringify(this.options); | ||
} | ||
|
||
}); | ||
|
||
return new Settings(); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters