snappymail/dev/Screen/User/Settings.js

128 lines
3.4 KiB
JavaScript
Raw Normal View History

2014-09-05 06:49:03 +08:00
(function () {
2014-08-25 23:49:01 +08:00
'use strict';
2014-08-20 23:03:12 +08:00
var
2014-08-25 23:49:01 +08:00
_ = require('_'),
2014-08-25 15:10:51 +08:00
2014-09-05 06:49:03 +08:00
Enums = require('Common/Enums'),
Globals = require('Common/Globals'),
Translator = require('Common/Translator'),
2014-09-05 06:49:03 +08:00
AppStore = require('Stores/User/App'),
Settings = require('Storage/Settings'),
2014-09-05 06:49:03 +08:00
kn = require('Knoin/Knoin'),
2014-08-22 23:08:56 +08:00
AbstractSettingsScreen = require('Screen/AbstractSettings')
2014-08-20 23:03:12 +08:00
;
/**
* @constructor
* @extends AbstractSettingsScreen
2014-08-20 23:03:12 +08:00
*/
2014-10-18 21:43:44 +08:00
function SettingsUserScreen()
2014-08-20 23:03:12 +08:00
{
AbstractSettingsScreen.call(this, [
2014-10-18 21:43:44 +08:00
require('View/User/Settings/SystemDropDown'),
require('View/User/Settings/Menu'),
require('View/User/Settings/Pane')
2014-08-20 23:03:12 +08:00
]);
Translator.initOnStartOrLangChange(function () {
this.sSettingsTitle = Translator.i18n('TITLES/SETTINGS');
2014-08-20 23:03:12 +08:00
}, this, function () {
2014-08-27 23:59:44 +08:00
this.setSettingsTitle();
2014-08-20 23:03:12 +08:00
});
}
2014-10-18 21:43:44 +08:00
_.extend(SettingsUserScreen.prototype, AbstractSettingsScreen.prototype);
2014-08-20 23:03:12 +08:00
2014-09-05 06:49:03 +08:00
/**
* @param {Function=} fCallback
*/
2014-10-18 21:43:44 +08:00
SettingsUserScreen.prototype.setupSettings = function (fCallback)
2014-09-05 06:49:03 +08:00
{
2014-10-18 21:43:44 +08:00
kn.addSettingsViewModel(require('Settings/User/General'),
2014-09-05 06:49:03 +08:00
'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true);
if (AppStore.contactsIsAllowed())
2014-09-05 06:49:03 +08:00
{
2014-10-18 21:43:44 +08:00
kn.addSettingsViewModel(require('Settings/User/Contacts'),
2014-09-05 06:49:03 +08:00
'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts');
}
if (Settings.capa(Enums.Capa.AdditionalAccounts))
{
2014-10-18 21:43:44 +08:00
kn.addSettingsViewModel(require('Settings/User/Accounts'),
2014-09-05 06:49:03 +08:00
'SettingsAccounts', 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME', 'accounts');
}
if (Settings.capa(Enums.Capa.Sieve))
2014-09-05 06:49:03 +08:00
{
2014-10-18 21:43:44 +08:00
kn.addSettingsViewModel(require('Settings/User/Filters'),
2014-09-05 06:49:03 +08:00
'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters');
}
if (Settings.capa(Enums.Capa.TwoFactor))
{
2014-10-18 21:43:44 +08:00
kn.addSettingsViewModel(require('Settings/User/Security'),
2014-09-05 06:49:03 +08:00
'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security');
}
2014-11-06 03:40:20 +08:00
if ((Settings.settingsGet('AllowGoogleSocial') && Settings.settingsGet('AllowGoogleSocialAuth')) ||
2014-09-05 06:49:03 +08:00
Settings.settingsGet('AllowFacebookSocial') ||
Settings.settingsGet('AllowTwitterSocial'))
{
2014-10-18 21:43:44 +08:00
kn.addSettingsViewModel(require('Settings/User/Social'),
2014-09-05 06:49:03 +08:00
'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social');
}
if (Settings.settingsGet('ChangePasswordIsAllowed'))
{
2014-10-18 21:43:44 +08:00
kn.addSettingsViewModel(require('Settings/User/ChangePassword'),
2014-09-05 06:49:03 +08:00
'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password');
}
if (Settings.capa(Enums.Capa.Templates))
{
kn.addSettingsViewModel(require('Settings/User/Templates'),
'SettingsTemplates', 'SETTINGS_LABELS/LABEL_TEMPLATES_NAME', 'templates');
}
2014-10-18 21:43:44 +08:00
kn.addSettingsViewModel(require('Settings/User/Folders'),
2014-09-05 06:49:03 +08:00
'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders');
if (Settings.capa(Enums.Capa.Themes))
{
2014-10-18 21:43:44 +08:00
kn.addSettingsViewModel(require('Settings/User/Themes'),
2014-09-05 06:49:03 +08:00
'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes');
}
if (Settings.capa(Enums.Capa.OpenPGP))
{
2014-10-18 21:43:44 +08:00
kn.addSettingsViewModel(require('Settings/User/OpenPgp'),
2014-09-05 06:49:03 +08:00
'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp');
}
if (fCallback)
{
fCallback();
}
};
2014-10-18 21:43:44 +08:00
SettingsUserScreen.prototype.onShow = function ()
2014-08-20 23:03:12 +08:00
{
2014-08-27 23:59:44 +08:00
this.setSettingsTitle();
2014-08-22 23:08:56 +08:00
Globals.keyScope(Enums.KeyState.Settings);
2014-08-20 23:03:12 +08:00
};
2014-10-18 21:43:44 +08:00
SettingsUserScreen.prototype.setSettingsTitle = function ()
2014-08-27 23:59:44 +08:00
{
2014-10-18 21:43:44 +08:00
require('App/User').setTitle(this.sSettingsTitle);
2014-08-27 23:59:44 +08:00
};
2014-08-20 23:03:12 +08:00
2014-10-18 21:43:44 +08:00
module.exports = SettingsUserScreen;
2014-08-20 23:03:12 +08:00
2014-09-05 06:49:03 +08:00
}());