~ubuntu-branches/ubuntu/utopic/jquery-goodies/utopic-proposed

« back to all changes in this revision

Viewing changes to tablesorter/docs/example-parsers.html

  • Committer: Bazaar Package Importer
  • Author(s): Marcelo Jorge Vieira (metal)
  • Date: 2011-07-25 15:39:18 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110725153918-mig1d2wa18u168cr
Tags: 4-1
* New Upstream Version
  + Added jQuery-metadata
  + Added jQuery-tablesorter, thanks Ben Finney (Closes: #631219, #584127)
  + Added jQuery-treetable (Closes: #584403)
  + Added jQuery-livequery
  + Fixed wrong path to images in the jQuery-fancybox (Closes: #628029)
* Updated Standards-Version to 3.9.2 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
2
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
3
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
 
4
<head>
 
5
        <title>jQuery plugin: Tablesorter 2.0 - Writing custom parsers</title>
 
6
        <link rel="stylesheet" href="css/jq.css" type="text/css" media="print, projection, screen" />
 
7
        <link rel="stylesheet" href="../themes/blue/style.css" type="text/css" media="print, projection, screen" />
 
8
        <script type="text/javascript" src="../jquery-latest.js"></script>
 
9
        
 
10
        <script type="text/javascript" src="../jquery.tablesorter.js"></script>
 
11
        <script type="text/javascript" src="../addons/pager/jquery.tablesorter.pager.js"></script>
 
12
        <script type="text/javascript" src="js/chili/chili-1.8b.js"></script>
 
13
        <script type="text/javascript" src="js/docs.js"></script>
 
14
        <script type="text/javascript" src="js/examples.js"></script>
 
15
        <script type="text/javascript" id="js">
 
16
        // add parser through the tablesorter addParser method
 
17
        $.tablesorter.addParser({
 
18
                // set a unique id
 
19
                id: 'grades',
 
20
                is: function(s) {
 
21
                        // return false so this parser is not auto detected
 
22
                        return false;
 
23
                },
 
24
                format: function(s) {
 
25
                        // format your data for normalization
 
26
                        return s.toLowerCase().replace(/good/,2).replace(/medium/,1).replace(/bad/,0);
 
27
                },
 
28
                // set type, either numeric or text
 
29
                type: 'numeric'
 
30
        });
 
31
        
 
32
        $(function() {
 
33
                $("table").tablesorter({
 
34
                        headers: {
 
35
                                6: {
 
36
                                        sorter:'grades'
 
37
                                }
 
38
                        }
 
39
                });
 
40
        });                             
 
41
        </script>
 
42
</head>
 
43
<body>
 
44
<div id="banner">       
 
45
        <h1>table<em>sorter</em></h1>
 
46
        <h2>Writing custom parsers</h2>
 
47
        <h3>Flexible client-side table sorting</h3>
 
48
        <a href="index.html">Back to documentation</a>
 
49
</div>
 
50
<div id="main">
 
51
        <h1>Demo</h1>
 
52
        <div id="demo">
 
53
        <table cellspacing="1" class="tablesorter">
 
54
                <thead>
 
55
                        <tr>
 
56
                                <th>Name</th>
 
57
                                <th>Major</th>
 
58
                                <th>Gender</th>
 
59
                                <th>English</th>
 
60
                                <th>Japanese</th>
 
61
                                <th>Calculus</th>
 
62
                                <th>Overall grades</th>
 
63
                        </tr>
 
64
                </thead>
 
65
                <tbody>
 
66
                        <tr>
 
67
                                <td>Student01</td>
 
68
                                <td>Languages</td>
 
69
                                <td>male</td>
 
70
                                <td>80</td>
 
71
                                <td>70</td>
 
72
                                <td>75</td>
 
73
                                <td>bad</td>
 
74
                        </tr>
 
75
                        <tr>
 
76
                                <td>Student02</td>
 
77
                                <td>Mathematics</td>
 
78
                                <td>male</td>
 
79
                                <td>90</td>
 
80
                                <td>88</td>
 
81
                                <td>100</td>
 
82
                                <td>good</td>
 
83
                        </tr>
 
84
                        <tr>
 
85
                                <td>Student03</td>
 
86
                                <td>Languages</td>
 
87
                                <td>female</td>
 
88
                                <td>85</td>
 
89
                                <td>95</td>
 
90
                                <td>80</td>
 
91
                                <td>medium</td>
 
92
                        </tr>
 
93
                </tbody>
 
94
        </table>
 
95
        </div>
 
96
        <h1>Javascript</h1>
 
97
        <div id="javascript">
 
98
                <pre class="javascript"></pre>
 
99
        </div>
 
100
        <h1>HTML</h1>
 
101
        <div id="html">
 
102
                <pre class="html"></pre>
 
103
        </div>
 
104
</div>
 
105
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
 
106
<script type="text/javascript">
 
107
_uacct = "UA-2189649-2";
 
108
urchinTracker();
 
109
</script>
 
110
</body>
 
111
</html>
 
112