[SSE] Spell checking settings
This commit is contained in:
parent
c06027dd25
commit
9e9848c6ec
|
@ -93,7 +93,8 @@ define([
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.addListeners({
|
this.addListeners({
|
||||||
'FileMenu': {
|
'FileMenu': {
|
||||||
'settings:apply': _.bind(this.applySettings, this)
|
'settings:apply': _.bind(this.applySettings, this),
|
||||||
|
'spellcheck:apply': _.bind(this.applySpellcheckSettings, this)
|
||||||
},
|
},
|
||||||
'Common.Views.ReviewChanges': {
|
'Common.Views.ReviewChanges': {
|
||||||
'settings:apply': _.bind(this.applySettings, this)
|
'settings:apply': _.bind(this.applySettings, this)
|
||||||
|
@ -685,6 +686,15 @@ define([
|
||||||
Common.Utils.InternalSettings.set("sse-settings-coauthmode", me._state.fastCoauth);
|
Common.Utils.InternalSettings.set("sse-settings-coauthmode", me._state.fastCoauth);
|
||||||
/** coauthoring end **/
|
/** coauthoring end **/
|
||||||
|
|
||||||
|
/** spellcheck settings begin **/
|
||||||
|
var ignoreUppercase = Common.localStorage.getBool("sse-spellcheck-ignore-uppercase-words", true);
|
||||||
|
Common.Utils.InternalSettings.set("sse-spellcheck-ignore-uppercase-words", ignoreUppercase);
|
||||||
|
this.api.asc_ignoreUppercase(ignoreUppercase);
|
||||||
|
var ignoreNumbers = Common.localStorage.getBool("sse-spellcheck-ignore-numbers-words", true);
|
||||||
|
Common.Utils.InternalSettings.set("sse-spellcheck-ignore-numbers-words", ignoreNumbers);
|
||||||
|
this.api.asc_ignoreUppercase(ignoreNumbers);
|
||||||
|
/** spellcheck settings end **/
|
||||||
|
|
||||||
me.api.asc_registerCallback('asc_onStartAction', _.bind(me.onLongActionBegin, me));
|
me.api.asc_registerCallback('asc_onStartAction', _.bind(me.onLongActionBegin, me));
|
||||||
me.api.asc_registerCallback('asc_onConfirmAction', _.bind(me.onConfirmAction, me));
|
me.api.asc_registerCallback('asc_onConfirmAction', _.bind(me.onConfirmAction, me));
|
||||||
me.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(me.onActiveSheetChanged, me));
|
me.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(me.onActiveSheetChanged, me));
|
||||||
|
@ -2040,6 +2050,17 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
applySpellcheckSettings: function() {
|
||||||
|
if (this.appOptions.isEdit && !this.appOptions.isOffline && this.appOptions.canCoAuthoring && this.api) {
|
||||||
|
var value = Common.localStorage.getBool("sse-spellcheck-ignore-uppercase-words");
|
||||||
|
this.api.asc_ignoreUppercase(value);
|
||||||
|
value = Common.localStorage.getBool("sse-spellcheck-ignore-numbers-words");
|
||||||
|
this.api.asc_ignoreNumbers(value);
|
||||||
|
value = parseInt(Common.localStorage.getItem("sse-spellcheck-locale"));
|
||||||
|
this.api.asc_setDefaultLanguage(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onDocumentName: function(name) {
|
onDocumentName: function(name) {
|
||||||
this.headerView.setDocumentCaption(name);
|
this.headerView.setDocumentCaption(name);
|
||||||
this.updateWindowTitle(this.api.asc_isDocumentModified(), true);
|
this.updateWindowTitle(this.api.asc_isDocumentModified(), true);
|
||||||
|
|
|
@ -55,6 +55,7 @@ define([
|
||||||
'Spellcheck': {
|
'Spellcheck': {
|
||||||
'show': function() {
|
'show': function() {
|
||||||
me._initSettings && me.loadLanguages();
|
me._initSettings && me.loadLanguages();
|
||||||
|
me.updateLanguages();
|
||||||
me.onClickNext();
|
me.onClickNext();
|
||||||
},
|
},
|
||||||
'hide': function() {
|
'hide': function() {
|
||||||
|
@ -124,20 +125,16 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
loadLanguages: function () {
|
loadLanguages: function () {
|
||||||
var value = Common.localStorage.getItem("sse-spellcheck-locale");
|
var me = this;
|
||||||
if (value)
|
Common.Utils.InternalSettings.set("sse-spellcheck-locale", Common.localStorage.getItem("sse-spellcheck-locale"));
|
||||||
value = parseInt(value);
|
|
||||||
else
|
|
||||||
value = this.mode.lang ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.mode.lang)) : 0x0409;
|
|
||||||
|
|
||||||
var combo = this.panelSpellcheck.cmbDictionaryLanguage;
|
|
||||||
if (this.languages && this.languages.length>0) {
|
if (this.languages && this.languages.length>0) {
|
||||||
var langs = [], info,
|
var langs = [], info;
|
||||||
allLangs = Common.util.LanguageInfo.getLanguages();
|
this.allLangs = Common.util.LanguageInfo.getLanguages();
|
||||||
this.languages.forEach(function (code) {
|
this.languages.forEach(function (code) {
|
||||||
code = parseInt(code);
|
code = parseInt(code);
|
||||||
if (allLangs.hasOwnProperty(code)) {
|
if (me.allLangs.hasOwnProperty(code)) {
|
||||||
info = allLangs[code];
|
info = me.allLangs[code];
|
||||||
langs.push({
|
langs.push({
|
||||||
displayValue: info[1],
|
displayValue: info[1],
|
||||||
shortName: info[0],
|
shortName: info[0],
|
||||||
|
@ -151,10 +148,27 @@ define([
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
this.langs = langs;
|
this.langs = langs;
|
||||||
combo.setData(langs);
|
} else {
|
||||||
|
this.langs = undefined;
|
||||||
|
}
|
||||||
|
this._initSettings = false;
|
||||||
|
|
||||||
|
return [this.allLangs, this.langs];
|
||||||
|
},
|
||||||
|
|
||||||
|
updateLanguages: function() {
|
||||||
|
var sessionValue = Common.Utils.InternalSettings.get("sse-spellcheck-locale"),
|
||||||
|
value;
|
||||||
|
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);
|
||||||
var item = combo.store.findWhere({value: value});
|
var item = combo.store.findWhere({value: value});
|
||||||
if (!item && allLangs[value]) {
|
if (!item && this.allLangs[value]) {
|
||||||
value = allLangs[value][0].split(/[\-\_]/)[0];
|
value = this.allLangs[value][0].split(/[\-\_]/)[0];
|
||||||
item = combo.store.find(function(model){
|
item = combo.store.find(function(model){
|
||||||
return model.get('shortName').indexOf(value)==0;
|
return model.get('shortName').indexOf(value)==0;
|
||||||
});
|
});
|
||||||
|
@ -165,18 +179,21 @@ define([
|
||||||
combo.setValue(Common.util.LanguageInfo.getLocalLanguageName(value)[1]);
|
combo.setValue(Common.util.LanguageInfo.getLocalLanguageName(value)[1]);
|
||||||
combo.setDisabled(true);
|
combo.setDisabled(true);
|
||||||
}
|
}
|
||||||
this.langValue = value;
|
if (this.api) {
|
||||||
this.api.asc_setDefaultLanguage(value);
|
this.api.asc_setDefaultLanguage(value);
|
||||||
this._initSettings = false;
|
if (value !== sessionValue) {
|
||||||
|
Common.Utils.InternalSettings.set("sse-spellcheck-locale", value);
|
||||||
return [this.langs, this.langValue];
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onSelectLanguage: function (combo, record) {
|
onSelectLanguage: function (combo, record) {
|
||||||
var lang = record.value;
|
var lang = record.value;
|
||||||
if (this.api && lang) {
|
if (this.api && lang) {
|
||||||
this.api.asc_setDefaultLanguage(lang);
|
this.api.asc_setDefaultLanguage(lang);
|
||||||
Common.localStorage.setItem("sse-spellcheck-locale", this.panelSpellcheck.cmbDictionaryLanguage.getValue());
|
var value = this.panelSpellcheck.cmbDictionaryLanguage.getValue();
|
||||||
|
Common.localStorage.setItem("sse-spellcheck-locale", value);
|
||||||
|
Common.Utils.InternalSettings.set("sse-spellcheck-locale", value);
|
||||||
}
|
}
|
||||||
Common.NotificationCenter.trigger('edit:complete', this, {restorefocus:true});
|
Common.NotificationCenter.trigger('edit:complete', this, {restorefocus:true});
|
||||||
},
|
},
|
||||||
|
@ -250,7 +267,7 @@ define([
|
||||||
onApiEditCell: function(state) {
|
onApiEditCell: function(state) {
|
||||||
if (state == Asc.c_oAscCellEditorState.editEnd) {
|
if (state == Asc.c_oAscCellEditorState.editEnd) {
|
||||||
this.panelSpellcheck.buttonNext.setDisabled(!this.panelSpellcheck.lblComplete.hasClass('hidden'));
|
this.panelSpellcheck.buttonNext.setDisabled(!this.panelSpellcheck.lblComplete.hasClass('hidden'));
|
||||||
this.panelSpellcheck.cmbDictionaryLanguage.setDisabled(false);
|
this.panelSpellcheck.cmbDictionaryLanguage.setDisabled((this.languages && this.languages.length > 0) ? false : true);
|
||||||
} else {
|
} else {
|
||||||
this.panelSpellcheck.buttonNext.setDisabled(true);
|
this.panelSpellcheck.buttonNext.setDisabled(true);
|
||||||
this.panelSpellcheck.currentWord.setDisabled(true);
|
this.panelSpellcheck.currentWord.setDisabled(true);
|
||||||
|
|
|
@ -232,6 +232,7 @@ define([
|
||||||
if (!this.mode.canPrint)
|
if (!this.mode.canPrint)
|
||||||
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);
|
||||||
},
|
},
|
||||||
|
|
||||||
setApi: function(api) {
|
setApi: function(api) {
|
||||||
|
@ -970,6 +971,11 @@ define([
|
||||||
'<label class="input-label"><%= scope.strDictionaryLanguage %></label>',
|
'<label class="input-label"><%= scope.strDictionaryLanguage %></label>',
|
||||||
'<div id="fms-cmb-dictionary-language" style="width: 200px;"></div>',
|
'<div id="fms-cmb-dictionary-language" style="width: 200px;"></div>',
|
||||||
'</td></tr>',
|
'</td></tr>',
|
||||||
|
'<tr class="divider"></tr>',
|
||||||
|
'<tr>',
|
||||||
|
'<td class="left"></td>',
|
||||||
|
'<td class="right"><button id="fms-spellcheck-btn-apply" class="btn normal dlg-btn primary"><%= scope.okButtonText %></button></td>',
|
||||||
|
'</tr>',
|
||||||
'</tbody></table>'
|
'</tbody></table>'
|
||||||
].join('')),
|
].join('')),
|
||||||
|
|
||||||
|
@ -986,13 +992,11 @@ define([
|
||||||
this.chIgnoreUppercase = new Common.UI.CheckBox({
|
this.chIgnoreUppercase = new Common.UI.CheckBox({
|
||||||
el: $markup.findById('#fms-chb-ignore-uppercase-words'),
|
el: $markup.findById('#fms-chb-ignore-uppercase-words'),
|
||||||
labelText: this.strIgnoreWordsInUPPERCASE
|
labelText: this.strIgnoreWordsInUPPERCASE
|
||||||
}).on('change', function(field, newValue, oldValue, eOpts){
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.chIgnoreNumbers = new Common.UI.CheckBox({
|
this.chIgnoreNumbers = new Common.UI.CheckBox({
|
||||||
el: $markup.findById('#fms-chb-ignore-numbers-words'),
|
el: $markup.findById('#fms-chb-ignore-numbers-words'),
|
||||||
labelText: this.strIgnoreWordsWithNumbers
|
labelText: this.strIgnoreWordsWithNumbers
|
||||||
}).on('change', function(field, newValue, oldValue, eOpts){
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.cmbDictionaryLanguage = new Common.UI.ComboBox({
|
this.cmbDictionaryLanguage = new Common.UI.ComboBox({
|
||||||
|
@ -1003,7 +1007,7 @@ define([
|
||||||
});
|
});
|
||||||
|
|
||||||
this.btnApply = new Common.UI.Button({
|
this.btnApply = new Common.UI.Button({
|
||||||
el: $markup.findById('#fms-btn-apply')
|
el: $markup.findById('#fms-spellcheck-btn-apply')
|
||||||
});
|
});
|
||||||
|
|
||||||
this.btnApply.on('click', _.bind(this.applySettings, this));
|
this.btnApply.on('click', _.bind(this.applySettings, this));
|
||||||
|
@ -1035,25 +1039,60 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
updateSettings: function() {
|
updateSettings: function() {
|
||||||
var array = SSE.getController('Spellcheck').loadLanguages(),
|
var lang = SSE.getController('Spellcheck').loadLanguages(),
|
||||||
lang = array[0],
|
allLangs = lang[0],
|
||||||
value = array[1];
|
lang = lang[1];
|
||||||
if (lang) {
|
var sessionValue = Common.Utils.InternalSettings.get("sse-spellcheck-locale"),
|
||||||
|
value;
|
||||||
|
if (sessionValue)
|
||||||
|
value = parseInt(sessionValue);
|
||||||
|
else
|
||||||
|
value = this.mode.lang ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.mode.lang)) : 0x0409;
|
||||||
|
if (lang && lang.length > 0) {
|
||||||
this.cmbDictionaryLanguage.setData(lang);
|
this.cmbDictionaryLanguage.setData(lang);
|
||||||
this.cmbDictionaryLanguage.setValue(value);
|
var item = this.cmbDictionaryLanguage.store.findWhere({value: value});
|
||||||
|
if (!item && allLangs[value]) {
|
||||||
|
value = allLangs[value][0].split(/[\-\_]/)[0];
|
||||||
|
item = combo.store.find(function(model){
|
||||||
|
return model.get('shortName').indexOf(value)==0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.cmbDictionaryLanguage.setValue(item ? item.get('value') : langs[0].value);
|
||||||
|
value = this.cmbDictionaryLanguage.getValue();
|
||||||
|
if (value !== sessionValue) {
|
||||||
|
Common.Utils.InternalSettings.set("sse-spellcheck-locale", value);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.cmbDictionaryLanguage.setValue(Common.util.LanguageInfo.getLocalLanguageName(value)[1]);
|
this.cmbDictionaryLanguage.setValue(Common.util.LanguageInfo.getLocalLanguageName(value)[1]);
|
||||||
this.cmbDictionaryLanguage.setDisabled(true);
|
this.cmbDictionaryLanguage.setDisabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.chIgnoreUppercase.setValue(Common.Utils.InternalSettings.get("sse-spellcheck-ignore-uppercase-words"));
|
||||||
|
this.chIgnoreNumbers.setValue(Common.Utils.InternalSettings.get("sse-spellcheck-ignore-numbers-words"));
|
||||||
},
|
},
|
||||||
|
|
||||||
applySettings: function() {
|
applySettings: function() {
|
||||||
|
var value = this.chIgnoreUppercase.isChecked();
|
||||||
|
Common.localStorage.setBool("sse-spellcheck-ignore-uppercase-words", value);
|
||||||
|
Common.Utils.InternalSettings.set("sse-spellcheck-ignore-uppercase-words", value);
|
||||||
|
value = this.chIgnoreNumbers.isChecked();
|
||||||
|
Common.localStorage.setBool("sse-spellcheck-ignore-numbers-words", value);
|
||||||
|
Common.Utils.InternalSettings.set("sse-spellcheck-ignore-numbers-words", value);
|
||||||
|
|
||||||
|
value = this.cmbDictionaryLanguage.getValue();
|
||||||
|
Common.localStorage.setItem("sse-spellcheck-locale", value);
|
||||||
|
Common.Utils.InternalSettings.set("sse-spellcheck-locale", value);
|
||||||
|
|
||||||
|
Common.localStorage.save();
|
||||||
|
if (this.menu) {
|
||||||
|
this.menu.fireEvent('spellcheck:apply', [this.menu]);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
strIgnoreWordsInUPPERCASE: 'Ignore words in UPPERCASE',
|
strIgnoreWordsInUPPERCASE: 'Ignore words in UPPERCASE',
|
||||||
strIgnoreWordsWithNumbers: 'Ignore words with numbers',
|
strIgnoreWordsWithNumbers: 'Ignore words with numbers',
|
||||||
strDictionaryLanguage: 'Dictionary language'
|
strDictionaryLanguage: 'Dictionary language',
|
||||||
|
okButtonText: 'Apply'
|
||||||
|
|
||||||
}, SSE.Views.FileMenuPanels.MainSpellCheckSettings || {}));
|
}, SSE.Views.FileMenuPanels.MainSpellCheckSettings || {}));
|
||||||
|
|
||||||
|
|
|
@ -1591,6 +1591,10 @@
|
||||||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtPt": "Point",
|
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtPt": "Point",
|
||||||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtRu": "Russian",
|
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtRu": "Russian",
|
||||||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtWin": "as Windows",
|
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtWin": "as Windows",
|
||||||
|
"SSE.Views.FileMenuPanels.MainSpellCheckSettings.strIgnoreWordsInUPPERCASE": "Ignore words in UPPERCASE",
|
||||||
|
"SSE.Views.FileMenuPanels.MainSpellCheckSettings.strIgnoreWordsWithNumbers": "Ignore words with numbers",
|
||||||
|
"SSE.Views.FileMenuPanels.MainSpellCheckSettings.strDictionaryLanguage": "Dictionary language",
|
||||||
|
"SSE.Views.FileMenuPanels.MainSpellCheckSettings.okButtonText": "Apply",
|
||||||
"SSE.Views.FileMenuPanels.ProtectDoc.notcriticalErrorTitle": "Warning",
|
"SSE.Views.FileMenuPanels.ProtectDoc.notcriticalErrorTitle": "Warning",
|
||||||
"SSE.Views.FileMenuPanels.ProtectDoc.strEncrypt": "With password",
|
"SSE.Views.FileMenuPanels.ProtectDoc.strEncrypt": "With password",
|
||||||
"SSE.Views.FileMenuPanels.ProtectDoc.strProtect": "Protect Spreadsheet",
|
"SSE.Views.FileMenuPanels.ProtectDoc.strProtect": "Protect Spreadsheet",
|
||||||
|
|
Loading…
Reference in a new issue