diff --git a/docs/example-widget-header-titles.html b/docs/example-widget-header-titles.html new file mode 100644 index 00000000..85a342e0 --- /dev/null +++ b/docs/example-widget-header-titles.html @@ -0,0 +1,122 @@ + + + + + jQuery plugin: Tablesorter 2.0 - headerTitles widget + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ NOTE! +

+

+ +

Demo

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
First NameLast NameAgeTotalDiscountDate
PeterParker28$9.9920%Jan 18, 2001 9:12 AM
JohnEvans33$9.9925%Dec 10, 2002 5:14 AM
ClarkKent22$15.8944%Jan 12, 2003 11:14 AM
BruceAlmighty45$15.8944%Jan 18, 2001 9:12 AM
BruceEvans22$13.1911%Jul 6, 2006 8:14 AM
+ +

Javascript

+
+

+	
+ +
+ + + + diff --git a/docs/index.html b/docs/index.html index 203156d5..eaa5adc5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -404,6 +404,7 @@
+
  • Header titles widget (v2.15.6)
  • Pager plugin (v2.15).
  • @@ -452,8 +453,8 @@

    Widgets / Plugins

    diff --git a/js/widgets/widget-headerTitles.js b/js/widgets/widget-headerTitles.js new file mode 100644 index 00000000..d7f1b6d9 --- /dev/null +++ b/js/widgets/widget-headerTitles.js @@ -0,0 +1,32 @@ +/*! tablesorter headerTitles widget - updated 3/5/2014 (core v2.15.6) + * Requires tablesorter v2.8+ and jQuery 1.7+ + * by Rob Garrison + */ +/*jshint browser:true, jquery:true, unused:false */ +/*global jQuery: false */ +;(function($){ +"use strict"; + + $.tablesorter.addWidget({ + id: 'headerTitles', + options: { + headerTitle_prefix : 'Sort: ', + headerTitle_text : [ 'A - Z', 'Z - A' ], + headerTitle_numeric : [ '0 - 9', '9 - 0' ] + }, + format: function (table, c, wo) { + var txt; + // clear out all titles + c.$headers.attr('title', ''); + // only add titles to sorted columns + $.each(c.sortList, function(indx, group) { + txt = wo.headerTitle_prefix + wo['headerTitle_' + (c.parsers[ group[0] ].type || 'text')][ group[1] ]; + c.$headers.filter('[data-column="' + group[0] + '"]').attr('title', txt); + }); + }, + remove: function (table, c) { + c.$headers.attr('title', ''); + } + }); + +})(jQuery);