comparison core/modules/block/js/block.admin.js @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 1fec387a4317
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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 $filter_rows = 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 $filter_rows.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 $filter_rows.each(function (index) {
30 $(this).parent().parent().show();
31 });
32 }
33 }
34
35 if ($table.length) {
36 $filter_rows = $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) {
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);