keeweb/app/scripts/models/app-settings-model.js

43 lines
1005 B
JavaScript
Raw Normal View History

2015-10-17 23:49:24 +02:00
'use strict';
var Backbone = require('backbone'),
2015-12-05 14:57:43 +01:00
SettingsStore = require('../comp/settings-store');
2015-10-17 23:49:24 +02:00
var AppSettingsModel = Backbone.Model.extend({
defaults: {
2015-12-05 14:57:43 +01:00
theme: 'fb',
2015-11-11 19:58:29 +01:00
expandGroups: true,
listViewWidth: null,
menuViewWidth: null,
2015-11-14 19:18:34 +01:00
tagsViewHeight: null,
autoUpdate: 'install',
2015-11-17 21:57:32 +01:00
clipboardSeconds: 0,
2015-11-21 07:49:39 +01:00
autoSave: true,
2015-11-21 08:29:49 +01:00
idleMinutes: 15,
2015-11-21 15:55:42 +01:00
minimizeOnClose: false,
2015-12-02 22:12:14 +01:00
tableView: false,
colorfulIcons: false,
lockOnMinimize: true
2015-10-17 23:49:24 +02:00
},
initialize: function() {
2015-10-24 21:06:44 +02:00
this.listenTo(this, 'change', this.save);
2015-10-17 23:49:24 +02:00
},
load: function() {
2015-12-05 14:57:43 +01:00
var data = SettingsStore.load('app-settings');
if (data) {
this.set(data, {silent: true});
2015-10-17 23:49:24 +02:00
}
},
save: function() {
2015-12-05 14:57:43 +01:00
SettingsStore.save('app-settings', this.attributes);
2015-10-17 23:49:24 +02:00
}
});
AppSettingsModel.instance = new AppSettingsModel();
AppSettingsModel.instance.load();
module.exports = AppSettingsModel;