snappymail/dev/Settings/Admin/Branding.js

121 lines
3.9 KiB
JavaScript
Raw Normal View History

2014-08-21 23:08:34 +08:00
2014-09-05 06:49:03 +08:00
(function () {
2014-08-25 23:49:01 +08:00
'use strict';
2014-08-21 23:08:34 +08:00
var
2014-08-25 23:49:01 +08:00
_ = require('_'),
ko = require('ko'),
2014-08-22 23:08:56 +08:00
2015-04-10 06:05:49 +08:00
Utils = require('Common/Utils'),
Translator = require('Common/Translator')
2014-08-21 23:08:34 +08:00
;
/**
* @constructor
*/
function BrandingAdminSettings()
2014-08-21 23:08:34 +08:00
{
2014-08-25 15:10:51 +08:00
var
2014-09-05 06:49:03 +08:00
Enums = require('Common/Enums'),
2015-02-03 18:42:06 +08:00
Settings = require('Storage/Settings'),
AppStore = require('Stores/Admin/App')
2014-08-25 15:10:51 +08:00
;
2015-02-03 18:42:06 +08:00
this.capa = AppStore.prem;
2014-08-27 23:59:44 +08:00
this.title = ko.observable(Settings.settingsGet('Title'));
2014-08-21 23:08:34 +08:00
this.title.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
2014-08-27 23:59:44 +08:00
this.loadingDesc = ko.observable(Settings.settingsGet('LoadingDescription'));
2014-08-21 23:08:34 +08:00
this.loadingDesc.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.faviconUrl = ko.observable(Settings.settingsGet('FaviconUrl'));
this.faviconUrl.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
2015-01-19 05:57:29 +08:00
this.loginLogo = ko.observable(Settings.settingsGet('LoginLogo') || '');
2014-08-21 23:08:34 +08:00
this.loginLogo.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loginBackground = ko.observable(Settings.settingsGet('LoginBackground') || '');
this.loginBackground.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
2015-01-19 05:57:29 +08:00
this.userLogo = ko.observable(Settings.settingsGet('UserLogo') || '');
this.userLogo.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.userLogoMessage = ko.observable(Settings.settingsGet('UserLogoMessage') || '');
this.userLogoMessage.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.userIframeMessage = ko.observable(Settings.settingsGet('UserIframeMessage') || '');
this.userIframeMessage.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
2015-04-29 04:28:30 +08:00
this.userLogoTitle = ko.observable(Settings.settingsGet('UserLogoTitle') || '');
this.userLogoTitle.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
2014-08-27 23:59:44 +08:00
this.loginDescription = ko.observable(Settings.settingsGet('LoginDescription'));
2014-08-21 23:08:34 +08:00
this.loginDescription.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
2014-08-27 23:59:44 +08:00
this.loginCss = ko.observable(Settings.settingsGet('LoginCss'));
2014-08-21 23:08:34 +08:00
this.loginCss.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
2014-10-24 01:59:21 +08:00
this.userCss = ko.observable(Settings.settingsGet('UserCss'));
this.userCss.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
2015-04-10 06:05:49 +08:00
this.welcomePageUrl = ko.observable(Settings.settingsGet('WelcomePageUrl'));
this.welcomePageUrl.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.welcomePageDisplay = ko.observable(Settings.settingsGet('WelcomePageDisplay'));
this.welcomePageDisplay.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.welcomePageDisplay.options = ko.computed(function () {
Translator.trigger();
return [
{'optValue': 'none', 'optText': Translator.i18n('TAB_BRANDING/OPTION_WELCOME_PAGE_DISPLAY_NONE')},
{'optValue': 'once', 'optText': Translator.i18n('TAB_BRANDING/OPTION_WELCOME_PAGE_DISPLAY_ONCE')},
{'optValue': 'always', 'optText': Translator.i18n('TAB_BRANDING/OPTION_WELCOME_PAGE_DISPLAY_ALWAYS')}
];
});
2014-10-24 01:59:21 +08:00
this.loginPowered = ko.observable(!!Settings.settingsGet('LoginPowered'));
2015-05-03 04:22:32 +08:00
this.community = RL_COMMUNITY || AppStore.community();
2014-08-21 23:08:34 +08:00
}
BrandingAdminSettings.prototype.onBuild = function ()
2014-08-21 23:08:34 +08:00
{
2015-04-10 16:17:49 +08:00
var
self = this,
Remote = require('Remote/Admin/Ajax')
;
2014-10-24 01:59:21 +08:00
2015-04-17 21:56:29 +08:00
_.delay(function () {
2015-04-10 16:17:49 +08:00
2015-04-17 21:56:29 +08:00
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.title.trigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.loadingDesc.trigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.faviconUrl.trigger, self)
2015-04-17 21:56:29 +08:00
;
self.title.subscribe(function (sValue) {
Remote.saveAdminConfig(f1, {
'Title': Utils.trim(sValue)
2015-04-10 16:17:49 +08:00
});
2015-04-17 21:56:29 +08:00
});
2015-04-10 16:17:49 +08:00
2015-04-17 21:56:29 +08:00
self.loadingDesc.subscribe(function (sValue) {
Remote.saveAdminConfig(f2, {
'LoadingDescription': Utils.trim(sValue)
2015-04-10 16:17:49 +08:00
});
2015-04-17 21:56:29 +08:00
});
2015-04-10 16:17:49 +08:00
self.faviconUrl.subscribe(function (sValue) {
Remote.saveAdminConfig(f3, {
'FaviconUrl': Utils.trim(sValue)
});
});
2015-04-17 21:56:29 +08:00
}, 50);
2014-08-21 23:08:34 +08:00
};
module.exports = BrandingAdminSettings;
2014-08-21 23:08:34 +08:00
2014-09-05 06:49:03 +08:00
}());