Changeset 352


Ignore:
Timestamp:
Nov 1, 2017, 10:57:07 PM (7 years ago)
Author:
g7moreau
Message:
  • Remove trainig space to be more like the original lib
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sorttable-klask.js

    r344 r352  
    44  7th April 2007
    55  Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
    6  
     6
    77  Instructions:
    88  Download this file
     
    1010  Add class="sortable" to any table you'd like to make sortable
    1111  Click on the headers to sort
    12  
     12
    1313  Thanks to many, many people for contributions and suggestions.
    1414  Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
     
    1616*/
    1717
    18  
     18
    1919var stIsIE = /*@cc_on!@*/false;
    2020
     
    2727    // kill the timer
    2828    if (_timer) clearInterval(_timer);
    29    
     29
    3030    if (!document.createElement || !document.getElementsByTagName) return;
    31    
     31
    3232    sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
    33    
     33
    3434    forEach(document.getElementsByTagName('table'), function(table) {
    3535      if (table.className.search(/\bsortable\b/) != -1) {
     
    3737      }
    3838    });
    39    
    40   },
    41  
     39
     40  },
     41
    4242  makeSortable: function(table) {
    4343    if (table.getElementsByTagName('thead').length == 0) {
     
    5050    // Safari doesn't support table.tHead, sigh
    5151    if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];
    52    
     52
    5353    if (table.tHead.rows.length != 1) return; // can't cope with two header rows
    54    
     54
    5555    // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
    5656    // "total" rows, for example). This is B&R, since what you're supposed
     
    7474      delete sortbottomrows;
    7575    }
    76    
     76
    7777    // work through each column and calculate its type
    7878    headrow = table.tHead.rows[0].cells;
     
    9393
    9494          if (this.className.search(/\bsorttable_sorted\b/) != -1) {
    95             // if we're already sorted by this column, just 
     95            // if we're already sorted by this column, just
    9696            // reverse the table, which is quicker
    9797            sorttable.reverse(this.sorttable_tbody);
     
    106106          }
    107107          if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
    108             // if we're already sorted by this column in reverse, just 
     108            // if we're already sorted by this column in reverse, just
    109109            // re-reverse the table, which is quicker
    110110            sorttable.reverse(this.sorttable_tbody);
     
    118118            return;
    119119          }
    120          
     120
    121121          // remove sorttable_sorted classes
    122122          theadrow = this.parentNode;
     
    131131          sortrevind = document.getElementById('sorttable_sortrevind');
    132132          if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
    133          
     133
    134134          this.className += ' sorttable_sorted';
    135135          sortfwdind = document.createElement('span');
     
    152152                /* and comment out this one */
    153153                row_array.sort(this.sorttable_sortfunction);
    154                
     154
    155155                tb = this.sorttable_tbody;
    156156// gabriel
     
    160160        // gabriel
    161161if ( memory != row_array[j][0] ) {
    162   memory = row_array[j][0]; 
     162  memory = row_array[j][0];
    163163  color = color =="odd" ? "even" : "odd";
    164164  }
     
    167167                  tb.appendChild(row_array[j][1]);
    168168                }
    169                
     169
    170170                delete row_array;
    171171              });
     
    173173    }
    174174  },
    175  
     175
    176176  guessType: function(table, column) {
    177177    // guess the type of a column based on its first non-blank row
     
    183183          return sorttable.sort_numeric;
    184184        }
    185         // check for a date: dd/mm/yyyy or dd/mm/yy 
     185        // check for a date: dd/mm/yyyy or dd/mm/yy
    186186        // can have / or . or - as separator
    187187        // can be mm/dd as well
     
    206206    return sortfn;
    207207  },
    208  
     208
    209209  getInnerText: function(node) {
    210210    // gets the text we want to use for sorting for a cell.
     
    213213    // for example, you can override the cell text with a customkey attribute.
    214214    // it also gets .value for <input> fields.
    215    
     215
    216216    hasInputs = (typeof node.getElementsByTagName == 'function') &&
    217217                 node.getElementsByTagName('input').length;
    218    
     218
    219219    if (node.getAttribute("sorttable_customkey") != null) {
    220220      return node.getAttribute("sorttable_customkey");
     
    251251    }
    252252  },
    253  
     253
    254254  reverse: function(tbody) {
    255255    // reverse the rows in a tbody
     
    263263    delete newrows;
    264264  },
    265  
     265
    266266  /* sort functions
    267267     each sort function takes two parameters, a and b
     
    270270    aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
    271271    if (isNaN(aa)) aa = 0;
    272     bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); 
     272    bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
    273273    if (isNaN(bb)) bb = 0;
    274274    return aa-bb;
     
    309309    return 1;
    310310  },
    311  
     311
    312312  shaker_sort: function(list, comp_func) {
    313313    // A stable sort function to allow multi-level sorting of data
     
    339339
    340340    } // while(swap)
    341   } 
     341  }
    342342}
    343343
Note: See TracChangeset for help on using the changeset viewer.