snappymail/dev/Settings/Admin/AdminSettingsBranding.js

92 lines
2.3 KiB
JavaScript
Raw Normal View History

2014-08-21 23:08:34 +08:00
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
2014-08-25 23:49:01 +08:00
(function (module, require) {
'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-08-25 23:49:01 +08:00
Utils = require('Utils')
2014-08-21 23:08:34 +08:00
;
/**
* @constructor
*/
function AdminSettingsBranding()
{
2014-08-25 15:10:51 +08:00
var
2014-08-25 23:49:01 +08:00
Enums = require('Enums'),
2014-08-27 23:59:44 +08:00
Settings = require('Storage:Settings')
2014-08-25 15:10:51 +08:00
;
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);
2014-08-27 23:59:44 +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);
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);
}
AdminSettingsBranding.prototype.onBuild = function ()
{
2014-08-25 15:10:51 +08:00
var
self = this,
2014-08-27 23:59:44 +08:00
Remote = require('Storage:Admin:Remote')
2014-08-25 15:10:51 +08:00
;
2014-08-21 23:08:34 +08:00
_.delay(function () {
var
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),
f5 = Utils.settingsSaveHelperSimpleFunction(self.loginCss.trigger, self)
;
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)
});
});
self.loginDescription.subscribe(function (sValue) {
Remote.saveAdminConfig(f4, {
'LoginDescription': Utils.trim(sValue)
});
});
self.loginCss.subscribe(function (sValue) {
Remote.saveAdminConfig(f5, {
'LoginCss': Utils.trim(sValue)
});
});
}, 50);
};
module.exports = AdminSettingsBranding;
2014-08-25 23:49:01 +08:00
}(module, require));