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