File: example-widget-current-sort.html

package info (click to toggle)
jquery-tablesorter 1%3A2.31.3%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,056 kB
  • sloc: javascript: 19,495; sh: 14; makefile: 8
file content (117 lines) | stat: -rw-r--r-- 3,467 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>jQuery tablesorter 2.0 - currentSort widget</title>

	<!-- jQuery -->
	<script src="js/jquery-latest.min.js"></script>

	<!-- Demo stuff -->
	<link rel="stylesheet" href="css/jq.css">
	<link href="css/prettify.css" rel="stylesheet">
	<script src="js/prettify.js"></script>
	<script src="js/docs.js"></script>

	<!-- Tablesorter: required -->
	<link rel="stylesheet" href="../css/theme.blue.css">
	<script src="../js/jquery.tablesorter.js"></script>
	<script src="../js/widgets/widget-currentSort.js"></script>
	<style>
	#display li:last-child { color: #008080; }
	</style>

<script id="js">$(function() {

	$.tablesorter.currentSortLanguage = {
		0: 'asc',
		1: 'desc',
		2: 'unsorted'
	};

	$('table').tablesorter({
		theme: 'blue',
		widgets : ['zebra', 'currentSort'],
		widgetOptions: {
			currentSort_callback: function(config, values) {
				// values also contained in config.currentSort
				// update display
				var $display = $('#display');
				$display
					.append('<li>[ "'  + values.join('", "') + '" ]</li>')
					.find('li:first').remove();
			}
		}
	});

}); </script>
</head>
<body>

<div id="banner">
	<h1>table<em>sorter</em></h1>
	<h2>currentSort Widget</h2>
	<h3>Flexible client-side table sorting</h3>
	<a href="index.html">Back to documentation</a>
</div>

<div id="main">

	<p class="tip">
		<em>NOTE!</em>
	</p>
	<ul>
		<li>Added <span class="verison">v2.27.0</span>.
			<ul>
				<li>This widget has only one option - <code>currentSort_callback</code> - which provides the following parameters.
					<ul>
						<li><code>config</code> - The <code>table.config</code> object.</li>
						<li><code>values</code> - An array of the current sort using the <code>$.tablesorter.currentSortLanguage</code> settings.</li>
					</ul>
				</li>
				<li>Change the language of the output for this widget by modifying the <code>$.tablesorter.currentSortLanguage</code> object.</li>
				<li>The current sort array is also saved to <code>config.currentSort</code>.</li>
			</ul>
		</li>
	</ul>

	<h1>Current Sort</h1>
	<ul id="display">
		<li>The last three sort arrays will appear here.</li>
		<li>&nbsp;</li>
		<li>&nbsp;</li>
	</ul>

	<h1>Demo</h1>
	<table class="tablesorter">
		<thead>
			<tr>
				<th>AlphaNumeric Sort</th>
				<th>Currency</th>
				<th>Alphabetical</th>
				<th>Sites</th>
			</tr>
		</thead>
		<tbody>
			<tr><td>abc 123</td><td>&#163;10,40</td><td>Koala</td><td>http://www.google.com</td></tr>
			<tr><td>abc 1</td><td>&#163;234,10</td><td>Ox</td><td>http://www.yahoo.com</td></tr>
			<tr><td>abc 9</td><td>&#163;10,33</td><td>Girafee</td><td>http://www.facebook.com</td></tr>
			<tr><td>zyx 24</td><td>&#163;10</td><td>Bison</td><td>http://www.whitehouse.gov/</td></tr>
			<tr><td>abc 11</td><td>&#163;3,20</td><td>Chimp</td><td>http://www.ucla.edu/</td></tr>
			<tr><td>abc 2</td><td>&#163;56,10</td><td>Elephant</td><td>http://www.wikipedia.org/</td></tr>
			<tr><td>abc 9</td><td>&#163;3,20</td><td>Lion</td><td>http://www.nytimes.com/</td></tr>
			<tr><td>ABC 10</td><td>&#163;87,00</td><td>Zebra</td><td>https://github.com</td></tr>
			<tr><td>zyx 1</td><td>&#163;99,90</td><td>Koala</td><td>http://www.mit.edu/</td></tr>
			<tr><td>zyx 12</td><td>&#163;234,10</td><td>Llama</td><td>http://www.nasa.gov/</td></tr>
		</tbody>
	</table>

	<h1>Javascript</h1>
	<div id="javascript">
		<pre class="prettyprint lang-javascript"></pre>
	</div>

</div>

</body>
</html>