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

View file

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