mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 13:39:22 +03:00
es5 -> es2015 (last stage)
Signature plugin fixes Add view decorator A large number of fixes
This commit is contained in:
parent
e88c193334
commit
17669b7be0
153 changed files with 21193 additions and 21115 deletions
|
|
@ -1,88 +1,76 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
import {convertLangName} from 'Common/Utils';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LanguagesPopupView()
|
||||
@view({
|
||||
name: 'View/Popup/Languages',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsLanguages'
|
||||
})
|
||||
class LanguagesPopupView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsLanguages');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
var self = this;
|
||||
this.fLang = null;
|
||||
this.userLanguage = ko.observable('');
|
||||
|
||||
this.fLang = null;
|
||||
this.userLanguage = ko.observable('');
|
||||
this.langs = ko.observableArray([]);
|
||||
|
||||
this.langs = ko.observableArray([]);
|
||||
|
||||
this.languages = ko.computed(function() {
|
||||
var sUserLanguage = self.userLanguage();
|
||||
return _.map(self.langs(), function(sLanguage) {
|
||||
return {
|
||||
'key': sLanguage,
|
||||
'user': sLanguage === sUserLanguage,
|
||||
'selected': ko.observable(false),
|
||||
'fullName': Utils.convertLangName(sLanguage)
|
||||
};
|
||||
this.languages = ko.computed(() => {
|
||||
const userLanguage = this.userLanguage();
|
||||
return _.map(this.langs(), (language) => ({
|
||||
key: language,
|
||||
user: language === userLanguage,
|
||||
selected: ko.observable(false),
|
||||
fullName: convertLangName(language)
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
this.langs.subscribe(function() {
|
||||
this.setLanguageSelection();
|
||||
}, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Languages', 'PopupsLanguagesViewModel'], LanguagesPopupView);
|
||||
_.extend(LanguagesPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
LanguagesPopupView.prototype.languageTooltipName = function(sLanguage)
|
||||
{
|
||||
var sResult = Utils.convertLangName(sLanguage, true);
|
||||
return Utils.convertLangName(sLanguage, false) === sResult ? '' : sResult;
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.setLanguageSelection = function()
|
||||
{
|
||||
var currentLang = this.fLang ? ko.unwrap(this.fLang) : '';
|
||||
_.each(this.languages(), function(item) {
|
||||
item.selected(item.key === currentLang);
|
||||
});
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.onBeforeShow = function()
|
||||
{
|
||||
this.fLang = null;
|
||||
this.userLanguage('');
|
||||
|
||||
this.langs([]);
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.onShow = function(fLanguage, aLangs, sUserLanguage)
|
||||
{
|
||||
this.fLang = fLanguage;
|
||||
this.userLanguage(sUserLanguage || '');
|
||||
|
||||
this.langs(aLangs);
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.changeLanguage = function(sLang)
|
||||
{
|
||||
if (this.fLang)
|
||||
{
|
||||
this.fLang(sLang);
|
||||
this.langs.subscribe(() => {
|
||||
this.setLanguageSelection();
|
||||
});
|
||||
}
|
||||
|
||||
this.cancelCommand();
|
||||
};
|
||||
languageTooltipName(language) {
|
||||
const result = convertLangName(language, true);
|
||||
return convertLangName(language, false) === result ? '' : result;
|
||||
}
|
||||
|
||||
setLanguageSelection() {
|
||||
const currentLang = this.fLang ? ko.unwrap(this.fLang) : '';
|
||||
_.each(this.languages(), (item) => {
|
||||
item.selected(item.key === currentLang);
|
||||
});
|
||||
}
|
||||
|
||||
onBeforeShow() {
|
||||
this.fLang = null;
|
||||
this.userLanguage('');
|
||||
|
||||
this.langs([]);
|
||||
}
|
||||
|
||||
onShow(fLanguage, langs, userLanguage) {
|
||||
this.fLang = fLanguage;
|
||||
this.userLanguage(userLanguage || '');
|
||||
|
||||
this.langs(langs);
|
||||
}
|
||||
|
||||
changeLanguage(lang) {
|
||||
if (this.fLang)
|
||||
{
|
||||
this.fLang(lang);
|
||||
}
|
||||
|
||||
this.cancelCommand();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = LanguagesPopupView;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue