[SSE] Spellcheck refactoring
This commit is contained in:
parent
3286d33058
commit
5efad36585
|
@ -126,12 +126,13 @@ define([
|
|||
var langs = [], info,
|
||||
allLangs = Common.util.LanguageInfo.getLanguages();
|
||||
this.languages.forEach(function (code) {
|
||||
if (allLangs.hasOwnProperty(parseInt(code))) {
|
||||
info = allLangs[parseInt(code)];
|
||||
code = parseInt(code);
|
||||
if (allLangs.hasOwnProperty(code)) {
|
||||
info = allLangs[code];
|
||||
langs.push({
|
||||
displayValue: info[1],
|
||||
shortName: info[0],
|
||||
value: parseInt(code)
|
||||
value: code
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -141,14 +142,15 @@ define([
|
|||
return 0;
|
||||
});
|
||||
combo.setData(langs);
|
||||
if (value) {
|
||||
var item = combo.store.findWhere({value: value});
|
||||
combo.setValue(item ? item.get('value') : 0x0409);
|
||||
value = combo.getValue();
|
||||
} else {
|
||||
value = this.mode.lang ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.mode.lang)) : 0x0409;
|
||||
combo.setValue(Common.util.LanguageInfo.getLocalLanguageName(value)[1]);
|
||||
if (!item && allLangs[value]) {
|
||||
value = allLangs[value][0].split(/[\-\_]/)[0];
|
||||
item = combo.store.find(function(model){
|
||||
return model.get('shortName').indexOf(value)==0;
|
||||
});
|
||||
}
|
||||
combo.setValue(item ? item.get('value') : langs[0].value);
|
||||
value = combo.getValue();
|
||||
} else {
|
||||
combo.setValue(Common.util.LanguageInfo.getLocalLanguageName(value)[1]);
|
||||
combo.setDisabled(true);
|
||||
|
@ -201,11 +203,11 @@ define([
|
|||
onSpellCheckVariantsFound: function (property) {
|
||||
this._currentSpellObj = property;
|
||||
|
||||
var word = property.get_Word();
|
||||
this.panelSpellcheck.currentWord.setValue(word);
|
||||
|
||||
var variants = property.get_Variants(),
|
||||
arr = [];
|
||||
var arr = [],
|
||||
word;
|
||||
if (property) {
|
||||
word = property.get_Word();
|
||||
var variants = property.get_Variants();
|
||||
variants.forEach(function (item) {
|
||||
var rec = new Common.UI.DataViewModel();
|
||||
rec.set({
|
||||
|
@ -213,7 +215,14 @@ define([
|
|||
});
|
||||
arr.push(rec);
|
||||
});
|
||||
}
|
||||
this.panelSpellcheck.currentWord.setValue(word || '');
|
||||
this.panelSpellcheck.suggestionList.store.reset(arr);
|
||||
this.panelSpellcheck.currentWord.setDisabled(!word);
|
||||
this.panelSpellcheck.btnChange.setDisabled(arr.length<1);
|
||||
this.panelSpellcheck.btnIgnore.setDisabled(!word);
|
||||
this.panelSpellcheck.btnToDictionary.setDisabled(!word);
|
||||
this.panelSpellcheck.lblComplete.toggleClass('hidden', !property || !!word);
|
||||
}
|
||||
|
||||
}, SSE.Controllers.Spellcheck || {}));
|
||||
|
|
|
@ -58,7 +58,7 @@ define([
|
|||
'<div id="spellcheck-change" style="width: 105px; display: inline-block; padding-bottom: 16px;"></div><div id="spellcheck-ignore" class="padding-large" style="margin-left: 19px; width: 105px; display: inline-block;"></div>',
|
||||
'<button class="btn btn-text-default" id="spellcheck-add-to-dictionary" style="width: 105px; display: block; margin-bottom: 16px;"><%= scope.txtAddToDictionary %></button>',
|
||||
'<label class="header"><%= scope.txtDictionaryLanguage %></label><div id="spellcheck-dictionary-language" style="margin-top: 3px; padding-bottom: 16px;"></div>',
|
||||
'<div id="spellcheck-complete" style="display: flex;"><i class="img-commonctrl img-complete" style="display: inline-block;margin-right: 10px;"></i><%= scope.txtComplete %></div>',
|
||||
'<div id="spellcheck-complete" style="display: flex;" class="hidden"><i class="img-commonctrl img-complete" style="display: inline-block;margin-right: 10px;"></i><%= scope.txtComplete %></div>',
|
||||
'</div>'
|
||||
].join('')),
|
||||
|
||||
|
@ -145,6 +145,7 @@ define([
|
|||
el: $('#spellcheck-add-to-dictionary')
|
||||
});
|
||||
|
||||
this.lblComplete = this.$el.find('#spellcheck-complete');
|
||||
this.trigger('render:after', this);
|
||||
return this;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue