Skip to content

Commit

Permalink
zebra for table: add styling for any data group after the first data …
Browse files Browse the repository at this point in the history
…group

Fixed the table parser to support multiple consecutive data group when no header are present.
A Sudoku table can now be styled with the zebra stripping
  • Loading branch information
duboisp committed Aug 15, 2012
1 parent 3292809 commit 50ed363
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build/js/css/pe-ap-ie-min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/css/pe-ap-min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/pe-ap-min.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/js/sass/zebra.scss
Expand Up @@ -142,9 +142,12 @@ dl.wet-boew-zebra {
background-color:#eee!important;
}
}
tbody.table-summary, tfoot.table-summary {
tbody.table-rowgroupmarker, tfoot.table-rowgroupmarker {
border-top: solid black 2px!important;
}
colgroup.table-colgroupmarker {
border-left: solid black 2px!important;
}
td, th {
&.table-layoutCell {
background-color: white!important;
Expand Down
10 changes: 7 additions & 3 deletions src/js/workers/parser.table.js
Expand Up @@ -651,7 +651,7 @@

if (currColgroupStructure[i].end <= curColgroupFrame.end) {

if (currColgroupStructure[i].level < groupLevel) {
if (currColgroupStructure[i].level < groupLevel && theadRowStack.length > 0) {
curColgroupFrame.type = 3;
}

Expand All @@ -666,7 +666,7 @@
}

// Catch the second and the third possible grouping at level 1
if (groupLevel === 1 && groupZero.colgrp[1] && groupZero.colgrp[1].length > 1) {
if (groupLevel === 1 && groupZero.colgrp[1] && groupZero.colgrp[1].length > 1 && theadRowStack.length > 0) {

// Check if in the group at level 1 if we don't already have a summary colgroup
for (i = 0; i < groupZero.colgrp[1].length; i += 1) {
Expand Down Expand Up @@ -825,8 +825,12 @@
}

// if no cell in the stack and not the first row group, this are a summary group
if (rowgroupHeaderRowStack.length === 0 && lstRowGroup.length > 0 && !currentRowGroup.type) {
// This is only valid if the first colgroup is a header colgroup.
if (rowgroupHeaderRowStack.length === 0 && lstRowGroup.length > 0 && !currentRowGroup.type && colgroupFrame[0] && colgroupFrame[0].type === 1) {
currentRowGroup.type = 3;
} else {
currentRowGroup.type = 2;
currentRowGroup.level = 1; // Default Row Group Level
}

// console.log(rowgroupHeaderRowStack); rowlevel
Expand Down
32 changes: 26 additions & 6 deletions src/js/workers/zebra.js
Expand Up @@ -24,7 +24,10 @@
opts,
overrides,
getCellHeaders,
autoRemoveTimeout;
autoRemoveTimeout,
lstDlItems = [],
isodd = false,
dlitem = [];
// Defaults Options
opts = {
noheaderhighlight: false,
Expand Down Expand Up @@ -88,8 +91,9 @@
}
}
}
// Summary group styling
if (tblparser.row[i].type && tblparser.row[i].type === 3) {
$(tblparser.row[i].elem).parent().addClass('table-summary');
$(tblparser.row[i].elem).parent().addClass('table-rowgroupmarker');
}
}
}
Expand All @@ -100,6 +104,26 @@
$this.addClass('table-headgroup' + $this.data().tblparser.scope + $this.data().tblparser.level); // level is a number, scope either "row" || "col"
}
});

// Data Column Group
if (tblparser.colgroup) {
for (i = 0; i < tblparser.colgroup.length; i += 1) {
if (tblparser.colgroup[i].elem && ((i > 0 && tblparser.colgroup[i].type === 3 && tblparser.colgroup[i - 1].type === 3 && tblparser.colgroup[i - 1].level > tblparser.colgroup[i].level)
||
(tblparser.colgroup[i].type === 2 && (i > 0 && tblparser.colgroup[0].type === 2 || i > 1 && tblparser.colgroup[0].type === 1)))) {
$(tblparser.colgroup[i].elem).addClass('table-colgroupmarker');
}
}
}

// Data Row Group
if (tblparser.lstrowgroup) {
for (i = 0; i < tblparser.lstrowgroup.length; i += 1) {
if (tblparser.lstrowgroup[i].elem && tblparser.lstrowgroup[i].type === 2 && i > 0) {
$(tblparser.lstrowgroup[i].elem).addClass('table-rowgroupmarker');
}
}
}

/* The Heading highlight take times to be set up in ÌE and just a little bit more in Firefox
*
Expand Down Expand Up @@ -212,10 +236,6 @@
}
} else if (elem.is('dl')) {
// Create a list based on "dt" element with their one or more "dd" after each of them
var lstDlItems = [],
isodd = false;
dlitem = [];

$(elem).children().each(function () {
var $this = $(this);
switch (this.nodeName.toLowerCase()) {
Expand Down

0 comments on commit 50ed363

Please sign in to comment.