PageSourceSearch

https://www.usagm.gov/wp-content/themes/bbgRedesign/js/components/accordion.js?ver=20160223

js usagm.gov collected 2026-10-02 04:00:57 UTC 1,078 bytes, 46 lines download raw bytes

1/**
2 * Accordion
3 *
4 * An accordion component.
5 *
6 * @param {jQuery} $el A jQuery html element to turn into an accordion.
7 */
8function Accordion($el) {
9  var self = this;
10  this.$root = $el;
11  this.$root.on('click', 'button', function(ev) {
12    var expanded = JSON.parse(jQuery(this).attr('aria-expanded'));
13    ev.preventDefault();
14    self.hideAll();
15    if (!expanded) {
16      self.show(jQuery(this));
17    }
18  });
19}
20
21Accordion.prototype.$ = function(selector) {
22  return this.$root.find(selector);
23}
24
25Accordion.prototype.hide = function($button) {
26  var selector = $button.attr('aria-controls'),
27      $content = this.$('#' + selector);
28
29  $button.attr('aria-expanded', false);
30  $content.attr('aria-hidden', true);
31};
32
33Accordion.prototype.show = function($button) {
34  var selector = $button.attr('aria-controls'),
35      $content = this.$('#' + selector);
36
37  $button.attr('aria-expanded', true);
38  $content.attr('aria-hidden', false);
39};
40
41Accordion.prototype.hideAll = function() {
42  var self = this;
43  this.$('button').each(function() {
44    self.hide(jQuery(this));
45  });
46};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.