PageSourceSearch

https://sag.cl/core/misc/collapse.js?v=9.3.11

js sag.cl collected 2026-10-02 03:58:08 UTC 2,455 bytes, 72 lines download raw bytes

1/**
2* DO NOT EDIT THIS FILE.
3* See the following change record for more information,
4* https://www.drupal.org/node/2815083
5* @preserve
6**/
7
8(function ($, Modernizr, Drupal) {
9  function CollapsibleDetails(node) {
10    this.$node = $(node);
11    this.$node.data('details', this);
12    var anchor = window.location.hash && window.location.hash !== '#' ? ", ".concat(window.location.hash) : '';
13
14    if (this.$node.find(".error".concat(anchor)).length) {
15      this.$node.attr('open', true);
16    }
17
18    this.setupSummaryPolyfill();
19  }
20
21  $.extend(CollapsibleDetails, {
22    instances: []
23  });
24  $.extend(CollapsibleDetails.prototype, {
25    setupSummaryPolyfill: function setupSummaryPolyfill() {
26      var $summary = this.$node.find('> summary');
27      $summary.attr('tabindex', '-1');
28      $('<span class="details-summary-prefix visually-hidden"></span>').append(this.$node.attr('open') ? Drupal.t('Hide') : Drupal.t('Show')).prependTo($summary).after(document.createTextNode(' '));
29      $('<a class="details-title"></a>').attr('href', "#".concat(this.$node.attr('id'))).prepend($summary.contents()).appendTo($summary);
30      $summary.append(this.$summary).on('click', $.proxy(this.onSummaryClick, this));
31    },
32    onSummaryClick: function onSummaryClick(e) {
33      this.toggle();
34      e.preventDefault();
35    },
36    toggle: function toggle() {
37      var _this = this;
38
39      var isOpen = !!this.$node.attr('open');
40      var $summaryPrefix = this.$node.find('> summary span.details-summary-prefix');
41
42      if (isOpen) {
43        $summaryPrefix.html(Drupal.t('Show'));
44      } else {
45        $summaryPrefix.html(Drupal.t('Hide'));
46      }
47
48      setTimeout(function () {
49        _this.$node.attr('open', !isOpen);
50      }, 0);
51    }
52  });
53  Drupal.behaviors.collapse = {
54    attach: function attach(context) {
55      if (Modernizr.details) {
56        return;
57      }
58
59      once('collapse', 'details', context).forEach(function (detail) {
60        detail.classList.add('collapse-processed');
61        CollapsibleDetails.instances.push(new CollapsibleDetails(detail));
62      });
63    }
64  };
65
66  var handleFragmentLinkClickOrHashChange = function handleFragmentLinkClickOrHashChange(e, $target) {
67    $target.parents('details').not('[open]').find('> summary').trigger('click');
68  };
69
70  $('body').on('formFragmentLinkClickOrHashChange.details', handleFragmentLinkClickOrHashChange);
71  Drupal.CollapsibleDetails = CollapsibleDetails;
72})(jQuery, Modernizr, Drupal);

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.