From 67f1c2f05df06795e476dc44f8a5d1d34d323ea1 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Sat, 26 Sep 2020 20:16:29 +0300 Subject: [PATCH] [Common] Add focus method for dataview components. Fix list focus in modal dialogs --- apps/common/main/lib/component/Calendar.js | 6 +++--- apps/common/main/lib/component/DataView.js | 8 ++++++++ apps/common/main/lib/component/ListView.js | 4 ++++ apps/common/main/lib/component/TreeView.js | 4 ++++ apps/common/main/lib/view/AutoCorrectDialog.js | 4 ++-- apps/common/main/lib/view/SymbolTableDialog.js | 2 +- .../documenteditor/main/app/view/ControlSettingsDialog.js | 8 ++++---- apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js | 2 +- apps/spreadsheeteditor/main/app/view/FormulaDialog.js | 2 +- apps/spreadsheeteditor/main/app/view/NameManagerDlg.js | 4 ++-- apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js | 6 +++--- .../spreadsheeteditor/main/app/view/NamedRangePasteDlg.js | 2 +- .../main/app/view/RemoveDuplicatesDialog.js | 2 +- apps/spreadsheeteditor/main/app/view/SlicerAddDialog.js | 2 +- apps/spreadsheeteditor/main/app/view/Statusbar.js | 4 ++-- 15 files changed, 38 insertions(+), 22 deletions(-) diff --git a/apps/common/main/lib/component/Calendar.js b/apps/common/main/lib/component/Calendar.js index 2304ab1f5..0ae99149c 100644 --- a/apps/common/main/lib/component/Calendar.js +++ b/apps/common/main/lib/component/Calendar.js @@ -237,7 +237,7 @@ define([ me.yearPicker.store.reset(arrYears); me.enableKeyEvents && _.delay(function() { - me.monthPicker.cmpEl.find('.dataview').focus(); + me.monthPicker.focus(); }, 10); }, @@ -312,7 +312,7 @@ define([ me.monthsPicker.store.reset(arrMonths); me.enableKeyEvents && _.delay(function() { - me.monthPicker.cmpEl.find('.dataview').focus(); + me.monthPicker.focus(); }, 10); }, @@ -435,7 +435,7 @@ define([ me.monthPicker.store.reset(arrDays); me.enableKeyEvents && _.delay(function() { - me.monthPicker.cmpEl.find('.dataview').focus(); + me.monthPicker.focus(); }, 10); }, diff --git a/apps/common/main/lib/component/DataView.js b/apps/common/main/lib/component/DataView.js index 855f52d0f..0db6f9a79 100644 --- a/apps/common/main/lib/component/DataView.js +++ b/apps/common/main/lib/component/DataView.js @@ -764,6 +764,10 @@ define([ onResize: function() { this._layoutParams = undefined; + }, + + focus: function() { + this.cmpEl && this.cmpEl.find('.dataview').focus(); } }); @@ -1193,6 +1197,10 @@ define([ onResize: function() { this._layoutParams = undefined; + }, + + focus: function() { + this.cmpEl && this.cmpEl.find('.dataview').focus(); } }); diff --git a/apps/common/main/lib/component/ListView.js b/apps/common/main/lib/component/ListView.js index 080d6e15f..0c4016ac1 100644 --- a/apps/common/main/lib/component/ListView.js +++ b/apps/common/main/lib/component/ListView.js @@ -115,6 +115,10 @@ define([ if (!this.isSuspendEvents) this.trigger('item:add', this, view, record); } + }, + + focus: function() { + this.cmpEl && this.cmpEl.find('.listview').focus(); } } })()); diff --git a/apps/common/main/lib/component/TreeView.js b/apps/common/main/lib/component/TreeView.js index 8f32ea245..b79ab988c 100644 --- a/apps/common/main/lib/component/TreeView.js +++ b/apps/common/main/lib/component/TreeView.js @@ -280,6 +280,10 @@ define([ this.store.collapseSubItems(record); this.scroller.update({minScrollbarLength: 40, alwaysVisibleY: this.scrollAlwaysVisible}); } + }, + + focus: function() { + this.cmpEl && this.cmpEl.find('.treeview').focus(); } } })()); diff --git a/apps/common/main/lib/view/AutoCorrectDialog.js b/apps/common/main/lib/view/AutoCorrectDialog.js index 9651fa4fa..044798b37 100644 --- a/apps/common/main/lib/view/AutoCorrectDialog.js +++ b/apps/common/main/lib/view/AutoCorrectDialog.js @@ -215,7 +215,7 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', me.mathList.scrollToRecord(_selectedItem); } _.delay(function(){ - me.mathList.cmpEl.find('.listview').focus(); + me.mathList.focus(); },10); } @@ -295,7 +295,7 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', me.mathRecList.scrollToRecord(_selectedItem); } _.delay(function(){ - me.mathRecList.cmpEl.find('.listview').focus(); + me.mathRecList.focus(); },10); } diff --git a/apps/common/main/lib/view/SymbolTableDialog.js b/apps/common/main/lib/view/SymbolTableDialog.js index a1755132e..572e6bcdb 100644 --- a/apps/common/main/lib/view/SymbolTableDialog.js +++ b/apps/common/main/lib/view/SymbolTableDialog.js @@ -1472,7 +1472,7 @@ define([ this.specialPanel.toggleClass('hidden', !special); var me = this; _.delay(function(){ - special ? me.specialList.cmpEl.find('.listview').focus() : me.previewPanel.focus(); + special ? me.specialList.focus() : me.previewPanel.focus(); },50); }, diff --git a/apps/documenteditor/main/app/view/ControlSettingsDialog.js b/apps/documenteditor/main/app/view/ControlSettingsDialog.js index 5b4d78bee..4e9bdc717 100644 --- a/apps/documenteditor/main/app/view/ControlSettingsDialog.js +++ b/apps/documenteditor/main/app/view/ControlSettingsDialog.js @@ -679,7 +679,7 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template', me.disableListButtons(); } } - me.list.cmpEl.find('.listview').focus(); + me.list.focus(); } }); win.show(); @@ -699,7 +699,7 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template', }); } } - me.list.cmpEl.find('.listview').focus(); + me.list.focus(); } }); rec && win.show(); @@ -719,7 +719,7 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template', } } this.disableListButtons(); - this.list.cmpEl.find('.listview').focus(); + this.list.focus(); }, onMoveItem: function(up) { @@ -732,7 +732,7 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template', this.list.selectRecord(rec); this.list.scrollToRecord(rec); } - this.list.cmpEl.find('.listview').focus(); + this.list.focus(); }, updateFormats: function(lang) { diff --git a/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js b/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js index d836b6875..cd19edffe 100644 --- a/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js +++ b/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js @@ -1628,7 +1628,7 @@ define([ this.updateCellCheck(listView, record); _.delay(function () { - listView.$el.find('.listview').focus(); + listView.focus(); }, 100, this); } } diff --git a/apps/spreadsheeteditor/main/app/view/FormulaDialog.js b/apps/spreadsheeteditor/main/app/view/FormulaDialog.js index 44c10a850..dd7c2d540 100644 --- a/apps/spreadsheeteditor/main/app/view/FormulaDialog.js +++ b/apps/spreadsheeteditor/main/app/view/FormulaDialog.js @@ -214,7 +214,7 @@ define([ onUpdateFocus: function () { if (this.cmbListFunctions) { _.delay(function (me) { - me.cmbListFunctions.$el.find('.listview').focus(); + me.cmbListFunctions.focus(); }, 100, this); } }, diff --git a/apps/spreadsheeteditor/main/app/view/NameManagerDlg.js b/apps/spreadsheeteditor/main/app/view/NameManagerDlg.js index 9ac77fb32..bb7ba835f 100644 --- a/apps/spreadsheeteditor/main/app/view/NameManagerDlg.js +++ b/apps/spreadsheeteditor/main/app/view/NameManagerDlg.js @@ -250,7 +250,7 @@ define([ 'text!spreadsheeteditor/main/app/template/NameManagerDlg.template', this.rangeList.cmpEl.on('mouseover', _.bind(me.onMouseOverLock, me)).on('mouseout', _.bind(me.onMouseOutLock, me)); } _.delay(function () { - me.rangeList.cmpEl.find('.listview').focus(); + me.rangeList.focus(); me.rangeList.scroller.update({alwaysVisibleY: true}); }, 100, this); }, @@ -311,7 +311,7 @@ define([ 'text!spreadsheeteditor/main/app/template/NameManagerDlg.template', }).on('close', function() { me.show(); _.delay(function () { - me.rangeList.cmpEl.find('.listview').focus(); + me.rangeList.focus(); }, 100, me); }); diff --git a/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js b/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js index 6b8f371c9..a8e4cef06 100644 --- a/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js +++ b/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js @@ -187,7 +187,7 @@ define([ var me = this; _.delay(function(){ - me.inputName.cmpEl.find('input').focus(); + me.inputName.focus(); },200); }, show: function() { @@ -274,12 +274,12 @@ define([ var checkname = this.inputName.checkValidate(), checkrange = this.txtDataRange.checkValidate(); if (checkname !== true) { - this.inputName.cmpEl.find('input').focus(); + this.inputName.focus(); this.isInputFirstChange = true; return; } if (checkrange !== true) { - this.txtDataRange.cmpEl.find('input').focus(); + this.txtDataRange.focus(); return; } this.handler && this.handler.call(this, state, (state == 'ok') ? this.getSettings() : undefined); diff --git a/apps/spreadsheeteditor/main/app/view/NamedRangePasteDlg.js b/apps/spreadsheeteditor/main/app/view/NamedRangePasteDlg.js index 9bb702072..a977ac207 100644 --- a/apps/spreadsheeteditor/main/app/view/NamedRangePasteDlg.js +++ b/apps/spreadsheeteditor/main/app/view/NamedRangePasteDlg.js @@ -141,7 +141,7 @@ define([ this.rangeList.scroller.update({alwaysVisibleY: true}); _.delay(function () { - me.rangeList.cmpEl.find('.listview').focus(); + me.rangeList.focus(); }, 100, this); } }, diff --git a/apps/spreadsheeteditor/main/app/view/RemoveDuplicatesDialog.js b/apps/spreadsheeteditor/main/app/view/RemoveDuplicatesDialog.js index 83c9469c8..cd253f42b 100644 --- a/apps/spreadsheeteditor/main/app/view/RemoveDuplicatesDialog.js +++ b/apps/spreadsheeteditor/main/app/view/RemoveDuplicatesDialog.js @@ -198,7 +198,7 @@ define([ this.updateCellCheck(listView, record); _.delay(function () { - listView.$el.find('.listview').focus(); + listView.focus(); }, 100, this); } } diff --git a/apps/spreadsheeteditor/main/app/view/SlicerAddDialog.js b/apps/spreadsheeteditor/main/app/view/SlicerAddDialog.js index cb436fbb3..b4d0078ed 100644 --- a/apps/spreadsheeteditor/main/app/view/SlicerAddDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SlicerAddDialog.js @@ -153,7 +153,7 @@ define([ this.updateCellCheck(listView, record); _.delay(function () { - listView.$el.find('.listview').focus(); + listView.focus(); }, 100, this); } } diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 7ec57c21c..7b36925d1 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -1014,7 +1014,7 @@ define([ Common.UI.Window.prototype.show.apply(this, arguments); _.delay(function(me){ - me.listNames.$el.find('.listview').focus(); + me.listNames.focus(); }, 100, this); }, @@ -1045,7 +1045,7 @@ define([ onUpdateFocus: function () { _.delay(function(me){ - me.listNames.$el.find('.listview').focus(); + me.listNames.focus(); }, 100, this); },