snappymail/dev/Stores/Language.js

52 lines
1.1 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('')
.extend({'limitedList': this.languages});
2015-03-28 06:06:56 +08:00
this.languageAdmin = ko.observable('')
.extend({'limitedList': this.languagesAdmin});
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
aLanguages = Settings.settingsGet('Languages'),
2015-03-28 06:06:56 +08:00
aLanguagesAdmin = Settings.settingsGet('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();
}());