PageSourceSearch

https://www.mysprintt.eu/sites/all/modules/accordions/accordions_v-1.0.js

js mysprintt.eu collected 2026-10-04 19:38:34 UTC 6,441 bytes, 173 lines download raw bytes

1(function ($) {
2
3  Drupal.accordion = Drupal.accordion || {};
4
5  /**
6   * Toggle the visibility of an individual accordion using smooth animations.
7   */
8  Drupal.accordion.toggle = function (accordion, context, accordion_type_info) {
9    var $accordion = $(accordion);
10    if ($accordion.is('.collapsed')) {
11      // Collapse all items in the accordion group.
12      $('.accordion[data-accordions-group="' + $accordion.attr('data-accordions-group') + '"]', context).each(function () {
13        Drupal.accordion.collapse.call(this, accordion_type_info);
14      });
15      // Then expand this item.
16      Drupal.accordion.expand.call(accordion, accordion_type_info);
17    }
18    else {
19      Drupal.accordion.collapse.call(accordion, accordion_type_info);
20    }
21  };
22
23  Drupal.accordion.expand = function (accordion_type_info) {
24    var accordion = this;
25    var $accordion = $(accordion);
26    var $content = $accordion.closestDescendant(accordion_type_info.content).hide();
27    $accordion
28      .removeClass('collapsed')
29      .trigger({ type: 'collapsed', value: false });
30    $('span.accordions-label-prefix', $accordion.closestDescendant(accordion_type_info.label)).html(Drupal.t('Hide'));
31    $content.slideDown({
32      duration: 100,
33      easing: 'linear',
34      complete: function () {
35        Drupal.collapseScrollIntoView(accordion);
36        accordion.animating = false;
37      },
38      step: function () {
39        // Scroll the accordion into view.
40        Drupal.collapseScrollIntoView(accordion);
41      }
42    });
43  };
44
45  Drupal.accordion.collapse = function (accordion_type_info) {
46    var accordion = this;
47    var $accordion = $(accordion);
48    $accordion.trigger({ type: 'collapsed', value: true });
49    $accordion.closestDescendant(accordion_type_info.content).slideUp({
50      duration: 100,
51      easing: 'linear',
52      complete: function () {
53        $accordion.addClass('collapsed');
54        $('span.accordions-label-prefix', $accordion.closestDescendant(accordion_type_info.label)).html(Drupal.t('Show'));
55        accordion.animating = false;
56      }
57    });
58  };
59
60  /**
61   * Based on Drupal.behaviors.collapse
62   */
63  Drupal.behaviors.accordions = {
64    attach: function (context, settings) {
65      if (settings.accordions != 'undefined'  && typeof settings.accordions != 'undefined') {
66        $('.accordion', context).once('collapse', function () {
67          var accordion = this;
68          var $accordion = $(accordion);
69          var accordion_type = $accordion.attr('data-accordions-type');
70          if (settings.accordions.hasOwnProperty(accordion_type)) {
71            // Turn the title into a clickable link.
72            var $title = $accordion.closestDescendant(settings.accordions[accordion_type].label); // @todo currently only works for accordion items with titles.
73            if ($title.length > 0) {
74              // Expand accordion if it contains an element that is targeted by the
75              // URI fragment identifier.
76              var anchor = location.hash && location.hash != '#' ? location.hash : '';
77              if ('#' + $accordion.attr('id') == anchor || $accordion.find(anchor).length) {
78                $accordion.removeClass('collapsed');
79              }
80              // Collapse accordion initially unless specified as initially expanded.
81              else if (!$accordion.attr('data-accordions-initial')) {
82                Drupal.accordion.collapse.call(accordion, settings.accordions[accordion_type]);
83              }
84
85              $('<span class="accordions-label-prefix element-invisible"></span>')
86                .append($accordion.hasClass('collapsed') ? Drupal.t('Show') : Drupal.t('Hide'))
87                .prependTo($title)
88                .after(' ');
89
90              // .wrapInner() does not retain bound events.
91              var $link = $('<a class="accordions-label" href="#"></a>')
92                .prepend($title.contents())
93                .appendTo($title)
94                .click(function () {
95                  // Don't animate multiple times.
96                  if (!accordion.animating) {
97                    accordion.animating = true;
98                    Drupal.accordion.toggle(accordion, context, settings.accordions[accordion_type]);
99                  }
100                  return false;
101                });
102            }
103            else {
104              // @todo Remove this code that removes accordion items without
105              // titles from the accordion group once we support those.
106              $accordion.removeAttr('data-accordions-group');
107            }
108          }
109        });
110      }
111    }
112  };
113
114  // THIS PART COPIED FROM https://github.com/tlindig/jquery-closest-descendant
115  /**
116   * closestDescendant - 0.1.1 - 2013-04-09
117   * https://github.com/tlindig/jquery-closest-descendant
118   *
119   * Copyright (c) 2013 Tobias Lindig
120   * http://tlindig.de/
121   *
122   * Licensed MIT
123   */
124  /**
125   * Get the first element(s) that matches the selector by traversing down
126   * through descendants in the DOM tree level by level. It use a breadth
127   * first search (BFS), that mean it will stop search and not going deeper in
128   * the current subtree if the first matching descendant was found.
129   *
130   * @param  {selectors} selector -required- a jQuery selector
131   * @param  {boolean} findAll -optional- default is false, if true, every
132   *                           subtree will be visited until first match
133   * @return {jQuery} matched element(s)
134   */
135  $.fn.closestDescendant = $.fn.closestDescendant || function(selector, findAll) {
136
137    if (!selector || selector === '') {
138      return $();
139    }
140
141    findAll = findAll ? true : false;
142
143    var resultSet = $();
144
145    this.each(function() {
146
147      var $this = $(this);
148
149      // breadth first search for every matched node,
150      // go deeper, until a child was found in the current subtree or the leave was reached.
151      var queue = [];
152      queue.push( $this );
153      while ( queue.length > 0 ) {
154        var node = queue.shift();
155        var children = node.children();
156        for ( var i = 0; i < children.length; ++i ) {
157          var $child = $(children[i]);
158          if ( $child.is( selector ) ) {
159            resultSet.push( $child[0] ); //well, we found one
160            if ( ! findAll ) {
161              return false;//stop processing
162            }
163          } else {
164            queue.push( $child ); //go deeper
165          }
166        }
167      }
168    });
169
170    return resultSet;
171  };
172
173})(jQuery);

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.