X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fblock%2Fjs%2Fblock.admin.js;h=7cafed16ac64cf2108a40a7c33a39312cc0dadef;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=9f99b7fabaf04afe897a6683529ca142473cb669;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/block/js/block.admin.js b/web/core/modules/block/js/block.admin.js index 9f99b7fab..7cafed16a 100644 --- a/web/core/modules/block/js/block.admin.js +++ b/web/core/modules/block/js/block.admin.js @@ -1,51 +1,20 @@ /** - * @file - * Block admin behaviors. - */ +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ -(function ($, Drupal) { - - 'use strict'; - - /** - * Filters the block list by a text input search string. - * - * The text input will have the selector `input.block-filter-text`. - * - * The target element to do searching in will be in the selector - * `input.block-filter-text[data-element]` - * - * The text source where the text should be found will have the selector - * `.block-filter-text-source` - * - * @type {Drupal~behavior} - * - * @prop {Drupal~behaviorAttach} attach - * Attaches the behavior for the block filtering. - */ +(function ($, Drupal, debounce) { Drupal.behaviors.blockFilterByText = { - attach: function (context, settings) { + attach: function attach(context, settings) { var $input = $('input.block-filter-text').once('block-filter-text'); var $table = $($input.attr('data-element')); - var $filter_rows; + var $filterRows = void 0; - /** - * Filters the block list. - * - * @param {jQuery.Event} e - * The jQuery event for the keyup event that triggered the filter. - */ function filterBlockList(e) { var query = $(e.target).val().toLowerCase(); - /** - * Shows or hides the block entry based on the query. - * - * @param {number} index - * The index in the loop, as provided by `jQuery.each` - * @param {HTMLElement} label - * The label of the block. - */ function toggleBlockEntry(index, label) { var $label = $(label); var $row = $label.parent().parent(); @@ -53,39 +22,29 @@ $row.toggle(textMatch); } - // Filter if the length of the query is at least 2 characters. if (query.length >= 2) { - $filter_rows.each(toggleBlockEntry); - } - else { - $filter_rows.each(function (index) { + $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) { - $filter_rows = $table.find('div.block-filter-text-source'); - $input.on('keyup', filterBlockList); + $filterRows = $table.find('div.block-filter-text-source'); + $input.on('keyup', debounce(filterBlockList, 200)); } } }; - /** - * Highlights the block that was just placed into the block listing. - * - * @type {Drupal~behavior} - * - * @prop {Drupal~behaviorAttach} attach - * Attaches the behavior for the block placement highlighting. - */ Drupal.behaviors.blockHighlightPlacement = { - attach: function (context, settings) { + attach: function attach(context, settings) { if (settings.blockPlacement) { $(context).find('[data-drupal-selector="edit-blocks"]').once('block-highlight').each(function () { var $container = $(this); - // Just scrolling the document.body will not work in Firefox. The html - // element is needed as well. + $('html, body').animate({ scrollTop: $('.js-block-placed').offset().top - $container.offset().top + $container.scrollTop() }, 500); @@ -93,5 +52,4 @@ } } }; - -}(jQuery, Drupal)); +})(jQuery, Drupal, Drupal.debounce); \ No newline at end of file