Pull merge.
[yaffs-website] / web / core / modules / block / js / block.admin.js
1 /**
2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
5 * @preserve
6 **/
7
8 (function ($, Drupal, debounce) {
9   Drupal.behaviors.blockFilterByText = {
10     attach: function attach(context, settings) {
11       var $input = $('input.block-filter-text').once('block-filter-text');
12       var $table = $($input.attr('data-element'));
13       var $filterRows = void 0;
14
15       function filterBlockList(e) {
16         var query = $(e.target).val().toLowerCase();
17
18         function toggleBlockEntry(index, label) {
19           var $label = $(label);
20           var $row = $label.parent().parent();
21           var textMatch = $label.text().toLowerCase().indexOf(query) !== -1;
22           $row.toggle(textMatch);
23         }
24
25         if (query.length >= 2) {
26           $filterRows.each(toggleBlockEntry);
27           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.'));
28         } else {
29           $filterRows.each(function (index) {
30             $(this).parent().parent().show();
31           });
32         }
33       }
34
35       if ($table.length) {
36         $filterRows = $table.find('div.block-filter-text-source');
37         $input.on('keyup', debounce(filterBlockList, 200));
38       }
39     }
40   };
41
42   Drupal.behaviors.blockHighlightPlacement = {
43     attach: function attach(context, settings) {
44       if (settings.blockPlacement && $('.js-block-placed').length) {
45         $(context).find('[data-drupal-selector="edit-blocks"]').once('block-highlight').each(function () {
46           var $container = $(this);
47
48           $('html, body').animate({
49             scrollTop: $('.js-block-placed').offset().top - $container.offset().top + $container.scrollTop()
50           }, 500);
51         });
52       }
53     }
54   };
55 })(jQuery, Drupal, Drupal.debounce);