[SSE] Load spellcheck languages
This commit is contained in:
parent
b73a916af4
commit
57d7a0c701
|
@ -164,6 +164,7 @@ define([
|
||||||
this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this));
|
this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this));
|
||||||
this.api.asc_registerCallback('asc_onPrintUrl', _.bind(this.onPrintUrl, this));
|
this.api.asc_registerCallback('asc_onPrintUrl', _.bind(this.onPrintUrl, this));
|
||||||
this.api.asc_registerCallback('asc_onMeta', _.bind(this.onMeta, this));
|
this.api.asc_registerCallback('asc_onMeta', _.bind(this.onMeta, this));
|
||||||
|
this.api.asc_registerCallback('asc_onSpellCheckInit', _.bind(this.loadLanguages, this));
|
||||||
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
|
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
|
||||||
Common.NotificationCenter.on('goback', _.bind(this.goBack, this));
|
Common.NotificationCenter.on('goback', _.bind(this.goBack, this));
|
||||||
Common.NotificationCenter.on('namedrange:locked', _.bind(this.onNamedRangeLocked, this));
|
Common.NotificationCenter.on('namedrange:locked', _.bind(this.onNamedRangeLocked, this));
|
||||||
|
@ -742,6 +743,7 @@ define([
|
||||||
|
|
||||||
documentHolderView.createDelayedElements();
|
documentHolderView.createDelayedElements();
|
||||||
toolbarController.createDelayedElements();
|
toolbarController.createDelayedElements();
|
||||||
|
me.setLanguages();
|
||||||
|
|
||||||
if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) {
|
if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) {
|
||||||
var shapes = me.api.asc_getPropertyEditorShapes();
|
var shapes = me.api.asc_getPropertyEditorShapes();
|
||||||
|
@ -1817,6 +1819,15 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
loadLanguages: function(apiLangs) {
|
||||||
|
this.languages = apiLangs;
|
||||||
|
window.styles_loaded && this.setLanguages();
|
||||||
|
},
|
||||||
|
|
||||||
|
setLanguages: function() {
|
||||||
|
this.getApplication().getController('Spellcheck').setLanguages(this.languages);
|
||||||
|
},
|
||||||
|
|
||||||
onInternalCommand: function(data) {
|
onInternalCommand: function(data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
switch (data.command) {
|
switch (data.command) {
|
||||||
|
|
|
@ -54,6 +54,7 @@ define([
|
||||||
this.addListeners({
|
this.addListeners({
|
||||||
'Spellcheck': {
|
'Spellcheck': {
|
||||||
'show': function() {
|
'show': function() {
|
||||||
|
me.loadLanguages();
|
||||||
if (me.api) {
|
if (me.api) {
|
||||||
me.api.asc_startSpellCheck();
|
me.api.asc_startSpellCheck();
|
||||||
}
|
}
|
||||||
|
@ -76,18 +77,21 @@ define([
|
||||||
|
|
||||||
setApi: function(api) {
|
setApi: function(api) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.api.asc_registerCallback('asc_onSpellCheckInit',_.bind(this.loadLanguages, this));
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
setMode: function(mode) {
|
setMode: function(mode) {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
|
if (this.panelSpellcheck) {
|
||||||
|
this.panelSpellcheck.btnToDictionary.setVisible(mode.isDesktopApp);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
onAfterRender: function(panelSpellcheck) {
|
onAfterRender: function(panelSpellcheck) {
|
||||||
panelSpellcheck.buttonPreview.on('click', _.bind(this.onClickPreview, this));
|
panelSpellcheck.buttonPreview.on('click', _.bind(this.onClickPreview, this));
|
||||||
panelSpellcheck.buttonNext.on('click', _.bind(this.onClickNext, this));
|
panelSpellcheck.buttonNext.on('click', _.bind(this.onClickNext, this));
|
||||||
|
panelSpellcheck.btnToDictionary.on('click', _.bind(this.onDictionary, this));
|
||||||
panelSpellcheck.cmbDictionaryLanguage.on('selected', _.bind(this.onSelectLanguage, this));
|
panelSpellcheck.cmbDictionaryLanguage.on('selected', _.bind(this.onSelectLanguage, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -103,29 +107,42 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onDictionary: function() {
|
||||||
|
if (this.api) {
|
||||||
|
var rec = this.panelSpellcheck.suggestionList.getSelectedRec();
|
||||||
|
rec && this.api.asc_AddToDictionary(rec.get('value'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
SetDisabled: function(state) {
|
SetDisabled: function(state) {
|
||||||
this._isDisabled = state;
|
this._isDisabled = state;
|
||||||
},
|
},
|
||||||
|
|
||||||
loadLanguages: function (apiLangs) {
|
setLanguages: function (array) {
|
||||||
|
this.languages = array;
|
||||||
|
},
|
||||||
|
|
||||||
|
loadLanguages: function () {
|
||||||
|
if (this.languages && this.languages.length>0) {
|
||||||
var langs = [], info,
|
var langs = [], info,
|
||||||
allLangs = Common.util.LanguageInfo.getLanguages();
|
allLangs = Common.util.LanguageInfo.getLanguages();
|
||||||
apiLangs.forEach(function (code) {
|
this.languages.forEach(function (code) {
|
||||||
if (allLangs.hasOwnProperty(parseInt(code))) {
|
if (allLangs.hasOwnProperty(parseInt(code))) {
|
||||||
info = allLangs[parseInt(code)];
|
info = allLangs[parseInt(code)];
|
||||||
langs.push({
|
langs.push({
|
||||||
displayValue: info[1],
|
displayValue: info[1],
|
||||||
value: info[0],
|
value: info[0],
|
||||||
code: parseInt(code),
|
code: parseInt(code)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.languages = langs;
|
this.panelSpellcheck.cmbDictionaryLanguage.setData(langs);
|
||||||
this.panelSpellcheck.cmbDictionaryLanguage.setData(this.languages);
|
|
||||||
/*var codeCurLang = this.api.asc_getDefaultLanguage();*/
|
/*var codeCurLang = this.api.asc_getDefaultLanguage();*/
|
||||||
var codeCurLang = 1036;
|
var codeCurLang = 1036;
|
||||||
var curLang = allLangs[codeCurLang][0];
|
var curLang = allLangs[codeCurLang][0];
|
||||||
this.panelSpellcheck.cmbDictionaryLanguage.setValue(curLang);
|
this.panelSpellcheck.cmbDictionaryLanguage.setValue(curLang);
|
||||||
|
} else
|
||||||
|
this.panelSpellcheck.cmbDictionaryLanguage.setDisabled(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
onSelectLanguage: function (combo, record) {
|
onSelectLanguage: function (combo, record) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ define([
|
||||||
'<div style="display: flex; width: 100%; padding-bottom: 8px;"><div id="spellcheck-current-word" style="vertical-align: top; width: 100%; display: inline-block;"></div><div id="spellcheck-preview" style="display: inline-block;"></div><div id="spellcheck-next" style="display: inline-block;"></div></div>',
|
'<div style="display: flex; width: 100%; padding-bottom: 8px;"><div id="spellcheck-current-word" style="vertical-align: top; width: 100%; display: inline-block;"></div><div id="spellcheck-preview" style="display: inline-block;"></div><div id="spellcheck-next" style="display: inline-block;"></div></div>',
|
||||||
'<div id="spellcheck-suggestions-list" style="width: 100%; height: 100px; background-color: #fff; margin-bottom: 8px;"></div>',
|
'<div id="spellcheck-suggestions-list" style="width: 100%; height: 100px; background-color: #fff; margin-bottom: 8px;"></div>',
|
||||||
'<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>',
|
'<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>',
|
||||||
'<div id="spellcheck-add-to-dictionary" style="padding-bottom: 16px;"><button class="btn btn-text-default" style="width: auto; padding: 0 15px;"><%= scope.txtAddToDictionary %></button></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>',
|
'<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;"><i class="img-commonctrl img-complete" style="display: inline-block;margin-right: 10px;"></i><%= scope.txtComplete %></div>',
|
||||||
'</div>'
|
'</div>'
|
||||||
|
@ -151,11 +151,14 @@ define([
|
||||||
this.cmbDictionaryLanguage = new Common.UI.ComboBox({
|
this.cmbDictionaryLanguage = new Common.UI.ComboBox({
|
||||||
el : $('#spellcheck-dictionary-language'),
|
el : $('#spellcheck-dictionary-language'),
|
||||||
style : 'width: 230px',
|
style : 'width: 230px',
|
||||||
menuStyle : 'min-width: 230px;max-height: 300px;',
|
menuStyle : 'min-width: 230px;max-height: 200px;',
|
||||||
editable : false,
|
editable : false,
|
||||||
cls : 'input-group-nr'
|
cls : 'input-group-nr'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.btnToDictionary = new Common.UI.Button({
|
||||||
|
el: $('#spellcheck-add-to-dictionary')
|
||||||
|
});
|
||||||
|
|
||||||
this.trigger('render:after', this);
|
this.trigger('render:after', this);
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Reference in a new issue