mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 03:29:20 +03:00
Language popup otimizations
This commit is contained in:
parent
d0efae7d35
commit
9bec1d0a8f
6 changed files with 109 additions and 23 deletions
|
|
@ -4,6 +4,7 @@
|
|||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
|
@ -17,6 +18,7 @@
|
|||
function LanguageStore()
|
||||
{
|
||||
this.languages = ko.observableArray([]);
|
||||
this.languagesTop = ko.observableArray([]);
|
||||
|
||||
this.language = ko.observable('')
|
||||
.extend({'limitedList': this.languages});
|
||||
|
|
@ -24,9 +26,14 @@
|
|||
|
||||
LanguageStore.prototype.populate = function ()
|
||||
{
|
||||
var aLanguages = Settings.settingsGet('Languages');
|
||||
var
|
||||
aLanguages = Settings.settingsGet('Languages'),
|
||||
aLanguagesTop = Settings.settingsGet('LanguagesTop')
|
||||
;
|
||||
|
||||
this.languages(Utils.isArray(aLanguages) ? aLanguages : []);
|
||||
this.languagesTop(Utils.isArray(aLanguagesTop) ? aLanguagesTop : []);
|
||||
|
||||
this.language(Settings.settingsGet('Language'));
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,38 @@
|
|||
});
|
||||
}, this);
|
||||
|
||||
this.languagesTop = ko.computed(function () {
|
||||
|
||||
var
|
||||
aTop = this.LanguageStore.languagesTop(),
|
||||
aLangs = this.languages()
|
||||
;
|
||||
|
||||
return 0 < aTop.length ? _.compact(_.map(aTop, function (sLang) {
|
||||
return _.find(aLangs, function (aItem) {
|
||||
return aItem && sLang === aItem.key;
|
||||
});
|
||||
})) : [];
|
||||
}, this);
|
||||
|
||||
this.languagesBottom = ko.computed(function () {
|
||||
|
||||
var
|
||||
aTop = this.languagesTop(),
|
||||
aLangs = this.languages()
|
||||
;
|
||||
|
||||
if (0 < aTop.length)
|
||||
{
|
||||
return _.filter(aLangs, function (aItem) {
|
||||
return -1 === Utils.inArray(aItem, aTop);
|
||||
});
|
||||
}
|
||||
|
||||
return aLangs;
|
||||
|
||||
}, this);
|
||||
|
||||
this.LanguageStore.language.subscribe(function () {
|
||||
this.resetMainLanguage();
|
||||
}, this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue