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

84 lines
2.1 KiB
JavaScript
Raw Normal View History

2019-09-15 14:16:32 +02:00
import Backbone from 'backbone';
import { SettingsStore } from 'comp/settings/settings-store';
2015-10-17 23:49:24 +02:00
2017-01-31 07:50:28 +01:00
const AppSettingsModel = Backbone.Model.extend({
2015-10-17 23:49:24 +02:00
defaults: {
2015-12-05 14:57:43 +01:00
theme: 'fb',
2016-08-21 23:12:49 +02:00
locale: null,
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,
autoSaveInterval: 0,
2016-02-14 12:20:21 +01:00
rememberKeyFiles: false,
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,
2019-03-03 12:53:47 +01:00
directAutotype: true,
2017-03-26 01:57:52 +01:00
titlebarStyle: 'default',
2016-01-13 18:46:43 +01:00
lockOnMinimize: true,
lockOnCopy: false,
lockOnAutoType: false,
2017-06-02 20:16:09 +02:00
lockOnOsLock: false,
2016-02-23 07:08:57 +01:00
helpTipCopyShown: false,
2017-05-03 20:44:16 +02:00
templateHelpShown: false,
2016-03-05 09:35:22 +01:00
skipOpenLocalWarn: false,
hideEmptyFields: false,
2016-03-13 10:54:16 +01:00
skipHttpsWarning: false,
2016-03-13 17:45:55 +01:00
demoOpened: false,
fontSize: 0,
2016-07-27 00:01:32 +02:00
tableViewColumns: null,
2016-08-13 22:19:15 +02:00
generatorPresets: null,
2019-08-15 04:59:53 +02:00
generatorHidePassword: false,
2017-02-05 13:35:38 +01:00
cacheConfigSettings: false,
canOpen: true,
canOpenDemo: true,
canOpenSettings: true,
canCreate: true,
canImportXml: true,
canRemoveLatest: true,
canExportXml: true,
2019-09-08 20:28:02 +02:00
canExportHtml: true,
2017-02-05 13:35:38 +01:00
dropbox: true,
webdav: true,
2016-03-26 23:05:59 +01:00
gdrive: true,
2016-03-27 13:54:35 +02:00
onedrive: true
2015-10-17 23:49:24 +02:00
},
2019-08-18 10:17:09 +02:00
initialize() {
2015-10-24 21:06:44 +02:00
this.listenTo(this, 'change', this.save);
2015-10-17 23:49:24 +02:00
},
2019-08-18 10:17:09 +02:00
load() {
return SettingsStore.load('app-settings').then(data => {
if (data) {
this.upgrade(data);
2019-08-16 23:05:39 +02:00
this.set(data, { silent: true });
}
});
},
2019-08-18 10:17:09 +02:00
upgrade(data) {
2017-01-28 23:36:30 +01:00
if (data.rememberKeyFiles === true) {
data.rememberKeyFiles = 'data';
}
2017-02-05 16:15:14 +01:00
if (data.versionWarningShown) {
delete data.versionWarningShown;
}
2017-01-28 23:36:30 +01:00
},
2019-08-18 10:17:09 +02:00
save() {
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();
2019-09-15 14:16:32 +02:00
export { AppSettingsModel };