[DE] Fix focus for overlapping windows

This commit is contained in:
Julia Radzhabova 2020-10-13 13:29:07 +03:00
parent 1cb3bcdea9
commit 198c25e580
3 changed files with 33 additions and 19 deletions

View file

@ -131,7 +131,8 @@ Common.UI.FocusManager = function (tabindex, parent) {
Common.UI.FocusManager2 = new(function() {
var _tabindex = 1,
_windows = [];
_windows = [],
_count = 0;
var register = function(fields) {
var arr = [];
@ -184,6 +185,17 @@ Common.UI.FocusManager2 = new(function() {
current.traps = [trapFirst, trapLast];
};
var updateTabIndexes = function(increment) {
var step = increment ? 1 : -1;
for (var cid in _windows) {
if (_windows.hasOwnProperty(cid)) {
var item = _windows[cid];
if (item && item.index < _count-1 && item.traps)
item.traps[1].attr('tabindex', (parseInt(item.traps[1].attr('tabindex')) + step).toString());
}
}
};
var _add = function(e, fields) {
if (e && e.cid) {
if (_windows[e.cid]) {
@ -192,7 +204,8 @@ Common.UI.FocusManager2 = new(function() {
_windows[e.cid] = {
parent: e,
fields: register(fields),
hidden: false
hidden: false,
index: _count++
};
}
addTraps(_windows[e.cid]);
@ -207,8 +220,10 @@ Common.UI.FocusManager2 = new(function() {
} else {
_windows[e.cid] = {
parent: e,
hidden: false
hidden: false,
index: _count++
};
updateTabIndexes(true);
}
}
},
@ -220,7 +235,9 @@ Common.UI.FocusManager2 = new(function() {
},
'modal:close': function(e, last) {
if (e && e.cid && _windows[e.cid]) {
updateTabIndexes(false);
delete _windows[e.cid];
_count--;
}
},
'modal:hide': function(e, last) {

View file

@ -53,8 +53,7 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
contentWidth: 310,
height: 392,
toggleGroup: 'control-adv-settings-group',
storageName: 'de-control-settings-adv-category',
focusManager: true
storageName: 'de-control-settings-adv-category'
},
initialize : function(options) {
@ -350,20 +349,17 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
this.spnWidth.setDisabled(!checked);
}, this));
// 0 tab
this.focusManager.add([this.txtName, this.txtTag, this.txtPlaceholder, this.cmbShow], '.form-control');
// 2 tab
this.focusManager.add([this.list], '.listview');
// 3 tab
this.focusManager.add([this.txtDate], '.form-control');
this.focusManager.add([this.listFormats], '.listview');
this.focusManager.add([this.cmbLang], '.form-control');
this.afterRender();
},
getFocusedComponents: function() {
return [
this.txtName, this.txtTag, this.txtPlaceholder, this.cmbShow, // 0 tab
{cmp: this.list, selector: '.listview'}, // 2 tab
this.txtDate, {cmp: this.listFormats, selector: '.listview'}, this.cmbLang // 3 tab
];
},
onCategoryClick: function(btn, index) {
Common.Views.AdvancedSettingsWindow.prototype.onCategoryClick.call(this, btn, index);

View file

@ -49,8 +49,7 @@ define([
width: 330,
header: false,
cls: 'modal-dlg',
buttons: ['ok', 'cancel'],
focusManager: true
buttons: ['ok', 'cancel']
},
initialize : function(options) {
@ -124,8 +123,10 @@ define([
var $window = this.getChild();
$window.find('.btn').on('click', _.bind(this.onBtnClick, this));
},
this.focusManager.add([this.inputName, this.inputValue], '.form-control');
getFocusedComponents: function() {
return [this.inputName, this.inputValue];
},
show: function() {