3 * Attaches behavior for the Filter module.
6 (function ($, Drupal) {
8 * Displays the guidelines of the selected text format automatically.
10 * @type {Drupal~behavior}
12 * @prop {Drupal~behaviorAttach} attach
13 * Attaches behavior for updating filter guidelines.
15 Drupal.behaviors.filterGuidelines = {
17 function updateFilterGuidelines(event) {
18 const $this = $(event.target);
19 const value = $this.val();
20 $this.closest('.filter-wrapper')
21 .find('.filter-guidelines-item').hide()
22 .filter(`.filter-guidelines-${value}`).show();
25 $(context).find('.filter-guidelines').once('filter-guidelines')
26 .find(':header').hide()
27 .closest('.filter-wrapper').find('select.filter-list')
28 .on('change.filterGuidelines', updateFilterGuidelines)
29 // Need to trigger the namespaced event to avoid triggering formUpdated
30 // when initializing the select.
31 .trigger('change.filterGuidelines');