[SSE] Spell checking settings

This commit is contained in:
Julia Svinareva 2019-11-28 16:13:50 +03:00
parent 997eb2f678
commit b940aa67d7
2 changed files with 22 additions and 6 deletions

View file

@ -122,6 +122,9 @@ define([
setLanguages: function (array) {
this.languages = array;
this._initSettings = true;
if (this.panelSpellcheck.cmbDictionaryLanguage.store.length > 0) {
this.panelSpellcheck.cmbDictionaryLanguage.store.reset();
}
},
loadLanguages: function () {
@ -155,19 +158,25 @@ define([
}
this._initSettings = false;
return [this.allLangs, this.langs];
var change = this.panelSpellcheck.cmbDictionaryLanguage.store.length === 0;
return [this.allLangs, this.langs, change];
},
updateLanguages: function() {
var sessionValue = Common.Utils.InternalSettings.get("sse-spellcheck-locale"),
value;
value,
isApply = false;
if (sessionValue)
value = parseInt(sessionValue);
else
value = this.mode.lang ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.mode.lang)) : 0x0409;
var combo = this.panelSpellcheck.cmbDictionaryLanguage;
if (this.langs && this.langs.length>0) {
combo.setData(this.langs);
if (combo.store.length === 0) {
combo.setData(this.langs);
isApply = true;
}
var item = combo.store.findWhere({value: value});
if (!item && this.allLangs[value]) {
value = this.allLangs[value][0].split(/[\-\_]/)[0];
@ -181,11 +190,12 @@ define([
combo.setValue(Common.util.LanguageInfo.getLocalLanguageName(value)[1]);
combo.setDisabled(true);
}
if (this.api) {
if (isApply && this.api) {
this.api.asc_setDefaultLanguage(value);
if (value !== parseInt(sessionValue)) {
Common.Utils.InternalSettings.set("sse-spellcheck-locale", value);
}
isApply = false;
}
},

View file

@ -233,6 +233,9 @@ define([
this.viewSettingsPicker.store.pop();
this.generalSettings && this.generalSettings.setMode(this.mode);
this.spellcheckSettings && this.spellcheckSettings.setMode(this.mode);
if (!this.mode.isEdit) {
$(this.viewSettingsPicker.dataViewItems[2].el).hide();
}
},
setApi: function(api) {
@ -1043,7 +1046,8 @@ define([
updateSettings: function() {
var arrLang = SSE.getController('Spellcheck').loadLanguages(),
allLangs = arrLang[0],
langs = arrLang[1];
langs = arrLang[1],
change = arrLang[2];
var sessionValue = Common.Utils.InternalSettings.get("sse-spellcheck-locale"),
value;
if (sessionValue)
@ -1051,7 +1055,9 @@ define([
else
value = this.mode.lang ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.mode.lang)) : 0x0409;
if (langs && langs.length > 0) {
this.cmbDictionaryLanguage.setData(langs);
if (this.cmbDictionaryLanguage.store.length === 0 || change) {
this.cmbDictionaryLanguage.setData(langs);
}
var item = this.cmbDictionaryLanguage.store.findWhere({value: value});
if (!item && allLangs[value]) {
value = allLangs[value][0].split(/[\-\_]/)[0];