name: "Hack",
kind: "VFlexBox",
preferences: [],
+ create: function() {
+ this.inherited(arguments);
+ try {
+ var str = localStorage['hacks/' + this.kind];
+ if (str)
+ this.setPreferences(JSON.parse(str), true, true);
+ } catch(e) {
+ enyo.log("Could not load preferences: " + e.toString());
+ }
+ },
stop: function() {
},
start: function() {
}
return o;
},
- setPreferences: function(prefs) {
+ setPreferences: function(prefs, nosave, nonotify) {
for (var i in prefs) {
if (this[i] == undefined)
throw new Error('Cannot set nonexistent preference "' + i + '"');
this[i] = prefs[i];
}
- this.preferencesChanged();
+ if (!nosave)
+ this.savePreferences();
+ if (!nonotify)
+ this.preferencesChanged();
+ },
+ savePreferences: function() {
+ try {
+ localStorage['hacks/' + this.kind] = JSON.stringify(this.getPreferences());
+ } catch(e) {
+ enyo.log("Could not save prefs: " + e.toString());
+ }
+ },
+ resetPreferences: function() {
+ delete localStorage['hacks/' + this.kind];
},
- preferencesChanged: function() {
- }
+ preferencesChanged: function() { }
});