X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=doc%2Fwebdeveloper%2Fgenerated%2Ftable_pivot.js;fp=doc%2Fwebdeveloper%2Fgenerated%2Ftable_pivot.js;h=23fa4043e33f2225af39c89781af647deed82edb;hb=c3b0deb3d8c9f439739c79806e915c29bc1d4b84;hp=0000000000000000000000000000000000000000;hpb=cff6539539a79e014f6ac8df46716cafce2c8472;p=pompage.git diff --git a/doc/webdeveloper/generated/table_pivot.js b/doc/webdeveloper/generated/table_pivot.js new file mode 100644 index 0000000..23fa404 --- /dev/null +++ b/doc/webdeveloper/generated/table_pivot.js @@ -0,0 +1,79 @@ +// Makes all tables on the page with a cell with a pivot class pivotable +function webdeveloper_makeTablesPivotable() +{ + var tableCellList = webdeveloper_evaluateXPath(document, "//td[@class='pivot']"); + var tableCellLength = tableCellList.length; + + // Loop through the table cells + for(var i = 0; i < tableCellLength; i++) + { + tableCellList[i].addEventListener("click", webdeveloper_pivotTable, false); + } +} + +// Pivots a table +function webdeveloper_pivotTable(event) +{ + // If the event is set + if(event) + { + var hide = true; + var pivotRow = event.target.parentNode; + var tableCell = null; + var tableRow = pivotRow; + + // If the pivot row class attribute is set to collapsed + if(pivotRow.getAttribute("class") == "collapsed") + { + hide = false; + + pivotRow.setAttribute("class", "expanded"); + } + else + { + pivotRow.setAttribute("class", "collapsed"); + } + + // Loop through the table rows + while((tableRow = tableRow.nextSibling) != null) + { + tableCell = tableRow.firstChild; + + // If the table cell is set and has a class attribute set to indent + if(tableCell && tableCell.hasAttribute("class") && tableCell.getAttribute("class") == "indent") + { + // If the table row has a class attribute that contains shaded + if(tableRow.hasAttribute("class") && tableRow.getAttribute("class").indexOf("shaded") != -1) + { + // If hiding the row + if(hide) + { + tableRow.setAttribute("class", "hidden shaded"); + } + else + { + tableRow.setAttribute("class", "shaded"); + } + } + else + { + // If hiding the row + if(hide) + { + tableRow.setAttribute("class", "hidden"); + } + else + { + tableRow.removeAttribute("class"); + } + } + } + else + { + break; + } + } + } +} + +webdeveloper_makeTablesPivotable();