tablesorter/dist/js/widgets/widget-headerTitles.min.js

5 lines
2.1 KiB
JavaScript
Raw Normal View History

/*! tablesorter headerTitles widget - updated 3/5/2014 (core v2.15.6)
* Requires tablesorter v2.8+ and jQuery 1.7+
* by Rob Garrison
*/
!function(a){"use strict";var b=a.tablesorter;b.addWidget({id:"headerTitles",options:{headerTitle_useAria:!1,headerTitle_tooltip:"",headerTitle_cur_text:[" sort: A - Z"," sort: Z - A","ly unsorted"],headerTitle_cur_numeric:[" sort: 0 - 9"," sort: 9 - 0","ly unsorted"],headerTitle_nxt_text:[" sort: A - Z"," sort: Z - A","remove sort"],headerTitle_nxt_numeric:[" sort: 0 - 9"," sort: 9 - 0","remove sort"],headerTitle_output_sorted:"current{current}; activate to {next}",headerTitle_output_unsorted:"current{current}; activate to {next} ",headerTitle_output_nosort:"No sort available",headerTitle_type:[],headerTitle_callback:null},init:function(b,c,d,e){d.$table.on("refreshHeaderTitle",function(){c.format(b,d,e)}),a.isArray(e.headerTitle_tooltip)?d.$headers.each(function(){a(this).addClass(e.headerTitle_tooltip[this.column]||"")}):""!==e.headerTitle_tooltip&&d.$headers.addClass(e.headerTitle_tooltip)},format:function(c,d,e){var f;d.$headers.each(function(){var c=this,g=a(this),h=e.headerTitle_type[c.column]||d.parsers[c.column].type||"text",i=g.hasClass(b.css.sortAsc)?0:g.hasClass(b.css.sortDesc)?1:2,j=c.order[(c.count+1)%(d.sortReset?3:2)];e.headerTitle_useAria?f=g.hasClass("sorter-false")?e.headerTitle_output_nosort:g.attr("aria-label")||"":(f=(e.headerTitle_prefix||"")+(g.hasClass("sorter-false")?e.headerTitle_output_nosort:b.isValueInArray(c.column,d.sortList)>=0?e.headerTitle_output_sorted:e.headerTitle_output_unsorted),f=f.replace(/\{(current|next|name)\}/gi,function(a){return{"{name}":g.text(),"{current}":e["headerTitle_cur_"+h][i]||"","{next}":e["headerTitle_nxt_"+h][j]||""}[a.toLowerCase()]})),g.attr("title",a.isFunction(e.headerTitle_callback)?e.headerTitle_callback(g,f):f)})},remove:function(b,c,d){c.$headers.attr("title",""),c.$table.off("refreshHeaderTitle"),a.isArray(d.headerTitle_tooltip)?c.$headers.each(function(){a(this).removeClass(d.headerTitle_tooltip[this.column]||"")}):""!==d.headerTitle_tooltip&&c.$headers.removeClass(d.headerTitle_tooltip)}})}(jQuery);