3 * Attaches behavior for the Filter module.
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();
21 .closest('.filter-wrapper')
22 .find('.filter-guidelines-item')
24 .filter(`.filter-guidelines-${value}`)
29 .find('.filter-guidelines')
30 .once('filter-guidelines')
33 .closest('.filter-wrapper')
34 .find('select.filter-list')
35 .on('change.filterGuidelines', updateFilterGuidelines)
36 // Need to trigger the namespaced event to avoid triggering formUpdated
37 // when initializing the select.
38 .trigger('change.filterGuidelines');