|
|
|
import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;DataTable.LengthLinks=function(a){var r=new DataTable.Api(a),e=r.settings()[0],l=$("<div></div>").addClass(e.oClasses.sLength),i=null;this.container=function(){return l[0]},l.on("click.dtll","a",function(a){a.preventDefault(),r.page.len(+$(this).data("length")).draw(!1)}),r.on("draw",function(){var t,n,a;r.page.len()!==i&&(a=e.aLengthMenu,t=2===a.length&&Array.isArray(a[0])?a[1]:a,n=2===a.length&&Array.isArray(a[0])?a[0]:a,a=$.map(n,function(a,e){return a==r.page.len()?'<a class="active" data-length="'+n[e]+'">'+t[e]+"</a>":'<a data-length="'+n[e]+'">'+t[e]+"</a>"}),l.html(e.oLanguage.sLengthMenu.replace("_MENU_",a.join(" | "))),i=r.page.len())}),r.on("destroy",function(){l.off("click.dtll","a")})},DataTable.ext.feature.push({fnInit:function(a){return new DataTable.LengthLinks(a).container()},cFeature:"L",sFeature:"LengthLinks"});export default DataTable;
|