PageSourceSearch

https://www.kabirproject.org/misc/tableheader_r.js

js kabirproject.org collected 2026-10-02 17:00:40 UTC 4,580 bytes, 128 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opens = _____WB$wombat$assign$function_____("opens");
10// $Id: tableheader.js,v 1.16.2.2 2009/03/30 12:48:09 goba Exp $
11
12Drupal.tableHeaderDoScroll = function() {
13  if (typeof(Drupal.tableHeaderOnScroll)=='function') {
14    Drupal.tableHeaderOnScroll();
15  }
16};
17
18Drupal.behaviors.tableHeader = function (context) {
19  // This breaks in anything less than IE 7. Prevent it from running.
20  if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7) {
21    return;
22  }
23
24  // Keep track of all cloned table headers.
25  var headers = [];
26
27  $('table.sticky-enabled thead:not(.tableHeader-processed)', context).each(function () {
28    // Clone thead so it inherits original jQuery properties.
29    var headerClone = $(this).clone(true).insertBefore(this.parentNode).wrap('<table class="sticky-header"></table>').parent().css({
30      position: 'fixed',
31      top: '0px'
32    });
33
34    headerClone = $(headerClone)[0];
35    headers.push(headerClone);
36
37    // Store parent table.
38    var table = $(this).parent('table')[0];
39    headerClone.table = table;
40    // Finish initialzing header positioning.
41    tracker(headerClone);
42
43    $(table).addClass('sticky-table');
44    $(this).addClass('tableHeader-processed');
45  });
46
47  // Define the anchor holding var.
48  var prevAnchor = '';
49
50  // Track positioning and visibility.
51  function tracker(e) {
52    // Save positioning data.
53    var viewHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
54    if (e.viewHeight != viewHeight) {
55      e.viewHeight = viewHeight;
56      e.vPosition = $(e.table).offset().top - 4;
57      e.hPosition = $(e.table).offset().left;
58      e.vLength = e.table.clientHeight - 100;
59      // Resize header and its cell widths.
60      var parentCell = $('th', e.table);
61      $('th', e).each(function(index) {
62        var cellWidth = parentCell.eq(index).css('width');
63        // Exception for IE7.
64        if (cellWidth == 'auto') {
65          cellWidth = parentCell.get(index).clientWidth +'px';
66        }
67        $(this).css('width', cellWidth);
68      });
69      $(e).css('width', $(e.table).css('width'));
70    }
71
72    // Track horizontal positioning relative to the viewport and set visibility.
73    var hScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
74    var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - e.vPosition;
75    var visState = (vOffset > 0 && vOffset < e.vLength) ? 'visible' : 'hidden';
76    $(e).css({left: -hScroll + e.hPosition +'px', visibility: visState});
77
78    // Check the previous anchor to see if we need to scroll to make room for the header.
79    // Get the height of the header table and scroll up that amount.
80    if (prevAnchor != location.hash) {
81      if (location.hash != '') {
82        var offset = $('td' + location.hash).offset();
83        if (offset) {
84          var top = offset.top;
85          var scrollLocation = top - $(e).height();
86          $('body, html').scrollTop(scrollLocation);
87        }
88      }
89      prevAnchor = location.hash;
90    }
91  }
92
93  // Only attach to scrollbars once, even if Drupal.attachBehaviors is called
94  //  multiple times.
95  if (!$('body').hasClass('tableHeader-processed')) {
96    $('body').addClass('tableHeader-processed');
97    $(window).scroll(Drupal.tableHeaderDoScroll);
98    $(document.documentElement).scroll(Drupal.tableHeaderDoScroll);
99  }
100
101  // Track scrolling.
102  Drupal.tableHeaderOnScroll = function() {
103    $(headers).each(function () {
104      tracker(this);
105    });
106  };
107
108  // Track resizing.
109  var time = null;
110  var resize = function () {
111    // Ensure minimum time between adjustments.
112    if (time) {
113      return;
114    }
115    time = setTimeout(function () {
116      $('table.sticky-header').each(function () {
117        // Force cell width calculation.
118        this.viewHeight = 0;
119        tracker(this);
120      });
121      // Reset timer
122      time = null;
123    }, 250);
124  };
125  $(window).resize(resize);
126};
127
128}

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.