comparison core/modules/block/js/block.admin.es6.js @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
22 */ 22 */
23 Drupal.behaviors.blockFilterByText = { 23 Drupal.behaviors.blockFilterByText = {
24 attach(context, settings) { 24 attach(context, settings) {
25 const $input = $('input.block-filter-text').once('block-filter-text'); 25 const $input = $('input.block-filter-text').once('block-filter-text');
26 const $table = $($input.attr('data-element')); 26 const $table = $($input.attr('data-element'));
27 let $filter_rows; 27 let $filterRows;
28 28
29 /** 29 /**
30 * Filters the block list. 30 * Filters the block list.
31 * 31 *
32 * @param {jQuery.Event} e 32 * @param {jQuery.Event} e
50 $row.toggle(textMatch); 50 $row.toggle(textMatch);
51 } 51 }
52 52
53 // Filter if the length of the query is at least 2 characters. 53 // Filter if the length of the query is at least 2 characters.
54 if (query.length >= 2) { 54 if (query.length >= 2) {
55 $filter_rows.each(toggleBlockEntry); 55 $filterRows.each(toggleBlockEntry);
56 Drupal.announce( 56 Drupal.announce(
57 Drupal.formatPlural( 57 Drupal.formatPlural(
58 $table.find('tr:visible').length - 1, 58 $table.find('tr:visible').length - 1,
59 '1 block is available in the modified list.', 59 '1 block is available in the modified list.',
60 '@count blocks are available in the modified list.' 60 '@count blocks are available in the modified list.',
61 ) 61 ),
62 ); 62 );
63 } 63 }
64 else { 64 else {
65 $filter_rows.each(function (index) { 65 $filterRows.each(function (index) {
66 $(this).parent().parent().show(); 66 $(this).parent().parent().show();
67 }); 67 });
68 } 68 }
69 } 69 }
70 70
71 if ($table.length) { 71 if ($table.length) {
72 $filter_rows = $table.find('div.block-filter-text-source'); 72 $filterRows = $table.find('div.block-filter-text-source');
73 $input.on('keyup', debounce(filterBlockList, 200)); 73 $input.on('keyup', debounce(filterBlockList, 200));
74 } 74 }
75 }, 75 },
76 }; 76 };
77 77
89 $(context).find('[data-drupal-selector="edit-blocks"]').once('block-highlight').each(function () { 89 $(context).find('[data-drupal-selector="edit-blocks"]').once('block-highlight').each(function () {
90 const $container = $(this); 90 const $container = $(this);
91 // Just scrolling the document.body will not work in Firefox. The html 91 // Just scrolling the document.body will not work in Firefox. The html
92 // element is needed as well. 92 // element is needed as well.
93 $('html, body').animate({ 93 $('html, body').animate({
94 scrollTop: $('.js-block-placed').offset().top - $container.offset().top + $container.scrollTop(), 94 scrollTop: ($('.js-block-placed').offset().top - $container.offset().top) + $container.scrollTop(),
95 }, 500); 95 }, 500);
96 }); 96 });
97 } 97 }
98 }, 98 },
99 }; 99 };