/*! Widget: headerTitles - updated 10/31/2015 (v2.24.0) */ /* * Requires tablesorter v2.8+ and jQuery 1.7+ * by Rob Garrison */ /*jshint browser:true, jquery:true, unused:false */ /*global jQuery: false */ !function(a){"use strict";var b=a.tablesorter;b.addWidget({id:"headerTitles",options:{ // use aria-label text // e.g. 'First Name: Ascending sort applied, activate to apply a descending sort' headerTitle_useAria:!1, // add tooltip class headerTitle_tooltip:"", // custom titles [ ascending, descending, unsorted ] 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"], // title display; {prefix} adds above prefix // {type} adds the current sort order from above (text or numeric) // {next} adds the next sort direction using the sort order above headerTitle_output_sorted:"current{current}; activate to {next}",headerTitle_output_unsorted:"current{current}; activate to {next} ",headerTitle_output_nosort:"No sort available", // use this type to override the parser detection result // e.g. use for numerically parsed columns (e.g. dates), but you // want the user to see a text sort, e.g. [ 'text', 'numeric' ] headerTitle_type:[], // manipulate the title as desired headerTitle_callback:null},init:function(b,c,d,e){ // force refresh d.$table.on("refreshHeaderTitle",function(){c.format(b,d,e)}), // add tooltip class 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=a(this),g=parseInt(c.attr("data-column"),10),h=e.headerTitle_type[g]||d.parsers[g].type||"text",i=c.hasClass(b.css.sortAsc)?0:c.hasClass(b.css.sortDesc)?1:2,j=d.sortVars[g].order[(d.sortVars[g].count+1)%(d.sortReset?3:2)];e.headerTitle_useAria?f=c.hasClass("sorter-false")?e.headerTitle_output_nosort:c.attr("aria-label")||"":(f=(e.headerTitle_prefix||"")+(// now deprecated c.hasClass("sorter-false")?e.headerTitle_output_nosort:b.isValueInArray(g,d.sortList)>=0?e.headerTitle_output_sorted:e.headerTitle_output_unsorted),f=f.replace(/\{(current|next|name)\}/gi,function(a){return{"{name}":c.text(),"{current}":e["headerTitle_cur_"+h][i]||"","{next}":e["headerTitle_nxt_"+h][j]||""}[a.toLowerCase()]})),c.attr("title",a.isFunction(e.headerTitle_callback)?e.headerTitle_callback(c,f):f)})},remove:function(b,c,d){c.$headers.attr("title",""),c.$table.off("refreshHeaderTitle"), // remove tooltip class 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);