diff --git a/core/modules/views_ui/js/views_ui.listing.js b/core/modules/views_ui/js/views_ui.listing.js index ee2199f..e5f0217 100644 --- a/core/modules/views_ui/js/views_ui.listing.js +++ b/core/modules/views_ui/js/views_ui.listing.js @@ -51,4 +51,31 @@ } }; + //Enable button fix + Drupal.behaviors.viewsEnableFocus = { + attach: function (context, settings) { + String.prototype.endsWith = function(str) { + return (this.match(str+"$") == str); + }; + + if (window.location.href.endsWith('/admin/structure/views') == true) { + $('tr.views-ui-list-disabled li.enable .use-ajax', context).on('click', function() { + // Get element title. + var title=$(this).closest('tr').attr('title'); + var interval=setInterval(function() { + var trs = $('tr.views-ui-list-enabled'); + trs.each(function(i) { + // If upper DOM gets updated get element(based on title) and scrool to it. + if ($(this).attr('title') == title) { + $('html, body').animate({scrollTop: Math.round($(this).offset().top) - $(this).innerHeight() },'fast'); + $(this).find('a').focus(); + clearInterval(interval); + } + }); + }, 500); + }); + } + } + }; + }(jQuery, Drupal));