web/data/jquery.tablesorter.js
author Christophe de Vienne <christophe@unlish.com>
Thu, 27 Nov 2014 12:11:29 +0100
changeset 10108 129af90b2364
parent 8071 9ab3a9406473
permissions -rw-r--r--
[devtools] Use the pause_trace context manager instead of pause_tracing/resume_tracing The later were deprecated in logilab-common 0.63.1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7945
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
     1
/*
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
     2
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
     3
 * TableSorter 2.0 - Client-side table sorting with ease!
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
     4
 * Version 2.0.5b
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
     5
 * @requires jQuery v1.2.3
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
     6
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
     7
 * Copyright (c) 2007 Christian Bach
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
     8
 * Examples and docs at: http://tablesorter.com
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
     9
 * Dual licensed under the MIT and GPL licenses:
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    10
 * http://www.opensource.org/licenses/mit-license.php
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    11
 * http://www.gnu.org/licenses/gpl.html
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    12
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    13
 */
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    14
/**
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    15
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    16
 * @description Create a sortable table with multi-column sorting capabilitys
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    17
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    18
 * @example $('table').tablesorter();
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    19
 * @desc Create a simple tablesorter interface.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    20
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    21
 * @example $('table').tablesorter({ sortList:[[0,0],[1,0]] });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    22
 * @desc Create a tablesorter interface and sort on the first and secound column column headers.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    23
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    24
 * @example $('table').tablesorter({ headers: { 0: { sorter: false}, 1: {sorter: false} } });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    25
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    26
 * @desc Create a tablesorter interface and disableing the first and second  column headers.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    27
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    28
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    29
 * @example $('table').tablesorter({ headers: { 0: {sorter:"integer"}, 1: {sorter:"currency"} } });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    30
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    31
 * @desc Create a tablesorter interface and set a column parser for the first
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    32
 *       and second column.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    33
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    34
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    35
 * @param Object
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    36
 *            settings An object literal containing key/value pairs to provide
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    37
 *            optional settings.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    38
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    39
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    40
 * @option String cssHeader (optional) A string of the class name to be appended
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    41
 *         to sortable tr elements in the thead of the table. Default value:
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    42
 *         "header"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    43
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    44
 * @option String cssAsc (optional) A string of the class name to be appended to
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    45
 *         sortable tr elements in the thead on a ascending sort. Default value:
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    46
 *         "headerSortUp"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    47
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    48
 * @option String cssDesc (optional) A string of the class name to be appended
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    49
 *         to sortable tr elements in the thead on a descending sort. Default
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    50
 *         value: "headerSortDown"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    51
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    52
 * @option String sortInitialOrder (optional) A string of the inital sorting
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    53
 *         order can be asc or desc. Default value: "asc"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    54
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    55
 * @option String sortMultisortKey (optional) A string of the multi-column sort
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    56
 *         key. Default value: "shiftKey"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    57
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    58
 * @option String textExtraction (optional) A string of the text-extraction
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    59
 *         method to use. For complex html structures inside td cell set this
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    60
 *         option to "complex", on large tables the complex option can be slow.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    61
 *         Default value: "simple"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    62
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    63
 * @option Object headers (optional) An array containing the forces sorting
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    64
 *         rules. This option let's you specify a default sorting rule. Default
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    65
 *         value: null
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    66
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    67
 * @option Array sortList (optional) An array containing the forces sorting
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    68
 *         rules. This option let's you specify a default sorting rule. Default
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    69
 *         value: null
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    70
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    71
 * @option Array sortForce (optional) An array containing forced sorting rules.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    72
 *         This option let's you specify a default sorting rule, which is
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    73
 *         prepended to user-selected rules. Default value: null
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    74
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    75
 * @option Boolean sortLocaleCompare (optional) Boolean flag indicating whatever
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    76
 *         to use String.localeCampare method or not. Default set to true.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    77
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    78
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    79
 * @option Array sortAppend (optional) An array containing forced sorting rules.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    80
 *         This option let's you specify a default sorting rule, which is
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    81
 *         appended to user-selected rules. Default value: null
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    82
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    83
 * @option Boolean widthFixed (optional) Boolean flag indicating if tablesorter
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    84
 *         should apply fixed widths to the table columns. This is usefull when
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    85
 *         using the pager companion plugin. This options requires the dimension
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    86
 *         jquery plugin. Default value: false
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    87
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    88
 * @option Boolean cancelSelection (optional) Boolean flag indicating if
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    89
 *         tablesorter should cancel selection of the table headers text.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    90
 *         Default value: true
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    91
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    92
 * @option Boolean debug (optional) Boolean flag indicating if tablesorter
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    93
 *         should display debuging information usefull for development.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    94
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    95
 * @type jQuery
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    96
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    97
 * @name tablesorter
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    98
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
    99
 * @cat Plugins/Tablesorter
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   100
 *
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   101
 * @author Christian Bach/christian.bach@polyester.se
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   102
 */
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   103
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   104
(function ($) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   105
    $.extend({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   106
        tablesorter: new
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   107
        function () {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   108
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   109
            var parsers = [],
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   110
                widgets = [];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   111
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   112
            this.defaults = {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   113
                cssHeader: "header",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   114
                cssAsc: "headerSortUp",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   115
                cssDesc: "headerSortDown",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   116
                cssChildRow: "expand-child",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   117
                sortInitialOrder: "asc",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   118
                sortMultiSortKey: "shiftKey",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   119
                sortForce: null,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   120
                sortAppend: null,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   121
                sortLocaleCompare: true,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   122
                textExtraction: "simple",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   123
                parsers: {}, widgets: [],
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   124
                widgetZebra: {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   125
                    css: ["even", "odd"]
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   126
                }, headers: {}, widthFixed: false,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   127
                cancelSelection: true,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   128
                sortList: [],
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   129
                headerList: [],
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   130
                dateFormat: "us",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   131
                decimal: '/\.|\,/g',
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   132
                onRenderHeader: null,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   133
                selectorHeaders: 'thead th',
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   134
                debug: false
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   135
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   136
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   137
            /* debuging utils */
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   138
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   139
            function benchmark(s, d) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   140
                log(s + "," + (new Date().getTime() - d.getTime()) + "ms");
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   141
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   142
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   143
            this.benchmark = benchmark;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   144
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   145
            function log(s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   146
                if (typeof console != "undefined" && typeof console.debug != "undefined") {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   147
                    console.log(s);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   148
                } else {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   149
                    alert(s);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   150
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   151
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   152
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   153
            /* parsers utils */
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   154
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   155
            function buildParserCache(table, $headers) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   156
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   157
                if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   158
                    var parsersDebug = "";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   159
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   160
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   161
                if (table.tBodies.length == 0) return; // In the case of empty tables
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   162
                var rows = table.tBodies[0].rows;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   163
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   164
                if (rows[0]) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   165
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   166
                    var list = [],
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   167
                        cells = rows[0].cells,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   168
                        l = cells.length;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   169
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   170
                    for (var i = 0; i < l; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   171
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   172
                        var p = false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   173
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   174
                        if ($.metadata && ($($headers[i]).metadata() && $($headers[i]).metadata().sorter)) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   175
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   176
                            p = getParserById($($headers[i]).metadata().sorter);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   177
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   178
                        } else if ((table.config.headers[i] && table.config.headers[i].sorter)) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   179
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   180
                            p = getParserById(table.config.headers[i].sorter);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   181
                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   182
                        if (!p) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   183
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   184
                            p = detectParserForColumn(table, rows, -1, i);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   185
                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   186
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   187
                        if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   188
                            parsersDebug += "column:" + i + " parser:" + p.id + "\n";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   189
                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   190
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   191
                        list.push(p);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   192
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   193
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   194
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   195
                if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   196
                    log(parsersDebug);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   197
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   198
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   199
                return list;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   200
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   201
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   202
            function detectParserForColumn(table, rows, rowIndex, cellIndex) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   203
                var l = parsers.length,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   204
                    node = false,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   205
                    nodeValue = false,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   206
                    keepLooking = true;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   207
                while (nodeValue == '' && keepLooking) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   208
                    rowIndex++;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   209
                    if (rows[rowIndex]) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   210
                        node = getNodeFromRowAndCellIndex(rows, rowIndex, cellIndex);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   211
                        nodeValue = trimAndGetNodeText(table.config, node);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   212
                        if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   213
                            log('Checking if value was empty on row:' + rowIndex);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   214
                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   215
                    } else {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   216
                        keepLooking = false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   217
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   218
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   219
                for (var i = 1; i < l; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   220
                    if (parsers[i].is(nodeValue, table, node)) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   221
                        return parsers[i];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   222
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   223
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   224
                // 0 is always the generic parser (text)
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   225
                return parsers[0];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   226
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   227
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   228
            function getNodeFromRowAndCellIndex(rows, rowIndex, cellIndex) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   229
                return rows[rowIndex].cells[cellIndex];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   230
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   231
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   232
            function trimAndGetNodeText(config, node) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   233
                return $.trim(getElementText(config, node));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   234
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   235
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   236
            function getParserById(name) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   237
                var l = parsers.length;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   238
                for (var i = 0; i < l; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   239
                    if (parsers[i].id.toLowerCase() == name.toLowerCase()) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   240
                        return parsers[i];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   241
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   242
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   243
                return false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   244
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   245
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   246
            /* utils */
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   247
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   248
            function buildCache(table) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   249
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   250
                if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   251
                    var cacheTime = new Date();
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   252
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   253
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   254
                var totalRows = (table.tBodies[0] && table.tBodies[0].rows.length) || 0,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   255
                    totalCells = (table.tBodies[0].rows[0] && table.tBodies[0].rows[0].cells.length) || 0,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   256
                    parsers = table.config.parsers,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   257
                    cache = {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   258
                        row: [],
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   259
                        normalized: []
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   260
                    };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   261
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   262
                for (var i = 0; i < totalRows; ++i) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   263
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   264
                    /** Add the table data to main data array */
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   265
                    var c = $(table.tBodies[0].rows[i]),
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   266
                        cols = [];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   267
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   268
                    // if this is a child row, add it to the last row's children and
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   269
                    // continue to the next row
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   270
                    if (c.hasClass(table.config.cssChildRow)) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   271
                        cache.row[cache.row.length - 1] = cache.row[cache.row.length - 1].add(c);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   272
                        // go to the next for loop
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   273
                        continue;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   274
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   275
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   276
                    cache.row.push(c);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   277
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   278
                    for (var j = 0; j < totalCells; ++j) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   279
                        cols.push(parsers[j].format(getElementText(table.config, c[0].cells[j]), table, c[0].cells[j]));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   280
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   281
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   282
                    cols.push(cache.normalized.length); // add position for rowCache
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   283
                    cache.normalized.push(cols);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   284
                    cols = null;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   285
                };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   286
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   287
                if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   288
                    benchmark("Building cache for " + totalRows + " rows:", cacheTime);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   289
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   290
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   291
                return cache;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   292
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   293
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   294
            function getElementText(config, node) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   295
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   296
                var text = "";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   297
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   298
                if (!node) return "";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   299
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   300
                if (!config.supportsTextContent) config.supportsTextContent = node.textContent || false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   301
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   302
                if (config.textExtraction == "simple") {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   303
                    if (config.supportsTextContent) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   304
                        text = node.textContent;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   305
                    } else {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   306
                        if (node.childNodes[0] && node.childNodes[0].hasChildNodes()) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   307
                            text = node.childNodes[0].innerHTML;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   308
                        } else {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   309
                            text = node.innerHTML;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   310
                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   311
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   312
                } else {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   313
                    if (typeof(config.textExtraction) == "function") {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   314
                        text = config.textExtraction(node);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   315
                    } else {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   316
                        text = $(node).text();
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   317
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   318
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   319
                return text;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   320
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   321
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   322
            function appendToTable(table, cache) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   323
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   324
                if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   325
                    var appendTime = new Date()
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   326
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   327
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   328
                var c = cache,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   329
                    r = c.row,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   330
                    n = c.normalized,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   331
                    totalRows = n.length,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   332
                    checkCell = (n[0].length - 1),
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   333
                    tableBody = $(table.tBodies[0]),
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   334
                    rows = [];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   335
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   336
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   337
                for (var i = 0; i < totalRows; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   338
                    var pos = n[i][checkCell];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   339
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   340
                    rows.push(r[pos]);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   341
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   342
                    if (!table.config.appender) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   343
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   344
                        //var o = ;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   345
                        var l = r[pos].length;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   346
                        for (var j = 0; j < l; j++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   347
                            tableBody[0].appendChild(r[pos][j]);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   348
                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   349
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   350
                        //
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   351
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   352
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   353
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   354
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   355
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   356
                if (table.config.appender) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   357
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   358
                    table.config.appender(table, rows);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   359
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   360
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   361
                rows = null;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   362
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   363
                if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   364
                    benchmark("Rebuilt table:", appendTime);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   365
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   366
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   367
                // apply table widgets
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   368
                applyWidget(table);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   369
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   370
                // trigger sortend
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   371
                setTimeout(function () {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   372
                    $(table).trigger("sortEnd");
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   373
                }, 0);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   374
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   375
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   376
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   377
            function buildHeaders(table) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   378
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   379
                if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   380
                    var time = new Date();
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   381
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   382
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   383
                var meta = ($.metadata) ? true : false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   384
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   385
                var header_index = computeTableHeaderCellIndexes(table);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   386
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   387
                $tableHeaders = $(table.config.selectorHeaders, table).each(function (index) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   388
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   389
                    this.column = header_index[this.parentNode.rowIndex + "-" + this.cellIndex];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   390
                    // this.column = index;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   391
                    this.order = formatSortingOrder(table.config.sortInitialOrder);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   392
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   393
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   394
                    this.count = this.order;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   395
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   396
                    if (checkHeaderMetadata(this) || checkHeaderOptions(table, index)) this.sortDisabled = true;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   397
                    if (checkHeaderOptionsSortingLocked(table, index)) this.order = this.lockedOrder = checkHeaderOptionsSortingLocked(table, index);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   398
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   399
                    if (!this.sortDisabled) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   400
                        var $th = $(this).addClass(table.config.cssHeader);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   401
                        if (table.config.onRenderHeader) table.config.onRenderHeader.apply($th);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   402
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   403
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   404
                    // add cell to headerList
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   405
                    table.config.headerList[index] = this;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   406
                });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   407
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   408
                if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   409
                    benchmark("Built headers:", time);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   410
                    log($tableHeaders);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   411
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   412
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   413
                return $tableHeaders;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   414
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   415
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   416
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   417
            // from:
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   418
            // http://www.javascripttoolbox.com/lib/table/examples.php
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   419
            // http://www.javascripttoolbox.com/temp/table_cellindex.html
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   420
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   421
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   422
            function computeTableHeaderCellIndexes(t) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   423
                var matrix = [];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   424
                var lookup = {};
8043
c699f6edd067 [js table sort] use lower cased tag names since HTML is case insensitive and XHTML is case sensitive and wants lower case tag names
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8003
diff changeset
   425
                var thead = t.getElementsByTagName('thead')[0];
c699f6edd067 [js table sort] use lower cased tag names since HTML is case insensitive and XHTML is case sensitive and wants lower case tag names
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8003
diff changeset
   426
                var trs = thead.getElementsByTagName('tr');
7945
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   427
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   428
                for (var i = 0; i < trs.length; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   429
                    var cells = trs[i].cells;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   430
                    for (var j = 0; j < cells.length; j++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   431
                        var c = cells[j];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   432
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   433
                        var rowIndex = c.parentNode.rowIndex;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   434
                        var cellId = rowIndex + "-" + c.cellIndex;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   435
                        var rowSpan = c.rowSpan || 1;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   436
                        var colSpan = c.colSpan || 1
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   437
                        var firstAvailCol;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   438
                        if (typeof(matrix[rowIndex]) == "undefined") {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   439
                            matrix[rowIndex] = [];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   440
                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   441
                        // Find first available column in the first row
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   442
                        for (var k = 0; k < matrix[rowIndex].length + 1; k++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   443
                            if (typeof(matrix[rowIndex][k]) == "undefined") {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   444
                                firstAvailCol = k;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   445
                                break;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   446
                            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   447
                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   448
                        lookup[cellId] = firstAvailCol;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   449
                        for (var k = rowIndex; k < rowIndex + rowSpan; k++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   450
                            if (typeof(matrix[k]) == "undefined") {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   451
                                matrix[k] = [];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   452
                            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   453
                            var matrixrow = matrix[k];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   454
                            for (var l = firstAvailCol; l < firstAvailCol + colSpan; l++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   455
                                matrixrow[l] = "x";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   456
                            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   457
                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   458
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   459
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   460
                return lookup;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   461
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   462
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   463
            function checkCellColSpan(table, rows, row) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   464
                var arr = [],
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   465
                    r = table.tHead.rows,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   466
                    c = r[row].cells;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   467
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   468
                for (var i = 0; i < c.length; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   469
                    var cell = c[i];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   470
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   471
                    if (cell.colSpan > 1) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   472
                        arr = arr.concat(checkCellColSpan(table, headerArr, row++));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   473
                    } else {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   474
                        if (table.tHead.length == 1 || (cell.rowSpan > 1 || !r[row + 1])) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   475
                            arr.push(cell);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   476
                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   477
                        // headerArr[row] = (i+row);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   478
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   479
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   480
                return arr;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   481
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   482
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   483
            function checkHeaderMetadata(cell) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   484
                if (($.metadata) && ($(cell).metadata().sorter === false)) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   485
                    return true;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   486
                };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   487
                return false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   488
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   489
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   490
            function checkHeaderOptions(table, i) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   491
                if ((table.config.headers[i]) && (table.config.headers[i].sorter === false)) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   492
                    return true;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   493
                };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   494
                return false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   495
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   496
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   497
            function checkHeaderOptionsSortingLocked(table, i) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   498
                if ((table.config.headers[i]) && (table.config.headers[i].lockedOrder)) return table.config.headers[i].lockedOrder;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   499
                return false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   500
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   501
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   502
            function applyWidget(table) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   503
                var c = table.config.widgets;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   504
                var l = c.length;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   505
                for (var i = 0; i < l; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   506
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   507
                    getWidgetById(c[i]).format(table);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   508
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   509
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   510
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   511
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   512
            function getWidgetById(name) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   513
                var l = widgets.length;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   514
                for (var i = 0; i < l; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   515
                    if (widgets[i].id.toLowerCase() == name.toLowerCase()) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   516
                        return widgets[i];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   517
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   518
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   519
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   520
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   521
            function formatSortingOrder(v) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   522
                if (typeof(v) != "Number") {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   523
                    return (v.toLowerCase() == "desc") ? 1 : 0;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   524
                } else {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   525
                    return (v == 1) ? 1 : 0;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   526
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   527
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   528
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   529
            function isValueInArray(v, a) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   530
                var l = a.length;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   531
                for (var i = 0; i < l; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   532
                    if (a[i][0] == v) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   533
                        return true;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   534
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   535
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   536
                return false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   537
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   538
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   539
            function setHeadersCss(table, $headers, list, css) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   540
                // remove all header information
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   541
                $headers.removeClass(css[0]).removeClass(css[1]);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   542
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   543
                var h = [];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   544
                $headers.each(function (offset) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   545
                    if (!this.sortDisabled) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   546
                        h[this.column] = $(this);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   547
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   548
                });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   549
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   550
                var l = list.length;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   551
                for (var i = 0; i < l; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   552
                    h[list[i][0]].addClass(css[list[i][1]]);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   553
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   554
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   555
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   556
            function fixColumnWidth(table, $headers) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   557
                var c = table.config;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   558
                if (c.widthFixed) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   559
                    var colgroup = $('<colgroup>');
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   560
                    $("tr:first td", table.tBodies[0]).each(function () {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   561
                        colgroup.append($('<col>').css('width', $(this).width()));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   562
                    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   563
                    $(table).prepend(colgroup);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   564
                };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   565
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   566
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   567
            function updateHeaderSortCount(table, sortList) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   568
                var c = table.config,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   569
                    l = sortList.length;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   570
                for (var i = 0; i < l; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   571
                    var s = sortList[i],
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   572
                        o = c.headerList[s[0]];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   573
                    o.count = s[1];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   574
                    o.count++;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   575
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   576
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   577
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   578
            /* sorting methods */
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   579
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   580
            function multisort(table, sortList, cache) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   581
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   582
                if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   583
                    var sortTime = new Date();
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   584
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   585
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   586
                var dynamicExp = "var sortWrapper = function(a,b) {",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   587
                    l = sortList.length;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   588
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   589
                // TODO: inline functions.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   590
                for (var i = 0; i < l; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   591
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   592
                    var c = sortList[i][0];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   593
                    var order = sortList[i][1];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   594
                    // var s = (getCachedSortType(table.config.parsers,c) == "text") ?
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   595
                    // ((order == 0) ? "sortText" : "sortTextDesc") : ((order == 0) ?
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   596
                    // "sortNumeric" : "sortNumericDesc");
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   597
                    // var s = (table.config.parsers[c].type == "text") ? ((order == 0)
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   598
                    // ? makeSortText(c) : makeSortTextDesc(c)) : ((order == 0) ?
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   599
                    // makeSortNumeric(c) : makeSortNumericDesc(c));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   600
                    var s = (table.config.parsers[c].type == "text") ? ((order == 0) ? makeSortFunction("text", "asc", c) : makeSortFunction("text", "desc", c)) : ((order == 0) ? makeSortFunction("numeric", "asc", c) : makeSortFunction("numeric", "desc", c));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   601
                    var e = "e" + i;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   602
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   603
                    dynamicExp += "var " + e + " = " + s; // + "(a[" + c + "],b[" + c
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   604
                    // + "]); ";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   605
                    dynamicExp += "if(" + e + ") { return " + e + "; } ";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   606
                    dynamicExp += "else { ";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   607
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   608
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   609
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   610
                // if value is the same keep orignal order
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   611
                var orgOrderCol = cache.normalized[0].length - 1;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   612
                dynamicExp += "return a[" + orgOrderCol + "]-b[" + orgOrderCol + "];";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   613
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   614
                for (var i = 0; i < l; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   615
                    dynamicExp += "}; ";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   616
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   617
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   618
                dynamicExp += "return 0; ";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   619
                dynamicExp += "}; ";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   620
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   621
                if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   622
                    benchmark("Evaling expression:" + dynamicExp, new Date());
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   623
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   624
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   625
                eval(dynamicExp);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   626
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   627
                cache.normalized.sort(sortWrapper);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   628
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   629
                if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   630
                    benchmark("Sorting on " + sortList.toString() + " and dir " + order + " time:", sortTime);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   631
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   632
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   633
                return cache;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   634
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   635
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   636
            function makeSortFunction(type, direction, index) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   637
                var a = "a[" + index + "]",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   638
                    b = "b[" + index + "]";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   639
                if (type == 'text' && direction == 'asc') {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   640
                    return "(" + a + " == " + b + " ? 0 : (" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " === null ? Number.NEGATIVE_INFINITY : (" + a + " < " + b + ") ? -1 : 1 )));";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   641
                } else if (type == 'text' && direction == 'desc') {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   642
                    return "(" + a + " == " + b + " ? 0 : (" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " === null ? Number.NEGATIVE_INFINITY : (" + b + " < " + a + ") ? -1 : 1 )));";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   643
                } else if (type == 'numeric' && direction == 'asc') {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   644
                    return "(" + a + " === null && " + b + " === null) ? 0 :(" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " === null ? Number.NEGATIVE_INFINITY : " + a + " - " + b + "));";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   645
                } else if (type == 'numeric' && direction == 'desc') {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   646
                    return "(" + a + " === null && " + b + " === null) ? 0 :(" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " === null ? Number.NEGATIVE_INFINITY : " + b + " - " + a + "));";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   647
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   648
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   649
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   650
            function makeSortText(i) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   651
                return "((a[" + i + "] < b[" + i + "]) ? -1 : ((a[" + i + "] > b[" + i + "]) ? 1 : 0));";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   652
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   653
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   654
            function makeSortTextDesc(i) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   655
                return "((b[" + i + "] < a[" + i + "]) ? -1 : ((b[" + i + "] > a[" + i + "]) ? 1 : 0));";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   656
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   657
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   658
            function makeSortNumeric(i) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   659
                return "a[" + i + "]-b[" + i + "];";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   660
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   661
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   662
            function makeSortNumericDesc(i) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   663
                return "b[" + i + "]-a[" + i + "];";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   664
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   665
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   666
            function sortText(a, b) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   667
                if (table.config.sortLocaleCompare) return a.localeCompare(b);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   668
                return ((a < b) ? -1 : ((a > b) ? 1 : 0));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   669
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   670
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   671
            function sortTextDesc(a, b) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   672
                if (table.config.sortLocaleCompare) return b.localeCompare(a);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   673
                return ((b < a) ? -1 : ((b > a) ? 1 : 0));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   674
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   675
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   676
            function sortNumeric(a, b) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   677
                return a - b;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   678
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   679
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   680
            function sortNumericDesc(a, b) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   681
                return b - a;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   682
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   683
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   684
            function getCachedSortType(parsers, i) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   685
                return parsers[i].type;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   686
            }; /* public methods */
8003
7e240c04c69f undo garbage shipped in 9a73d5e762b0
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8000
diff changeset
   687
            this.construct = function (settings) {
7945
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   688
                return this.each(function () {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   689
                    // if no thead or tbody quit.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   690
                    if (!this.tHead || !this.tBodies) return;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   691
                    // declare
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   692
                    var $this, $document, $headers, cache, config, shiftDown = 0,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   693
                        sortOrder;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   694
                    // new blank config object
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   695
                    this.config = {};
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   696
                    // merge and extend.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   697
                    config = $.extend(this.config, $.tablesorter.defaults, settings);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   698
                    // store common expression for speed
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   699
                    $this = $(this);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   700
                    // save the settings where they read
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   701
                    $.data(this, "tablesorter", config);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   702
                    // build headers
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   703
                    $headers = buildHeaders(this);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   704
                    // try to auto detect column type, and store in tables config
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   705
                    this.config.parsers = buildParserCache(this, $headers);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   706
                    // build the cache for the tbody cells
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   707
                    cache = buildCache(this);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   708
                    // get the css class names, could be done else where.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   709
                    var sortCSS = [config.cssDesc, config.cssAsc];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   710
                    // fixate columns if the users supplies the fixedWidth option
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   711
                    fixColumnWidth(this);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   712
                    // apply event handling to headers
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   713
                    // this is to big, perhaps break it out?
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   714
                    $headers.click(
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   715
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   716
                    function (e) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   717
                        var totalRows = ($this[0].tBodies[0] && $this[0].tBodies[0].rows.length) || 0;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   718
                        if (!this.sortDisabled && totalRows > 0) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   719
                            // Only call sortStart if sorting is
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   720
                            // enabled.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   721
                            $this.trigger("sortStart");
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   722
                            // store exp, for speed
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   723
                            var $cell = $(this);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   724
                            // get current column index
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   725
                            var i = this.column;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   726
                            // get current column sort order
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   727
                            this.order = this.count++ % 2;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   728
                            // always sort on the locked order.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   729
                            if(this.lockedOrder) this.order = this.lockedOrder;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   730
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   731
                            // user only whants to sort on one
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   732
                            // column
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   733
                            if (!e[config.sortMultiSortKey]) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   734
                                // flush the sort list
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   735
                                config.sortList = [];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   736
                                if (config.sortForce != null) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   737
                                    var a = config.sortForce;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   738
                                    for (var j = 0; j < a.length; j++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   739
                                        if (a[j][0] != i) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   740
                                            config.sortList.push(a[j]);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   741
                                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   742
                                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   743
                                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   744
                                // add column to sort list
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   745
                                config.sortList.push([i, this.order]);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   746
                                // multi column sorting
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   747
                            } else {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   748
                                // the user has clicked on an all
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   749
                                // ready sortet column.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   750
                                if (isValueInArray(i, config.sortList)) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   751
                                    // revers the sorting direction
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   752
                                    // for all tables.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   753
                                    for (var j = 0; j < config.sortList.length; j++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   754
                                        var s = config.sortList[j],
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   755
                                            o = config.headerList[s[0]];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   756
                                        if (s[0] == i) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   757
                                            o.count = s[1];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   758
                                            o.count++;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   759
                                            s[1] = o.count % 2;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   760
                                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   761
                                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   762
                                } else {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   763
                                    // add column to sort list array
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   764
                                    config.sortList.push([i, this.order]);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   765
                                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   766
                            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   767
                            setTimeout(function () {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   768
                                // set css for headers
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   769
                                setHeadersCss($this[0], $headers, config.sortList, sortCSS);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   770
                                appendToTable(
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   771
	                                $this[0], multisort(
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   772
	                                $this[0], config.sortList, cache)
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   773
								);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   774
                            }, 1);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   775
                            // stop normal event by returning false
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   776
                            return false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   777
                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   778
                        // cancel selection
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   779
                    }).mousedown(function () {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   780
                        if (config.cancelSelection) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   781
                            this.onselectstart = function () {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   782
                                return false
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   783
                            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   784
                            return false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   785
                        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   786
                    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   787
                    // apply easy methods that trigger binded events
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   788
                    $this.bind("update", function () {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   789
                        var me = this;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   790
                        setTimeout(function () {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   791
                            // rebuild parsers.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   792
                            me.config.parsers = buildParserCache(
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   793
                            me, $headers);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   794
                            // rebuild the cache map
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   795
                            cache = buildCache(me);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   796
                        }, 1);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   797
                    }).bind("updateCell", function (e, cell) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   798
                        var config = this.config;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   799
                        // get position from the dom.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   800
                        var pos = [(cell.parentNode.rowIndex - 1), cell.cellIndex];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   801
                        // update cache
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   802
                        cache.normalized[pos[0]][pos[1]] = config.parsers[pos[1]].format(
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   803
                        getElementText(config, cell), cell);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   804
                    }).bind("sorton", function (e, list) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   805
                        $(this).trigger("sortStart");
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   806
                        config.sortList = list;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   807
                        // update and store the sortlist
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   808
                        var sortList = config.sortList;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   809
                        // update header count index
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   810
                        updateHeaderSortCount(this, sortList);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   811
                        // set css for headers
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   812
                        setHeadersCss(this, $headers, sortList, sortCSS);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   813
                        // sort the table and append it to the dom
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   814
                        appendToTable(this, multisort(this, sortList, cache));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   815
                    }).bind("appendCache", function () {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   816
                        appendToTable(this, cache);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   817
                    }).bind("applyWidgetId", function (e, id) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   818
                        getWidgetById(id).format(this);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   819
                    }).bind("applyWidgets", function () {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   820
                        // apply widgets
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   821
                        applyWidget(this);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   822
                    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   823
                    if ($.metadata && ($(this).metadata() && $(this).metadata().sortlist)) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   824
                        config.sortList = $(this).metadata().sortlist;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   825
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   826
                    // if user has supplied a sort list to constructor.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   827
                    if (config.sortList.length > 0) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   828
                        $this.trigger("sorton", [config.sortList]);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   829
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   830
                    // apply widgets
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   831
                    applyWidget(this);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   832
                });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   833
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   834
            this.addParser = function (parser) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   835
                var l = parsers.length,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   836
                    a = true;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   837
                for (var i = 0; i < l; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   838
                    if (parsers[i].id.toLowerCase() == parser.id.toLowerCase()) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   839
                        a = false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   840
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   841
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   842
                if (a) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   843
                    parsers.push(parser);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   844
                };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   845
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   846
            this.addWidget = function (widget) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   847
                widgets.push(widget);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   848
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   849
            this.formatFloat = function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   850
                var i = parseFloat(s);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   851
                return (isNaN(i)) ? 0 : i;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   852
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   853
            this.formatInt = function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   854
                var i = parseInt(s);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   855
                return (isNaN(i)) ? 0 : i;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   856
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   857
            this.isDigit = function (s, config) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   858
                // replace all an wanted chars and match.
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   859
                return /^[-+]?\d*$/.test($.trim(s.replace(/[,.']/g, '')));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   860
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   861
            this.clearTableBody = function (table) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   862
                if ($.browser.msie) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   863
                    function empty() {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   864
                        while (this.firstChild)
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   865
                        this.removeChild(this.firstChild);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   866
                    }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   867
                    empty.apply(table.tBodies[0]);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   868
                } else {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   869
                    table.tBodies[0].innerHTML = "";
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   870
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   871
            };
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   872
        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   873
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   874
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   875
    // extend plugin scope
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   876
    $.fn.extend({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   877
        tablesorter: $.tablesorter.construct
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   878
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   879
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   880
    // make shortcut
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   881
    var ts = $.tablesorter;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   882
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   883
    // add default parsers
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   884
    ts.addParser({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   885
        id: "text",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   886
        is: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   887
            return true;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   888
        }, format: function (s) {
8071
9ab3a9406473 [js/tablesorter] work around tablesorter deficiencies (bool handling)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8043
diff changeset
   889
            return $.trim(s); // CW PATCH: lowercasing decision taken in the server
7945
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   890
        }, type: "text"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   891
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   892
8071
9ab3a9406473 [js/tablesorter] work around tablesorter deficiencies (bool handling)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8043
diff changeset
   893
    // CW PATCH: ugly hack to catch booleans
9ab3a9406473 [js/tablesorter] work around tablesorter deficiencies (bool handling)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8043
diff changeset
   894
    ts.addParser({
9ab3a9406473 [js/tablesorter] work around tablesorter deficiencies (bool handling)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8043
diff changeset
   895
        id: 'boolean',
9ab3a9406473 [js/tablesorter] work around tablesorter deficiencies (bool handling)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8043
diff changeset
   896
        is: function (s) {
9ab3a9406473 [js/tablesorter] work around tablesorter deficiencies (bool handling)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8043
diff changeset
   897
            return (s == "true" || s == "false");
9ab3a9406473 [js/tablesorter] work around tablesorter deficiencies (bool handling)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8043
diff changeset
   898
        },
9ab3a9406473 [js/tablesorter] work around tablesorter deficiencies (bool handling)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8043
diff changeset
   899
       format: function (s) {
9ab3a9406473 [js/tablesorter] work around tablesorter deficiencies (bool handling)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8043
diff changeset
   900
           if (s) { return "0"; } else { return "1"; }
9ab3a9406473 [js/tablesorter] work around tablesorter deficiencies (bool handling)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8043
diff changeset
   901
       },
9ab3a9406473 [js/tablesorter] work around tablesorter deficiencies (bool handling)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8043
diff changeset
   902
      type: 'boolean'});
9ab3a9406473 [js/tablesorter] work around tablesorter deficiencies (bool handling)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8043
diff changeset
   903
7945
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   904
    ts.addParser({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   905
        id: "digit",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   906
        is: function (s, table) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   907
            var c = table.config;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   908
            return $.tablesorter.isDigit(s, c);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   909
        }, format: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   910
            return $.tablesorter.formatFloat(s);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   911
        }, type: "numeric"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   912
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   913
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   914
    ts.addParser({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   915
        id: "currency",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   916
        is: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   917
            return /^[£$€?.]/.test(s);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   918
        }, format: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   919
            return $.tablesorter.formatFloat(s.replace(new RegExp(/[£$€]/g), ""));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   920
        }, type: "numeric"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   921
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   922
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   923
    ts.addParser({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   924
        id: "ipAddress",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   925
        is: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   926
            return /^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   927
        }, format: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   928
            var a = s.split("."),
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   929
                r = "",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   930
                l = a.length;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   931
            for (var i = 0; i < l; i++) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   932
                var item = a[i];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   933
                if (item.length == 2) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   934
                    r += "0" + item;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   935
                } else {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   936
                    r += item;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   937
                }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   938
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   939
            return $.tablesorter.formatFloat(r);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   940
        }, type: "numeric"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   941
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   942
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   943
    ts.addParser({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   944
        id: "url",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   945
        is: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   946
            return /^(https?|ftp|file):\/\/$/.test(s);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   947
        }, format: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   948
            return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//), ''));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   949
        }, type: "text"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   950
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   951
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   952
    ts.addParser({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   953
        id: "isoDate",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   954
        is: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   955
            return /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   956
        }, format: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   957
            return $.tablesorter.formatFloat((s != "") ? new Date(s.replace(
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   958
            new RegExp(/-/g), "/")).getTime() : "0");
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   959
        }, type: "numeric"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   960
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   961
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   962
    ts.addParser({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   963
        id: "percent",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   964
        is: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   965
            return /\%$/.test($.trim(s));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   966
        }, format: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   967
            return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g), ""));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   968
        }, type: "numeric"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   969
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   970
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   971
    ts.addParser({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   972
        id: "usLongDate",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   973
        is: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   974
            return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/));
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   975
        }, format: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   976
            return $.tablesorter.formatFloat(new Date(s).getTime());
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   977
        }, type: "numeric"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   978
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   979
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   980
    ts.addParser({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   981
        id: "shortDate",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   982
        is: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   983
            return /\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   984
        }, format: function (s, table) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   985
            var c = table.config;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   986
            s = s.replace(/\-/g, "/");
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   987
            if (c.dateFormat == "us") {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   988
                // reformat the string in ISO format
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   989
                s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$1/$2");
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   990
            } else if (c.dateFormat == "uk") {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   991
                // reformat the string in ISO format
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   992
                s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1");
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   993
            } else if (c.dateFormat == "dd/mm/yy" || c.dateFormat == "dd-mm-yy") {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   994
                s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/, "$1/$2/$3");
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   995
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   996
            return $.tablesorter.formatFloat(new Date(s).getTime());
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   997
        }, type: "numeric"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   998
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
   999
    ts.addParser({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1000
        id: "time",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1001
        is: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1002
            return /^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1003
        }, format: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1004
            return $.tablesorter.formatFloat(new Date("2000/01/01 " + s).getTime());
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1005
        }, type: "numeric"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1006
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1007
    ts.addParser({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1008
        id: "metadata",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1009
        is: function (s) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1010
            return false;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1011
        }, format: function (s, table, cell) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1012
            var c = table.config,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1013
                p = (!c.parserMetadataName) ? 'sortValue' : c.parserMetadataName;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1014
            return $(cell).metadata()[p];
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1015
        }, type: "numeric"
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1016
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1017
    // add default widgets
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1018
    ts.addWidget({
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1019
        id: "zebra",
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1020
        format: function (table) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1021
            if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1022
                var time = new Date();
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1023
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1024
            var $tr, row = -1,
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1025
                odd;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1026
            // loop through the visible rows
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1027
            $("tr:visible", table.tBodies[0]).each(function (i) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1028
                $tr = $(this);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1029
                // style children rows the same way the parent
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1030
                // row was styled
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1031
                if (!$tr.hasClass(table.config.cssChildRow)) row++;
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1032
                odd = (row % 2 == 0);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1033
                $tr.removeClass(
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1034
                table.config.widgetZebra.css[odd ? 0 : 1]).addClass(
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1035
                table.config.widgetZebra.css[odd ? 1 : 0])
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1036
            });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1037
            if (table.config.debug) {
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1038
                $.tablesorter.benchmark("Applying Zebra widget", time);
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1039
            }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1040
        }
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1041
    });
5959f94c0358 [table js] Update jquery-tablesorter to 2.0.5 (closes #1989018)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5658
diff changeset
  1042
})(jQuery);