jquery-tablesorter 1.10.1 → 1.10.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/{README.markdown → README.md} +8 -3
  3. data/Rakefile +39 -35
  4. data/lib/jquery-tablesorter/version.rb +1 -1
  5. data/lib/jquery-tablesorter.rb +1 -1
  6. data/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js +66 -29
  7. data/vendor/assets/javascripts/jquery-tablesorter/extras/jquery.quicksearch.js +191 -0
  8. data/vendor/assets/javascripts/jquery-tablesorter/extras/semver-mod.js +1026 -0
  9. data/vendor/assets/javascripts/jquery-tablesorter/extras/semver.js +1011 -0
  10. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js +156 -99
  11. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets-filter-formatter.js +22 -22
  12. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.js +68 -42
  13. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-iso8601.js +34 -0
  14. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-month.js +33 -0
  15. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-two-digit-year.js +74 -0
  16. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-weekday.js +33 -0
  17. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date.js +36 -0
  18. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-feet-inch-fraction.js +63 -0
  19. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-file-type.js +73 -0
  20. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-ignore-articles.js +47 -0
  21. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-input-select.js +87 -0
  22. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-ipv6.js +76 -0
  23. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-metric.js +77 -0
  24. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-alignChar.js +145 -0
  25. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-build-table.js +441 -0
  26. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-columnSelector.js +306 -0
  27. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-cssStickyHeaders.js +67 -0
  28. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-editable.js +89 -0
  29. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-grouping.js +249 -0
  30. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-headerTitles.js +91 -0
  31. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-pager.js +864 -0
  32. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-repeatheaders.js +50 -0
  33. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-scroller.js +241 -0
  34. data/vendor/assets/stylesheets/jquery-tablesorter/theme.black-ice.css +4 -0
  35. data/vendor/assets/stylesheets/jquery-tablesorter/theme.blue.css +4 -0
  36. data/vendor/assets/stylesheets/jquery-tablesorter/theme.bootstrap.css +14 -5
  37. data/vendor/assets/stylesheets/jquery-tablesorter/theme.bootstrap_2.css +4 -0
  38. data/vendor/assets/stylesheets/jquery-tablesorter/theme.dark.css +4 -0
  39. data/vendor/assets/stylesheets/jquery-tablesorter/theme.default.css +4 -0
  40. data/vendor/assets/stylesheets/jquery-tablesorter/theme.dropbox.css +4 -0
  41. data/vendor/assets/stylesheets/jquery-tablesorter/theme.green.css +4 -0
  42. data/vendor/assets/stylesheets/jquery-tablesorter/theme.grey.css +4 -0
  43. data/vendor/assets/stylesheets/jquery-tablesorter/theme.ice.css +4 -0
  44. data/vendor/assets/stylesheets/jquery-tablesorter/theme.jui.css +9 -3
  45. metadata +28 -12
  46. data/vendor/assets/images/jquery-tablesorter/dropbox-asc1.png +0 -0
  47. data/vendor/assets/images/jquery-tablesorter/dropbox-asc2.png +0 -0
  48. data/vendor/assets/images/jquery-tablesorter/dropbox-desc1.png +0 -0
  49. data/vendor/assets/images/jquery-tablesorter/dropbox-desc2.png +0 -0
  50. data/vendor/assets/images/jquery-tablesorter/green-asc.png +0 -0
  51. data/vendor/assets/images/jquery-tablesorter/green-desc.png +0 -0
  52. data/vendor/assets/images/jquery-tablesorter/green-header.png +0 -0
  53. data/vendor/assets/images/jquery-tablesorter/green-unsorted.png +0 -0
