diff core/modules/block/js/block.admin.js @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children a9cd425dd02b
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/modules/block/js/block.admin.js	Thu Jul 05 14:24:15 2018 +0000
@@ -0,0 +1,55 @@
+/**
+* DO NOT EDIT THIS FILE.
+* See the following change record for more information,
+* https://www.drupal.org/node/2815083
+* @preserve
+**/
+
+(function ($, Drupal, debounce) {
+  Drupal.behaviors.blockFilterByText = {
+    attach: function attach(context, settings) {
+      var $input = $('input.block-filter-text').once('block-filter-text');
+      var $table = $($input.attr('data-element'));
+      var $filterRows = void 0;
+
+      function filterBlockList(e) {
+        var query = $(e.target).val().toLowerCase();
+
+        function toggleBlockEntry(index, label) {
+          var $label = $(label);
+          var $row = $label.parent().parent();
+          var textMatch = $label.text().toLowerCase().indexOf(query) !== -1;
+          $row.toggle(textMatch);
+        }
+
+        if (query.length >= 2) {
+          $filterRows.each(toggleBlockEntry);
+          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.'));
+        } else {
+          $filterRows.each(function (index) {
+            $(this).parent().parent().show();
+          });
+        }
+      }
+
+      if ($table.length) {
+        $filterRows = $table.find('div.block-filter-text-source');
+        $input.on('keyup', debounce(filterBlockList, 200));
+      }
+    }
+  };
+
+  Drupal.behaviors.blockHighlightPlacement = {
+    attach: function attach(context, settings) {
+      if (settings.blockPlacement) {
+        $(context).find('[data-drupal-selector="edit-blocks"]').once('block-highlight').each(function () {
+          var $container = $(this);
+
+          $('html, body').animate({
+            scrollTop: $('.js-block-placed').offset().top - $container.offset().top + $container.scrollTop()
+          }, 500);
+        });
+      }
+    }
+  };
+})(jQuery, Drupal, Drupal.debounce);
\ No newline at end of file