Update bootstrap (fixed adding of active class to dropdown menu items, fixed moving through dropdown items)

This commit is contained in:
JuliaSvinareva 2020-10-17 19:19:54 +03:00
parent 1f27ad8632
commit 7156601948
4 changed files with 15 additions and 12 deletions

View file

@ -451,8 +451,9 @@ define([
} }
$('button:first', el).toggleClass('active', select); $('button:first', el).toggleClass('active', select);
} else } else {
$('[data-toggle^=dropdown]', el).toggleClass('active', select); $('[data-toggle^=dropdown]:not(.dropdown-item)', el).toggleClass('active', select);
}
el.toggleClass('active', select); el.toggleClass('active', select);
}; };

View file

@ -76,11 +76,12 @@ function patchDropDownKeyDown(e) {
if ($this.is('.disabled, :disabled')) return; if ($this.is('.disabled, :disabled')) return;
var $parent = getParent($this); var $parent = getParent($this);
var isActive = $parent.hasClass('show') || $parent.hasClass('over'); var $reference = $(e.currentTarget).hasClass('dropdown-item') ? $parent.parent().parent() : $parent;
var isActive = $reference.hasClass('open') || $reference.hasClass('show') || $reference.hasClass('over');
if (!isActive || (isActive && e.keyCode == 27)) { if (!isActive || (isActive && e.keyCode == 27)) {
if (e.which == 27) { if (e.which == 27) {
$items = $('[role=menu] li.dropdown-submenu.over:visible', $parent); $items = $('[role=menu] li.dropdown-submenu.over:visible', $reference);
if ($items.length) { if ($items.length) {
$items.eq($items.length-1).removeClass('over'); $items.eq($items.length-1).removeClass('over');
return false; return false;
@ -88,14 +89,15 @@ function patchDropDownKeyDown(e) {
$parent.removeClass('over'); $parent.removeClass('over');
$parent.find('> a').focus(); $parent.find('> a').focus();
} else { } else {
$parent.find('[data-toggle=dropdown]').focus(); $reference.find('[data-toggle=dropdown]:not(.dropdown-item)').focus().click();
return false;
} }
} }
return (isActive) ? $this.click() : undefined; return (isActive) ? $this.click() : undefined;
} }
// var $items = $('[role=menu] li:not(.divider):visible a', $parent) - original search function // var $items = $('[role=menu] li:not(.divider):visible a', $parent) - original search function
var $items = $('> [role=menu] > li:not(.dropdown-divider):not(.disabled):visible', $parent).find('> a'); var $items = $('> [role=menu] > li:not(.dropdown-divider):not(.disabled):visible', $reference).find('> a');
if (!$items.length) return; if (!$items.length) return;

View file

@ -243,7 +243,7 @@ define([
}); });
if (!this.appConfig.isRestrictedEdit) {// hide Display mode option for fillForms and commenting mode if (!this.appConfig.isRestrictedEdit) {// hide Display mode option for fillForms and commenting mode
var menuTemplate = _.template('<a id="<%= id %>" tabindex="-1" type="menuitem"><div><%= caption %></div>' + var menuTemplate = _.template('<a id="<%= id %>" tabindex="-1" type="menuitem" class="dropdown-item"><div><%= caption %></div>' +
'<% if (options.description !== null) { %><label style="display: block;color: #a5a5a5;cursor: pointer;white-space: normal;"><%= options.description %></label>' + '<% if (options.description !== null) { %><label style="display: block;color: #a5a5a5;cursor: pointer;white-space: normal;"><%= options.description %></label>' +
'<% } %></a>'); '<% } %></a>');
@ -351,7 +351,7 @@ define([
(new Promise(function (accept, reject) { (new Promise(function (accept, reject) {
accept(); accept();
})).then(function(){ })).then(function(){
var menuTemplate = _.template('<a id="<%= id %>" tabindex="-1" type="menuitem"><div><%= caption %></div>' + var menuTemplate = _.template('<a id="<%= id %>" tabindex="-1" type="menuitem" class="dropdown-item"><div><%= caption %></div>' +
'<% if (options.description !== null) { %><label style="display: block;color: #a5a5a5;cursor: pointer;white-space: normal;"><%= options.description %></label>' + '<% if (options.description !== null) { %><label style="display: block;color: #a5a5a5;cursor: pointer;white-space: normal;"><%= options.description %></label>' +
'<% } %></a>'); '<% } %></a>');

View file

@ -256,7 +256,7 @@ define([
'</div></a></li>', '</div></a></li>',
'<% }); %>', '<% }); %>',
'<li class="dropdown-divider">', '<li class="dropdown-divider">',
'<li id="id-toolbar-mnu-item-more-formats" data-value="-1"><a tabindex="-1" type="menuitem">' + me.textMoreFormats + '</a></li>' '<li id="id-toolbar-mnu-item-more-formats" data-value="-1"><a tabindex="-1" type="menuitem" class="dropdown-item">' + me.textMoreFormats + '</a></li>'
].join('')); ].join(''));
me.cmbNumberFormat = new Common.UI.ComboBox({ me.cmbNumberFormat = new Common.UI.ComboBox({
@ -824,7 +824,7 @@ define([
'</div></a></li>', '</div></a></li>',
'<% }); %>', '<% }); %>',
'<li class="dropdown-divider">', '<li class="dropdown-divider">',
'<li id="id-toolbar-mnu-item-more-formats" data-value="-1"><a tabindex="-1" type="menuitem">' + me.textMoreFormats + '</a></li>' '<li id="id-toolbar-mnu-item-more-formats" data-value="-1"><a tabindex="-1" type="menuitem" class="dropdown-item">' + me.textMoreFormats + '</a></li>'
].join('')); ].join(''));
me.cmbNumberFormat = new Common.UI.ComboBox({ me.cmbNumberFormat = new Common.UI.ComboBox({
@ -1803,7 +1803,7 @@ define([
iconCls : 'menu__icon btn-border-style', iconCls : 'menu__icon btn-border-style',
// template : _.template('<a id="<%= id %>" tabindex="-1" type="menuitem"><span class="menu-item-icon" style="background-image: none; width: 11px; height: 11px; margin: 2px 7px 0 -9px;"></span><%= caption %></a>'), // template : _.template('<a id="<%= id %>" tabindex="-1" type="menuitem"><span class="menu-item-icon" style="background-image: none; width: 11px; height: 11px; margin: 2px 7px 0 -9px;"></span><%= caption %></a>'),
menu : (function(){ menu : (function(){
var itemTemplate = _.template('<a id="<%= id %>" tabindex="-1" type="menuitem"><div class="border-size-item" style="background-position: 0 -<%= options.offsety %>px;"></div></a>'); var itemTemplate = _.template('<a id="<%= id %>" tabindex="-1" type="menuitem" class="dropdown-item"><div class="border-size-item" style="background-position: 0 -<%= options.offsety %>px;"></div></a>');
me.mnuBorderWidth = new Common.UI.Menu({ me.mnuBorderWidth = new Common.UI.Menu({
style : 'min-width: 100px;', style : 'min-width: 100px;',
@ -1831,7 +1831,7 @@ define([
id : 'id-toolbar-mnu-item-border-color', id : 'id-toolbar-mnu-item-border-color',
caption : this.textBordersColor, caption : this.textBordersColor,
iconCls : 'mnu-icon-item mnu-border-color', iconCls : 'mnu-icon-item mnu-border-color',
template : _.template('<a id="<%= id %>"tabindex="-1" type="menuitem"><span class="menu-item-icon" style="background-image: none; width: 12px; height: 12px; margin: 2px 9px 0 -11px; border-style: solid; border-width: 3px; border-color: #000;"></span><%= caption %></a>'), template : _.template('<a id="<%= id %>"tabindex="-1" type="menuitem" class="dropdown-item"><span class="menu-item-icon" style="background-image: none; width: 12px; height: 12px; margin: 2px 9px 0 -11px; border-style: solid; border-width: 3px; border-color: #000;"></span><%= caption %></a>'),
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
menuAlign : 'tl-tr', menuAlign : 'tl-tr',
items : [ items : [