|
|
|
!function(){function n(a,t,e){t.empty(),t.append("Search: ");var a=a.column(e.column).data(),n=function(a,t){for(var e,n={},i=0,r=a.length;i<r;i++)n[e=t.caseSensitive?a[i].toString().replace(/<.*?>/g,"").charAt(0):a[i].toString().replace(/<.*?>/g,"").charAt(0).toUpperCase()]?n[e]++:n[e]=1;return n}(a,e);if($('<span class="clear active"/>').data("letter","").data("match-count",a.length).html("None").appendTo(t),e.numbers)for(var i=0;i<10;i++){var r=String.fromCharCode(48+i);$("<span/>").data("letter",r).data("match-count",n[r]||0).addClass(n[r]?"":"empty").html(r).appendTo(t)}for(i=0;i<26;i++){r=String.fromCharCode(65+i);$("<span/>").data("letter",r).data("match-count",n[r]||0).addClass(n[r]?"":"empty").html(r).appendTo(t)}if(e.caseSensitive)for(i=0;i<26;i++){r=String.fromCharCode(97+i);$("<span/>").data("letter",r).data("match-count",n[r]||0).addClass(n[r]?"":"empty").html(r).appendTo(t)}$('<div class="alphabetInfo"></div>').appendTo(t)}$.fn.dataTable.Api.register("alphabetSearch()",function(t){return this.iterator("table",function(a){a.alphabetSearch=t}),this}),$.fn.dataTable.Api.register("alphabetSearch.recalc()",function(a){return this.iterator("table",function(a){n(new $.fn.dataTable.Api(a),$("div.alphabet",this.table().container()))}),this}),$.fn.dataTable.ext.search.push(function(a,t){if(!a.alphabetSearch)return!0;var e;if(void 0!==a.oInit.alphabet?(e=void 0!==a.oInit.alphabet.column?a.oInit.alphabet.column:0,void 0!==a.oInit.alphabet.caseSensitive&&a.oInit.alphabet.caseSensitive):(e=0,!1)){if(t[e].charAt(0)===a.alphabetSearch)return!0}else if(t[e].charAt(0).toUpperCase()===a.alphabetSearch)return!0;return!1}),$.fn.dataTable.AlphabetSearch=function(a){var t=new $.fn.dataTable.Api(a),e=$('<div class="alphabet"/>'),a=$.extend({column:0,caseSensitive:!1,numbers:!1},t.init().alphabet);n(t,e,a),e.on("click","span",function(){e.find(".active").removeClass("active"),$(this).addClass("active"),t.alphabetSearch($(this).data("letter")).draw()}),e.on("mouseenter","span",function(){e.find("div.alphabetInfo").css({opacity:1,left:$(this).position().left,width:$(this).width()}).html($(this).data("match-count"))}).on("mouseleave","span",function(){e.find("div.alphabetInfo").css("opacity",0)}),this.node=function(){return e}},$.fn.DataTable.AlphabetSearch=$.fn.dataTable.AlphabetSearch,$.fn.dataTable.ext.feature.push({fnInit:function(a){return new $.fn.dataTable.AlphabetSearch(a).node()},cFeature:"A"})}();
|