snappymail/dev/Stores/Language.js

56 lines
1.2 KiB
JavaScript
Raw Normal View History

(function () {
'use strict';
var
ko = require('ko'),
Utils = require('Common/Utils'),
Settings = require('Storage/Settings')
;
/**
* @constructor
*/
function LanguageStore()
{
this.languages = ko.observableArray([]);
2015-03-28 06:06:56 +08:00
this.languagesAdmin = ko.observableArray([]);
this.language = ko.observable('')
2016-06-17 07:23:49 +08:00
.extend({'limitedList': this.languages})
.extend({'reversible': true})
;
2015-03-28 06:06:56 +08:00
this.languageAdmin = ko.observable('')
2016-06-17 07:23:49 +08:00
.extend({'limitedList': this.languagesAdmin})
.extend({'reversible': true})
;
2015-03-28 06:06:56 +08:00
2015-04-17 21:56:29 +08:00
this.userLanguage = ko.observable('');
this.userLanguageAdmin = ko.observable('');
}
LanguageStore.prototype.populate = function ()
{
2015-03-16 21:54:56 +08:00
var
2016-05-03 04:42:29 +08:00
aLanguages = Settings.appSettingsGet('languages'),
aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin')
2015-03-16 21:54:56 +08:00
;
this.languages(Utils.isArray(aLanguages) ? aLanguages : []);
2015-03-28 06:06:56 +08:00
this.languagesAdmin(Utils.isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);
2015-03-16 21:54:56 +08:00
this.language(Settings.settingsGet('Language'));
2015-03-28 06:06:56 +08:00
this.languageAdmin(Settings.settingsGet('LanguageAdmin'));
this.userLanguage(Settings.settingsGet('UserLanguage'));
this.userLanguageAdmin(Settings.settingsGet('UserLanguageAdmin'));
};
module.exports = new LanguageStore();
}());