Security update to Drupal 8.4.6
[yaffs-website] / web / core / modules / filter / filter.es6.js
1 /**
2  * @file
3  * Attaches behavior for the Filter module.
4  */
5
6 (function ($, Drupal) {
7   /**
8    * Displays the guidelines of the selected text format automatically.
9    *
10    * @type {Drupal~behavior}
11    *
12    * @prop {Drupal~behaviorAttach} attach
13    *   Attaches behavior for updating filter guidelines.
14    */
15   Drupal.behaviors.filterGuidelines = {
16     attach(context) {
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();
23       }
24
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');
32     },
33   };
34 }(jQuery, Drupal));