FSN#34665 fixed sorttable.js with floating headers

svn path=/Website/trunk/; revision=31142
This commit is contained in:
2016-10-19 10:32:47 +00:00
parent 174a06abab
commit d331665e67
2 changed files with 46 additions and 28 deletions

View File

@@ -405,8 +405,23 @@ $(function ()
function updateTableHeaders() {
$("div.divrstable").each(function() {
var originalHeaderRow = $(".tableFloatingHeaderOriginal", this);
var floatingHeaderRow = $(".tableFloatingHeader", this);
// to do: samenvoegen met .children()
// Copy cell widths from original header cells
$("th", floatingHeaderRow).each(function(index) {
var cellWidth = $("th", originalHeaderRow).eq(index).css('width');
$(this).css('width', cellWidth);
});
// Some <thead>'s contain <td>'s
$("td", floatingHeaderRow).each(function(index) {
var cellWidth = $("td", originalHeaderRow).eq(index).css('width');
$(this).css('width', cellWidth);
});
// Copy row width from whole table
floatingHeaderRow.css("width", $(this).css("width")-1);
var insideFrame = $(this).offset();
var outsideFrame = $(window.frameElement).offset();
var scrollTop = $(window.parent).scrollTop();
@@ -415,26 +430,16 @@ function updateTableHeaders() {
if (outsideFrame) offset += outsideFrame.top;
// if browser is IE then correct the top positioning
var IEcorr = (/*@cc_on!@*/false)?-4:0;
if ((scrollTop > offset) && (scrollTop < offset + $(this).height())) {
floatingHeaderRow.css("visibility", "visible");
if ((scrollTop > offset) && (scrollTop < offset + $(this).height()))
{
originalHeaderRow.css("visibility", "visible");
floatingHeaderRow.css("top", (IEcorr + Math.min(scrollTop - offset, $(this).height() - floatingHeaderRow.height())) + "px");
// Copy cell widths from original header cells
$("th", floatingHeaderRow).each(function(index) {
var cellWidth = $("th", originalHeaderRow).eq(index).css('width');
$(this).css('width', cellWidth);
});
// Some <thead>'s contain <td>'s
$("td", floatingHeaderRow).each(function(index) {
var cellWidth = $("td", originalHeaderRow).eq(index).css('width');
$(this).css('width', cellWidth);
});
// Copy row width from whole table
floatingHeaderRow.css("width", $(this).css("width")-1);
}
else {
floatingHeaderRow.css("visibility", "hidden");
else
{
originalHeaderRow.css("visibility", "hidden");
floatingHeaderRow.css("top", "0px");
}
});
@@ -446,7 +451,7 @@ $(document).ready(function() {
$(this).wrap("<div class=\"divrstable\" style=\"position:relative\"></div>");
var originalHeaderRow = $("thead:first", this)
originalHeaderRow.before(originalHeaderRow.clone());
originalHeaderRow.before(originalHeaderRow.clone(true));
var clonedHeaderRow = $("thead:first", this)
// if browser is IE then correct the left margin
var IEcorr = (/*@cc_on!@*/false)?-2:1;
@@ -454,7 +459,6 @@ $(document).ready(function() {
clonedHeaderRow.css("position", "absolute");
clonedHeaderRow.css("top", "0px");
clonedHeaderRow.css("left", IEcorr);
clonedHeaderRow.css("visibility", "hidden");
clonedHeaderRow.css("opacity", "0.90");
originalHeaderRow.addClass("tableFloatingHeaderOriginal");

View File

@@ -15,10 +15,6 @@
This basically means: do what you want with it.
*/
var stIsIE = /*@cc_on!@*/false;
stIsIE = false; // te lastig met sortering terugvinden voor printen
var sorttable = {
init: function() {
// quit if this function has already been called
@@ -114,8 +110,9 @@ var sorttable = {
this.removeChild(document.getElementById('sorttable_sortfwdind'));
sortrevind = document.createElement('span');
sortrevind.id = "sorttable_sortrevind";
sortrevind.innerHTML = stIsIE ? '&nbsp<font face="webdings">5</font>' : '&nbsp;&#x25B4;';
sortrevind.innerHTML = '&nbsp;&#x25B4;';
this.appendChild(sortrevind);
sorttable.corrFloat.apply(this);
return;
}
if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
@@ -127,13 +124,15 @@ var sorttable = {
this.removeChild(document.getElementById('sorttable_sortrevind'));
sortfwdind = document.createElement('span');
sortfwdind.id = "sorttable_sortfwdind";
sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
sortfwdind.innerHTML = '&nbsp;&#x25BE;';
this.appendChild(sortfwdind);
sorttable.corrFloat.apply(this);
return;
}
// remove sorttable_sorted classes
theadrow = this.parentNode;
forEach(theadrow.childNodes, function(cell) {
if (cell.nodeType == 1) { // an element
cell.className = cell.className.replace('sorttable_sorted_reverse','');
@@ -141,15 +140,17 @@ var sorttable = {
}
});
sortfwdind = document.getElementById('sorttable_sortfwdind');
if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); sorttable.corrFloat.apply(this); }
sortrevind = document.getElementById('sorttable_sortrevind');
if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); sorttable.corrFloat.apply(this); }
this.className += ' sorttable_sorted';
sortfwdind = document.createElement('span');
sortfwdind.id = "sorttable_sortfwdind";
sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
sortfwdind.innerHTML = '&nbsp;&#x25BE;';
this.appendChild(sortfwdind);
sorttable.corrFloat.apply(this);
// build an array to sort. This is a Schwartzian transform thing,
// i.e., we "decorate" each row with the actual sort key,
@@ -172,6 +173,19 @@ var sorttable = {
}
/* JGL */ FcltMgr.resized();
},
// floating headers hebben 2x <thead>
corrFloat: function() {
var sib = this.parentNode.parentNode.nextSibling;
if (sib && sib.nodeName == "THEAD" && sib.className == "tableFloatingHeaderOriginal")
{
var sortWidth = $(this).width();
var sortIndex = $(this.nodeName).index(this);
var thlist = sib.firstChild.childNodes; // firstChild want er is maar 1 <tr> onder elke <thead>
$(thlist[sortIndex]).css('width', sortWidth + "px");
}
},
guessType: function(table, column) {