snappymail/dev/Settings/Admin/Branding.js

135 lines
3.7 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
2014-09-05 06:49:03 +08:00
Utils = require('Common/Utils')
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);
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);
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);
2014-10-24 01:59:21 +08:00
this.loginPowered = ko.observable(!!Settings.settingsGet('LoginPowered'));
2014-08-21 23:08:34 +08:00
}
BrandingAdminSettings.prototype.onBuild = function ()
2014-08-21 23:08:34 +08:00
{
2014-10-25 01:08:03 +08:00
if (this.capa)
{
2014-10-24 01:59:21 +08:00
var
2014-10-25 01:08:03 +08:00
self = this,
Remote = require('Storage/Admin/Remote')
2014-10-24 01:59:21 +08:00
;
_.delay(function () {
var
2014-10-25 01:08:03 +08:00
f1 = Utils.settingsSaveHelperSimpleFunction(self.title.trigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.loadingDesc.trigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.loginLogo.trigger, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.loginDescription.trigger, self),
2015-01-19 05:57:29 +08:00
f5 = Utils.settingsSaveHelperSimpleFunction(self.loginCss.trigger, self),
f6 = Utils.settingsSaveHelperSimpleFunction(self.userLogo.trigger, self),
f7 = Utils.settingsSaveHelperSimpleFunction(self.loginBackground.trigger, self),
f8 = Utils.settingsSaveHelperSimpleFunction(self.userCss.trigger, self)
;
2014-10-25 01:08:03 +08:00
self.title.subscribe(function (sValue) {
Remote.saveAdminConfig(f1, {
'Title': Utils.trim(sValue)
});
});
self.loadingDesc.subscribe(function (sValue) {
Remote.saveAdminConfig(f2, {
'LoadingDescription': Utils.trim(sValue)
});
});
self.loginLogo.subscribe(function (sValue) {
Remote.saveAdminConfig(f3, {
'LoginLogo': Utils.trim(sValue)
});
2014-08-21 23:08:34 +08:00
});
self.loginBackground.subscribe(function (sValue) {
Remote.saveAdminConfig(f7, {
'LoginBackground': Utils.trim(sValue)
});
});
2015-01-19 05:57:29 +08:00
self.userLogo.subscribe(function (sValue) {
Remote.saveAdminConfig(f6, {
'UserLogo': Utils.trim(sValue)
});
});
self.loginDescription.subscribe(function (sValue) {
Remote.saveAdminConfig(f4, {
'LoginDescription': Utils.trim(sValue)
});
2014-08-21 23:08:34 +08:00
});
self.loginCss.subscribe(function (sValue) {
Remote.saveAdminConfig(f5, {
'LoginCss': Utils.trim(sValue)
});
2014-08-21 23:08:34 +08:00
});
self.userCss.subscribe(function (sValue) {
Remote.saveAdminConfig(f8, {
'UserCss': Utils.trim(sValue)
});
});
2014-10-24 01:59:21 +08:00
self.loginPowered.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'LoginPowered': bValue ? '1' : '0'
});
});
2014-10-25 01:08:03 +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
}());