snappymail/dev/Stores/Language.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

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