snappymail/dev/View/Popup/Languages.js
RainLoop Team 06274c6a7c Code refactoring
Fixed owncloud password encoder/decoder (#291)
Fixed ckeditor in ownCloud iframe (Closes #302)
Release commit
2014-09-06 01:44:29 +04:00

82 lines
No EOL
1.7 KiB
JavaScript

(function () {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Utils = require('Common/Utils'),
Globals = require('Common/Globals'),
kn = require('Knoin/Knoin'),
AbstractView = require('Knoin/AbstractView')
;
/**
* @constructor
* @extends AbstractView
*/
function LanguagesPopupView()
{
AbstractView.call(this, 'Popups', 'PopupsLanguages');
this.Data = Globals.__APP__.data(); // TODO
this.exp = ko.observable(false);
this.languages = ko.computed(function () {
return _.map(this.Data.languages(), function (sLanguage) {
return {
'key': sLanguage,
'selected': ko.observable(false),
'fullName': Utils.convertLangName(sLanguage)
};
});
}, this);
this.Data.mainLanguage.subscribe(function () {
this.resetMainLanguage();
}, this);
kn.constructorEnd(this);
}
kn.extendAsViewModel(['View/Popup/Languages', 'PopupsLanguagesViewModel'], LanguagesPopupView);
_.extend(LanguagesPopupView.prototype, AbstractView.prototype);
LanguagesPopupView.prototype.languageEnName = function (sLanguage)
{
return Utils.convertLangName(sLanguage, true);
};
LanguagesPopupView.prototype.resetMainLanguage = function ()
{
var sCurrent = this.Data.mainLanguage();
_.each(this.languages(), function (oItem) {
oItem['selected'](oItem['key'] === sCurrent);
});
};
LanguagesPopupView.prototype.onShow = function ()
{
this.exp(true);
this.resetMainLanguage();
};
LanguagesPopupView.prototype.onHide = function ()
{
this.exp(false);
};
LanguagesPopupView.prototype.changeLanguage = function (sLang)
{
this.Data.mainLanguage(sLang);
this.cancelCommand();
};
module.exports = LanguagesPopupView;
}());