/*----------------------------------------------------------------------------\ | Sortable Table 1.1 | |-----------------------------------------------------------------------------| | Created by Erik Arvidsson | | (http://webfx.eae.net/contact.html#erik) | | For WebFX (http://webfx.eae.net/) | |-----------------------------------------------------------------------------| | A DOM 1 based script that allows an ordinary HTML table to be sortable. | |-----------------------------------------------------------------------------| | Copyright (c) 1998 - 2003 Erik Arvidsson | |-----------------------------------------------------------------------------| | This software is provided "as is", without warranty of any kind, express or | | implied, including but not limited to the warranties of merchantability, | | fitness for a particular purpose and noninfringement. In no event shall the | | authors or copyright holders be liable for any claim, damages or other | | liability, whether in an action of contract, tort or otherwise, arising | | from, out of or in connection with the software or the use or other | | dealings in the software. | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | | This software is available under the three different licenses mentioned | | below. To use this software you must chose, and qualify, for one of those. | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | | The WebFX Non-Commercial License http://webfx.eae.net/license.html | | Permits anyone the right to use the software in a non-commercial context | | free of charge. | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | | The WebFX Commercial license http://webfx.eae.net/commercial.html | | Permits the license holder the right to use the software in a commercial | | context. Such license must be specifically obtained, however it's valid for | | any number of implementations of the licensed software. | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | | GPL - The GNU General Public License http://www.gnu.org/licenses/gpl.txt | | Permits anyone the right to use and modify the software without limitations | | as long as proper credits are given and the original and modified source | | code are included. Requires that the final product, software derivate from | | the original source or any software utilizing a GPL component, such as | | this, is also licensed under the GPL license. | |-----------------------------------------------------------------------------| | 2003-01-10 | First version | | 2003-01-19 | Minor changes to the date parsing | | 2003-01-28 | JScript 5.0 fixes (no support for 'in' operator) | | 2003-02-01 | Sloppy typo like error fixed in getInnerText | | 2003-07-04 | Added workaround for IE cellIndex bug. | | 2003-11-09 | The bDescending argument to sort was not correctly working | | | Using onclick DOM0 event if no support for addEventListener | | | or attachEvent | | 2004-01-13 | Adding addSortType and removeSortType which makes it a lot | | | easier to add new, custom sort types. | | 2004-01-27 | Switch to use descending = false as the default sort order. | | | Change defaultDescending to suit your needs. | |-----------------------------------------------------------------------------| | Created 2003-01-10 | All changes are in the log above. | Updated 2004-01-27 | \----------------------------------------------------------------------------*/ var tooltipDiv = null; var tooltipPopup = null; var tooltipX = 0; var tooltipY = 0; var tooltipSrcObj = null; var tooltipCaptionColor = "#6699FF"; //"#808080"; var tooltipBodyColor = "#FFFF99"; //"#C0C0C0"; var tooltipBodyTextColor = "black"; var tooltipMaxWidth = screen.width; var sortImagePath = '/esp/files_/img/'; /*----------------------------------------------------------------------------\ | Handle Split Tables | | Table header and body are in separate tables in their own divs. | \----------------------------------------------------------------------------*/ var a_fixedTableNames = []; function initFixedTables(fixedTableNames) { if (typeof fixedTableNames != 'undefined') a_fixedTableNames = a_fixedTableNames.concat( fixedTableNames ); var nFixedTables = a_fixedTableNames.length; if (nFixedTables) { document.body.onresize=resizeFixedTableBodyDivs; for (var i=0; i h) bDiv.style.height = h; else { var tw = bTable.offsetWidth; var th = bTable.offsetHeight; var dw = bDiv.offsetWidth; var doubleBorder = 2; if (dw < tw+doubleBorder) bDiv.style.height = Math.min(h, th+20);//add height to fit horiz scrollbar to avoid vertical scrollbar else if (dw > tw+doubleBorder) bDiv.style.height = th+doubleBorder; } resizeFixedTableHeaderDiv(bDiv, a_fixedTableNames[0]) for (var i=1; i 2) {//resize every 2 pixels var delta = event.clientX - firstX; var sz = Math.max(5, size + delta); th.style.width = sz; lastX = newX; } }; function finishResizing() { var newWidth = Math.max(size + event.clientX - firstX, 5); th.style.width = newWidth; if (typeof resizer.onmouseleave == "function") resizer.onmouseleave() resizer.detachEvent("onmousemove", doResize); resizer.detachEvent("onmouseup", finishResizing); resizer.detachEvent("onlosecapture", finishResizing); resizer.releaseCapture(); var hTableId = hTable.id; if (hTableId && hTableId.indexOf('H.') == 0) { var bTableId = hTableId.substring(2); var bTable = document.getElementById( bTableId ); var hDiv = document.getElementById( 'DH.' + bTableId ); var bDiv = document.getElementById( 'DB.' + bTableId ); hDiv.style.width = bDiv.offsetWidth; bTable.style.width = hTable.offsetWidth; var hCells = hTable.rows[0].cells; var nCells = hCells.length; var nCol = th.cellIndex; var rows = bTable.rows; var nRows = rows.length; for (var r=0; r descending, false -> ascending SortableTable.prototype.defaultDescending = false; // shared between all instances. This is intentional to allow external files // to modify the prototype SortableTable.prototype._sortTypeInfo = {}; // adds arrow containers and events // also binds sort type to the header cells so that reordering columns does // not break the sort types SortableTable.prototype.initHeader = function (oSortTypes) { var cells = this.tHead.rows[0].cells; var l = cells.length; var img, c; for (var i = 0; i < l; i++) { c = cells[i]; if (oSortTypes[i] && oSortTypes[i] == "None") continue; img = document.createElement("IMG"); img.src = sortImagePath + "blank.png"; img.className = 'sort-arrow'; c.appendChild(img); if (oSortTypes[i] != null && oSortTypes[i] != "None") { c._sortType = oSortTypes[i]; } if (typeof c.addEventListener != "undefined") c.addEventListener("click", this._headerOnclick, false); else if (typeof c.attachEvent != "undefined") c.attachEvent("onclick", this._headerOnclick); else c.onclick = this._headerOnclick; c.onmouseover=function() {this.bgColor = this._resizing ? "#CCCCCC" : "#FFFFFF";}; c.onmouseout=function() {this.bgColor = "#CCCCCC";}; } this.updateHeaderArrows(); }; // remove arrows and events SortableTable.prototype.uninitHeader = function () { var cells = this.tHead.rows[0].cells; var l = cells.length; for (var i = 0; i < l; i++) { var c = cells[i]; var imgs = c.getElementsByTagName('img'); var nImages = imgs.length; for (var j=0; j