This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/web/core/modules/block/js/block.admin.js
2019-01-24 08:00:03 +00:00

55 lines
1.8 KiB
JavaScript

/**
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/
(function ($, Drupal, debounce) {
Drupal.behaviors.blockFilterByText = {
attach: function attach(context, settings) {
var $input = $('input.block-filter-text').once('block-filter-text');
var $table = $($input.attr('data-element'));
var $filterRows = void 0;
function filterBlockList(e) {
var query = $(e.target).val().toLowerCase();
function toggleBlockEntry(index, label) {
var $label = $(label);
var $row = $label.parent().parent();
var textMatch = $label.text().toLowerCase().indexOf(query) !== -1;
$row.toggle(textMatch);
}
if (query.length >= 2) {
$filterRows.each(toggleBlockEntry);
Drupal.announce(Drupal.formatPlural($table.find('tr:visible').length - 1, '1 block is available in the modified list.', '@count blocks are available in the modified list.'));
} else {
$filterRows.each(function (index) {
$(this).parent().parent().show();
});
}
}
if ($table.length) {
$filterRows = $table.find('div.block-filter-text-source');
$input.on('keyup', debounce(filterBlockList, 200));
}
}
};
Drupal.behaviors.blockHighlightPlacement = {
attach: function attach(context, settings) {
if (settings.blockPlacement && $('.js-block-placed').length) {
$(context).find('[data-drupal-selector="edit-blocks"]').once('block-highlight').each(function () {
var $container = $(this);
$('html, body').animate({
scrollTop: $('.js-block-placed').offset().top - $container.offset().top + $container.scrollTop()
}, 500);
});
}
}
};
})(jQuery, Drupal, Drupal.debounce);