Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / filter / filter.js
1 /**
2  * @file
3  * Attaches behavior for the Filter module.
4  */
5
6 (function ($, Drupal) {
7
8   'use strict';
9
10   /**
11    * Displays the guidelines of the selected text format automatically.
12    *
13    * @type {Drupal~behavior}
14    *
15    * @prop {Drupal~behaviorAttach} attach
16    *   Attaches behavior for updating filter guidelines.
17    */
18   Drupal.behaviors.filterGuidelines = {
19     attach: function (context) {
20
21       function updateFilterGuidelines(event) {
22         var $this = $(event.target);
23         var value = $this.val();
24         $this.closest('.filter-wrapper')
25           .find('.filter-guidelines-item').hide()
26           .filter('.filter-guidelines-' + value).show();
27       }
28
29       $(context).find('.filter-guidelines').once('filter-guidelines')
30         .find(':header').hide()
31         .closest('.filter-wrapper').find('select.filter-list')
32         .on('change.filterGuidelines', updateFilterGuidelines)
33         // Need to trigger the namespaced event to avoid triggering formUpdated
34         // when initializing the select.
35         .trigger('change.filterGuidelines');
36     }
37   };
38
39 })(jQuery, Drupal);