Mercurial > hg > cmmr2012-drupal-site
diff core/modules/block/js/block.admin.es6.js @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
line wrap: on
line diff
--- a/core/modules/block/js/block.admin.es6.js Thu Feb 28 11:14:44 2019 +0000 +++ b/core/modules/block/js/block.admin.es6.js Thu Feb 28 13:11:55 2019 +0000 @@ -3,7 +3,7 @@ * Block admin behaviors. */ -(function ($, Drupal, debounce) { +(function($, Drupal, debounce) { /** * Filters the block list by a text input search string. * @@ -33,7 +33,9 @@ * The jQuery event for the keyup event that triggered the filter. */ function filterBlockList(e) { - const query = $(e.target).val().toLowerCase(); + const query = $(e.target) + .val() + .toLowerCase(); /** * Shows or hides the block entry based on the query. @@ -46,7 +48,11 @@ function toggleBlockEntry(index, label) { const $label = $(label); const $row = $label.parent().parent(); - const textMatch = $label.text().toLowerCase().indexOf(query) !== -1; + const textMatch = + $label + .text() + .toLowerCase() + .indexOf(query) !== -1; $row.toggle(textMatch); } @@ -60,10 +66,12 @@ '@count blocks are available in the modified list.', ), ); - } - else { - $filterRows.each(function (index) { - $(this).parent().parent().show(); + } else { + $filterRows.each(function(index) { + $(this) + .parent() + .parent() + .show(); }); } } @@ -85,16 +93,26 @@ */ Drupal.behaviors.blockHighlightPlacement = { attach(context, settings) { - if (settings.blockPlacement) { - $(context).find('[data-drupal-selector="edit-blocks"]').once('block-highlight').each(function () { - const $container = $(this); - // Just scrolling the document.body will not work in Firefox. The html - // element is needed as well. - $('html, body').animate({ - scrollTop: ($('.js-block-placed').offset().top - $container.offset().top) + $container.scrollTop(), - }, 500); - }); + // Ensure that the block we are attempting to scroll to actually exists. + if (settings.blockPlacement && $('.js-block-placed').length) { + $(context) + .find('[data-drupal-selector="edit-blocks"]') + .once('block-highlight') + .each(function() { + const $container = $(this); + // Just scrolling the document.body will not work in Firefox. The html + // element is needed as well. + $('html, body').animate( + { + scrollTop: + $('.js-block-placed').offset().top - + $container.offset().top + + $container.scrollTop(), + }, + 500, + ); + }); } }, }; -}(jQuery, Drupal, Drupal.debounce)); +})(jQuery, Drupal, Drupal.debounce);