mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-15 12:15:20 +08:00
81 lines
No EOL
1.7 KiB
JavaScript
81 lines
No EOL
1.7 KiB
JavaScript
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
|
|
(function (module, require) {
|
|
|
|
'use strict';
|
|
|
|
var
|
|
_ = require('_'),
|
|
ko = require('ko'),
|
|
|
|
Utils = require('Utils'),
|
|
|
|
Data = require('Storage:RainLoop:Data'),
|
|
|
|
kn = require('App:Knoin'),
|
|
KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
|
|
;
|
|
|
|
/**
|
|
* @constructor
|
|
* @extends KnoinAbstractViewModel
|
|
*/
|
|
function PopupsLanguagesViewModel()
|
|
{
|
|
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsLanguages');
|
|
|
|
this.exp = ko.observable(false);
|
|
|
|
this.languages = ko.computed(function () {
|
|
return _.map(Data.languages(), function (sLanguage) {
|
|
return {
|
|
'key': sLanguage,
|
|
'selected': ko.observable(false),
|
|
'fullName': Utils.convertLangName(sLanguage)
|
|
};
|
|
});
|
|
});
|
|
|
|
Data.mainLanguage.subscribe(function () {
|
|
this.resetMainLanguage();
|
|
}, this);
|
|
|
|
kn.constructorEnd(this);
|
|
}
|
|
|
|
kn.extendAsViewModel('PopupsLanguagesViewModel', PopupsLanguagesViewModel);
|
|
|
|
PopupsLanguagesViewModel.prototype.languageEnName = function (sLanguage)
|
|
{
|
|
return Utils.convertLangName(sLanguage, true);
|
|
};
|
|
|
|
PopupsLanguagesViewModel.prototype.resetMainLanguage = function ()
|
|
{
|
|
var sCurrent = Data.mainLanguage();
|
|
_.each(this.languages(), function (oItem) {
|
|
oItem['selected'](oItem['key'] === sCurrent);
|
|
});
|
|
};
|
|
|
|
PopupsLanguagesViewModel.prototype.onShow = function ()
|
|
{
|
|
this.exp(true);
|
|
|
|
this.resetMainLanguage();
|
|
};
|
|
|
|
PopupsLanguagesViewModel.prototype.onHide = function ()
|
|
{
|
|
this.exp(false);
|
|
};
|
|
|
|
PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang)
|
|
{
|
|
Data.mainLanguage(sLang);
|
|
this.cancelCommand();
|
|
};
|
|
|
|
module.exports = PopupsLanguagesViewModel;
|
|
|
|
}(module, require)); |