block.admin.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. (function ($, Drupal, debounce) {
  8. Drupal.behaviors.blockFilterByText = {
  9. attach: function attach(context, settings) {
  10. var $input = $('input.block-filter-text').once('block-filter-text');
  11. var $table = $($input.attr('data-element'));
  12. var $filter_rows = void 0;
  13. function filterBlockList(e) {
  14. var query = $(e.target).val().toLowerCase();
  15. function toggleBlockEntry(index, label) {
  16. var $label = $(label);
  17. var $row = $label.parent().parent();
  18. var textMatch = $label.text().toLowerCase().indexOf(query) !== -1;
  19. $row.toggle(textMatch);
  20. }
  21. if (query.length >= 2) {
  22. $filter_rows.each(toggleBlockEntry);
  23. 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.'));
  24. } else {
  25. $filter_rows.each(function (index) {
  26. $(this).parent().parent().show();
  27. });
  28. }
  29. }
  30. if ($table.length) {
  31. $filter_rows = $table.find('div.block-filter-text-source');
  32. $input.on('keyup', debounce(filterBlockList, 200));
  33. }
  34. }
  35. };
  36. Drupal.behaviors.blockHighlightPlacement = {
  37. attach: function attach(context, settings) {
  38. if (settings.blockPlacement) {
  39. $(context).find('[data-drupal-selector="edit-blocks"]').once('block-highlight').each(function () {
  40. var $container = $(this);
  41. $('html, body').animate({
  42. scrollTop: $('.js-block-placed').offset().top - $container.offset().top + $container.scrollTop()
  43. }, 500);
  44. });
  45. }
  46. }
  47. };
  48. })(jQuery, Drupal, Drupal.debounce);