phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r5079 - phpcompta/tags/rel650/html/js


From: phpcompta-dev
Subject: [Phpcompta-dev] r5079 - phpcompta/tags/rel650/html/js
Date: Fri, 20 Jul 2012 14:57:16 +0200 (CEST)

Author: danydb
Date: 2012-07-20 14:57:16 +0200 (Fri, 20 Jul 2012)
New Revision: 5079

Modified:
   phpcompta/tags/rel650/html/js/sorttable.js
Log:
add documentation

Modified: phpcompta/tags/rel650/html/js/sorttable.js
===================================================================
--- phpcompta/tags/rel650/html/js/sorttable.js  2012-07-20 12:55:50 UTC (rev 
5078)
+++ phpcompta/tags/rel650/html/js/sorttable.js  2012-07-20 12:57:16 UTC (rev 
5079)
@@ -1,21 +1,39 @@
-/*
+/**
+ *
   SortTable
   version 2
   7th April 2007
   Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
-  
+
   Instructions:
   Download this file
   Add <script src="sorttable.js"></script> to your HTML
   Add class="sortable" to any table you'd like to make sortable
   Click on the headers to sort
-  
+
   Thanks to many, many people for contributions and suggestions.
   Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
   This basically means: do what you want with it.
+
address@hidden
+Documentation http://www.kryogenix.org/code/browser/sorttable/
+
+Show the default order
+example:
+<th class=" sorttable_sorted_reverse">
+....<span id="sorttable_sortrevind">&nbsp;&blacktriangle;</span>
+
+Sort on date
+<td sorttable_customkey="<?=$row_bank['b_date']?>"> // format YYYYMMDD
+
+force as numeric (normally useless):
+<th class="sorttable_numeric">Part number</th>
+
+To avoid the sort on the last row, use tfoot
+
 */
 
- 
+
 var stIsIE = /address@hidden@*/false;
 
 sorttable = {
@@ -26,19 +44,19 @@
     arguments.callee.done = true;
     // kill the timer
     if (_timer) clearInterval(_timer);
-    
+
     if (!document.createElement || !document.getElementsByTagName) return;
-    
+
     sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
-    
+
     forEach(document.getElementsByTagName('table'), function(table) {
       if (table.className.search(/\bsortable\b/) != -1) {
         sorttable.makeSortable(table);
       }
     });
-    
+
   },
-  
+
   makeSortable: function(table) {
     if (table.getElementsByTagName('thead').length == 0) {
       // table doesn't have a tHead. Since it should have, create one and
@@ -49,9 +67,9 @@
     }
     // Safari doesn't support table.tHead, sigh
     if (table.tHead == null) table.tHead = 
table.getElementsByTagName('thead')[0];
-    
+
     if (table.tHead.rows.length != 1) return; // can't cope with two header 
rows
-    
+
     // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
     // "total" rows, for example). This is B&R, since what you're supposed
     // to do is put them in a tfoot. So, if there are sortbottom rows,
@@ -73,7 +91,7 @@
       }
       delete sortbottomrows;
     }
-    
+
     // work through each column and calculate its type
     headrow = table.tHead.rows[0].cells;
     for (var i=0; i<headrow.length; i++) {
@@ -92,7 +110,7 @@
              dean_addEvent(headrow[i],"click", function(e) {
 
           if (this.className.search(/\bsorttable_sorted\b/) != -1) {
-            // if we're already sorted by this column, just 
+            // if we're already sorted by this column, just
             // reverse the table, which is quicker
             sorttable.reverse(this.sorttable_tbody);
             this.className = this.className.replace('sorttable_sorted',
@@ -105,7 +123,7 @@
             return;
           }
           if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
-            // if we're already sorted by this column in reverse, just 
+            // if we're already sorted by this column in reverse, just
             // re-reverse the table, which is quicker
             sorttable.reverse(this.sorttable_tbody);
             this.className = this.className.replace('sorttable_sorted_reverse',
@@ -117,7 +135,7 @@
             this.appendChild(sortfwdind);
             return;
           }
-          
+
           // remove sorttable_sorted classes
           theadrow = this.parentNode;
           forEach(theadrow.childNodes, function(cell) {
@@ -130,7 +148,7 @@
           if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
           sortrevind = document.getElementById('sorttable_sortrevind');
           if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
-          
+
           this.className += ' sorttable_sorted';
           sortfwdind = document.createElement('span');
           sortfwdind.id = "sorttable_sortfwdind";
@@ -151,28 +169,28 @@
                //sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
                /* and comment out this one */
                row_array.sort(this.sorttable_sortfunction);
-               
+
                tb = this.sorttable_tbody;
                for (var j=0; j<row_array.length; j++) {
                  tb.appendChild(row_array[j][1]);
                }
-               
+
                delete row_array;
              });
            }
     }
   },
-  
+
   guessType: function(table, column) {
     // guess the type of a column based on its first non-blank row
     sortfn = sorttable.sort_alpha;
     for (var i=0; i<table.tBodies[0].rows.length; i++) {
       text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]);
       if (text != '') {
-        if (text.match(/^-?[�$�]?[\d,.]+%?$/)) {
+        if (text.match(/^-?[�$�]?[\d,.]+%?$/)) {
           return sorttable.sort_numeric;
         }
-        // check for a date: dd/mm/yyyy or dd/mm/yy 
+        // check for a date: dd/mm/yyyy or dd/mm/yy
         // can have / or . or - as separator
         // can be mm/dd as well
         possdate = text.match(sorttable.DATE_RE)
@@ -195,19 +213,19 @@
     }
     return sortfn;
   },
-  
+
   getInnerText: function(node) {
     // gets the text we want to use for sorting for a cell.
     // strips leading and trailing whitespace.
     // this is *not* a generic getInnerText function; it's special to 
sorttable.
     // for example, you can override the cell text with a customkey attribute.
     // it also gets .value for <input> fields.
-    
+
     if (!node) return "";
 
     hasInputs = (typeof node.getElementsByTagName == 'function') &&
                  node.getElementsByTagName('input').length;
-    
+
     if (node.getAttribute("sorttable_customkey") != null) {
       return node.getAttribute("sorttable_customkey");
     }
@@ -242,7 +260,7 @@
       }
     }
   },
-  
+
   reverse: function(tbody) {
     // reverse the rows in a tbody
     newrows = [];
@@ -254,14 +272,14 @@
     }
     delete newrows;
   },
-  
+
   /* sort functions
      each sort function takes two parameters, a and b
      you are comparing a[0] and b[0] */
   sort_numeric: function(a,b) {
     aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
     if (isNaN(aa)) aa = 0;
-    bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); 
+    bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
     if (isNaN(bb)) bb = 0;
     return aa-bb;
   },
@@ -300,7 +318,7 @@
     if (dt1<dt2) return -1;
     return 1;
   },
-  
+
   shaker_sort: function(list, comp_func) {
     // A stable sort function to allow multi-level sorting of data
     // see: http://en.wikipedia.org/wiki/Cocktail_sort
@@ -330,7 +348,7 @@
         b++;
 
     } // while(swap)
-  }  
+  }
 }
 
 /* ******************************************************************



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]