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...

22 lines
5.0 KiB
JavaScript

/*!
5 years ago
Copyright 2014 SpryMedia Ltd.
License MIT - http://datatables.net/license/mit
For more detailed information please see:
http://datatables.net/blog/2014-09-22
AlphabetSearch for DataTables v1.0.0
2014 SpryMedia Ltd - datatables.net/license
*/
3 years ago
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(c,a,b){c instanceof String&&(c=String(c));for(var e=c.length,d=0;d<e;d++){var g=c[d];if(a.call(b,g,d,c))return{i:d,v:g}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(c,a,b){if(c==Array.prototype||c==Object.prototype)return c;c[a]=b.value;return c};$jscomp.getGlobal=function(c){c=["object"==typeof globalThis&&globalThis,c,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var a=0;a<c.length;++a){var b=c[a];if(b&&b.Math==Math)return b}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(c,a){var b=$jscomp.propertyToPolyfillSymbol[a];if(null==b)return c[a];b=c[b];return void 0!==b?b:c[a]};
$jscomp.polyfill=function(c,a,b,e){a&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(c,a,b,e):$jscomp.polyfillUnisolated(c,a,b,e))};$jscomp.polyfillUnisolated=function(c,a,b,e){b=$jscomp.global;c=c.split(".");for(e=0;e<c.length-1;e++){var d=c[e];if(!(d in b))return;b=b[d]}c=c[c.length-1];e=b[c];a=a(e);a!=e&&null!=a&&$jscomp.defineProperty(b,c,{configurable:!0,writable:!0,value:a})};
$jscomp.polyfillIsolated=function(c,a,b,e){var d=c.split(".");c=1===d.length;e=d[0];e=!c&&e in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var g=0;g<d.length-1;g++){var h=d[g];if(!(h in e))return;e=e[h]}d=d[d.length-1];b=$jscomp.IS_SYMBOL_NATIVE&&"es6"===b?e[d]:null;a=a(b);null!=a&&(c?$jscomp.defineProperty($jscomp.polyfills,d,{configurable:!0,writable:!0,value:a}):a!==b&&($jscomp.propertyToPolyfillSymbol[d]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(d):$jscomp.POLYFILL_PREFIX+d,d=
$jscomp.propertyToPolyfillSymbol[d],$jscomp.defineProperty(e,d,{configurable:!0,writable:!0,value:a})))};$jscomp.polyfill("Array.prototype.find",function(c){return c?c:function(a,b){return $jscomp.findInternal(this,a,b).v}},"es6","es3");
(function(){function c(a,b,e){b.empty();b.append("Search: ");var d=a.column(e.column).data();a={};for(var g=0,h=d.length;g<h;g++){var f=e.caseSensitive?d[g].toString().replace(/<.*?>/g,"").charAt(0):d[g].toString().replace(/<.*?>/g,"").charAt(0).toUpperCase();a[f]?a[f]++:a[f]=1}$('<span class="clear active"/>').data("letter","").data("match-count",d.length).html("None").appendTo(b);if(e.numbers)for(d=0;10>d;d++)f=String.fromCharCode(48+d),$("<span/>").data("letter",f).data("match-count",a[f]||0).addClass(a[f]?
"":"empty").html(f).appendTo(b);for(d=0;26>d;d++)f=String.fromCharCode(65+d),$("<span/>").data("letter",f).data("match-count",a[f]||0).addClass(a[f]?"":"empty").html(f).appendTo(b);if(e.caseSensitive)for(d=0;26>d;d++)f=String.fromCharCode(97+d),$("<span/>").data("letter",f).data("match-count",a[f]||0).addClass(a[f]?"":"empty").html(f).appendTo(b);$('<div class="alphabetInfo"></div>').appendTo(b)}$.fn.dataTable.Api.register("alphabetSearch()",function(a){this.iterator("table",function(b){b.alphabetSearch=
a});return this});$.fn.dataTable.Api.register("alphabetSearch.recalc()",function(a){this.iterator("table",function(b){c(new $.fn.dataTable.Api(b),$("div.alphabet",this.table().container()))});return this});$.fn.dataTable.ext.search.push(function(a,b){if(!a.alphabetSearch)return!0;if(void 0!==a.oInit.alphabet)var e=void 0!==a.oInit.alphabet.column?a.oInit.alphabet.column:0,d=void 0!==a.oInit.alphabet.caseSensitive?a.oInit.alphabet.caseSensitive:!1;else e=0,d=!1;if(d){if(b[e].charAt(0)===a.alphabetSearch)return!0}else if(b[e].charAt(0).toUpperCase()===
a.alphabetSearch)return!0;return!1});$.fn.dataTable.AlphabetSearch=function(a){var b=new $.fn.dataTable.Api(a),e=$('<div class="alphabet"/>');a=$.extend({column:0,caseSensitive:!1,numbers:!1},b.init().alphabet);c(b,e,a);e.on("click","span",function(){e.find(".active").removeClass("active");$(this).addClass("active");b.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"})})();