You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Plugins/features/alphabetSearch/dataTables.alphabetSearch.m...

2 lines
3.0 KiB
JavaScript

/*! © SpryMedia Ltd - datatables.net/license */
!function(a){var n,i;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(t){return a(t,window,document)}):"object"==typeof exports?(n=require("jquery"),i=function(t,e){e.fn.dataTable||require("datatables.net")(t,e)},"undefined"==typeof window?module.exports=function(t,e){return t=t||window,e=e||n(t),i(t,e),a(e,0,t.document)}:(i(window,n),module.exports=a(n,window,window.document))):a(jQuery,window,document)}(function(o,t,e){"use strict";var i=o.fn.dataTable;function r(t,e,a){e.empty(),e.append("Search: ");var t=t.column(a.column).data(),n=function(t,e){for(var a,n={},i=0,r=t.length;i<r;i++)n[a=e.caseSensitive?t[i].toString().replace(/<.*?>/g,"").charAt(0):t[i].toString().replace(/<.*?>/g,"").charAt(0).toUpperCase()]?n[a]++:n[a]=1;return n}(t,a);if(o('<span class="clear active"/>').data("letter","").data("match-count",t.length).html("None").appendTo(e),a.numbers)for(var i=0;i<10;i++){var r=String.fromCharCode(48+i);o("<span/>").data("letter",r).data("match-count",n[r]||0).addClass(n[r]?"":"empty").html(r).appendTo(e)}for(i=0;i<26;i++){r=String.fromCharCode(65+i);o("<span/>").data("letter",r).data("match-count",n[r]||0).addClass(n[r]?"":"empty").html(r).appendTo(e)}if(a.caseSensitive)for(i=0;i<26;i++){r=String.fromCharCode(97+i);o("<span/>").data("letter",r).data("match-count",n[r]||0).addClass(n[r]?"":"empty").html(r).appendTo(e)}o('<div class="alphabetInfo"></div>').appendTo(e)}return i.Api.register("alphabetSearch()",function(e){return this.iterator("table",function(t){t.alphabetSearch=e}),this}),i.Api.register("alphabetSearch.recalc()",function(){return this.iterator("table",function(t){r(new i.Api(t),t._alphabet,t._alphabetOptions)}),this}),i.Api.register("alphabetSearch.node()",function(){return this._context.length?this._context._alphabet:null}),i.ext.search.push(function(t,e){if(!t.alphabetSearch)return!0;var a=0,n=!1;if(void 0!==t.oInit.alphabet&&(a=void 0!==t.oInit.alphabet.column?t.oInit.alphabet.column:0,n=void 0!==t.oInit.alphabet.caseSensitive&&t.oInit.alphabet.caseSensitive),n){if(e[a].charAt(0)===t.alphabetSearch)return!0}else if(e[a].charAt(0).toUpperCase()===t.alphabetSearch)return!0;return!1}),i.AlphabetSearch=function(t){var e=new i.Api(t),a=o('<div class="alphabet"/>'),n=o.extend({column:0,caseSensitive:!1,numbers:!1},e.init().alphabet);r(e,a,n),t._alphabet=a,t._alphabetOptions=n,a.on("click","span",function(){a.find(".active").removeClass("active"),o(this).addClass("active"),e.alphabetSearch(o(this).data("letter")).draw()}),a.on("mouseenter","span",function(){a.find("div.alphabetInfo").css({opacity:1,left:o(this).position().left,width:o(this).width()}).html(o(this).data("match-count"))}).on("mouseleave","span",function(){a.find("div.alphabetInfo").css("opacity",0)}),this.node=function(){return a}},i.ext.feature.push({fnInit:function(t){return new i.AlphabetSearch(t).node()},cFeature:"A"}),i.feature.register("alphabetSearch",function(t,e){return new i.AlphabetSearch(t).node()}),i});