From 4ca4897e9c09ff7fc8b249642283e44d4f0bb2e7 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 3 Jul 2020 18:06:34 +0300 Subject: [PATCH] Change autocorrect options --- .../common/main/lib/view/AutoCorrectDialog.js | 71 +++++++++++++++++-- apps/documenteditor/main/locale/en.json | 2 + apps/presentationeditor/main/locale/en.json | 2 + apps/spreadsheeteditor/main/locale/en.json | 2 + 4 files changed, 73 insertions(+), 4 deletions(-) diff --git a/apps/common/main/lib/view/AutoCorrectDialog.js b/apps/common/main/lib/view/AutoCorrectDialog.js index d2ef90c61..ba49b37a0 100644 --- a/apps/common/main/lib/view/AutoCorrectDialog.js +++ b/apps/common/main/lib/view/AutoCorrectDialog.js @@ -62,13 +62,25 @@ define([ '
', '', '', - '', '', '', '', + '', + '', + '', + '', + '', + '', '', '
', - '', + '', + '', '
', - '
', + '', + '', + '
', + '
', + '
', + '
', + '
', '
', @@ -89,6 +101,7 @@ define([ Common.UI.Window.prototype.render.call(this); var $window = this.getChild(); + var me = this; // special this.mathList = new Common.UI.ListView({ @@ -104,9 +117,57 @@ define([ ].join('')), scrollAlwaysVisible: true }); + this.mathList.on('item:select', _.bind(this.onSelectMathItem, this)); + + this.inputReplace = new Common.UI.InputField({ + el : $window.find('#auto-correct-replace'), + allowBlank : true, + validateOnChange : true, + validation : function () { return true; } + }).on ('changing', function (input, value) { + if (value.length) { + var store = me.mathList.store; + var _selectedItem = store.find(function(item) { + if ( item.get('replaced').indexOf(value) == 0) { + return true; + } + }); + if (_selectedItem) { + me.mathList.selectRecord(_selectedItem, true); + me.mathList.scrollToRecord(_selectedItem); + } else { + me.mathList.deselectAll(); + } + } else { + me.mathList.deselectAll(); + } + }); + + this.inputBy = new Common.UI.InputField({ + el : $window.find('#auto-correct-by'), + allowBlank : true, + validateOnChange : true, + validation : function () { return true; } + }); + // this.inputBy.cmpEl.find('input').css('font-size', '13px'); + $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); }, + onSelectMathItem: function(lisvView, itemView, record) { + this.inputReplace.setValue(record.get('replaced')); + this.inputBy.setValue(record.get('by')); + }, + + show: function() { + Common.UI.Window.prototype.show.apply(this, arguments); + + var me = this; + _.delay(function(){ + $('input', me.inputReplace.cmpEl).select().focus(); + },100); + }, + onBtnClick: function(event) { this.close(); }, @@ -116,7 +177,9 @@ define([ }, textTitle: 'AutoCorrect', - textMathCorrect: 'Math AutoCorrect' + textMathCorrect: 'Math AutoCorrect', + textReplace: 'Replace:', + textBy: 'By:' }, Common.Views.AutoCorrectDialog || {})) }); diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index d871d544c..79b088a3a 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -159,6 +159,8 @@ "Common.Views.About.txtVersion": "Version ", "Common.Views.AutoCorrectDialog.textTitle": "AutoCorrect", "Common.Views.AutoCorrectDialog.textMathCorrect": "Math AutoCorrect", + "Common.Views.AutoCorrectDialog.textReplace": "Replace:", + "Common.Views.AutoCorrectDialog.textBy": "By:", "Common.Views.Chat.textSend": "Send", "Common.Views.Comments.textAdd": "Add", "Common.Views.Comments.textAddComment": "Add Comment", diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index fd52cf811..6ae930552 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -60,6 +60,8 @@ "Common.Views.About.txtVersion": "Version ", "Common.Views.AutoCorrectDialog.textTitle": "AutoCorrect", "Common.Views.AutoCorrectDialog.textMathCorrect": "Math AutoCorrect", + "Common.Views.AutoCorrectDialog.textReplace": "Replace:", + "Common.Views.AutoCorrectDialog.textBy": "By:", "Common.Views.Chat.textSend": "Send", "Common.Views.Comments.textAdd": "Add", "Common.Views.Comments.textAddComment": "Add Comment", diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 7d7a4d017..d21b9534b 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -61,6 +61,8 @@ "Common.Views.About.txtVersion": "Version ", "Common.Views.AutoCorrectDialog.textTitle": "AutoCorrect", "Common.Views.AutoCorrectDialog.textMathCorrect": "Math AutoCorrect", + "Common.Views.AutoCorrectDialog.textReplace": "Replace:", + "Common.Views.AutoCorrectDialog.textBy": "By:", "Common.Views.Chat.textSend": "Send", "Common.Views.Comments.textAdd": "Add", "Common.Views.Comments.textAddComment": "Add Comment",