From 1949441c5557aea63e2368362dc50764ac9d9c3b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 14 Apr 2021 01:30:54 +0300 Subject: [PATCH] Refactoring focus manager --- apps/common/main/lib/component/FocusManager.js | 3 ++- apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js | 2 +- .../main/app/view/HyperlinkSettingsDialog.js | 2 +- apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js | 4 ++++ apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js | 2 +- apps/spreadsheeteditor/main/app/view/FormulaDialog.js | 2 +- .../main/app/view/HyperlinkSettingsDialog.js | 2 +- apps/spreadsheeteditor/main/app/view/NameManagerDlg.js | 2 +- 8 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/common/main/lib/component/FocusManager.js b/apps/common/main/lib/component/FocusManager.js index 1bd20b9e6..f67dfd0ce 100644 --- a/apps/common/main/lib/component/FocusManager.js +++ b/apps/common/main/lib/component/FocusManager.js @@ -58,7 +58,6 @@ Common.UI.FocusManager = new(function() { } fields.forEach(function(field) { if (field) { - // var item = (field.cmp && typeof field.selector == 'string') ? field : {cmp: field, selector: '.form-control'}; var item = {}; if (field.cmp && typeof field.selector == 'string') item = field; @@ -68,6 +67,8 @@ Common.UI.FocusManager = new(function() { item.selector = '.listview'; else if (field instanceof Common.UI.CheckBox) item.selector = '.checkbox-indeterminate'; + else if (field instanceof Common.UI.TreeView) + item.selector = '.treeview'; else item.selector = '.form-control'; } diff --git a/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js b/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js index 4ad958c2f..e5212662d 100644 --- a/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js @@ -188,7 +188,7 @@ define([ }, getFocusedComponents: function() { - return [this.inputUrl, {cmp: this.internalList, selector: '.treeview'}, this.inputDisplay, this.inputTip]; + return [this.inputUrl, this.internalList, this.inputDisplay, this.inputTip]; }, ShowHideElem: function(value) { diff --git a/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js b/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js index fe6233f80..9bb50805a 100644 --- a/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js @@ -191,7 +191,7 @@ define([ }, getFocusedComponents: function() { - return [this.inputUrl, {cmp: this.internalList, selector: '.treeview'}, this.inputDisplay, this.inputTip]; + return [this.inputUrl, this.internalList, this.inputDisplay, this.inputTip]; }, setSettings: function (props) { diff --git a/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js b/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js index e7e21ac83..05929c13f 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js +++ b/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js @@ -807,6 +807,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', }); this.chIconShow.on('change', function(field, newValue, oldValue, eOpts){ }); + Common.UI.FocusManager.add(this, this.chIconShow); this.btnReverse = new Common.UI.Button({ el: $('#format-rules-edit-btn-icon-reverse') @@ -916,6 +917,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', this.chFill.on('change', function(field, newValue, oldValue, eOpts){ me.btnNegFill.setDisabled(field.getValue()=='checked'); }); + Common.UI.FocusManager.add(this, this.chFill); // Border this.cmbBorder = new Common.UI.ComboBox({ @@ -966,6 +968,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', this.chBorder.on('change', function(field, newValue, oldValue, eOpts){ me.btnNegBorder.setDisabled(field.getValue()=='checked'); }); + Common.UI.FocusManager.add(this, this.chBorder); // Axis this.cmbBarDirection = new Common.UI.ComboBox({ @@ -993,6 +996,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', el: $('#format-rules-edit-chk-show-bar'), labelText: this.textShowBar }); + Common.UI.FocusManager.add(this, this.chShowBar); this.cmbAxisPos = new Common.UI.ComboBox({ el : $('#format-rules-edit-combo-axis-pos'), diff --git a/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js b/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js index 6cba717a5..190e8a1d4 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js +++ b/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js @@ -213,7 +213,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa _setDefaults: function (props) { Common.UI.FocusManager.add(this, this.cmbScope); - Common.UI.FocusManager.add(this, {cmp: this.rulesList, selector: '.listview'}); + Common.UI.FocusManager.add(this, this.rulesList); this.rulesList.on('item:add', _.bind(this.addControls, this)); this.rulesList.on('item:change', _.bind(this.addControls, this)); diff --git a/apps/spreadsheeteditor/main/app/view/FormulaDialog.js b/apps/spreadsheeteditor/main/app/view/FormulaDialog.js index ff96e354f..51ac8ca62 100644 --- a/apps/spreadsheeteditor/main/app/view/FormulaDialog.js +++ b/apps/spreadsheeteditor/main/app/view/FormulaDialog.js @@ -125,7 +125,7 @@ define([ }, getFocusedComponents: function() { - return [this.inputSearch, this.cmbFuncGroup, {cmp: this.cmbListFunctions, selector: '.listview'}]; + return [this.inputSearch, this.cmbFuncGroup, this.cmbListFunctions]; }, getDefaultFocusableComponent: function () { diff --git a/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js index 3cd375ee4..e1d31ad34 100644 --- a/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js @@ -255,7 +255,7 @@ define([ }, getFocusedComponents: function() { - return [this.inputUrl, {cmp: this.internalList, selector: '.treeview'}, this.inputRange, this.inputDisplay, this.inputTip]; + return [this.inputUrl, this.internalList, this.inputRange, this.inputDisplay, this.inputTip]; }, setSettings: function(settings) { diff --git a/apps/spreadsheeteditor/main/app/view/NameManagerDlg.js b/apps/spreadsheeteditor/main/app/view/NameManagerDlg.js index ee0269127..8e320e77f 100644 --- a/apps/spreadsheeteditor/main/app/view/NameManagerDlg.js +++ b/apps/spreadsheeteditor/main/app/view/NameManagerDlg.js @@ -172,7 +172,7 @@ define([ 'text!spreadsheeteditor/main/app/template/NameManagerDlg.template', }, getFocusedComponents: function() { - return [ this.cmbFilter, {cmp: this.rangeList, selector: '.listview'} ]; + return [ this.cmbFilter, this.rangeList ]; }, getDefaultFocusableComponent: function () {