1 // Makes all tables on the page with a cell with a pivot class pivotable
2 function webdeveloper_makeTablesPivotable()
4 var tableCellList
= webdeveloper_evaluateXPath(document
, "//td[@class='pivot']");
5 var tableCellLength
= tableCellList
.length
;
7 // Loop through the table cells
8 for(var i
= 0; i
< tableCellLength
; i
++)
10 tableCellList
[i
].addEventListener("click", webdeveloper_pivotTable
, false);
15 function webdeveloper_pivotTable(event
)
17 // If the event is set
21 var pivotRow
= event
.target
.parentNode
;
23 var tableRow
= pivotRow
;
25 // If the pivot row class attribute is set to collapsed
26 if(pivotRow
.getAttribute("class") == "collapsed")
30 pivotRow
.setAttribute("class", "expanded");
34 pivotRow
.setAttribute("class", "collapsed");
37 // Loop through the table rows
38 while((tableRow
= tableRow
.nextSibling
) != null)
40 tableCell
= tableRow
.firstChild
;
42 // If the table cell is set and has a class attribute set to indent
43 if(tableCell
&& tableCell
.hasAttribute("class") && tableCell
.getAttribute("class") == "indent")
45 // If the table row has a class attribute that contains shaded
46 if(tableRow
.hasAttribute("class") && tableRow
.getAttribute("class").indexOf("shaded") != -1)
51 tableRow
.setAttribute("class", "hidden shaded");
55 tableRow
.setAttribute("class", "shaded");
63 tableRow
.setAttribute("class", "hidden");
67 tableRow
.removeAttribute("class");
79 webdeveloper_makeTablesPivotable();