2014-08-21 23:08:34 +08:00
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
(function () {
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2014-08-25 23:49:01 +08:00
|
|
|
'use strict';
|
2014-09-02 08:15:31 +08:00
|
|
|
|
2014-08-21 23:08:34 +08:00
|
|
|
var
|
2014-08-25 23:49:01 +08:00
|
|
|
_ = require('_'),
|
|
|
|
ko = require('ko'),
|
2014-08-25 15:10:51 +08:00
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
Enums = require('Common/Enums'),
|
|
|
|
Utils = require('Common/Utils'),
|
2014-10-06 02:37:31 +08:00
|
|
|
Links = require('Common/Links'),
|
2015-03-28 06:06:56 +08:00
|
|
|
Translator = require('Common/Translator'),
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2015-01-27 05:06:00 +08:00
|
|
|
ThemeStore = require('Stores/Theme'),
|
|
|
|
LanguageStore = require('Stores/Language'),
|
|
|
|
AppAdminStore = require('Stores/Admin/App'),
|
|
|
|
CapaAdminStore = require('Stores/Admin/Capa'),
|
2015-01-26 07:09:22 +08:00
|
|
|
|
2015-01-27 05:06:00 +08:00
|
|
|
Settings = require('Storage/Settings')
|
2014-08-21 23:08:34 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
2014-10-30 21:59:25 +08:00
|
|
|
function GeneralAdminSettings()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2015-01-27 05:06:00 +08:00
|
|
|
this.language = LanguageStore.language;
|
|
|
|
this.languages = LanguageStore.languages;
|
2015-03-28 06:06:56 +08:00
|
|
|
this.languageAdmin = LanguageStore.languageAdmin;
|
|
|
|
this.languagesAdmin = LanguageStore.languagesAdmin;
|
|
|
|
|
2015-01-27 05:06:00 +08:00
|
|
|
this.theme = ThemeStore.theme;
|
|
|
|
this.themes = ThemeStore.themes;
|
|
|
|
|
|
|
|
this.capaThemes = CapaAdminStore.themes;
|
|
|
|
this.capaUserBackground = CapaAdminStore.userBackground;
|
|
|
|
this.capaGravatar = CapaAdminStore.gravatar;
|
|
|
|
this.capaAdditionalAccounts = CapaAdminStore.additionalAccounts;
|
2015-05-18 04:38:20 +08:00
|
|
|
this.capaIdentities = CapaAdminStore.identities;
|
2015-01-27 05:06:00 +08:00
|
|
|
this.capaAttachmentThumbnails = CapaAdminStore.attachmentThumbnails;
|
2015-02-12 05:39:27 +08:00
|
|
|
this.capaTemplates = CapaAdminStore.templates;
|
2015-01-27 05:06:00 +08:00
|
|
|
|
|
|
|
this.allowLanguagesOnSettings = AppAdminStore.allowLanguagesOnSettings;
|
|
|
|
this.weakPassword = AppAdminStore.weakPassword;
|
2014-10-18 23:19:37 +08:00
|
|
|
|
2014-08-27 23:59:44 +08:00
|
|
|
this.mainAttachmentLimit = ko.observable(Utils.pInt(Settings.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25});
|
|
|
|
this.uploadData = Settings.settingsGet('PhpUploadSizes');
|
2016-06-28 04:54:38 +08:00
|
|
|
this.uploadDataDesc = this.uploadData && (this.uploadData.upload_max_filesize || this.uploadData.post_max_size) ? [
|
|
|
|
this.uploadData.upload_max_filesize ? 'upload_max_filesize = ' + this.uploadData.upload_max_filesize + '; ' : '',
|
|
|
|
this.uploadData.post_max_size ? 'post_max_size = ' + this.uploadData.post_max_size : ''
|
2014-10-18 23:19:37 +08:00
|
|
|
].join('') : '';
|
2014-08-21 23:08:34 +08:00
|
|
|
|
|
|
|
this.themesOptions = ko.computed(function () {
|
2015-01-26 07:09:22 +08:00
|
|
|
return _.map(this.themes(), function (sTheme) {
|
2014-08-21 23:08:34 +08:00
|
|
|
return {
|
2016-06-28 04:54:38 +08:00
|
|
|
optValue: sTheme,
|
|
|
|
optText: Utils.convertThemeName(sTheme)
|
2014-08-21 23:08:34 +08:00
|
|
|
};
|
|
|
|
});
|
2015-01-26 07:09:22 +08:00
|
|
|
}, this);
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2015-01-26 07:09:22 +08:00
|
|
|
this.languageFullName = ko.computed(function () {
|
|
|
|
return Utils.convertLangName(this.language());
|
2014-08-21 23:08:34 +08:00
|
|
|
}, this);
|
|
|
|
|
2015-03-28 06:06:56 +08:00
|
|
|
this.languageAdminFullName = ko.computed(function () {
|
|
|
|
return Utils.convertLangName(this.languageAdmin());
|
|
|
|
}, this);
|
|
|
|
|
2014-08-21 23:08:34 +08:00
|
|
|
this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
|
|
|
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
2015-03-28 06:06:56 +08:00
|
|
|
this.languageAdminTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
|
2014-08-21 23:08:34 +08:00
|
|
|
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
|
|
|
}
|
|
|
|
|
2014-10-30 21:59:25 +08:00
|
|
|
GeneralAdminSettings.prototype.onBuild = function ()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2014-08-25 15:10:51 +08:00
|
|
|
var
|
|
|
|
self = this,
|
2015-02-23 00:35:17 +08:00
|
|
|
Remote = require('Remote/Admin/Ajax')
|
2014-08-25 15:10:51 +08:00
|
|
|
;
|
|
|
|
|
2014-08-21 23:08:34 +08:00
|
|
|
_.delay(function () {
|
|
|
|
|
|
|
|
var
|
|
|
|
f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self),
|
|
|
|
f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self),
|
2015-03-28 06:06:56 +08:00
|
|
|
f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self),
|
|
|
|
fReloadLanguageHelper = function (iSaveSettingsStep) {
|
|
|
|
return function() {
|
|
|
|
self.languageAdminTrigger(iSaveSettingsStep);
|
|
|
|
_.delay(function () {
|
|
|
|
self.languageAdminTrigger(Enums.SaveSettingsStep.Idle);
|
|
|
|
}, 1000);
|
|
|
|
};
|
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
self.mainAttachmentLimit.subscribe(function (sValue) {
|
|
|
|
Remote.saveAdminConfig(f1, {
|
|
|
|
'AttachmentLimit': Utils.pInt(sValue)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
self.language.subscribe(function (sValue) {
|
|
|
|
Remote.saveAdminConfig(f2, {
|
|
|
|
'Language': Utils.trim(sValue)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-03-28 06:06:56 +08:00
|
|
|
self.languageAdmin.subscribe(function (sValue) {
|
|
|
|
|
|
|
|
self.languageAdminTrigger(Enums.SaveSettingsStep.Animate);
|
|
|
|
|
2016-06-17 07:23:49 +08:00
|
|
|
Translator.reload(true, sValue).then(
|
2015-03-28 06:06:56 +08:00
|
|
|
fReloadLanguageHelper(Enums.SaveSettingsStep.TrueResult),
|
2016-06-17 07:23:49 +08:00
|
|
|
fReloadLanguageHelper(Enums.SaveSettingsStep.FalseResult)
|
|
|
|
).then(function() {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'LanguageAdmin': Utils.trim(sValue)
|
|
|
|
});
|
2015-03-28 06:06:56 +08:00
|
|
|
});
|
2016-06-17 07:23:49 +08:00
|
|
|
|
2015-03-28 06:06:56 +08:00
|
|
|
});
|
|
|
|
|
2014-08-21 23:08:34 +08:00
|
|
|
self.theme.subscribe(function (sValue) {
|
2014-10-18 23:19:37 +08:00
|
|
|
|
2015-02-05 13:14:13 +08:00
|
|
|
Utils.changeTheme(sValue, self.themeTrigger);
|
2014-10-18 23:06:31 +08:00
|
|
|
|
2014-08-21 23:08:34 +08:00
|
|
|
Remote.saveAdminConfig(f3, {
|
|
|
|
'Theme': Utils.trim(sValue)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
self.capaAdditionalAccounts.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'CapaAdditionalAccounts': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-05-18 04:38:20 +08:00
|
|
|
self.capaIdentities.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'CapaIdentities': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-02-12 05:39:27 +08:00
|
|
|
self.capaTemplates.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'CapaTemplates': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-08-21 23:08:34 +08:00
|
|
|
self.capaGravatar.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'CapaGravatar': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-01-05 03:30:07 +08:00
|
|
|
self.capaAttachmentThumbnails.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'CapaAttachmentThumbnails': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-08-21 23:08:34 +08:00
|
|
|
self.capaThemes.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'CapaThemes': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-11-07 01:52:07 +08:00
|
|
|
self.capaUserBackground.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'CapaUserBackground': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-08-21 23:08:34 +08:00
|
|
|
self.allowLanguagesOnSettings.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'AllowLanguagesOnSettings': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}, 50);
|
|
|
|
};
|
|
|
|
|
2014-10-30 21:59:25 +08:00
|
|
|
GeneralAdminSettings.prototype.selectLanguage = function ()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2015-03-28 06:06:56 +08:00
|
|
|
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
|
|
|
|
this.language, this.languages(), LanguageStore.userLanguage()
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
|
|
|
|
GeneralAdminSettings.prototype.selectLanguageAdmin = function ()
|
|
|
|
{
|
|
|
|
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
|
|
|
|
this.languageAdmin, this.languagesAdmin(), LanguageStore.userLanguageAdmin()
|
|
|
|
]);
|
2014-08-21 23:08:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {string}
|
|
|
|
*/
|
2014-10-30 21:59:25 +08:00
|
|
|
GeneralAdminSettings.prototype.phpInfoLink = function ()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2014-10-06 02:37:31 +08:00
|
|
|
return Links.phpInfo();
|
2014-08-21 23:08:34 +08:00
|
|
|
};
|
|
|
|
|
2014-10-30 21:59:25 +08:00
|
|
|
module.exports = GeneralAdminSettings;
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-06-28 04:54:38 +08:00
|
|
|
}());
|