Merge pull request #276 from ONLYOFFICE/feature/sse-spellchecking-settings
Feature/sse spellchecking settings
This commit is contained in:
commit
50ffc1ac58
|
@ -75,6 +75,7 @@ define([
|
|||
'saveas:format': _.bind(this.clickSaveAsFormat, this),
|
||||
'savecopy:format': _.bind(this.clickSaveCopyAsFormat, this),
|
||||
'settings:apply': _.bind(this.applySettings, this),
|
||||
'spellcheck:apply': _.bind(this.applySpellcheckSettings, this),
|
||||
'create:new': _.bind(this.onCreateNew, this),
|
||||
'recent:open': _.bind(this.onOpenRecent, this)
|
||||
},
|
||||
|
@ -394,6 +395,23 @@ define([
|
|||
this.leftMenu.fireEvent('settings:apply');
|
||||
},
|
||||
|
||||
applySpellcheckSettings: function(menu) {
|
||||
if (this.mode.isEdit && 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 = Common.localStorage.getItem("sse-spellcheck-locale");
|
||||
if (value) {
|
||||
this.api.asc_setDefaultLanguage(parseInt(value));
|
||||
}
|
||||
}
|
||||
|
||||
menu.hide();
|
||||
|
||||
this.leftMenu.fireEvent('spellcheck:update');
|
||||
},
|
||||
|
||||
onCreateNew: function(menu, type) {
|
||||
if ( !Common.Controllers.Desktop.process('create:new') ) {
|
||||
var newDocumentPage = window.open(type == 'blank' ? this.mode.createUrl : type, "_blank");
|
||||
|
|
|
@ -692,6 +692,15 @@ define([
|
|||
Common.Utils.InternalSettings.set("sse-settings-coauthmode", me._state.fastCoauth);
|
||||
/** 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_ignoreNumbers(ignoreNumbers);
|
||||
/** spellcheck settings end **/
|
||||
|
||||
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_onActiveSheetChanged', _.bind(me.onActiveSheetChanged, me));
|
||||
|
|
|
@ -55,11 +55,17 @@ define([
|
|||
'Spellcheck': {
|
||||
'show': function() {
|
||||
me._initSettings && me.loadLanguages();
|
||||
me.updateLanguages();
|
||||
me.onClickNext();
|
||||
},
|
||||
'hide': function() {
|
||||
me.api && me.api.asc_cancelSpellCheck();
|
||||
}
|
||||
},
|
||||
'LeftMenu': {
|
||||
'spellcheck:update': function () {
|
||||
me.updateLanguages();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -121,23 +127,24 @@ define([
|
|||
setLanguages: function (array) {
|
||||
this.languages = array;
|
||||
this._initSettings = true;
|
||||
if (this.panelSpellcheck.cmbDictionaryLanguage.store.length > 0) {
|
||||
this.panelSpellcheck.cmbDictionaryLanguage.store.reset();
|
||||
}
|
||||
},
|
||||
|
||||
loadLanguages: function () {
|
||||
var value = Common.localStorage.getItem("sse-spellcheck-locale");
|
||||
if (value)
|
||||
value = parseInt(value);
|
||||
else
|
||||
value = this.mode.lang ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.mode.lang)) : 0x0409;
|
||||
var me = this;
|
||||
if (this._initSettings) {
|
||||
Common.Utils.InternalSettings.set("sse-spellcheck-locale", Common.localStorage.getItem("sse-spellcheck-locale"));
|
||||
}
|
||||
|
||||
var combo = this.panelSpellcheck.cmbDictionaryLanguage;
|
||||
if (this.languages && this.languages.length>0) {
|
||||
var langs = [], info,
|
||||
allLangs = Common.util.LanguageInfo.getLanguages();
|
||||
var langs = [], info;
|
||||
this.allLangs = Common.util.LanguageInfo.getLanguages();
|
||||
this.languages.forEach(function (code) {
|
||||
code = parseInt(code);
|
||||
if (allLangs.hasOwnProperty(code)) {
|
||||
info = allLangs[code];
|
||||
if (me.allLangs.hasOwnProperty(code)) {
|
||||
info = me.allLangs[code];
|
||||
langs.push({
|
||||
displayValue: info[1],
|
||||
shortName: info[0],
|
||||
|
@ -150,29 +157,60 @@ define([
|
|||
if (a.shortName > b.shortName) return 1;
|
||||
return 0;
|
||||
});
|
||||
combo.setData(langs);
|
||||
var item = combo.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.langs = langs;
|
||||
} else {
|
||||
this.langs = undefined;
|
||||
}
|
||||
this._initSettings = false;
|
||||
|
||||
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,
|
||||
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) {
|
||||
if (combo.store.length === 0) {
|
||||
combo.setData(this.langs);
|
||||
isApply = true;
|
||||
}
|
||||
combo.setValue(item ? item.get('value') : langs[0].value);
|
||||
var item = combo.store.findWhere({value: value});
|
||||
if (!item && this.allLangs[value]) {
|
||||
value = this.allLangs[value][0].split(/[\-\_]/)[0];
|
||||
item = combo.store.find(function(model){
|
||||
return model.get('shortName').indexOf(value)==0;
|
||||
});
|
||||
}
|
||||
combo.setValue(item ? item.get('value') : this.langs[0].value);
|
||||
value = combo.getValue();
|
||||
} else {
|
||||
combo.setValue(Common.util.LanguageInfo.getLocalLanguageName(value)[1]);
|
||||
combo.setDisabled(true);
|
||||
}
|
||||
this.api.asc_setDefaultLanguage(value);
|
||||
this._initSettings = false;
|
||||
if (isApply && this.api) {
|
||||
this.api.asc_setDefaultLanguage(value);
|
||||
if (value !== parseInt(sessionValue)) {
|
||||
Common.Utils.InternalSettings.set("sse-spellcheck-locale", value);
|
||||
}
|
||||
isApply = false;
|
||||
}
|
||||
},
|
||||
|
||||
onSelectLanguage: function (combo, record) {
|
||||
var lang = record.value;
|
||||
if (this.api && 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});
|
||||
},
|
||||
|
@ -246,7 +284,7 @@ define([
|
|||
onApiEditCell: function(state) {
|
||||
if (state == Asc.c_oAscCellEditorState.editEnd) {
|
||||
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 {
|
||||
this.panelSpellcheck.buttonNext.setDisabled(true);
|
||||
this.panelSpellcheck.currentWord.setDisabled(true);
|
||||
|
|
|
@ -171,6 +171,7 @@ define([
|
|||
'<div id="id-settings-content" style="position: absolute; left: 200px; top: 0; right: 0; bottom: 0;" class="no-padding">',
|
||||
'<div id="panel-settings-general" style="width:100%; height:100%;" class="no-padding main-settings-panel active"></div>',
|
||||
'<div id="panel-settings-print" style="width:100%; height:100%;" class="no-padding main-settings-panel"></div>',
|
||||
'<div id="panel-settings-spellcheck" style="width:100%; height:100%;" class="no-padding main-settings-panel"></div>',
|
||||
'</div>',
|
||||
'</div>'
|
||||
].join('')),
|
||||
|
@ -192,11 +193,15 @@ define([
|
|||
this.printSettings.menu = this.menu;
|
||||
this.printSettings.render($markup.findById('#panel-settings-print'));
|
||||
|
||||
this.spellcheckSettings = new SSE.Views.FileMenuPanels.MainSpellCheckSettings({menu: this.menu});
|
||||
this.spellcheckSettings.render($markup.findById('#panel-settings-spellcheck'));
|
||||
|
||||
this.viewSettingsPicker = new Common.UI.DataView({
|
||||
el: $markup.findById('#id-settings-menu'),
|
||||
store: new Common.UI.DataViewStore([
|
||||
{name: this.txtGeneral, panel: this.generalSettings, iconCls:'mnu-settings-general', selected: true},
|
||||
{name: this.txtPageSettings, panel: this.printSettings, iconCls:'mnu-print'}
|
||||
{name: this.txtPageSettings, panel: this.printSettings, iconCls:'mnu-print'},
|
||||
{name: this.txtSpellChecking, panel: this.spellcheckSettings, iconCls:'mu-settings-spellcheck'}
|
||||
]),
|
||||
itemTemplate: _.template([
|
||||
'<div id="<%= id %>" class="settings-item-wrap">',
|
||||
|
@ -227,6 +232,10 @@ define([
|
|||
if (!this.mode.canPrint)
|
||||
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) {
|
||||
|
@ -234,7 +243,8 @@ define([
|
|||
},
|
||||
|
||||
txtGeneral: 'General',
|
||||
txtPageSettings: 'Page Settings'
|
||||
txtPageSettings: 'Page Settings',
|
||||
txtSpellChecking: 'Spell checking'
|
||||
}, SSE.Views.FileMenuPanels.Settings || {}));
|
||||
|
||||
SSE.Views.MainSettingsPrint = Common.UI.BaseView.extend(_.extend({
|
||||
|
@ -948,6 +958,154 @@ define([
|
|||
strR1C1: 'Turn on R1C1 style'
|
||||
}, SSE.Views.FileMenuPanels.MainSettingsGeneral || {}));
|
||||
|
||||
SSE.Views.FileMenuPanels.MainSpellCheckSettings = Common.UI.BaseView.extend(_.extend({
|
||||
el: '#panel-settings-spellcheck',
|
||||
menu: undefined,
|
||||
|
||||
template: _.template([
|
||||
'<table class="main"><tbody>',
|
||||
'<tr>',
|
||||
'<td class="left" style="padding-bottom: 8px;"><label><%= scope.strDictionaryLanguage %></label></td>',
|
||||
'<td class="right" style="padding-bottom: 8px;"><span id="fms-cmb-dictionary-language" /></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td class="left" style="padding-bottom: 8px;"></td>',
|
||||
'<td class="right" style="padding-bottom: 8px;"><span id="fms-chb-ignore-uppercase-words" /></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td class="left"></td>',
|
||||
'<td class="right"><span id="fms-chb-ignore-numbers-words" /></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>'
|
||||
].join('')),
|
||||
|
||||
initialize: function(options) {
|
||||
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
||||
|
||||
this.menu = options.menu;
|
||||
},
|
||||
|
||||
render: function(node) {
|
||||
var me = this;
|
||||
var $markup = $(this.template({scope: this}));
|
||||
|
||||
this.chIgnoreUppercase = new Common.UI.CheckBox({
|
||||
el: $markup.findById('#fms-chb-ignore-uppercase-words'),
|
||||
labelText: this.strIgnoreWordsInUPPERCASE
|
||||
});
|
||||
|
||||
this.chIgnoreNumbers = new Common.UI.CheckBox({
|
||||
el: $markup.findById('#fms-chb-ignore-numbers-words'),
|
||||
labelText: this.strIgnoreWordsWithNumbers
|
||||
});
|
||||
|
||||
this.cmbDictionaryLanguage = new Common.UI.ComboBox({
|
||||
el: $markup.findById('#fms-cmb-dictionary-language'),
|
||||
cls: 'input-group-nr',
|
||||
style: 'width: 267px;',
|
||||
editable: false,
|
||||
menuStyle: 'min-width: 267px; max-height: 209px;'
|
||||
});
|
||||
|
||||
this.btnApply = new Common.UI.Button({
|
||||
el: $markup.findById('#fms-spellcheck-btn-apply')
|
||||
});
|
||||
|
||||
this.btnApply.on('click', _.bind(this.applySettings, this));
|
||||
|
||||
this.$el = $(node).html($markup);
|
||||
|
||||
if (_.isUndefined(this.scroller)) {
|
||||
this.scroller = new Common.UI.Scroller({
|
||||
el: this.$el,
|
||||
suppressScrollX: true
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
show: function() {
|
||||
Common.UI.BaseView.prototype.show.call(this,arguments);
|
||||
|
||||
this.updateSettings();
|
||||
},
|
||||
|
||||
setMode: function(mode) {
|
||||
this.mode = mode;
|
||||
},
|
||||
|
||||
setApi: function(api) {
|
||||
this.api = api;
|
||||
},
|
||||
|
||||
updateSettings: function() {
|
||||
var arrLang = SSE.getController('Spellcheck').loadLanguages(),
|
||||
allLangs = arrLang[0],
|
||||
langs = arrLang[1],
|
||||
change = arrLang[2];
|
||||
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 (langs && langs.length > 0) {
|
||||
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];
|
||||
item = this.cmbDictionaryLanguage.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 !== parseInt(sessionValue)) {
|
||||
Common.Utils.InternalSettings.set("sse-spellcheck-locale", value);
|
||||
}
|
||||
} else {
|
||||
this.cmbDictionaryLanguage.setValue(Common.util.LanguageInfo.getLocalLanguageName(value)[1]);
|
||||
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() {
|
||||
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);
|
||||
|
||||
if (!this.cmbDictionaryLanguage.isDisabled()) {
|
||||
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',
|
||||
strIgnoreWordsWithNumbers: 'Ignore words with numbers',
|
||||
strDictionaryLanguage: 'Dictionary language',
|
||||
okButtonText: 'Apply'
|
||||
|
||||
}, SSE.Views.FileMenuPanels.MainSpellCheckSettings || {}));
|
||||
|
||||
SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
|
||||
el: '#panel-recentfiles',
|
||||
menu: undefined,
|
||||
|
|
|
@ -1591,6 +1591,10 @@
|
|||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtPt": "Point",
|
||||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtRu": "Russian",
|
||||
"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.strEncrypt": "With password",
|
||||
"SSE.Views.FileMenuPanels.ProtectDoc.strProtect": "Protect Spreadsheet",
|
||||
|
@ -1604,6 +1608,7 @@
|
|||
"SSE.Views.FileMenuPanels.ProtectDoc.txtView": "View signatures",
|
||||
"SSE.Views.FileMenuPanels.Settings.txtGeneral": "General",
|
||||
"SSE.Views.FileMenuPanels.Settings.txtPageSettings": "Page Settings",
|
||||
"SSE.Views.FileMenuPanels.Settings.txtSpellChecking": "Spell checking",
|
||||
"SSE.Views.FormatSettingsDialog.textCategory": "Category",
|
||||
"SSE.Views.FormatSettingsDialog.textDecimal": "Decimal",
|
||||
"SSE.Views.FormatSettingsDialog.textFormat": "Format",
|
||||
|
|
|
@ -201,6 +201,10 @@
|
|||
&.mnu-settings-general {
|
||||
background-position: 0 -1141px;
|
||||
}
|
||||
|
||||
&.mu-settings-spellcheck {
|
||||
background-position: 0px -1860px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,6 +225,10 @@
|
|||
&.mnu-settings-general {
|
||||
background-position: -20px -1141px;
|
||||
}
|
||||
|
||||
&.mu-settings-spellcheck {
|
||||
background-position: -20px -1860px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue