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.
6 lines
2.1 KiB
JavaScript
6 lines
2.1 KiB
JavaScript
7 years ago
|
(function(b){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(c){return b(c,window,document)}):"object"===typeof exports?module.exports=function(c,a){c||(c=window);if(!a||!a.fn.dataTable)a=require("datatables.net")(c,a).$;return b(a,c,c.document)}:b(jQuery,window,document)})(function(b,c,a){function f(c,a){var j=this,d=new k.Api(c),g=b('<div class="dt-searchPane"/>').appendTo(a.container);d.columns(a.columns).eq(0).each(function(l){for(var e=d.column(l),c=b("<ul/>"),
|
||
|
a=b(e.header()).hasClass("tags"),n=j._binData(e.data().flatten(),a),h=e.search(),h=h.length&&h[0]?h[0].substr(1,h[0].length-2).split("|"):[],a=a?d.ajax.json().tags:e.data().unique().sort().toArray(),i=0,m=a.length;i<m;i++)if(a[i]){var f=b("<li/>").html('<span class="label">'+a[i]+"</span>").data("filter",a[i]).append(b('<span class="count" />').html(n[a[i]]));-1!==b.inArray(a[i],h)&&f.addClass("selected");c.append(f)}b(g).append(b('<div class="pane"/>').data("column",l).addClass(h.length?"filtering":
|
||
|
"").append('<button type="button" class="close">×</button>').append(b('<div class="title"/>').html(b(e.header()).text())).append(b('<div class="scroller"/>').append(c)))});b(g).on("click","li",function(){b(this).hasClass("selected")?b(this).removeClass("selected"):b(this).addClass("selected");var a=b(this).closest("div.pane"),c=a.find("li.selected");0===c.length?(a.removeClass("filtering"),d.column(a.data("column")).search("").draw()):(a.addClass("filtering"),d.column(a.data("column")).search(b.map(c,
|
||
|
function(a){return b(a).data("filter")}).join("|"),!0,!1).draw())});b(g).on("click","button.close",function(){var a=b(this).closest("div.pane");a.find("li.selected").removeClass("selected");a.removeClass("filtering");d.column(a.data("column")).search("").draw()})}var k=b.fn.dataTable;b.extend(f.prototype,{_binData:function(a,b){var c={};a.each(function(a){if(a)if(b)for(var a=a.split(","),g=0,f=a.length;g<f;g++){var e=a[g];c[e]?c[e]++:c[e]=1}else c[a]?c[a]++:c[a]=1});return c}});b(a).on("init.dt",
|
||
|
function(a,c){if("dt"===a.namespace){var j=c.oInit.searchPane,d=k.defaults.searchPane;if(j||d)d=b.extend({},j,d),!1!==j&&new f(c,d)}})});
|