1;(function($) { 2 3// Keep track of all header cells. 4var cells = []; 5 6// Attach to all headers. 7$(document).ready(function() { 8 $('table thead.sticky').each(function () { 9 // Make all absolute positioned elements relative to the table. 10 var height = $(this).parent('table').css('position', 'relative').height(); 11 12 // Find all header cells. 13 $('th', this).each(function () { 14 15 // Ensure each cell has an element in it. 16 var html = $(this).html(); 17 if (html == ' ') { 18 html = ' '; 19 } 20 if ($(this).children().size() == 0) { 21 html = '<span>'+ html +'</span>'; 22 } 23 24 // Clone and wrap cell contents in sticky wrapper that overlaps the cell's padding. 25 $('<div class="sticky-header" style="position: fixed; display: none; top: 0px;">'+ html +'</div>').prependTo(this); 26 var div = $('div.sticky-header', this).css({ 27 'marginLeft': '-'+ $(this).css('paddingLeft'), 28 'marginRight': '-'+ $(this).css('paddingRight'), 29 'paddingLeft': $(this).css('paddingLeft'), 30 'paddingTop': $(this).css('paddingTop'), 31 'paddingRight': $(this).css('paddingRight'), 32 'paddingBottom': $(this).css('paddingBottom') 33 })[0]; 34 // Adjust width to fit cell and hide. 35 36 //CRM-6467 37 var length = $(this).width() - $(div).width(); 38 if ( length < 0 ) length = $(div).width() - $(this).width(); 39 $(div).css('paddingRight', parseInt($(div).css('paddingRight')) + length +'px'); 40 41 cells.push(div); 42 43 // Get position. 44 div.cell = this; 45 div.table = $(this).parent('table')[0]; 46 div.stickyMax = height; 47 div.stickyPosition = $(this).y(); 48 }); 49 }); 50}); 51 52// Track scrolling. 53var scroll = function() { 54 $(cells).each(function () { 55 // Fetch scrolling position. 56 var scroll = document.documentElement.scrollTop || document.body.scrollTop; 57 var offset = scroll - this.stickyPosition - 4; 58 if (offset > 0 && offset < this.stickyMax - 100) { 59 $(this).css({display:'block'}); 60 } 61 else { 62 $(this).css('display', 'none'); 63 } 64 }); 65}; 66$(window).scroll(scroll); 67$(document.documentElement).scroll(scroll); 68 69// Track resizing. 70var resize = function () { 71 $(cells).each(function () { 72 // Get position. 73 $(this).css({ 'position': 'relative', 'top': '0'}); 74 this.stickyPosition = $(this.cell).y(); 75 this.stickyMax = $(this.table).height(); 76 }); 77}; 78$(window).resize(resize); 79 80// Track the element positions 81$.fn.x = function(n) { 82 var result = null; 83 this.each(function() { 84 var o = this; 85 if (n === undefined) { 86 var x = 0; 87 if (o.offsetParent) { 88 while (o.offsetParent) { 89 x += o.offsetLeft; 90 o = o.offsetParent; 91 } 92 } 93 if (result === null) { 94 result = x; 95 } else { 96 result = Math.min(result, x); 97 } 98 } else { 99 o.style.left = n + 'px'; 100 } 101 }); 102 return result; 103}; 104 105$.fn.y = function(n) { 106 var result = null; 107 this.each(function() { 108 var o = this; 109 if (n === undefined) { 110 var y = 0; 111 if (o.offsetParent) { 112 while (o.offsetParent) { 113 y += o.offsetTop; 114 o = o.offsetParent; 115 } 116 } 117 if (result === null) { 118 result = y; 119 } else { 120 result = Math.min(result, y); 121 } 122 } else { 123 o.style.top = n + 'px'; 124 } 125 }); 126 return result; 127}; 128 129})(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.