@@ -0,0 +1,63 @@
1
+ /*! Distance parser
2
+ * This parser will parser numbers like 5'10" (5 foot 10 inches)
3
+ * and 31½ into sortable values.
4
+ * Demo: http://jsfiddle.net/Mottie/abkNM/154/
5
+ */
6
+ /*global jQuery: false */
7
+ ;(function($){
8
+ "use strict";
9
+
10
+ var ts = $.tablesorter;
11
+ ts.symbolRegex = /[\u215b\u215c\u215d\u215e\u00bc\u00bd\u00be]/g;
12
+ ts.processFractions = function(n, table) {
13
+ if (n) {
14
+ var t, p = 0;
15
+ n = $.trim(n.replace(/\"/,''));
16
+ // look for a space in the first part of the number: "10 3/4" and save the "10"
17
+ if (/\s/.test(n)) {
18
+ p = ts.formatFloat(n.split(' ')[0], table);
19
+ // remove stuff to the left of the space
20
+ n = $.trim(n.substring(n.indexOf(' '), n.length));
21
+ }
22
+ // look for a "/" to calculate fractions
23
+ if (/\//g.test(n)) {
24
+ t = n.split('/');
25
+ // turn 3/4 into .75; make sure we don't divide by zero
26
+ n = p + parseInt(t[0], 10) / parseInt(t[1] || 1, 10);
27
+ // look for fraction symbols
28
+ } else if (ts.symbolRegex.test(n)) {
29
+ n = p + n.replace(ts.symbolRegex, function(m){
30
+ return {
31
+ '\u215b' : '.125', // 1/8
32
+ '\u215c' : '.375', // 3/8
33
+ '\u215d' : '.625', // 5/8
34
+ '\u215e' : '.875', // 7/8
35
+ '\u00bc' : '.25', // 1/4
36
+ '\u00bd' : '.5', // 1/2
37
+ '\u00be' : '.75' // 3/4
38
+ }[m];
39
+ });
40
+ }
41
+ }
42
+ return n || 0;
43
+ };
44
+
45
+ $.tablesorter.addParser({
46
+ id: 'distance',
47
+ is: function() {
48
+ // return false so this parser is not auto detected
49
+ return false;
50
+ },
51
+ format: function(s, table) {
52
+ if (s === '') { return ''; }
53
+ // look for feet symbol = '
54
+ // very generic test to catch 1.1', 1 1/2' and 1½'
55
+ var d = (/^\s*\S*(\s+\S+)?\s*\'/.test(s)) ? s.split("'") : [0,s],
56
+ f = ts.processFractions(d[0], table), // feet
57
+ i = ts.processFractions(d[1], table); // inches
58
+ return (/[\'\"]/).test(s) ? parseFloat(f) + (parseFloat(i)/12 || 0) : parseFloat(f) + parseFloat(i);
59
+ },
60
+ type: 'numeric'
61
+ });
62
+
63
+ })(jQuery);
@@ -0,0 +1,73 @@
1
+ /*! File Type parser
2
+ * When a file type extension is found, the equivalent name is
3
+ * prefixed into the parsed data, so sorting occurs in groups
4
+ */
5
+ /*global jQuery: false */
6
+ ;(function($){
7
+ "use strict";
8
+
9
+ // basic list from http://en.wikipedia.org/wiki/List_of_file_formats
10
+ // To add a custom equivalent, define:
11
+ // $.tablesorter.fileTypes.equivalents['xx'] = "A|B|C";
12
+ $.tablesorter.fileTypes = {
13
+ // divides filetype extensions in the equivalent list below
14
+ separator : '|',
15
+ equivalents : {
16
+ "3D Image" : "3dm|3ds|dwg|max|obj",
17
+ "Audio" : "aif|aac|ape|flac|la|m4a|mid|midi|mp2|mp3|ogg|ra|raw|rm|wav|wma",
18
+ "Compressed" : "7z|bin|cab|cbr|gz|gzip|iso|lha|lz|rar|tar|tgz|zip|zipx|zoo",
19
+ "Database" : "csv|dat|db|dbf|json|ldb|mdb|myd|pdb|sql|tsv|wdb|wmdb|xlr|xls|xlsx|xml",
20
+ "Development" : "asm|c|class|cls|cpp|cc|cs|cxx|cbp|cs|dba|fla|h|java|lua|pl|py|pyc|pyo|sh|sln|r|rb|vb",
21
+ "Document" : "doc|docx|odt|ott|pages|pdf|rtf|tex|wpd|wps|wrd|wri",
22
+ "Executable" : "apk|app|com|exe|gadget|lnk|msi",
23
+ "Fonts" : "eot|fnt|fon|otf|ttf|woff",
24
+ "Icons" : "ani|cur|icns|ico",
25
+ "Images" : "bmp|gif|jpg|jpeg|jpe|jp2|pic|png|psd|tga|tif|tiff|wmf|webp",
26
+ "Presentation" : "pps|ppt",
27
+ "Published" : "chp|epub|lit|pub|ppp|fm|mobi",
28
+ "Script" : "as|bat|cgi|cmd|jar|js|lua|scpt|scptd|sh|vbs|vb|wsf",
29
+ "Styles" : "css|less|sass",
30
+ "Text" : "info|log|md|markdown|nfo|tex|text|txt",
31
+ "Vectors" : "awg|ai|eps|cdr|ps|svg",
32
+ "Video" : "asf|avi|flv|m4v|mkv|mov|mp4|mpe|mpeg|mpg|ogg|rm|rv|swf|vob|wmv",
33
+ "Web" : "asp|aspx|cer|cfm|htm|html|php|url|xhtml"
34
+ }
35
+ };
36
+
37
+ $.tablesorter.addParser({
38
+ id: 'filetype',
39
+ is: function() {
40
+ return false;
41
+ },
42
+ format: function(s, table) {
43
+ var t,
44
+ c = table.config,
45
+ wo = c.widgetOptions,
46
+ i = s.lastIndexOf('.'),
47
+ sep = $.tablesorter.fileTypes.separator,
48
+ m = $.tablesorter.fileTypes.matching,
49
+ types = $.tablesorter.fileTypes.equivalents;
50
+ if (!m) {
51
+ // make a string to "quick" match the existing equivalents
52
+ var t = [];
53
+ $.each(types, function(i,v){
54
+ t.push(v);
55
+ });
56
+ m = $.tablesorter.fileTypes.matching = sep + t.join(sep) + sep;
57
+ }
58
+ if (i >= 0) {
59
+ t = sep + s.substring(i + 1, s.length) + sep;
60
+ if (m.indexOf(t) >= 0) {
61
+ for (i in types) {
62
+ if ((sep + types[i] + sep).indexOf(t) >= 0) {
63
+ return i + (wo.group_separator ? wo.group_separator : '-') + s;
64
+ }
65
+ }
66
+ }
67
+ }
68
+ return s;
69
+ },
70
+ type: 'text'
71
+ });
72
+
73
+ })(jQuery);
@@ -0,0 +1,47 @@
1
+ /*! Title parser
2
+ * This parser will remove "The", "A" and "An" from the beginning of a book
3
+ * or movie title, so it sorts by the second word or number
4
+ * Demo: http://jsfiddle.net/Mottie/abkNM/5/
5
+ */
6
+ /*global jQuery: false */
7
+ ;(function($){
8
+ "use strict";
9
+
10
+ // basic list from http://en.wikipedia.org/wiki/Article_%28grammar%29
11
+ $.tablesorter.ignoreArticles = {
12
+ "en" : "the, a, an",
13
+ "de" : "der, die, das, des, dem, den, ein, eine, einer, eines, einem, einen",
14
+ "nl" : "de, het, de, een",
15
+ "es" : "el, la, lo, los, las, un, una, unos, unas",
16
+ "pt" : "o, a, os, as, um, uma, uns, umas",
17
+ "fr" : "le, la, l'_, les, un, une, des",
18
+ "it" : "il, lo, la, l'_, i, gli, le, un', uno, una, un",
19
+ "hu" : "a, az, egy"
20
+ };
21
+
22
+ // To add a custom parser, define:
23
+ // $.tablesorter.ignoreArticles['xx'] = "A, B, C";
24
+ // and then set the language id 'xx' in the headers option
25
+ // ignoreArticles : 'xx'
26
+
27
+ $.tablesorter.addParser({
28
+ id: 'ignoreArticles',
29
+ is: function() {
30
+ return false;
31
+ },
32
+ format: function(s, table, cell, cellIndex) {
33
+ var c = table.config, art, lang;
34
+ if ( !(c.headers && c.headers[cellIndex] && c.headers[cellIndex].ignoreArticlesRegex) ) {
35
+ // initialize - save regex in c.headers[cellIndex].ignoreArticles
36
+ if (!c.headers) { c.headers = {}; }
37
+ if (!c.headers[cellIndex]) { c.headers[cellIndex] = {}; }
38
+ lang = $.tablesorter.getData(c.$headers.eq(cellIndex), c.headers[cellIndex], 'ignoreArticles');
39
+ art = ($.tablesorter.ignoreArticles[lang] || "the, a, an" ) + "";
40
+ c.headers[cellIndex].ignoreArticlesRegex = new RegExp('^(' + $.trim( art.split(/\s*\,\s*/).join('\\s|') + "\\s" ).replace("_\\s","") + ')', 'i');
41
+ }
42
+ return (s || '').replace(c.headers[cellIndex].ignoreArticlesRegex, '');
43
+ },
44
+ type: 'text'
45
+ });
46
+
47
+ })(jQuery);
@@ -0,0 +1,87 @@
1
+ /*! input & select parsers for jQuery 1.7+ & tablesorter 2.7.11+
2
+ * Updated 2/19/2014 (v2.15.0)
3
+ * Demo: http://mottie.github.com/tablesorter/docs/example-widget-grouping.html
4
+ */
5
+ /*jshint browser: true, jquery:true, unused:false */
6
+ ;(function($){
7
+ "use strict";
8
+
9
+ var resort = true, // resort table after update
10
+ updateServer = function(event, $table, $input){
11
+ // do something here to update your server, if needed
12
+ // event = change event object
13
+ // $table = jQuery object of the table that was just updated
14
+ // $input = jQuery object of the input or select that was modified
15
+ };
16
+
17
+ // Custom parser for parsing input values
18
+ // updated dynamically using the "change" function below
19
+ $.tablesorter.addParser({
20
+ id: "inputs",
21
+ is: function(){
22
+ return false;
23
+ },
24
+ format: function(s, table, cell) {
25
+ return $(cell).find('input').val() || s;
26
+ },
27
+ parsed : true, // filter widget flag
28
+ type: "text"
29
+ });
30
+
31
+ // Custom parser for including checkbox status if using the grouping widget
32
+ // updated dynamically using the "change" function below
33
+ $.tablesorter.addParser({
34
+ id: "checkbox",
35
+ is: function(){
36
+ return false;
37
+ },
38
+ format: function(s, table, cell, cellIndex) {
39
+ var $c = $(cell),
40
+ $input = $c.find('input[type="checkbox"]'),
41
+ isChecked = $input.length ? $input[0].checked : '';
42
+ // adding class to row, indicating that a checkbox is checked; includes
43
+ // a column index in case more than one checkbox happens to be in a row
44
+ $c.closest('tr').toggleClass('checked-' + cellIndex, isChecked);
45
+ // returning plain language here because this is what is shown in the
46
+ // group headers - change it as desired
47
+ return $input.length ? isChecked ? 'checked' : 'unchecked' : s;
48
+ },
49
+ parsed : true, // filter widget flag
50
+ type: "text"
51
+ });
52
+
53
+ // Custom parser which returns the currently selected options
54
+ // updated dynamically using the "change" function below
55
+ $.tablesorter.addParser({
56
+ id: "select",
57
+ is: function(){
58
+ return false;
59
+ },
60
+ format: function(s, table, cell) {
61
+ return $(cell).find('select').val() || s;
62
+ },
63
+ parsed : true, // filter widget flag
64
+ type: "text"
65
+ });
66
+
67
+ // update select and all input types in the tablesorter cache when the change event fires.
68
+ // This method only works with jQuery 1.7+
69
+ // you can change it to use delegate (v1.4.3+) or live (v1.3+) as desired
70
+ // if this code interferes somehow, target the specific table $('#mytable'), instead of $('table')
71
+ $(window).load(function(){
72
+ // this flag prevents the updateCell event from being spammed
73
+ // it happens when you modify input text and hit enter
74
+ var alreadyUpdating = false;
75
+ $('table').find('tbody').on('change', 'select, input', function(e){
76
+ if (!alreadyUpdating) {
77
+ var $tar = $(e.target),
78
+ $table = $tar.closest('table');
79
+ alreadyUpdating = true;
80
+ $table.trigger('updateCell', [ $tar.closest('td'), resort ]);
81
+ updateServer(e, $table, $tar);
82
+ setTimeout(function(){ alreadyUpdating = false; }, 10);
83
+ }
84
+ });
85
+ });
86
+
87
+ })(jQuery);
@@ -0,0 +1,76 @@
1
+ /*! IPv6 Address parser (WIP)
2
+ * IPv6 Address (ffff:0000:0000:0000:0000:0000:0000:0000)
3
+ * needs to support short versions like "::8" or "1:2::7:8"
4
+ * and "::00:192.168.10.184" (embedded IPv4 address)
5
+ * see http://www.intermapper.com/support/tools/IPV6-Validator.aspx
6
+ */
7
+ /*global jQuery: false */
8
+ ;(function($){
9
+ "use strict";
10
+
11
+ var ts = $.tablesorter;
12
+
13
+ $.extend( ts.regex, {}, {
14
+ ipv4Validate : /((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})/,
15
+ ipv4Extract : /([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/,
16
+
17
+ // simplified regex from http://www.intermapper.com/support/tools/IPV6-Validator.aspx
18
+ // (specifically from http://download.dartware.com/thirdparty/ipv6validator.js)
19
+ ipv6Validate : /^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/i
20
+ });
21
+
22
+ ts.addParser({
23
+ id: "ipv6Address",
24
+ is: function(s) {
25
+ return ts.regex.ipv6Validate.test(s);
26
+ },
27
+ format: function(address, table) {
28
+ // code modified from http://forrst.com/posts/JS_Expand_Abbreviated_IPv6_Addresses-1OR
29
+ var i, t, sides, groups, groupsPresent,
30
+ hex = table ? (typeof table === "boolean" ? table : table && table.config.ipv6HexFormat || false) : false,
31
+ fullAddress = '',
32
+ expandedAddress = '',
33
+ validGroupCount = 8,
34
+ validGroupSize = 4;
35
+ // remove any extra spaces
36
+ address = address.replace(/\s*/g, '');
37
+ // look for embedded ipv4
38
+ if (ts.regex.ipv4Validate.test(address)) {
39
+ groups = address.match(ts.regex.ipv4Extract);
40
+ t = '';
41
+ for (i = 1; i < groups.length; i++){
42
+ t += ('00' + (parseInt(groups[i], 10).toString(16)) ).slice(-2) + ( i === 2 ? ':' : '' );
43
+ }
44
+ address = address.replace( ts.regex.ipv4Extract, t );
45
+ }
46
+
47
+ if (address.indexOf("::") == -1) {
48
+ // All eight groups are present
49
+ fullAddress = address;
50
+ } else {
51
+ // Consecutive groups of zeroes have been collapsed with "::".
52
+ sides = address.split("::");
53
+ groupsPresent = 0;
54
+ for (i = 0; i < sides.length; i++) {
55
+ groupsPresent += sides[i].split(":").length;
56
+ }
57
+ fullAddress += sides[0] + ":";
58
+ for (i = 0; i < validGroupCount - groupsPresent; i++) {
59
+ fullAddress += "0000:";
60
+ }
61
+ fullAddress += sides[1];
62
+ }
63
+ groups = fullAddress.split(":");
64
+ for (i = 0; i < validGroupCount; i++) {
65
+ // it's fastest & easiest for tablesorter to sort decimal values (vs hex)
66
+ groups[i] = hex ? ('0000' + groups[i]).slice(-4) :
67
+ ('00000' + (parseInt(groups[i], 16) || 0)).slice(-5);
68
+ expandedAddress += ( i != validGroupCount-1) ? groups[i] + ':' : groups[i];
69
+ }
70
+ return hex ? expandedAddress : expandedAddress.replace(/:/g, '');
71
+ },
72
+ // uses natural sort hex compare
73
+ type: "numeric"
74
+ });
75
+
76
+ })(jQuery);
@@ -0,0 +1,77 @@
1
+ /*! Metric parser
2
+ * Demo: http://jsfiddle.net/Mottie/abkNM/382/
3
+ * Set the metric name in the header (defaults to "m|meter"), e.g.
4
+ * <th data-metric-name="b|byte">HDD Size</th>
5
+ * <th data-metric-name="m|meter">Distance</th>
6
+ */
7
+ /*jshint jquery:true */
8
+ ;(function($){
9
+ "use strict";
10
+
11
+ var prefixes = {
12
+ // "prefix" : [ base 10, base 2 ]
13
+ // skipping IEEE 1541 defined prefixes: kibibyte, mebibyte, etc, for now.
14
+ "Y|Yotta|yotta" : [ 1e24, Math.pow(1024, 8) ], // 1024^8
15
+ "Z|Zetta|zetta" : [ 1e21, Math.pow(1024, 7) ], // 1024^7
16
+ "E|Exa|exa" : [ 1e18, Math.pow(1024, 6) ], // 1024^6
17
+ "P|Peta|peta" : [ 1e15, Math.pow(1024, 5) ], // 1024^5
18
+ "T|Tera|tera" : [ 1e12, Math.pow(1024, 4) ], // 1024^4
19
+ "G|Giga|giga" : [ 1e9, Math.pow(1024, 3) ], // 1024^3
20
+ "M|Mega|mega" : [ 1e6, Math.pow(1024, 2) ], // 1024^2
21
+ "k|Kilo|kilo" : [ 1e3, 1024 ], // 1024
22
+ // prefixes below here are rarely, if ever, used in binary
23
+ "h|hecto" : [ 1e2, 1e2 ],
24
+ "da|deka" : [ 1e1, 1e1 ],
25
+ "d|deci" : [ 1e-1, 1e-1 ],
26
+ "c|centi" : [ 1e-2, 1e-2],
27
+ "m|milli" : [ 1e-3, 1e-3 ],
28
+ "µ|micro" : [ 1e-6, 1e-6 ],
29
+ "n|nano" : [ 1e-9, 1e-9 ],
30
+ "p|pico" : [ 1e-12, 1e-12 ],
31
+ "f|femto" : [ 1e-15, 1e-15 ],
32
+ "a|atto" : [ 1e-18, 1e-18 ],
33
+ "z|zepto" : [ 1e-21, 1e-21 ],
34
+ "y|yocto" : [ 1e-24, 1e-24 ]
35
+ },
36
+ // the \\d+ will not catch digits with spaces, commas or decimals; so use the value from n instead
37
+ RegLong = "(\\d+)(\\s+)?([Zz]etta|[Ee]xa|[Pp]eta|[Tt]era|[Gg]iga|[Mm]ega|kilo|hecto|deka|deci|centi|milli|micro|nano|pico|femto|atto|zepto|yocto)(",
38
+ RegAbbr = "(\\d+)(\\s+)?(Z|E|P|T|G|M|k|h|da|d|c|m|µ|n|p|f|a|z|y)(";
39
+
40
+ $.tablesorter.addParser({
41
+ id: 'metric',
42
+ is: function() {
43
+ return false;
44
+ },
45
+ format: function(s, table, cell, cellIndex) {
46
+ var v = 'm|meter',
47
+ b, t,
48
+ // process number here to get a numerical format (us or eu)
49
+ n = $.tablesorter.formatFloat(s.replace(/[^\w,. \-()]/g, ""), table),
50
+ $t = table.config.$headers.filter('[data-column="' + cellIndex + '"]'),
51
+ m = $t.data('metric');
52
+ if (!m) {
53
+ // stored values
54
+ t = ($t.attr('data-metric-name') || v).split('|');
55
+ m = [ t[1] || t[0].substring(1), t[0] ];
56
+ m[2] = new RegExp(RegLong + m[0] + "|" + m[1] + ")");
57
+ m[3] = new RegExp(RegAbbr + m[1] + ")");
58
+ $t.data('metric', m);
59
+ }
60
+ // find match to full name or abbreviation
61
+ t = s.match(m[2]) || s.match(m[3]);
62
+ if (t) {
63
+ for (v in prefixes) {
64
+ if (t[3].match(v)) {
65
+ // exception when using binary prefix
66
+ // change base for binary use
67
+ b = /^[b|bit|byte|o|octet]/.test(t[4]) ? 1 : 0;
68
+ return n * prefixes[v][b];
69
+ }
70
+ }
71
+ }
72
+ return n;
73
+ },
74
+ type: 'numeric'
75
+ });
76
+
77
+ })(jQuery);
@@ -0,0 +1,145 @@
1
+ /*! tablesorter Align Character widget - updated 3/12/2014 (core v2.15.8)
2
+ * Requires tablesorter v2.8+ and jQuery 1.7+
3
+ * by Rob Garrison
4
+ */
5
+ /*jshint browser:true, jquery:true, unused:false */
6
+ /*global jQuery: false */
7
+ ;(function($){
8
+ "use strict";
9
+ var ts = $.tablesorter;
10
+
11
+ ts.alignChar = {
12
+
13
+ init : function(table, c, wo) {
14
+ c.$headers.filter('[' + wo.alignChar_charAttrib + ']').each(function(){
15
+ var $this = $(this),
16
+ vars = {
17
+ column : this.column,
18
+ align : $this.attr(wo.alignChar_charAttrib),
19
+ alignIndex : parseInt( $this.attr(wo.alignChar_indexAttrib) || 0, 10),
20
+ adjust : parseFloat($this.attr(wo.alignChar_adjustAttrib)) || 0,
21
+ };
22
+ vars.regex = new RegExp('\\' + vars.align, 'g');
23
+ if (typeof vars.align !== 'undefined') {
24
+ wo.alignChar_savedVars[this.column] = vars;
25
+ ts.alignChar.setup(table, c, wo, vars);
26
+ }
27
+ });
28
+ },
29
+
30
+ setup: function(table, c, wo, v){
31
+ // do nothing for empty tables
32
+ if ($.isEmptyObject(c.cache)) { return; }
33
+ var tbodyIndex, rowIndex, start, end, last, index, rows, val, count,
34
+ len, wLeft, wRight, alignChar, $row,
35
+ left = [],
36
+ right = [];
37
+ for (tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++){
38
+ rows = c.cache[tbodyIndex];
39
+ len = rows.normalized.length;
40
+ for (rowIndex = 0; rowIndex < len; rowIndex++) {
41
+ // set up to work with modified cache v2.16.0+
42
+ $row = rows.row ? rows.row[rowIndex] : rows.normalized[rowIndex][c.columns].$row;
43
+ val = $row.find('td').eq(v.column).text().replace(/[ ]/g, "\u00a0");
44
+ // count how many "align" characters are in the string
45
+ count = (val.match( v.regex ) || []).length;
46
+ // set alignment @ alignIndex (one-based index)
47
+ if (count > 0 && v.alignIndex > 0) {
48
+ end = Math.min(v.alignIndex, count);
49
+ start = 0;
50
+ index = 0;
51
+ last = 0;
52
+ // find index of nth align character based on alignIndex (data-align-index)
53
+ while (start++ < end) {
54
+ last = val.indexOf(v.align, last + 1);
55
+ index = last < 0 ? index : last;
56
+ }
57
+ } else {
58
+ index = val.indexOf(v.align);
59
+ }
60
+ if ( index >= 0 ) {
61
+ left.push( val.substring(0, index) || '' );
62
+ right.push( val.substring(index, val.length) || '' );
63
+ } else {
64
+ // no align character found!
65
+ // put val in right or left based on the align index
66
+ left.push( (count >= 1 && v.alignIndex >= count) ? '' : val || '' );
67
+ right.push( (count >= 1 && v.alignIndex >= count) ? val || '' : '' );
68
+ }
69
+ }
70
+ }
71
+
72
+ // find widest segments
73
+ wLeft = ($.extend([], left)).sort(function(a,b){ return b.length - a.length; })[0];
74
+ wRight = ($.extend([], right)).sort(function(a,b){ return b.length - a.length; })[0];
75
+ // calculate percentage widths
76
+ v.width = v.width || ( Math.floor(wLeft.length / (wLeft.length + wRight.length) * 100) + v.adjust );
77
+ wLeft = 'min-width:' + v.width + '%';
78
+ wRight = 'min-width:' + (100 - v.width) + '%';
79
+
80
+ for (tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++){
81
+ rows = c.cache[tbodyIndex];
82
+ len = rows.normalized.length;
83
+ for (rowIndex = 0; rowIndex < len; rowIndex++) {
84
+ alignChar = $(wo.alignChar_wrap).length ? $(wo.alignChar_wrap).html(v.align)[0].outerHTML : v.align;
85
+ $row = rows.row ? rows.row[rowIndex] : rows.normalized[rowIndex][c.columns].$row;
86
+ $row.find('td').eq(v.column).html(
87
+ '<span class="ts-align-wrap"><span class="ts-align-left" style="' + wLeft + '">' + left[rowIndex] + '</span>' +
88
+ '<span class="ts-align-right" style="' + wRight + '">' + alignChar +
89
+ right[rowIndex].slice(v.align.length) + '</span></span>'
90
+ );
91
+ }
92
+ }
93
+ wo.alignChar_initialized = true;
94
+
95
+ },
96
+ remove: function(table, c, column){
97
+ if ($.isEmptyObject(c.cache)) { return; }
98
+ var tbodyIndex, rowIndex, len, rows, $row, $cell;
99
+ for (tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++){
100
+ rows = c.cache[tbodyIndex];
101
+ len = rows.normalized.length;
102
+ for (rowIndex = 0; rowIndex < len; rowIndex++) {
103
+ $row = rows.row ? rows.row[rowIndex] : rows.normalized[rowIndex][c.columns].$row;
104
+ $cell = $row.find('td').eq(column);
105
+ $cell.html( $cell.text().replace(/\s/g, ' ') );
106
+ }
107
+ }
108
+ }
109
+ };
110
+
111
+ ts.addWidget({
112
+ id: 'alignChar',
113
+ priority: 100,
114
+ options: {
115
+ alignChar_wrap : '',
116
+ alignChar_charAttrib : 'data-align-char',
117
+ alignChar_indexAttrib : 'data-align-index',
118
+ alignChar_adjustAttrib : 'data-align-adjust' // percentage width adjustments
119
+ },
120
+ init: function(table, thisWidget, c, wo){
121
+ wo.alignChar_initialized = false;
122
+ wo.alignChar_savedVars = [];
123
+ ts.alignChar.init(table, c, wo);
124
+ c.$table.on('pagerEnd refreshAlign', function(){
125
+ c.$headers.filter('[' + wo.alignChar_charAttrib + ']').each(function(){
126
+ ts.alignChar.remove(table, c, this.column);
127
+ });
128
+ ts.alignChar.init(table, c, wo);
129
+ });
130
+ },
131
+ format : function(table, c, wo){
132
+ // reinitialize in case table is empty when first initialized
133
+ if (!wo.alignChar_initialized) {
134
+ c.$table.trigger('refreshAlign');
135
+ }
136
+ },
137
+ remove : function(table, c, wo){
138
+ c.$headers.filter('[' + wo.alignChar_charAttrib + ']').each(function(){
139
+ ts.alignChar.remove(table, c, this.column);
140
+ });
141
+ wo.alignChar_initialized = false;
142
+ }
143
+ });
144
+
145
+ })(jQuery);