Setting tag plewww-5.2-4
[plewww.git] / plekit / tablesort / tablesort.js
index 9b55e59..e9e8058 100644 (file)
@@ -25,6 +25,8 @@
         * Any of these conditions can be waived if you get permission from the copyright holder.
 */
 
+var debug=false;
+
 (function() {
 fdTableSort = {
         regExp_Currency:        /^[£$€¥¤]/,
@@ -127,6 +129,7 @@ fdTableSort = {
                 fdTableSort.init(false);
         },
         init: function(tableId) {
+               if (debug) plc_message ('entering tablesort.init');
                 if (!document.getElementsByTagName || !document.createElement || !document.getElementById) return;
 
                 var tables = tableId && document.getElementById(tableId) ? [document.getElementById(tableId)] : document.getElementsByTagName("table");
@@ -210,8 +213,8 @@ fdTableSort = {
                                                         columnNumSortObj[i]["thNode"] = workArr[c][i];
                                                         columnNumSortObj["active"] = true;
                                                 };
-
-                                                thtext = fdTableSort.getInnerText(workArr[c][i], true);
+                                               th_elt = workArr[c][i];
+                                                thtext = fdTableSort.getInnerText(th_elt, true);
                                                 
                                                 for(var cn = workArr[c][i].childNodes.length; cn--;) {
                                                         // Skip image nodes and links created by the filter script.
@@ -227,7 +230,12 @@ fdTableSort = {
                                                 aclone = a.cloneNode(true);
                                                 //aclone.appendChild(document.createTextNode(thtext));
                                                 aclone.innerHTML = thtext;
-                                                aclone.title = "Sort on \u201c" + thtext.replace('<br />', '') + "\u201d";
+                                               //if the <th> has title set, use this as an alternate text for the 'sort on ...'
+                                               if (th_elt.title) {
+                                                 aclone.title = th_elt.title;
+                                               } else {
+                                                 aclone.title = "Sort on \u201c" + (th_elt.title ? th_elt.title : thtext.replace('<br />', '')) + "\u201d";
+                                               }
                                                 aclone.onclick = aclone.onkeydown = workArr[c][i].onclick = fdTableSort.initWrapper;
                                                 workArr[c][i].appendChild(aclone);
                                                 if(showArrow) workArr[c][i].appendChild(span.cloneNode(false));
@@ -286,6 +294,7 @@ fdTableSort = {
                 };
 
                 fdTableSort.thNode = aclone = a = span = columnNumSortObj = thNode = tbl = allRowArr = rowArr = null;
+               if (debug) plc_message ('exiting tablesort.init');
         },
         initWrapper: function(e) {
                 e = e || window.event;
@@ -657,6 +666,7 @@ fdTableSort = {
                 fdTableSort.thNode = null;
         },
         redraw: function(tableid, identical) {
+               if (debug) plc_message ('entering tablesort.redraw');
                 if(!tableid || !(tableid in fdTableSort.tableCache)) { return; };
                 var dataObj     = fdTableSort.tableCache[tableid];
                 var data        = dataObj.data;
@@ -691,6 +701,7 @@ fdTableSort = {
                         };
                 };
                 tr = tds = hook = null;
+               if (debug) plc_message ('exiting tablesort.redraw');
         },
         getInnerText: function(el, allowBrTags) {
                 if (typeof el == "string" || typeof el == "undefined") return el;