comparison default/node_modules/tablesaw/demo/sort-custom.html @ 0:1d038bc9b3d2 default tip

Up:default
author Liny <dev@neowd.com>
date Sat, 31 May 2025 09:21:51 +0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1d038bc9b3d2
1 <!doctype html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6 <meta name="viewport" content="width=device-width, initial-scale=1">
7 <title>TableSaw Sortable Table</title>
8
9 <link rel="stylesheet" href="../dist/tablesaw.css">
10 <link rel="stylesheet" href="demo.css">
11 <link rel="stylesheet" href="//filamentgroup.github.io/demo-head/demohead.css">
12
13 <script src="../dist/tablesaw.js"></script>
14 <script src="../dist/tablesaw-init.js"></script>
15 <script src="//filamentgroup.github.io/demo-head/loadfont.js"></script>
16 <script>
17 $(function() {
18 $( "#custom-sort" ).data( "tablesaw-sort", function( ascending ) {
19 return function( a, b ) {
20 if( a.ignored || b.ignored ) {
21 return 0;
22 }
23 // a.cell
24 // a.element
25 // a.rowNum
26 var yearA = a.cell.split( "/" ),
27 yearB = b.cell.split( "/" );
28
29 if( ascending ) {
30 return parseInt( yearA[ 1 ], 10 ) - parseInt( yearB[ 1 ], 10 );
31 } else {
32 // descending
33 return parseInt( yearB[ 1 ], 10 ) - parseInt( yearA[ 1 ], 10 );
34 }
35 };
36 });
37 });
38 </script>
39 </head>
40 <body>
41 <div class="demo-header">
42 <div class="company">
43 <img src="http://filamentgroup.com/images/fg-logo-positive-sm-crop.png">
44 </div>
45 <div class="details">
46 <h1 class="description-container">Demo of <span class="repo-name">Tablesaw</span>
47 <span class="description">A group of plugins for responsive tables.</span>
48 </h1>
49 <ul class="outbound-links">
50 <li><a href="https://github.com/filamentgroup/tablesaw">Code</a></li>
51 <li><a href="https://github.com/filamentgroup/tablesaw/issues">Issues</a></li>
52 </ul>
53 </div>
54 </div>
55 <div class="nav-container">
56 <div class="docs-globalnav">
57 <nav class="docs-nav">
58 <a href="kitchensink.html">Kitchen Sink</a>
59 <a href="modeswitch.html">Mode Switch</a>
60 <a href="sort.html" class="current">Sortable</a>
61 <a href="stack.html">Stack</a>
62 <a href="stackonly.html">Stack Only</a>
63 <a href="swipe.html">Swipe Table</a>
64 <a href="toggle.html">Toggle</a>
65 </nav>
66 </div>
67 </div>
68 <div class="docs-main">
69 <h2>Sortable Table</h2>
70 <h3 class="docs">Default appearance (with optional sortable-switch)</h3>
71
72 <table class="tablesaw" data-tablesaw-sortable data-tablesaw-sortable-switch>
73 <thead>
74 <tr>
75 <th scope="col" data-tablesaw-sortable-col data-tablesaw-priority="persist">Movie Title</th>
76 <th scope="col" data-tablesaw-sortable-col data-tablesaw-sortable-default-col data-tablesaw-priority="3">Rank</th>
77 <th id="custom-sort" scope="col" data-tablesaw-sortable-col data-tablesaw-priority="2">Year</th>
78 <th scope="col" data-tablesaw-sortable-col data-tablesaw-priority="1"><abbr title="Rotten Tomato Rating">Rating</abbr></th>
79 <th scope="col" data-tablesaw-sortable-col data-tablesaw-priority="4">Gross</th>
80 </tr>
81 </thead>
82 <tbody>
83 <tr>
84 <td class="title"><a href="http://en.wikipedia.org/wiki/Avatar_(2009_film)">Avatar</a></td>
85 <td>1</td>
86 <td>11/2009</td>
87 <td>83%</td>
88 <td>$2.7B</td>
89 </tr>
90 <tr>
91 <td class="title"><a href="http://en.wikipedia.org/wiki/Titanic_(1997_film)">Titanic</a></td>
92 <td>2</td>
93 <td>12/1997</td>
94 <td>88%</td>
95 <td>$2.1B</td>
96 </tr>
97 <tr>
98 <td class="title"><a href="http://en.wikipedia.org/wiki/The_Avengers_(2012_film)">The Avengers</a></td>
99 <td>3</td>
100 <td>3/2012</td>
101 <td>92%</td>
102 <td>$1.5B</td>
103 </tr>
104 <tr>
105 <td class="title"><a href="http://en.wikipedia.org/wiki/Harry_Potter_and_the_Deathly_Hallows_%E2%80%93_Part_2">Harry Potter and the Deathly Hallows—Part 2</a></td>
106 <td>4</td>
107 <td>5/2011</td>
108 <td>96%</td>
109 <td>$1.3B</td>
110 </tr>
111 <tr>
112 <td class="title"><a href="http://en.wikipedia.org/wiki/Frozen_(2013_film)">Frozen</a></td>
113 <td>5</td>
114 <td>9/2013</td>
115 <td>89%</td>
116 <td>$1.2B</td>
117 </tr>
118 <tr>
119 <td class="title"><a href="http://en.wikipedia.org/wiki/Iron_Man_3">Iron Man 3</a></td>
120 <td>6</td>
121 <td>1/2013</td>
122 <td>78%</td>
123 <td>$1.2B</td>
124 </tr>
125 <tr>
126 <td class="title"><a href="http://en.wikipedia.org/wiki/Transformers:_Dark_of_the_Moon">Transformers: Dark of the Moon</a></td>
127 <td>7</td>
128 <td>3/2011</td>
129 <td>36%</td>
130 <td>$1.1B</td>
131 </tr>
132 <tr>
133 <td class="title"><a href="http://en.wikipedia.org/wiki/The_Lord_of_the_Rings:_The_Return_of_the_King">The Lord of the Rings: The Return of the King</a></td>
134 <td>8</td>
135 <td>4/2003</td>
136 <td>95%</td>
137 <td>$1.1B</td>
138 </tr>
139 <tr>
140 <td class="title"><a href="http://en.wikipedia.org/wiki/Skyfall">Skyfall</a></td>
141 <td>9</td>
142 <td>11/2012</td>
143 <td>92%</td>
144 <td>$1.1B</td>
145 </tr>
146 <tr>
147 <td class="title"><a href="http://en.wikipedia.org/wiki/Transformers:_Age_of_Extinction">Transformers: Age of Extinction</a></td>
148 <td>10</td>
149 <td>12/2014</td>
150 <td>18%</td>
151 <td>$1.0B</td>
152 </tr>
153 </tbody>
154 </table>
155 </div>
156 </body>
157 </html>