PageSourceSearch

https://zeneszapro.hu/misc/collapse.js

js zeneszapro.hu collected 2026-10-08 08:12:25 UTC 2,730 bytes, 79 lines download raw bytes

1// $Id: collapse.js,v 1.1.2.2 2008/05/30 21:41:14 sun Exp $
2
3/**
4 * Toggle the visibility of a fieldset using smooth animations
5 */
6Drupal.toggleFieldset = function(fieldset) {
7  if ($(fieldset).is('.collapsed')) {
8    var content = $('> div', fieldset).hide();
9    $(fieldset).removeClass('collapsed');
10    content.slideDown({
11      duration: 300,
12      complete: function() {
13        // Make sure we open to height auto
14        $(this).css('height', 'auto');
15        Drupal.collapseScrollIntoView(this.parentNode);
16        this.parentNode.animating = false;
17      },
18      step: function() {
19         // Scroll the fieldset into view
20        Drupal.collapseScrollIntoView(this.parentNode);
21      }
22    });
23    if (typeof Drupal.textareaAttach != 'undefined') {
24      // Initialize resizable textareas that are now revealed
25      Drupal.textareaAttach(null, fieldset);
26    }
27  }
28  else {
29    var content = $('> div', fieldset).slideUp('medium', function() {
30      $(this.parentNode).addClass('collapsed');
31      this.parentNode.animating = false;
32    });
33  }
34}
35
36/**
37 * Scroll a given fieldset into view as much as possible.
38 */
39Drupal.collapseScrollIntoView = function (node) {
40  var h = self.innerHeight || document.documentElement.clientHeight || $('body')[0].clientHeight || 0;
41  var offset = self.pageYOffset || document.documentElement.scrollTop || $('body')[0].scrollTop || 0;
42  var pos = Drupal.absolutePosition(node);
43  var fudge = 55;
44  if (pos.y + node.offsetHeight + fudge > h + offset) {
45    if (node.offsetHeight > h) {
46      window.scrollTo(0, pos.y);
47    } else {
48      window.scrollTo(0, pos.y + node.offsetHeight - h + fudge);
49    }
50  }
51}
52
53// Global Killswitch
54if (Drupal.jsEnabled) {
55  $(document).ready(function() {
56    $('fieldset.collapsible > legend').each(function() {
57      var fieldset = $(this.parentNode);
58      // Expand if there are errors inside
59      if ($('input.error, textarea.error, select.error', fieldset).size() > 0) {
60        fieldset.removeClass('collapsed');
61      }
62
63      // Turn the legend into a clickable link and wrap the contents of the fieldset
64      // in a div for easier animation
65      var text = this.innerHTML;
66      $(this).empty().append($('<a href="#">
66'+ text +'</a>').click(function() {
67        var fieldset = $(this).parents('fieldset:first')[0];
68        // Don't animate multiple times
69        if (!fieldset.animating) {
70          fieldset.animating = true;
71          Drupal.toggleFieldset(fieldset);
72        }
73        return false;
74      })).after($('<div class="fieldset-wrapper"></div>').append(fieldset.children(':not(legend)')));
75      fieldset.filter('.collapsed').children('.fieldset-wrapper')
76        .css({height: 'auto', display: 'inline'});
77    });
78  });
79}

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.