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/mark.js/datatables.mark.min.js

7 lines
1.9 KiB
JavaScript

/*!***************************************************
* datatables.mark.js v3.0.0
* https://github.com/julmot/datatables.mark.js
* Copyright (c) 20162020, Julian Kühnel, SpryMedia Ltd
* Released under the MIT license https://git.io/voRZ7
*****************************************************/
!function(n){"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(t){return n(t,window,document)}):"object"==typeof exports?module.exports=function(t,e){return t=t||window,(e=e||("undefined"!=typeof window?require("jquery"):require("jquery")(t))).fn.dataTable||require("datatables.net")(t,e),n(e,0,t.document)}:n(jQuery,window,document)}(function(r,t,e,n){"use strict";var i=r.fn.dataTable;class s{instance;options;intervalThreshold;intervalMs;constructor(t,e){if(!r.fn.mark||!r.fn.unmark)throw new Error("jquery.mark.js is necessary for datatables.mark.js");this.instance=t,this.options="object"==typeof e?e:{},this.intervalThreshold=49,this.intervalMs=300,this.initMarkListener()}initMarkListener(){let t="draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth",e=(t+=" responsive-display.dt.dth",null);this.instance.on(t,()=>{this.instance.rows({filter:"applied",page:"current"}).nodes().length>this.intervalThreshold?(clearTimeout(e),e=setTimeout(()=>{this.mark()},this.intervalMs)):this.mark()}),this.instance.on("destroy",()=>{this.instance.off(t)}),this.mark()}mark(){const s=this.instance.search();var t=r(this.instance.table().body());t.unmark(this.options),this.instance.table().rows({search:"applied"}).data().length&&t.mark(s,this.options),this.instance.columns({search:"applied",page:"current"}).nodes().each((t,e)=>{const n=this.instance.column(e).search(),i=n||s;i&&t.forEach(t=>{r(t).unmark(this.options).mark(i,this.options)})})}}return r(e).on("init.dt.dth",(e,n)=>{if("dt"===e.namespace){e=new i.Api(n);let t=!1;e.init().mark?t=e.init().mark:i.defaults.mark&&(t=i.defaults.mark),t&&new s(e,t)}}),i});