2013-11-16 06:21:12 +08:00
|
|
|
|
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'),
|
2015-01-26 07:09:22 +08:00
|
|
|
Translator = require('Common/Translator'),
|
2014-09-05 06:49:03 +08:00
|
|
|
|
2015-01-27 05:06:00 +08:00
|
|
|
AppStore = require('Stores/User/App'),
|
2014-09-06 05:44:29 +08:00
|
|
|
Settings = require('Storage/Settings'),
|
2014-09-05 06:49:03 +08:00
|
|
|
|
2014-09-06 05:44:29 +08:00
|
|
|
kn = require('Knoin/Knoin'),
|
2014-08-22 23:08:56 +08:00
|
|
|
|
2014-09-06 05:44:29 +08:00
|
|
|
AbstractSettingsScreen = require('Screen/AbstractSettings')
|
2014-08-20 23:03:12 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
2014-09-02 08:15:31 +08:00
|
|
|
* @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
|
|
|
{
|
2014-09-02 08:15:31 +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
|
|
|
]);
|
|
|
|
|
2015-01-26 07:09:22 +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);
|
|
|
|
|
2015-01-27 05:06:00 +08:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
2014-12-02 01:34:21 +08:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
2015-02-12 05:39:27 +08:00
|
|
|
if (Settings.capa(Enums.Capa.Templates))
|
|
|
|
{
|
|
|
|
kn.addSettingsViewModel(require('Settings/User/Templates'),
|
|
|
|
'SettingsTemplates', 'SETTINGS_LABELS/LABEL_TEMPLATES_NAME', 'templates');
|
|
|
|
}
|
2015-02-08 09:11:13 +08:00
|
|
|
|
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-09-02 08:15:31 +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
|
|
|
}());
|