added textSorter & modified sortLocaleCompare

This commit is contained in:
Rob Garrison 2012-05-03 23:38:10 -05:00
parent 28e9a07d59
commit e579f93e8f
14 changed files with 592 additions and 90 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
/*! /*!
* tablesorter pager plugin * tablesorter pager plugin
* updated 4/28/2012 * updated 5/3/2012
*/ */
;(function($) { ;(function($) {
$.extend({tablesorterPager: new function() { $.extend({tablesorterPager: new function() {

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,158 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery plugin: Tablesorter 2.0 - Sorting Accented Characters</title>
<!-- jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<!-- Demo stuff -->
<link rel="stylesheet" href="css/jq.css">
<script src="js/chili/jquery.chili-2.2.js"></script>
<script src="js/chili/recipes.js"></script>
<script src="js/docs.js"></script>
<!-- Tablesorter: required -->
<link rel="stylesheet" href="../css/blue/style.css">
<script src="../js/jquery.tablesorter.js"></script>
<script id="js">$(function() {
// these default equivalents were obtained from a table of equivalents
// provided by sugar.js sorting alogrithms: http://sugarjs.com/sorting
/*
$.tablesorter.characterEquivalents = {
"a" : "\u00e1\u00e0\u00e2\u00e3\u00e4", // áàâãä
"A" : "\u00c1\u00c0\u00c2\u00c3\u00c4", // ÁÀÂÃÄ
"c" : "\u00e7", // ç
"C" : "\u00c7", // Ç
"e" : "\u00e9\u00e8\u00ea\u00eb", // éèêë
"E" : "\u00c9\u00c8\u00ca\u00cb", // ÉÈÊË
"i" : "\u00ed\u00ec\u0130\u00ee\u00ef", // íìIîï
"I" : "\u00cd\u00cc\u0130\u00ce\u00cf", // ÍÌIÎÏ
"o" : "\u00f3\u00f2\u00f4\u00f5\u00f6", // óòôõö
"O" : "\u00d3\u00d2\u00d4\u00d5\u00d6", // ÓÒÔÕÖ
"S" : "\u00df", // ß
"u" : "\u00fa\u00f9\u00fb\u00fc", // úùûü
"U" : "\u00da\u00d9\u00db\u00dc" // ÚÙÛÜ
};
*/
// modify the above defaults as follows
$.extend( $.tablesorter.characterEquivalents, {
"ae" : "\u00e6;", // expanding characters æ Æ
"AE" : "\u00c6;",
"oe" : "\u00f6;\u0153;", // œ Œ
"OE" : "\u00d6;\u0152;",
"d" : "\u00f0;", // Eth (ð Ð)
"D" : "\u00d0;",
"o" : "\u00f3;\u00f2;\u00f4;\u00f5;", // remove ö because it's in the oe now
"O" : "\u00d3;\u00d2;\u00d4;\u00d5;" // remove Ö because it's in the OE now
});
$("table").tablesorter({
// Enable use of the characterEquivalents reference
sortLocaleCompare : true,
// upper case sorts BEFORE lower case
ignoreCase : false
});
});</script>
</head>
<body>
<div id="banner">
<h1>table<em>sorter</em></h1>
<h2>Sorting Accented Characters</h2>
<h3>Flexible client-side table sorting</h3>
<a href="index.html">Back to documentation</a>
</div>
<div id="main">
<h1>Demo</h1>
<div id="demo"><table class="tablesorter">
<thead>
<tr>
<th>Account #</th>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<tr>
<td>a1a10</td>
<td>AnderE</td>
<td>Parker</td>
<td>28</td>
<td>Béchar</td>
</tr>
<tr>
<td>a1a2</td>
<td>Ändere</td>
<td>Hood</td>
<td>33</td>
<td>Bebington</td>
</tr>
<tr>
<td>A1a1</td>
<td>Andére</td>
<td>Kent</td>
<td>18</td>
<td>Berlin</td>
</tr>
<tr>
<td>A2b2</td>
<td>CotÉ</td>
<td>Almighty</td>
<td>45</td>
<td>Beckum</td>
</tr>
<tr>
<td>A1d2</td>
<td>CÔte</td>
<td>Evans</td>
<td>56</td>
<td>Curaçao</td>
</tr>
<tr>
<td>a2b11</td>
<td>CÔtÉ</td>
<td>Clark</td>
<td>44</td>
<td>Béjaïa</td>
</tr>
<tr>
<td>A2b1</td>
<td>Çote</td>
<td>Presley</td>
<td>24</td>
<td>Bekkevoort</td>
</tr>
<tr>
<td>A1b0</td>
<td>Andéré</td>
<td>Carter</td>
<td>40</td>
<td>Bègles</td>
</tr>
</tbody>
</table></div>
<h1>Javascript</h1>
<div id="javascript">
<pre class="js"></pre>
</div>
<h1>HTML</h1>
<div id="html">
<pre class="html"></pre>
</div>
<div class="next-up">
<hr />
Next up: <a href="example-option-digits.html">Dealing with digits! &rsaquo;&rsaquo;</a>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,157 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery plugin: Tablesorter 2.0 - Using a Custom Sort Script</title>
<!-- jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<!-- Demo stuff -->
<link rel="stylesheet" href="css/jq.css">
<script src="js/chili/jquery.chili-2.2.js"></script>
<script src="js/chili/recipes.js"></script>
<script src="js/docs.js"></script>
<!-- custom sorting script -->
<script src="js/naturalSort.js"></script>
<!-- Tablesorter: required -->
<link rel="stylesheet" href="../css/blue/style.css">
<script src="../js/jquery.tablesorter.js"></script>
<script id="js">$(function() {
$("table").tablesorter({
textSorter : naturalSort
});
});</script>
</head>
<body>
<div id="banner">
<h1>table<em>sorter</em></h1>
<h2>Using a Custom Sort Script</h2>
<h3>Flexible client-side table sorting</h3>
<a href="index.html">Back to documentation</a>
</div>
<div id="main">
<h1>Demo</h1>
<div id="demo"><table class="tablesorter">
<thead>
<tr>
<th>Account #</th>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
<th>Total</th>
<th>Discount</th>
<th>Diff</th>
</tr>
</thead>
<tbody>
<tr>
<td>a1a10</td>
<td>Peter</td>
<td>Parker</td>
<td>28</td>
<td>9.99</td>
<td>20.3%</td>
<td>+3</td>
</tr>
<tr>
<td>a1a2</td>
<td>John</td>
<td>Hood</td>
<td>33</td>
<td>19.99</td>
<td>25.1%</td>
<td>-7</td>
</tr>
<tr>
<td>A1a1</td>
<td>Clark</td>
<td>Kent</td>
<td>18</td>
<td>2.89</td>
<td>44.2%</td>
<td>-15</td>
</tr>
<tr>
<td>A2b2</td>
<td>Bruce</td>
<td>Almighty</td>
<td>45</td>
<td>153.19</td>
<td>44%</td>
<td>+19</td>
</tr>
<tr>
<td>A1d2</td>
<td>Bruce</td>
<td>Evans</td>
<td>56</td>
<td>$153.19</td>
<td>23%</td>
<td>+9</td>
</tr>
<tr>
<td>a2b11</td>
<td>John</td>
<td>Clark</td>
<td>44</td>
<td>($19.89)</td>
<td>25.1%</td>
<td>(5)</td>
</tr>
<tr>
<td>A2b1</td>
<td>Elvis</td>
<td>Presley</td>
<td>24</td>
<td>($9.99)</td>
<td>50%</td>
<td>(22)</td>
</tr>
<tr>
<td>A1b0</td>
<td>Frank</td>
<td>Carter</td>
<td>40</td>
<td>-12.99</td>
<td>20%</td>
<td>(6)</td>
</tr>
</tbody>
</table></div>
<h1>Page Head</h1>
<div>
<pre class="html">&lt;!-- jQuery --&gt;
&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;!-- custom sorting script --&gt;
&lt;script src=&quot;js/naturalSort.js&quot;&gt;&lt;/script&gt;
&lt;!-- Tablesorter: required --&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;../css/blue/style.css&quot;&gt;
&lt;script src=&quot;../js/jquery.tablesorter.js&quot;&gt;&lt;/script&gt;</pre>
</div>
<h1>Javascript</h1>
<div id="javascript">
<pre class="js"></pre>
</div>
<h1>HTML</h1>
<div id="html">
<pre class="html"></pre>
</div>
<div class="next-up">
<hr />
Next up: <a href="example-locale-sort.html">Sorting Accented Characters &rsaquo;&rsaquo;</a>
</div>
</div>
</body>
</html>

View File

@ -107,7 +107,7 @@
<div class="next-up"> <div class="next-up">
<hr /> <hr />
Next up: <a href="example-option-digits.html">Dealing with digits! &rsaquo;&rsaquo;</a> Next up: <a href="example-option-custom-sort.html">Using a custom sort script &rsaquo;&rsaquo;</a>
</div> </div>
</div> </div>

View File

@ -15,11 +15,12 @@
<!-- Tablesorter: required --> <!-- Tablesorter: required -->
<link href="../css/blue/style.css" rel="stylesheet"> <link href="../css/blue/style.css" rel="stylesheet">
<script src="../js/jquery.tablesorter.min.js"></script> <script src="../js/jquery.tablesorter.js"></script>
<script src="../js/jquery.tablesorter.widgets.js"></script>
<script> <script>
$(function() { $(function() {
$("#tablesorter-demo").tablesorter({sortList:[[0,0],[2,1]],widgets:['zebra']}); $("#tablesorter-demo").tablesorter({sortList:[[0,0],[2,1]],widgets:['zebra']});
$("table.options").tablesorter({sortList:[[0,0]],headers:{3:{sorter:false},4:{sorter:false}}}); $("#options").tablesorter({sortList:[[0,0]],headers:{3:{sorter:false},4:{sorter:false}},widgets:['stickyHeaders']});
$("#methods,#events").tablesorter({sortList:[[0,0]],headers:{1:{sorter:false},2:{sorter:false}}}); $("#methods,#events").tablesorter({sortList:[[0,0]],headers:{1:{sorter:false},2:{sorter:false}}});
}); });
</script> </script>
@ -94,6 +95,7 @@
<ul> <ul>
<li>Multi-column sorting</li> <li>Multi-column sorting</li>
<li>Multi-tbody sorting - see the <a href="#options">options</a> table below</li>
<li>Parsers for sorting text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats), time. <a href="example-parsers.html">Add your own easily</a></li> <li>Parsers for sorting text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats), time. <a href="example-parsers.html">Add your own easily</a></li>
<!-- <!--
<li>Support for ROWSPAN and COLSPAN on TH elements</li> <li>Support for ROWSPAN and COLSPAN on TH elements</li>
@ -290,6 +292,8 @@
<li><a href="example-option-sortreset-sortrestart.html">Using sortReset &amp; sortRestart options</a></li> <li><a href="example-option-sortreset-sortrestart.html">Using sortReset &amp; sortRestart options</a></li>
<li><a href="example-option-sort-empty.html">Sorting empty cells</a> <span class="tip"><em>New!</em></span> v2.1.11</li> <li><a href="example-option-sort-empty.html">Sorting empty cells</a> <span class="tip"><em>New!</em></span> v2.1.11</li>
<li><a href="example-option-sort-key.html">Change the default multi-sorting key</a></li> <li><a href="example-option-sort-key.html">Change the default multi-sorting key</a></li>
<li><a href="example-option-custom-sort.html">Custom sort script</a> <span class="tip"><em>New!</em></span> v2.2</li>
<li><a href="example-locale-sort.html">Sorting Accented Characters</a> <span class="tip"><em>New!</em></span> v2.2</li>
</ul> </ul>
<h4>Parsers / Extracting Content</h4> <h4>Parsers / Extracting Content</h4>
@ -504,6 +508,32 @@
<td></td> <td></td>
</tr> </tr>
<tr id="cssinfoblock">
<td><a href="#" class="toggle2">cssInfoBlock</a></td>
<td>String</td>
<td>"tablesorter-infoOnly"</td>
<td>All tbodies with this class name will not have its contents sorted. <span class="tip"><em>New!</em></span> v2.2
<div class="collapsible">
<br>
With the addition of multiple tbody sorting in v2.2, you can now insert a non-sorting tbody within the table by adding this class to the tbody.
<pre class="html">&lt;tbody class=&quot;tablesorter-infoOnly&quot;&gt;
&lt;tr&gt;
&lt;th&gt;The contents of this tbody&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;will not be sorted&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;</pre>
As an example, I've split up this options table into three (3) tbodies. The first contains the active options, the second is the info block with a row that only contains the text "Deprecated Options", and the last tbody contains the deprecated options. Sort the table to see how each tbody sorts separately.
<br>
<p class="tip">
<em>NOTE!</em> The pager plugin will only be applied to the first tbody, as always. I may work on modifying this behavior in the future, if I can figure out the best implementation.
</p>
</div>
</td>
<td></td>
</tr>
<tr id="selectorremove"> <tr id="selectorremove">
<td><a href="#" class="toggle2">selectorRemove</a></td> <td><a href="#" class="toggle2">selectorRemove</a></td>
<td>String</td> <td>String</td>
@ -645,6 +675,14 @@
</td> </td>
</tr> </tr>
<tr id="ignorecase">
<td>ignoreCase</td>
<td>Boolean</td>
<td>true</td>
<td>When true, text sorting will ignore the character case. If false, upper case characters will sort before lower case.</td>
<td></td>
</tr>
<tr id="onrenderheader"> <tr id="onrenderheader">
<td><a href="#" class="toggle2">onRenderHeader</a></td> <td><a href="#" class="toggle2">onRenderHeader</a></td>
<td>Function</td> <td>Function</td>
@ -780,12 +818,36 @@
<td>Boolean</td> <td>Boolean</td>
<td>false</td> <td>false</td>
<td> <td>
Boolean flag indicating whenever to use javascript <code class="hilight">String.localeCompare</code> method or not. Boolean flag indicating if certain accented characters within the table will be replaced with their equivalent characters. <span class="tip"><em>Modified!</em></span> v2.2.
<div class="collapsible"> <div class="collapsible">
This is only used when comparing text with international character strings. A sort using localeCompare will sort accented characters the same as their unaccented counterparts. <ul>
<li>This option no longer switches the sort to use the <code class="hilight">String.localeCompare</code> method.</li>
<li>When this option is <code class="hilight">true</code>, the text parsed from table cells will convert accented characters to their equivalent to allow the alphanumeric sort to properly sort.</li>
<li>If <code class="hilight">false</code> (default), any accented characters are treated as their value in the standard unicode order.</li>
<li>The following characters are replaced for both upper and lower case (information obtained from <a href="http://sugarjs.com/sorting">sugar.js sorting equivalents</a> table):
<ul>
<li><code class="hilight">&#x00e1;&#x00e0;&#x00e2;&#x00e3;&#x00e4;</code> replaced with <code class="hilight">a</code></li>
<li><code class="hilight">&#x00e7;</code> replaced with <code class="hilight">c</code></li>
<li><code class="hilight">&#x00e9;&#x00e8;&#x00ea;&#x00eb;</code> replaced with <code class="hilight">e</code></li>
<li><code class="hilight">&#x00ed;&#x00ec;&#x0130;&#x00ee;&#x00ef;</code> replaced with <code class="hilight">i</code></li>
<li><code class="hilight">&#x00f3;&#x00f2;&#x00f4;&#x00f5;&#x00f6;</code> replaced with <code class="hilight">o</code></li>
<li><code class="hilight">&#x00fa;&#x00f9;&#x00fb;&#x00fc;</code> replaced with <code class="hilight">u</code></li>
<li><code class="hilight">&#x00df;</code> replaced with <code class="hilight">S</code></li>
</ul>
</li>
<li>Please see the example page for instrcutions on how to modify the above equivalency table.</li>
<li>If you would like to continuing using the <code class="hilight">String.localeCompare</code> method, then set the <code class="hilight">sortLocaleCompare</code> option to <code class="hilight">false</code> and use the new <code class="hilight">textSorter</code> option as follows:
<pre class="js">$('table').tablesorter({
textSorter: function(a,b) {
return a.localeCompare(b);
}
});</pre></li>
</ul>
<del>Boolean flag indicating whenever to use javascript <code class="hilight">String.localeCompare</code> method or not.<br>
This is only used when comparing text with international character strings. A sort using localeCompare will sort accented characters the same as their unaccented counterparts.</del>
</div> </div>
</td> </td>
<td><a href="example-pager-ajax.html">Example</a></td> <td><a href="example-locale-sort.html">Example</a></td>
</tr> </tr>
<tr id="sortreset"> <tr id="sortreset">
@ -891,6 +953,33 @@ $(function(){
<td><a href="example-option-text-extraction.html">Example</a></td> <td><a href="example-option-text-extraction.html">Example</a></td>
</tr> </tr>
<tr id="textsorter">
<td><a href="#" class="toggle2">textSorter</a></td>
<td>Function</td>
<td>null</td>
<td>
Replace the default sorting algorithm with a custom one using this option.
<div class="collapsible">
<br>
Include a script like <a href="https://github.com/overset/javascript-natural-sort">naturalSort.js</a> as follows:
<pre class="js">$(function(){
$("table").tablesorter({
textSorter : naturalSort
});
});</pre>
or use the localeCompare sort
<pre class="js">$(function(){
$("table").tablesorter({
textSorter: function(a,b) {
return a.localeCompare(b);
}
});
});</pre>There's no need to worry about reverse sorting, it's taken care of by the plugin.
</div>
</td>
<td><a href="example-option-custom-sort.html">Example</a></td>
</tr>
<tr id="usnumberformat"> <tr id="usnumberformat">
<td><a href="#" class="toggle2">usNumberFormat</a></td> <td><a href="#" class="toggle2">usNumberFormat</a></td>
<td>Boolean</td> <td>Boolean</td>
@ -992,7 +1081,14 @@ $(function(){
</td> </td>
<td><a href="example-widget-zebra.html">Example</a></td> <td><a href="example-widget-zebra.html">Example</a></td>
</tr> </tr>
</tbody>
<!-- non-sorting tbody -->
<tbody class="tablesorter-infoOnly">
<tr><th colspan="5">Deprecated Options</th></tr>
</tbody>
<tbody>
<tr id="widgetcolumns"> <!-- added hidden zzz to sort these deprecated options at the bottom --> <tr id="widgetcolumns"> <!-- added hidden zzz to sort these deprecated options at the bottom -->
<td><span class="hidden">zzz</span><a href="#" class="toggle2 deprecated">widgetColumns</a></td> <td><span class="hidden">zzz</span><a href="#" class="toggle2 deprecated">widgetColumns</a></td>
<td>Object with Array</td> <td>Object with Array</td>
@ -1340,7 +1436,7 @@ $("table").trigger("sorton", [sorting]);</pre></div>
<br> <br>
Note: This is the only method the pager widget uses - the entire table is stored in the cache, but only the visible portion is actually exists in the table. Note: This is the only method the pager widget uses - the entire table is stored in the cache, but only the visible portion is actually exists in the table.
<pre class="js">// Table data was just dynamically changed (more than one cell) <pre class="js">// Table data was just dynamically changed (more than one cell)
$(table) $("table")
.trigger("update") .trigger("update")
.trigger("appendCache");</pre></div> .trigger("appendCache");</pre></div>
</td> </td>
@ -1543,15 +1639,15 @@ $(table)
<strong id="Download-Required">Required:</strong> <strong id="Download-Required">Required:</strong>
<ul> <ul>
<li><a class="external" href="http://docs.jquery.com/Downloading_jQuery#Download_jQuery">jQuery</a> (1.2.6 or higher; some demos need jQuery 1.4.2+)</li> <li><a class="external" href="http://docs.jquery.com/Downloading_jQuery#Download_jQuery">jQuery</a> (1.2.6 or higher; some demos need jQuery 1.4.2+)</li>
<li><a href="../js/jquery.tablesorter.min.js">jquery.tablesorter.min.js</a> (17kb, minified for production - please put the file on your server)</li> <li><a href="../js/jquery.tablesorter.min.js">jquery.tablesorter.min.js</a> (19kb, minified for production - please put the file on your server)</li>
</ul> </ul>
<strong id="Download-Addons">Optional / Add-Ons:</strong> <strong id="Download-Addons">Optional / Add-Ons:</strong>
<ul> <ul>
<li><a class="external" href="http://plugins.jquery.com/files/jquery.metadata.2.1.zip">jQuery Metadata 2.1</a> (6kb, required for setting <a href="#Examples">inline options</a>)</li> <li><a class="external" href="http://plugins.jquery.com/files/jquery.metadata.2.1.zip">jQuery Metadata 2.1</a> (6kb, required for setting <a href="#Examples">inline options</a>)</li>
<li><a href="../js/jquery.tablesorter.js">jquery.tablesorter.js</a> (30kb/<a href="../js/jquery.tablesorter.min.js">17kb min</a>)</li> <li><a href="../js/jquery.tablesorter.js">jquery.tablesorter.js</a> (35kb/<a href="../js/jquery.tablesorter.min.js">19kb min</a>)</li>
<li><a href="../addons/pager/jquery.tablesorter.pager.js">jquery.tablesorter.pager.js</a> (14kb/<a href="../addons/pager/jquery.tablesorter.pager.min.js">7kb min</a>, <a href="example-pager.html">demo</a>)</li> <li><a href="../addons/pager/jquery.tablesorter.pager.js">jquery.tablesorter.pager.js</a> (14kb/<a href="../addons/pager/jquery.tablesorter.pager.min.js">7kb min</a>, <a href="example-pager.html">demo</a>)</li>
<li><a href="../js/jquery.tablesorter.widgets.js">jquery.tablesorter.widgets.js</a> (15kb/<a href="../js/jquery.tablesorter.widgets.min.js">7kb min</a>, includes the jQuery UI theme, columns styling, resizable columns, filter, sticky header and save sort widgets. <span class="tip"><em>Updated!</em></span> in v2.1.)</li> <li><a href="../js/jquery.tablesorter.widgets.js">jquery.tablesorter.widgets.js</a> (16kb/<a href="../js/jquery.tablesorter.widgets.min.js">8kb min</a>, includes the jQuery UI theme, columns styling, resizable columns, filter, sticky header and save sort widgets. <span class="tip"><em>Updated!</em></span> in v2.1.)</li>
</ul> </ul>
<strong id="Download-Themes">Themes:</strong> <strong id="Download-Themes">Themes:</strong>

View File

@ -164,7 +164,7 @@ ChiliBook.recipes[ "html.js" ] =
} }
, comment: { , comment: {
_match: /<!--[\w\W]*?-->/ _match: /<!--[\w\W]*?-->/
, _style: "color: #4040c2;" , _style: "color: gray;"
} }
, script: { , script: {
_match: /(<script\s+[^>]*>)([\w\W]*?)(<\/script\s*>)/ _match: /(<script\s+[^>]*>)([\w\W]*?)(<\/script\s*>)/
@ -191,7 +191,7 @@ ChiliBook.recipes[ "html.js" ] =
+ this.x( content, '/tag_attrs' ) + this.x( content, '/tag_attrs' )
+ "<span class='tag_start'>" + this.x( close ) + "</span>"; + "<span class='tag_start'>" + this.x( close ) + "</span>";
} }
, _style: "color: navy; font-weight: bold;" , _style: "color: navy;"
} }
// matches an ending tag // matches an ending tag
// like "</div>" // like "</div>"
@ -210,7 +210,7 @@ ChiliBook.recipes[ "html.js" ] =
// before in $1, name in $2, between in $3, value in $4 // before in $1, name in $2, between in $3, value in $4
_match: /(\W*?)([\w-]+)(\s*=\s*)((?:\'[^\']*(?:\\.[^\']*)*\')|(?:\"[^\"]*(?:\\.[^\"]*)*\"))/ _match: /(\W*?)([\w-]+)(\s*=\s*)((?:\'[^\']*(?:\\.[^\']*)*\')|(?:\"[^\"]*(?:\\.[^\"]*)*\"))/
, _replace: "$1<span class='attr_name'>$2</span>$3<span class='attr_value'>$4</span>" , _replace: "$1<span class='attr_name'>$2</span>$3<span class='attr_value'>$4</span>"
, _style: { attr_name: "color: green;", attr_value: "color: maroon;" } , _style: { attr_name: "color: royalBlue;", attr_value: "color: maroon;" }
} }
} }
}; };
@ -228,7 +228,7 @@ ChiliBook.recipes[ "js.js" ] =
} }
, sl_comment: { , sl_comment: {
_match: /\/\/.*/ _match: /\/\/.*/
, _style: 'color: green;' , _style: 'color: gray;'
} }
, string: { , string: {
_match: /(?:\'[^\'\\\n]*(?:\\.[^\'\\\n]*)*\')|(?:\"[^\"\\\n]*(?:\\.[^\"\\\n]*)*\")/ _match: /(?:\'[^\'\\\n]*(?:\\.[^\'\\\n]*)*\')|(?:\"[^\"\\\n]*(?:\\.[^\"\\\n]*)*\")/
@ -236,7 +236,7 @@ ChiliBook.recipes[ "js.js" ] =
} }
, num: { , num: {
_match: /\b[+-]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?\b/ _match: /\b[+-]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?\b/
, _style: 'color: red;' , _style: 'color: #a00;'
} }
, reg_not: { //this prevents "a / b / c" to be interpreted as a reg_exp , reg_not: { //this prevents "a / b / c" to be interpreted as a reg_exp
_match: /(?:\w+\s*)\/[^\/\\\n]*(?:\\.[^\/\\\n]*)*\/[gim]*(?:\s*\w+)/ _match: /(?:\w+\s*)\/[^\/\\\n]*(?:\\.[^\/\\\n]*)*\/[gim]*(?:\s*\w+)/
@ -250,7 +250,7 @@ ChiliBook.recipes[ "js.js" ] =
} }
, brace: { , brace: {
_match: /[\{\}]/ _match: /[\{\}]/
, _style: 'color: red; font-weight: bold;' , _style: 'color: #c00; font-weight: bold;'
} }
, statement: { , statement: {
_match: /\b(with|while|var|try|throw|switch|return|if|for|finally|else|do|default|continue|const|catch|case|break)\b/ _match: /\b(with|while|var|try|throw|switch|return|if|for|finally|else|do|default|continue|const|catch|case|break)\b/
@ -292,7 +292,7 @@ ChiliBook.recipes[ "css.js" ] =
, _main: { , _main: {
comment: { comment: {
_match: /\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\// _match: /\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\//
, _style: "color: olive;" , _style: "color: gray;"
} }
, directive: { , directive: {
_match: /@\w+/ _match: /@\w+/
@ -352,7 +352,7 @@ ChiliBook.recipes[ "css.js" ] =
} }
, number: { , number: {
_match: /(?:\b[+-]?(?:\d*\.?\d+|\d+\.?\d*))(?:%|(?:(?:px|pt|em|)\b))/ _match: /(?:\b[+-]?(?:\d*\.?\d+|\d+\.?\d*))(?:%|(?:(?:px|pt|em|)\b))/
, _style: "color: red;" , _style: "color: maroon;"
} }
, color : { , color : {
_match: /(?:\#[a-fA-F0-9]{3,6})|\b(?:yellow|white|teal|silver|red|purple|olive|navy|maroon|lime|green|gray|fuchsia|blue|black|aqua|YellowGreen|Yellow|WhiteSmoke|White|Wheat|Violet|Turquoise|Tomato|Thistle|Teal|Tan|SteelBlue|SpringGreen|Snow|SlateGrey|SlateGray|SlateBlue|SkyBlue|Silver|Sienna|SeaShell|SeaGreen|SandyBrown|Salmon|SaddleBrown|RoyalBlue|RosyBrown|Red|Purple|PowderBlue|Plum|Pink|Peru|PeachPuff|PapayaWhip|PaleVioletRed|PaleTurquoise|PaleGreen|PaleGoldenRod|Orchid|OrangeRed|Orange|OliveDrab|Olive|OldLace|Navy|NavajoWhite|Moccasin|MistyRose|MintCream|MidnightBlue|MediumVioletRed|MediumTurquoise|MediumSpringGreen|MediumSlateBlue|MediumSeaGreen|MediumPurple|MediumOrchid|MediumBlue|MediumAquaMarine|Maroon|Magenta|Linen|LimeGreen|Lime|LightYellow|LightSteelBlue|LightSlateGrey|LightSlateGray|LightSkyBlue|LightSeaGreen|LightSalmon|LightPink|LightGrey|LightGreen|LightGray|LightGoldenRodYellow|LightCyan|LightCoral|LightBlue|LemonChiffon|LawnGreen|LavenderBlush|Lavender|Khaki|Ivory|Indigo|IndianRed|HotPink|HoneyDew|Grey|GreenYellow|Green|Gray|GoldenRod|Gold|GhostWhite|Gainsboro|Fuchsia|ForestGreen|FloralWhite|FireBrick|DodgerBlue|DimGrey|DimGray|DeepSkyBlue|DeepPink|Darkorange|DarkViolet|DarkTurquoise|DarkSlateGrey|DarkSlateGray|DarkSlateBlue|DarkSeaGreen|DarkSalmon|DarkRed|DarkOrchid|DarkOliveGreen|DarkMagenta|DarkKhaki|DarkGrey|DarkGreen|DarkGray|DarkGoldenRod|DarkCyan|DarkBlue|Cyan|Crimson|Cornsilk|CornflowerBlue|Coral|Chocolate|Chartreuse|CadetBlue|BurlyWood|Brown|BlueViolet|Blue|BlanchedAlmond|Black|Bisque|Beige|Azure|Aquamarine|Aqua|AntiqueWhite|AliceBlue)\b/ _match: /(?:\#[a-fA-F0-9]{3,6})|\b(?:yellow|white|teal|silver|red|purple|olive|navy|maroon|lime|green|gray|fuchsia|blue|black|aqua|YellowGreen|Yellow|WhiteSmoke|White|Wheat|Violet|Turquoise|Tomato|Thistle|Teal|Tan|SteelBlue|SpringGreen|Snow|SlateGrey|SlateGray|SlateBlue|SkyBlue|Silver|Sienna|SeaShell|SeaGreen|SandyBrown|Salmon|SaddleBrown|RoyalBlue|RosyBrown|Red|Purple|PowderBlue|Plum|Pink|Peru|PeachPuff|PapayaWhip|PaleVioletRed|PaleTurquoise|PaleGreen|PaleGoldenRod|Orchid|OrangeRed|Orange|OliveDrab|Olive|OldLace|Navy|NavajoWhite|Moccasin|MistyRose|MintCream|MidnightBlue|MediumVioletRed|MediumTurquoise|MediumSpringGreen|MediumSlateBlue|MediumSeaGreen|MediumPurple|MediumOrchid|MediumBlue|MediumAquaMarine|Maroon|Magenta|Linen|LimeGreen|Lime|LightYellow|LightSteelBlue|LightSlateGrey|LightSlateGray|LightSkyBlue|LightSeaGreen|LightSalmon|LightPink|LightGrey|LightGreen|LightGray|LightGoldenRodYellow|LightCyan|LightCoral|LightBlue|LemonChiffon|LawnGreen|LavenderBlush|Lavender|Khaki|Ivory|Indigo|IndianRed|HotPink|HoneyDew|Grey|GreenYellow|Green|Gray|GoldenRod|Gold|GhostWhite|Gainsboro|Fuchsia|ForestGreen|FloralWhite|FireBrick|DodgerBlue|DimGrey|DimGray|DeepSkyBlue|DeepPink|Darkorange|DarkViolet|DarkTurquoise|DarkSlateGrey|DarkSlateGray|DarkSlateBlue|DarkSeaGreen|DarkSalmon|DarkRed|DarkOrchid|DarkOliveGreen|DarkMagenta|DarkKhaki|DarkGrey|DarkGreen|DarkGray|DarkGoldenRod|DarkCyan|DarkBlue|Cyan|Crimson|Cornsilk|CornflowerBlue|Coral|Chocolate|Chartreuse|CadetBlue|BurlyWood|Brown|BlueViolet|Blue|BlanchedAlmond|Black|Bisque|Beige|Azure|Aquamarine|Aqua|AntiqueWhite|AliceBlue)\b/

42
docs/js/naturalSort.js Normal file
View File

@ -0,0 +1,42 @@
/*
* Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
* Author: Jim Palmer (based on chunking idea from Dave Koelle)
*/
function naturalSort (a, b) {
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
sre = /(^[ ]*|[ ]*$)/g,
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
hre = /^0x[0-9a-f]+$/i,
ore = /^0/,
i = function(s) { return naturalSort.insensitive && (''+s).toLowerCase() || ''+s },
// convert all to strings strip whitespace
x = i(a).replace(sre, '') || '',
y = i(b).replace(sre, '') || '',
// chunk/tokenize
xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
// numeric, hex or date detection
xD = parseInt(x.match(hre)) || (xN.length != 1 && x.match(dre) && Date.parse(x)),
yD = parseInt(y.match(hre)) || xD && y.match(dre) && Date.parse(y) || null,
oFxNcL, oFyNcL;
// first try and sort Hex codes or Dates
if (yD)
if ( xD < yD ) return -1;
else if ( xD > yD ) return 1;
// natural sorting through split numeric strings and default strings
for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
// handle numeric vs string comparison - number < string - (Kyle Adams)
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { return (isNaN(oFxNcL)) ? 1 : -1; }
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
else if (typeof oFxNcL !== typeof oFyNcL) {
oFxNcL += '';
oFyNcL += '';
}
if (oFxNcL < oFyNcL) return -1;
if (oFxNcL > oFyNcL) return 1;
}
return 0;
}

View File

@ -1,5 +1,5 @@
/*! /*!
* TableSorter 2.1.20 - Client-side table sorting with ease! * TableSorter 2.2 - Client-side table sorting with ease!
* @requires jQuery v1.2.6+ * @requires jQuery v1.2.6+
* *
* Copyright (c) 2007 Christian Bach * Copyright (c) 2007 Christian Bach
@ -18,9 +18,9 @@
$.extend({ $.extend({
tablesorter: new function() { tablesorter: new function() {
this.version = "2.1.20"; this.version = "2.2";
var parsers = [], widgets = [], tbl; var parsers = [], widgets = [], tbl, $tbl;
this.defaults = { this.defaults = {
cssHeader: "tablesorter-header", cssHeader: "tablesorter-header",
cssAsc: "tablesorter-headerSortUp", cssAsc: "tablesorter-headerSortUp",
@ -34,9 +34,11 @@
sortLocaleCompare: false, sortLocaleCompare: false,
sortReset: false, sortReset: false,
sortRestart: false, sortRestart: false,
emptyTo : "bottom", // sort empty cell to bottom emptyTo: "bottom", // sort empty cell to bottom
stringTo : "max", // sort strings in numerical column as max value stringTo: "max", // sort strings in numerical column as max value
textExtraction: "simple", textExtraction: "simple",
textSorter: null, // use custom text sorter
ignoreCase: true,
parsers: {}, parsers: {},
widgets: [], widgets: [],
headers: {}, headers: {},
@ -196,13 +198,26 @@
} }
/* utils */ /* utils */
function buildRegex(){
var a, acc = '[', t = $.tablesorter,
reg = t.characterEquivalents;
t.characterRegexArray = {};
for (a in reg) {
if (typeof a === 'string') {
acc += reg[a];
t.characterRegexArray[a] = new RegExp('[' + reg[a] + ']', 'g');
}
}
t.characterRegex = new RegExp(acc + ']');
}
function buildCache(table) { function buildCache(table) {
var b = table.tBodies, var b = table.tBodies,
tc = table.config, tc = table.config,
totalRows, totalRows,
totalCells, totalCells,
parsers = tc.parsers, parsers = tc.parsers,
t, i, j, c, cols, cacheTime; t, i, j, k, c, cols, cacheTime;
tc.cache = {}; tc.cache = {};
if (tc.debug) { if (tc.debug) {
cacheTime = new Date(); cacheTime = new Date();
@ -267,7 +282,7 @@
b = table.tBodies, b = table.tBodies,
rows = [], rows = [],
r, n, totalRows, checkCell, r, n, totalRows, checkCell,
f, i, j, l, pos, appendTime; f, i, j, k, l, pos, appendTime;
if (c.debug) { if (c.debug) {
appendTime = new Date(); appendTime = new Date();
} }
@ -277,7 +292,6 @@
n = c.cache[k].normalized; n = c.cache[k].normalized;
totalRows = n.length; totalRows = n.length;
checkCell = totalRows ? (n[0].length - 1) : 0; checkCell = totalRows ? (n[0].length - 1) : 0;
for (i = 0; i < totalRows; i++) { for (i = 0; i < totalRows; i++) {
pos = n[i][checkCell]; pos = n[i][checkCell];
rows.push(r[pos]); rows.push(r[pos]);
@ -378,7 +392,7 @@
} }
$tableHeaders = $(c.selectorHeaders, table) $tableHeaders = $(c.selectorHeaders, table)
.wrapInner("<div class='tablesorter-header-inner' />") .wrapInner("<div class='tablesorter-header-inner' />")
.each(function (index) { .each(function(index) {
this.column = header_index[this.parentNode.rowIndex + "-" + this.cellIndex]; this.column = header_index[this.parentNode.rowIndex + "-" + this.cellIndex];
this.order = formatSortingOrder( checkHeaderOrder(table, index) ) ? [1,0,2] : [0,1,2]; this.order = formatSortingOrder( checkHeaderOrder(table, index) ) ? [1,0,2] : [0,1,2];
this.count = -1; // set to -1 because clicking on the header automatically adds one this.count = -1; // set to -1 because clicking on the header automatically adds one
@ -450,7 +464,7 @@
function fixColumnWidth(table) { function fixColumnWidth(table) {
if (table.config.widthFixed) { if (table.config.widthFixed) {
var colgroup = $('<colgroup>'); var colgroup = $('<colgroup>');
$("tr:first td", table.tBodies[0]).each(function () { $("tr:first td", table.tBodies[0]).each(function() {
colgroup.append($('<col>').css('width', $(this).width())); colgroup.append($('<col>').css('width', $(this).width()));
}); });
$(table).prepend(colgroup); $(table).prepend(colgroup);
@ -475,7 +489,7 @@
function multisort(table, sortList) { function multisort(table, sortList) {
var dynamicExp, col, mx = 0, dir = 0, tc = table.config, var dynamicExp, col, mx = 0, dir = 0, tc = table.config,
l = sortList.length, bl = table.tBodies.length, l = sortList.length, bl = table.tBodies.length,
sortTime, i, j, c, cache, lc, s, e, order, orgOrderCol; sortTime, i, j, k, c, cache, lc, s, e, order, orgOrderCol;
if (tc.debug) { sortTime = new Date(); } if (tc.debug) { sortTime = new Date(); }
for (k = 0; k < bl; k++) { for (k = 0; k < bl; k++) {
dynamicExp = "var sortWrapper = function(a,b) {"; dynamicExp = "var sortWrapper = function(a,b) {";
@ -521,10 +535,11 @@
// Natural sort modified from: http://www.webdeveloper.com/forum/showthread.php?t=107909 // Natural sort modified from: http://www.webdeveloper.com/forum/showthread.php?t=107909
function sortText(a, b, col) { function sortText(a, b, col) {
if (a === b) { return 0; } if (a === b) { return 0; }
var c = tbl[0].config, cnt = 0, L, t, x, e = c.string[ (c.empties[col] || c.emptyTo ) ]; var c = tbl.config, cnt = 0, L, t, x, e = c.string[ (c.empties[col] || c.emptyTo ) ];
if (a === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? -1 : 1) : -e || -1; } if (a === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? -1 : 1) : -e || -1; }
if (b === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? 1 : -1) : e || 1; } if (b === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? 1 : -1) : e || 1; }
if (c.sortLocaleCompare) { return a.localeCompare(b); } if (typeof c.textSorter === 'function') { return c.textSorter(a, b); }
// if (c.sortLocaleCompare) { return a.localeCompare(b); }
try { try {
x = /^(\.)?\d/; x = /^(\.)?\d/;
L = Math.min(a.length, b.length) + 1; L = Math.min(a.length, b.length) + 1;
@ -552,11 +567,12 @@
function sortTextDesc(a, b, col) { function sortTextDesc(a, b, col) {
if (a === b) { return 0; } if (a === b) { return 0; }
var c = tbl[0].config, e = c.string[ (c.empties[col] || c.emptyTo ) ]; var c = tbl.config, e = c.string[ (c.empties[col] || c.emptyTo ) ];
if (a === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? -1 : 1) : e || 1; } if (a === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? -1 : 1) : e || 1; }
if (b === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? 1 : -1) : -e || -1; } if (b === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? 1 : -1) : -e || -1; }
if (c.sortLocaleCompare) { return b.localeCompare(a); } if (typeof c.textSorter === 'function') { return c.textSorter(b, a); }
return -sortText(a, b); // if (c.sortLocaleCompare) { return b.localeCompare(a); }
return sortText(b, a);
} }
// return text string value by adding up ascii value // return text string value by adding up ascii value
@ -576,7 +592,7 @@
function sortNumeric(a, b, col, mx, d) { function sortNumeric(a, b, col, mx, d) {
if (a === b) { return 0; } if (a === b) { return 0; }
var c = tbl[0].config, e = c.string[ (c.empties[col] || c.emptyTo ) ]; var c = tbl.config, e = c.string[ (c.empties[col] || c.emptyTo ) ];
if (a === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? -1 : 1) : -e || -1; } if (a === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? -1 : 1) : -e || -1; }
if (b === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? 1 : -1) : e || 1; } if (b === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? 1 : -1) : e || 1; }
if (isNaN(a)) { a = getTextValue(a, mx, d); } if (isNaN(a)) { a = getTextValue(a, mx, d); }
@ -586,7 +602,7 @@
function sortNumericDesc(a, b, col, mx, d) { function sortNumericDesc(a, b, col, mx, d) {
if (a === b) { return 0; } if (a === b) { return 0; }
var c = tbl[0].config, e = c.string[ (c.empties[col] || c.emptyTo ) ]; var c = tbl.config, e = c.string[ (c.empties[col] || c.emptyTo ) ];
if (a === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? -1 : 1) : e || 1; } if (a === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? -1 : 1) : e || 1; }
if (b === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? 1 : -1) : -e || -1; } if (b === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? 1 : -1) : -e || -1; }
if (isNaN(a)) { a = getTextValue(a, mx, d); } if (isNaN(a)) { a = getTextValue(a, mx, d); }
@ -600,34 +616,37 @@
// if no thead or tbody quit. // if no thead or tbody quit.
if (!this.tHead || this.tBodies.length === 0) { return; } if (!this.tHead || this.tBodies.length === 0) { return; }
// declare // declare
var $this, $headers, config, var $headers, $cell, totalRows,
totalRows, $cell, c, i, j, k, a, s, o; config, c, i, j, k, a, s, o;
tbl = this;
// new blank config object // new blank config object
this.config = {}; tbl.config = {};
// merge and extend. // merge and extend.
c = config = $.extend(true, this.config, $.tablesorter.defaults, settings); c = config = $.extend(true, tbl.config, $.tablesorter.defaults, settings);
// store common expression for speed // store common expression for speed
tbl = $this = $(this).addClass(this.config.tableClass); $tbl = $(tbl).addClass(c.tableClass);
// save the settings where they read // save the settings where they read
$.data(this, "tablesorter", c); $.data(tbl, "tablesorter", c);
// build up character equivalent cross-reference
buildRegex();
// digit sort text location; keeping max+/- for backwards compatibility // digit sort text location; keeping max+/- for backwards compatibility
c.string = { 'max': 1, 'min': -1, 'max+': 1, 'max-': -1, 'zero': 0, 'none': 0, 'null': 0, 'top': true, 'bottom': false }; c.string = { 'max': 1, 'min': -1, 'max+': 1, 'max-': -1, 'zero': 0, 'none': 0, 'null': 0, 'top': true, 'bottom': false };
// build headers // build headers
$headers = buildHeaders(this); $headers = buildHeaders(tbl);
// try to auto detect column type, and store in tables config // try to auto detect column type, and store in tables config
c.parsers = buildParserCache(this, $headers); c.parsers = buildParserCache(tbl, $headers);
// build the cache for the tbody cells // build the cache for the tbody cells
buildCache(this); buildCache(tbl);
// fixate columns if the users supplies the fixedWidth option // fixate columns if the users supplies the fixedWidth option
fixColumnWidth(this); fixColumnWidth(tbl);
// apply event handling to headers // apply event handling to headers
// this is to big, perhaps break it out? // this is to big, perhaps break it out?
$headers $headers
.click(function(e) { .click(function(e) {
// totalRows = ($this[0].tBodies[0] && $this[0].tBodies[0].rows.length) || 0; // totalRows = (tbl.tBodies[0] && tbl.tBodies[0].rows.length) || 0;
if (!this.sortDisabled) { if (!this.sortDisabled) {
// Only call sortStart if sorting is enabled. // Only call sortStart if sorting is enabled.
$this.trigger("sortStart", tbl[0]); $tbl.trigger("sortStart", tbl);
// store exp, for speed // store exp, for speed
$cell = $(this); $cell = $(this);
k = !e[c.sortMultiSortKey]; k = !e[c.sortMultiSortKey];
@ -689,10 +708,10 @@
} }
} }
// sortBegin event triggered immediately before the sort // sortBegin event triggered immediately before the sort
$this.trigger("sortBegin", tbl[0]); $tbl.trigger("sortBegin", tbl);
// set css for headers // set css for headers
setHeadersCss($this[0], $headers, c.sortList); setHeadersCss(tbl, $headers, c.sortList);
appendToTable($this[0], multisort($this[0], c.sortList)); appendToTable(tbl, multisort(tbl, c.sortList));
// stop normal event by returning false // stop normal event by returning false
return false; return false;
} }
@ -707,7 +726,7 @@
} }
}); });
// apply easy methods that trigger binded events // apply easy methods that trigger binded events
$this $tbl
.bind("update", function(e, resort) { .bind("update", function(e, resort) {
// remove rows/elements before update // remove rows/elements before update
$(c.selectorRemove, this).remove(); $(c.selectorRemove, this).remove();
@ -715,25 +734,25 @@
c.parsers = buildParserCache(this, $headers); c.parsers = buildParserCache(this, $headers);
// rebuild the cache map // rebuild the cache map
buildCache(this); buildCache(this);
if (resort !== false) { $this.trigger("sorton", [c.sortList]); } if (resort !== false) { $tbl.trigger("sorton", [c.sortList]); }
}) })
.bind("updateCell", function(e, cell, resort) { .bind("updateCell", function(e, cell, resort) {
// get position from the dom. // get position from the dom.
var pos = [(cell.parentNode.rowIndex - 1), cell.cellIndex], var pos = [(cell.parentNode.rowIndex - 1), cell.cellIndex],
// update cache - format: function(s, table, cell, cellIndex) // update cache - format: function(s, table, cell, cellIndex)
tbodyindex = $(cell).closest('tbody').index(); tbodyindex = $tbl.find('tbody').index( $(cell).closest('tbody') );
table.cache[tbodyindex].normalized[pos[0]][pos[1]] = c.parsers[pos[1]].format(getElementText(c, cell, pos[1]), $this, cell, pos[1]); tbl.config.cache[tbodyindex].normalized[pos[0]][pos[1]] = c.parsers[pos[1]].format(getElementText(c, cell, pos[1]), tbl, cell, pos[1]);
if (resort !== false) { $this.trigger("sorton", [c.sortList]); } if (resort !== false) { $tbl.trigger("sorton", [c.sortList]); }
}) })
.bind("addRows", function(e, $row, resort) { .bind("addRows", function(e, $row, resort) {
var i, rows = $row.filter('tr').length, var i, rows = $row.filter('tr').length,
dat = [], l = $row[0].cells.length, dat = [], l = $row[0].cells.length,
tbodyindex = $row.closest('tbody').index(); tbodyindex = $tbl.find('tbody').index( $row.closest('tbody') );
// add each row // add each row
for (i = 0; i < rows; i++) { for (i = 0; i < rows; i++) {
// add each cell // add each cell
for (j = 0; j < l; j++) { for (j = 0; j < l; j++) {
dat[j] = c.parsers[j].format(getElementText(c, $row[i].cells[j], j), $this, $row[i].cells[j], j ); dat[j] = c.parsers[j].format( getElementText(c, $row[i].cells[j], j), tbl, $row[i].cells[j], j );
} }
// add the row index to the end // add the row index to the end
dat.push(c.cache[tbodyindex].row.length); dat.push(c.cache[tbodyindex].row.length);
@ -743,10 +762,10 @@
dat = []; dat = [];
} }
// resort using current settings // resort using current settings
if (resort !== false) { $this.trigger("sorton", [c.sortList]); } if (resort !== false) { $tbl.trigger("sorton", [c.sortList]); }
}) })
.bind("sorton", function(e, list) { .bind("sorton", function(e, list) {
$this.trigger("sortStart", tbl[0]); $tbl.trigger("sortStart", tbl);
c.sortList = list; c.sortList = list;
// update and store the sortlist // update and store the sortlist
var sortList = c.sortList; var sortList = c.sortList;
@ -757,13 +776,13 @@
// sort the table and append it to the dom // sort the table and append it to the dom
appendToTable(this, multisort(this, sortList)); appendToTable(this, multisort(this, sortList));
}) })
.bind("appendCache", function () { .bind("appendCache", function() {
appendToTable(this); appendToTable(this);
}) })
.bind("applyWidgetId", function (e, id) { .bind("applyWidgetId", function(e, id) {
getWidgetById(id).format(this); getWidgetById(id).format(this);
}) })
.bind("applyWidgets", function () { .bind("applyWidgets", function() {
// apply widgets // apply widgets
applyWidget(this); applyWidget(this);
}); });
@ -774,13 +793,13 @@
applyWidget(this, true); applyWidget(this, true);
// if user has supplied a sort list to constructor. // if user has supplied a sort list to constructor.
if (c.sortList.length > 0) { if (c.sortList.length > 0) {
$this.trigger("sorton", [c.sortList]); $tbl.trigger("sorton", [c.sortList]);
} else { } else {
// apply widget format // apply widget format
applyWidget(this); applyWidget(this);
} }
this.hasInitialized = true; this.hasInitialized = true;
$this.trigger('tablesorter-initialized', this); $tbl.trigger('tablesorter-initialized', this);
if (typeof c.initialized === 'function') { c.initialized(this); } if (typeof c.initialized === 'function') { c.initialized(this); }
}); });
}; };
@ -795,12 +814,12 @@
parsers.push(parser); parsers.push(parser);
} }
}; };
this.addWidget = function (widget) { this.addWidget = function(widget) {
widgets.push(widget); widgets.push(widget);
}; };
this.formatFloat = function(s) { this.formatFloat = function(s) {
if (typeof(s) !== 'string') { return s; } if (typeof(s) !== 'string') { return s; }
if (tbl[0].config.usNumberFormat) { if (tbl.config.usNumberFormat) {
// US Format - 1,234,567.89 -> 1234567.89 // US Format - 1,234,567.89 -> 1234567.89
s = s.replace(/,/g,''); s = s.replace(/,/g,'');
} else { } else {
@ -819,9 +838,37 @@
// replace all unwanted chars and match. // replace all unwanted chars and match.
return (/^[\-+(]?\d*[)]?$/).test($.trim(s.replace(/[,.'\s]/g, ''))); return (/^[\-+(]?\d*[)]?$/).test($.trim(s.replace(/[,.'\s]/g, '')));
}; };
this.clearTableBody = function (table) { // used when replacing accented characters during sorting
this.characterEquivalents = {
"a" : "\u00e1\u00e0\u00e2\u00e3\u00e4", // áàâãä
"A" : "\u00c1\u00c0\u00c2\u00c3\u00c4", // ÁÀÂÃÄ
"c" : "\u00e7", // ç
"C" : "\u00c7", // Ç
"e" : "\u00e9\u00e8\u00ea\u00eb", // éèêë
"E" : "\u00c9\u00c8\u00ca\u00cb", // ÉÈÊË
"i" : "\u00ed\u00ec\u0130\u00ee\u00ef", // íìİîï
"I" : "\u00cd\u00cc\u0130\u00ce\u00cf", // ÍÌİÎÏ
"o" : "\u00f3\u00f2\u00f4\u00f5\u00f6", // óòôõö
"O" : "\u00d3\u00d2\u00d4\u00d5\u00d6", // ÓÒÔÕÖ
"S" : "\u00df", // ß
"u" : "\u00fa\u00f9\u00fb\u00fc", // úùûü
"U" : "\u00da\u00d9\u00db\u00dc" // ÚÙÛÜ
};
this.replaceAccents = function(s) {
if (this.characterRegex.test(s)) {
var a, eq = this.characterEquivalents;
for (a in eq) {
if (typeof a === 'string') {
s = s.replace( this.characterRegexArray[a], a );
}
}
}
return s;
};
this.clearTableBody = function(table) {
$(table.tBodies).filter(':not(.' + table.config.cssInfoBlock + ')').empty(); $(table.tBodies).filter(':not(.' + table.config.cssInfoBlock + ')').empty();
}; };
} }
})(); })();
@ -839,8 +886,10 @@
is: function(s) { is: function(s) {
return true; return true;
}, },
format: function(s) { format: function(s, table) {
return $.trim(s.toLocaleLowerCase()); var c = table.config;
s = $.trim( c.ignoreCase ? s.toLocaleLowerCase() : s );
return c.sortLocaleCompare ? $.tablesorter.replaceAccents(s) : s;
}, },
type: "text" type: "text"
}); });
@ -859,7 +908,7 @@
ts.addParser({ ts.addParser({
id: "currency", id: "currency",
is: function(s) { is: function(s) {
return (/^\(?[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]/).test(s); // £$€¤¥¢?. return (/^\(?[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]/).test(s); // #$ $%"?.
}, },
format: function(s) { format: function(s) {
return $.tablesorter.formatFloat(s.replace(/[^0-9,. \-()]/g, "")); return $.tablesorter.formatFloat(s.replace(/[^0-9,. \-()]/g, ""));

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/*! tableSorter 2.1 widgets - updated 4/23/2012 /*! tableSorter 2.2 widgets - updated 5/3/2012
* *
* jQuery UI Theme * jQuery UI Theme
* Column Styles * Column Styles
@ -8,7 +8,7 @@
* Save Sort * Save Sort
* *
*/ */
(function($){ ;(function($){
// *** Store data in local storage, with a cookie fallback *** // *** Store data in local storage, with a cookie fallback ***
/* IE7 needs JSON library for JSON.stringify - (http://caniuse.com/#search=json) /* IE7 needs JSON library for JSON.stringify - (http://caniuse.com/#search=json)
@ -125,7 +125,7 @@ $.tablesorter.addWidget({
$.tablesorter.addWidget({ $.tablesorter.addWidget({
id: "columns", id: "columns",
format: function(table) { format: function(table) {
var $tr, $td, time, i, last, rmv, k, var $tr, $td, time, last, rmv, k,
c = table.config, c = table.config,
b = table.tBodies, b = table.tBodies,
list = c.sortList, list = c.sortList,
@ -144,7 +144,7 @@ $.tablesorter.addWidget({
for (k = 0; k < b.length; k++ ) { for (k = 0; k < b.length; k++ ) {
// loop through the visible rows // loop through the visible rows
$tr = $(b[k]).filter(':not(' + c.cssInfoBlock + ')').find('tr:visible:not(.' + c.cssInfoBlock + ')'); $tr = $(b[k]).filter(':not(' + c.cssInfoBlock + ')').find('tr:visible:not(.' + c.cssInfoBlock + ')');
$tr.each(function (i) { $tr.each(function(i) {
$td = $(this).children().removeClass(rmv); $td = $(this).children().removeClass(rmv);
// primary sort column class // primary sort column class
$td.eq(list[0][0]).addClass(css[0]); $td.eq(list[0][0]).addClass(css[0]);

View File

@ -1,10 +1,10 @@
/*! tableSorter 2.1 widgets - updated 4/23/2012 */ /*! tableSorter 2.1 widgets - updated 5/3/2012 */
(function(b){ ;(function(b){
b.tablesorter.storage=function(a,e,d){var c,g=!1;c={};var i=a.id||b(".tablesorter").index(b(a)),f=window.location.pathname;try{g=!!localStorage.getItem}catch(j){}b.parseJSON&&(g?c=b.parseJSON(localStorage[e])||{}:(c=document.cookie.split(/[;\s|=]/),a=b.inArray(e,c)+1,c=0!==a?b.parseJSON(c[a])||{}:{}));if(d&&JSON&&JSON.hasOwnProperty("stringify")){if(!c[f]||!c[f][i])c[f]||(c[f]={});c[f][i]=d;g?localStorage[e]=JSON.stringify(c):(a=new Date,a.setTime(a.getTime()+31536E6),document.cookie= e+"="+JSON.stringify(c).replace(/\"/g,'"')+"; expires="+a.toGMTString()+"; path=/")}else return c&&c.hasOwnProperty(f)&&c[f].hasOwnProperty(i)?c[f][i]:{}}; b.tablesorter.storage=function(a,f,d){var c,g=!1;c={};var i=a.id||b(".tablesorter").index(b(a)),e=window.location.pathname;try{g=!!localStorage.getItem}catch(h){}b.parseJSON&&(g?c=b.parseJSON(localStorage[f])||{}:(c=document.cookie.split(/[;\s|=]/),a=b.inArray(f,c)+1,c=0!==a?b.parseJSON(c[a])||{}:{}));if(d&&JSON&&JSON.hasOwnProperty("stringify")){if(!c[e]||!c[e][i])c[e]||(c[e]={});c[e][i]=d;g?localStorage[f]=JSON.stringify(c):(a=new Date,a.setTime(a.getTime()+31536E6),document.cookie= f+"="+JSON.stringify(c).replace(/\"/g,'"')+"; expires="+a.toGMTString()+"; path=/")}else return c&&c.hasOwnProperty(e)&&c[e].hasOwnProperty(i)?c[e][i]:{}};
b.tablesorter.addWidget({id:"uitheme",format:function(a){var e,d,c,g,i,f=b(a),j=a.config,h=j.widgetOptions,k=["ui-icon-arrowthick-2-n-s","ui-icon-arrowthick-1-s","ui-icon-arrowthick-1-n"],k=j.widgetUitheme&&j.widgetUitheme.hasOwnProperty("css")?j.widgetUitheme.css||k:h&&h.hasOwnProperty("uitheme")?h.uitheme:k;c=k.join(" ");j.debug&&(e=new Date); f.hasClass("ui-theme")||(f.addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),b.each(j.headerList,function(){b(this).addClass("ui-widget-header ui-corner-all ui-state-default").append('<span class="ui-icon"/>').wrapInner('<div class="tablesorter-inner"/>').hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")})}));b.each(j.headerList,function(a){g=b(this);if(this.sortDisabled)g.find("span.ui-icon").removeClass(c+" ui-icon");else{d=g.hasClass(j.cssAsc)? k[1]:g.hasClass(j.cssDesc)?k[2]:g.hasClass(j.cssHeader)?k[0]:"";i=f.hasClass("hasStickyHeaders")?f.find("tr."+(h.stickyHeaders||"tablesorter-stickyHeader")).find("th").eq(a).add(g):g;i[d===k[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(c).addClass(d)}});j.debug&&b.tablesorter.benchmark("Applying uitheme widget",e)}}); b.tablesorter.addWidget({id:"uitheme",format:function(a){var f,d,c,g,i,e=b(a),h=a.config,j=h.widgetOptions,k=["ui-icon-arrowthick-2-n-s","ui-icon-arrowthick-1-s","ui-icon-arrowthick-1-n"],k=h.widgetUitheme&&h.widgetUitheme.hasOwnProperty("css")?h.widgetUitheme.css||k:j&&j.hasOwnProperty("uitheme")?j.uitheme:k;c=k.join(" ");h.debug&&(f=new Date); e.hasClass("ui-theme")||(e.addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),b.each(h.headerList,function(){b(this).addClass("ui-widget-header ui-corner-all ui-state-default").append('<span class="ui-icon"/>').wrapInner('<div class="tablesorter-inner"/>').hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")})}));b.each(h.headerList,function(a){g=b(this);if(this.sortDisabled)g.find("span.ui-icon").removeClass(c+" ui-icon");else{d=g.hasClass(h.cssAsc)? k[1]:g.hasClass(h.cssDesc)?k[2]:g.hasClass(h.cssHeader)?k[0]:"";i=e.hasClass("hasStickyHeaders")?e.find("tr."+(j.stickyHeaders||"tablesorter-stickyHeader")).find("th").eq(a).add(g):g;i[d===k[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(c).addClass(d)}});h.debug&&b.tablesorter.benchmark("Applying uitheme widget",f)}});
b.tablesorter.addWidget({id:"columns",format:function(a){var e,d,c,g,i=a.config,f=i.sortList,j=f.length,h=["primary","secondary","tertiary"],h=i.widgetColumns&& i.widgetColumns.hasOwnProperty("css")?i.widgetColumns.css||h:i.widgetOptions&&i.widgetOptions.hasOwnProperty("columns")?i.widgetOptions.columns||h:h;c=h.length-1;g=h.join(" ");i.debug&&(d=new Date);f&&f[0]?b("tr:visible",a.tBodies[0]).each(function(a){e=b(this).children().removeClass(g);e.eq(f[0][0]).addClass(h[0]);if(1<j)for(a=1;a<j;a++)e.eq(f[a][0]).addClass(h[a]||h[c])}):b("td",a.tBodies[0]).removeClass(g);i.debug&&b.tablesorter.benchmark("Applying Columns widget",d)}}); b.tablesorter.addWidget({id:"columns",format:function(a){var f,d,c,g,i,e=a.config,h=a.tBodies,j=e.sortList,k=j.length,l=["primary","secondary","tertiary"], l=e.widgetColumns&&e.widgetColumns.hasOwnProperty("css")?e.widgetColumns.css||l:e.widgetOptions&&e.widgetOptions.hasOwnProperty("columns")?e.widgetOptions.columns||l:l;c=l.length-1;g=l.join(" ");e.debug&&(d=new Date);if(j&&j[0])for(i=0;i<h.length;i++)a=b(h[i]).filter(":not("+e.cssInfoBlock+")").find("tr:visible:not(."+e.cssInfoBlock+")"),a.each(function(a){f=b(this).children().removeClass(g);f.eq(j[0][0]).addClass(l[0]);if(1<k)for(a=1;a<k;a++)f.eq(j[a][0]).addClass(l[a]||l[c])});else b("td",a).removeClass(g); e.debug&&b.tablesorter.benchmark("Applying Columns widget",d)}});
b.tablesorter.addWidget({id:"filter", format:function(a){if(!b(a).hasClass("hasFilters")){var e,d,c,g,i,f,j,h=a.config,k=h.widgetOptions,l=k.filter_cssFilter||"tablesorter-filter",m=b(a).addClass("hasFilters"),n=m.find("tbody tr:first td").length,a='<tr class="'+l+'">',o;h.debug&&(o=new Date);for(e=0;e<n;e++)a+='<td><input type="search" data-col="'+e+'" class="'+l,a+=h.headers[e]&&h.headers[e].hasOwnProperty("filter")&&!1===h.headers[e].filter||b(h.headerList[e]).is(".filter-false")?' disabled" disabled':'"',a+="></td>";m.find("thead").append(a+= "</tr>").find("input."+l).bind("keyup search",function(){d=m.find("thead").find("input."+l).map(function(){return(b(this).val()||"").toLowerCase()}).get();""===d.join("")?m.find("tr").show():m.find("tbody").find("tr:not(."+h.cssChildRow+")").each(function(){c=!0;f=b(this).nextUntil("tr:not(."+h.cssChildRow+")");g=f.length&&(k&&k.hasOwnProperty("filter_childRows")&&"undefined"!==typeof k.filter_childRows?k.filter_childRows:1)?f.text():"";j=b(this).find("td");for(e=0;e<n;e++)i=b.trim(j.eq(e).text()+ g).toLowerCase().indexOf(d[e]),""!==d[e]&&(!k.filter_startsWith&&0<=i||k.filter_startsWith&&0===i)?c=c?!0:!1:""!==d[e]&&(c=!1);b(this)[c?"show":"hide"]();if(f.length)f[c?"show":"hide"]()});m.trigger("applyWidgets")});h.debug&&b.tablesorter.benchmark("Applying Filter widget",o)}}}); b.tablesorter.addWidget({id:"filter",format:function(a){if(!b(a).hasClass("hasFilters")){var f,d,c,g,i,e,h,j=a.config,k=j.widgetOptions,l=k.filter_cssFilter||"tablesorter-filter",m=b(a).addClass("hasFilters"),n=m.find("tbody tr:first td").length,a='<tr class="'+l+'">',o;j.debug&&(o=new Date);for(f=0;f<n;f++)a+='<td><input type="search" data-col="'+f+'" class="'+l,a+=j.headers[f]&&j.headers[f].hasOwnProperty("filter")&&!1===j.headers[f].filter|| b(j.headerList[f]).is(".filter-false")?' disabled" disabled':'"',a+="></td>";m.find("thead").append(a+="</tr>").find("input."+l).bind("keyup search",function(){d=m.find("thead").find("input."+l).map(function(){return(b(this).val()||"").toLowerCase()}).get();""===d.join("")?m.find("tr").show():m.find("tbody").find("tr:not(."+j.cssChildRow+"):not(."+j.cssInfoBlock+")").each(function(){c=!0;e=b(this).nextUntil("tr:not(."+j.cssChildRow+")");g=e.length&&(k&&k.hasOwnProperty("filter_childRows")&&"undefined"!== typeof k.filter_childRows?k.filter_childRows:1)?e.text():"";h=b(this).find("td");for(f=0;f<n;f++)i=b.trim(h.eq(f).text()+g).toLowerCase().indexOf(d[f]),""!==d[f]&&(!k.filter_startsWith&&0<=i||k.filter_startsWith&&0===i)?c=c?!0:!1:""!==d[f]&&(c=!1);b(this)[c?"show":"hide"]();if(e.length)e[c?"show":"hide"]()});m.trigger("applyWidgets")});j.debug&&b.tablesorter.benchmark("Applying Filter widget",o)}}});
b.tablesorter.addWidget({id:"stickyHeaders",format:function(a){if(!b(a).hasClass("hasStickyHeaders")){var e=b(a).addClass("hasStickyHeaders"),d=a.config.widgetOptions,c=b(window),g=b(a).find("thead"),i=g.find("tr:not(.sticky-false)").children(), f=d.stickyHeaders||"tablesorter-stickyHeader",j=i.eq(0),h=g.find("tr.tablesorter-header:not(.sticky-false)").clone().removeClass("tablesorter-header").addClass(f).css({width:g.outerWidth(!0),position:"fixed",left:j.offset().left,margin:0,top:0,visibility:"hidden",zIndex:10}),k=h.children(),l="";e.bind("sortEnd",function(a,c){var d=b(c).find("thead tr"),e=d.filter("."+f).children();d.filter(":not(."+f+")").children().each(function(a){e.eq(a).attr("class",b(this).attr("class"))})}).bind("pagerComplete", function(){c.resize()});i.each(function(a){var c=b(this);k.eq(a).bind("click",function(b){c.trigger(b)}).bind("mousedown",function(){this.onselectstart=function(){return!1};return!1}).find(".tablesorter-header-inner").width(c.find(".tablesorter-header-inner").width())});g.prepend(h);c.scroll(function(){var b=j.offset(),a=c.scrollTop(),a=a>b.top&&a<b.top+e.find("tbody").height()?"visible":"hidden";h.css({left:b.left-c.scrollLeft(),visibility:a});a!==l&&(c.resize(),l=a)}).resize(function(){var a=0; h.css({left:j.offset().left-c.scrollLeft(),width:g.outerWidth()}).each(function(c){b(this).css("top",a);a+=g.find("tr").eq(c).outerHeight()});k.find(".tablesorter-header-inner").each(function(a){b(this).width(i.eq(a).find(".tablesorter-header-inner").width())})})}}}); b.tablesorter.addWidget({id:"stickyHeaders",format:function(a){if(!b(a).hasClass("hasStickyHeaders")){var f= b(a).addClass("hasStickyHeaders"),d=a.config.widgetOptions,c=b(window),g=b(a).find("thead"),i=g.find("tr:not(.sticky-false)").children(),e=d.stickyHeaders||"tablesorter-stickyHeader",h=i.eq(0),j=f.find("tfoot"),k=g.find("tr.tablesorter-header:not(.sticky-false)").clone().removeClass("tablesorter-header").addClass(e).css({width:g.outerWidth(!0),position:"fixed",left:h.offset().left,margin:0,top:0,visibility:"hidden",zIndex:10}),l=k.children(),m="";f.bind("sortEnd",function(a,c){var d=b(c).find("thead tr"), f=d.filter("."+e).children();d.filter(":not(."+e+")").children().each(function(a){f.eq(a).attr("class",b(this).attr("class"))})}).bind("pagerComplete",function(){c.resize()});i.each(function(a){var c=b(this);l.eq(a).bind("click",function(a){c.trigger(a)}).bind("mousedown",function(){this.onselectstart=function(){return!1};return!1}).find(".tablesorter-header-inner").width(c.find(".tablesorter-header-inner").width())});g.prepend(k);c.scroll(function(){var a=h.offset(),b=c.scrollTop(),d=f.height()- (h.height()+(j.height()||0)),b=b>a.top&&b<a.top+d?"visible":"hidden";k.css({left:a.left-c.scrollLeft(),visibility:b});b!==m&&(c.resize(),m=b)}).resize(function(){var a=0;k.css({left:h.offset().left-c.scrollLeft(),width:g.outerWidth()}).each(function(c){b(this).css("top",a);a+=g.find("tr").eq(c).outerHeight()});l.find(".tablesorter-header-inner").each(function(a){b(this).width(i.eq(a).find(".tablesorter-header-inner").width())})})}}});
b.tablesorter.addWidget({id:"resizable",format:function(a){if(!b(a).hasClass("hasResizable")){b(a).addClass("hasResizable");var e,d,c=a.config,g=b(c.headerList).filter(":gt(0)"),i=0,f=null,j=null,h=function(){i=0;f=j=null;b(window).trigger("resize")}; if(d=b.tablesorter.storage?b.tablesorter.storage(a,"tablesorter-resizable"):"")for(e in d)!isNaN(e)&&e<c.headerList.length&&b(c.headerList[e]).width(d[e]);g.each(function(){b(this).append('<div class="tablesorter-resizer" style="cursor:w-resize;position:absolute;height:100%;width:20px;left:-20px;top:0;z-index:1;"></div>').wrapInner('<div style="position:relative;height:100%;width:100%"></div>')}).bind("mousemove",function(a){if(0!==i&&f){var b=a.pageX-i;f.width()<-b||j&&j.width()<=b||(j.width(j.width()+ b),i=a.pageX)}}).bind("mouseup",function(){d&&b.tablesorter.storage&&f&&(d[j.index()]=j.width(),b.tablesorter.storage(a,"tablesorter-resizable",d));h();return!1}).find(".tablesorter-resizer").bind("mousedown",function(a){f=b(a.target).closest("th");j=f.prev();i=a.pageX});b(a).find("thead").bind("mouseup mouseleave",function(){h()})}}}); b.tablesorter.addWidget({id:"resizable",format:function(a){if(!b(a).hasClass("hasResizable")){b(a).addClass("hasResizable"); var f,d,c=a.config,g=b(c.headerList).filter(":gt(0)"),i=0,e=null,h=null,j=function(){i=0;e=h=null;b(window).trigger("resize")};if(d=b.tablesorter.storage?b.tablesorter.storage(a,"tablesorter-resizable"):"")for(f in d)!isNaN(f)&&f<c.headerList.length&&b(c.headerList[f]).width(d[f]);g.each(function(){b(this).append('<div class="tablesorter-resizer" style="cursor:w-resize;position:absolute;height:100%;width:20px;left:-20px;top:0;z-index:1;"></div>').wrapInner('<div style="position:relative;height:100%;width:100%"></div>')}).bind("mousemove", function(a){if(0!==i&&e){var b=a.pageX-i;e.width()<-b||h&&h.width()<=b||(h.width(h.width()+b),i=a.pageX)}}).bind("mouseup",function(){d&&(b.tablesorter.storage&&e)&&(d[h.index()]=h.width(),b.tablesorter.storage(a,"tablesorter-resizable",d));j();return!1}).find(".tablesorter-resizer").bind("mousedown",function(a){e=b(a.target).closest("th");h=e.prev();i=a.pageX});b(a).find("thead").bind("mouseup mouseleave",function(){j()})}}});
b.tablesorter.addWidget({id:"saveSort",init:function(a,b,d){d.format(a,!0)},format:function(a,e){var d,c,g=a.config;d={sortList:g.sortList};g.debug&&(c=new Date);b(a).hasClass("hasSaveSort")? a.hasInitialized&&b.tablesorter.storage&&(b.tablesorter.storage(a,"tablesorter-savesort",d),g.debug&&b.tablesorter.benchmark("saveSort widget: Saving last sort: "+g.sortList,c)):(b(a).addClass("hasSaveSort"),d="",b.tablesorter.storage&&(d=(d=b.tablesorter.storage(a,"tablesorter-savesort"))&&d.hasOwnProperty("sortList")&&b.isArray(d.sortList)?d.sortList:"",g.debug&&b.tablesorter.benchmark("saveSort: Last sort loaded: "+d,c)),e&&d&&0<d.length?g.sortList=d:a.hasInitialized&&d&&0<d.length&&b(a).trigger("sorton",[d]))}}) b.tablesorter.addWidget({id:"saveSort",init:function(a,b,d){d.format(a, !0)},format:function(a,f){var d,c,g=a.config;d={sortList:g.sortList};g.debug&&(c=new Date);b(a).hasClass("hasSaveSort")?a.hasInitialized&&b.tablesorter.storage&&(b.tablesorter.storage(a,"tablesorter-savesort",d),g.debug&&b.tablesorter.benchmark("saveSort widget: Saving last sort: "+g.sortList,c)):(b(a).addClass("hasSaveSort"),d="",b.tablesorter.storage&&(d=(d=b.tablesorter.storage(a,"tablesorter-savesort"))&&d.hasOwnProperty("sortList")&&b.isArray(d.sortList)?d.sortList:"",g.debug&&b.tablesorter.benchmark("saveSort: Last sort loaded: "+ d,c)),f&&d&&0<d.length?g.sortList=d:a.hasInitialized&&(d&&0<d.length)&&b(a).trigger("sorton",[d]))}})
})(jQuery); })(jQuery);

View File

@ -1,6 +1,6 @@
{ {
"name": "tablesorter", "name": "tablesorter",
"version": "2.1.20", "version": "2.2",
"title": "tablesorter", "title": "tablesorter",
"author": { "author": {
"name": "Christian Bach", "name": "Christian Bach",