|
|
@ -20,6 +20,6 @@ h);this.s={dt:b};b.settings()[0].searchPane=this;b.columns(this.c.columns).eq(0)
|
|
|
|
typeof b?b(this.s.dt):b;"prepend"===this.c.insert?a(this.dom.container).prependTo(b):a(this.dom.container).appendTo(b)},_binData:function(a){var b={};a.each(function(a){a&&(b[a]?b[a]++:b[a]=1)});return b},_clear:function(a){var b=this.classes,f=b.item.selected;a.find("li."+f).removeClass(f);a.removeClass(b.pane.active);this.s.dt.column(a.data("column")).search("").draw()},_pane:function(b){var h=this.classes,f=h.item,h=h.pane,c=this.s.dt.column(b),e=a("<ul/>"),d=this._binData(c.data().flatten());
|
|
|
|
typeof b?b(this.s.dt):b;"prepend"===this.c.insert?a(this.dom.container).prependTo(b):a(this.dom.container).appendTo(b)},_binData:function(a){var b={};a.each(function(a){a&&(b[a]?b[a]++:b[a]=1)});return b},_clear:function(a){var b=this.classes,f=b.item.selected;a.find("li."+f).removeClass(f);a.removeClass(b.pane.active);this.s.dt.column(a.data("column")).search("").draw()},_pane:function(b){var h=this.classes,f=h.item,h=h.pane,c=this.s.dt.column(b),e=a("<ul/>"),d=this._binData(c.data().flatten());
|
|
|
|
if(!(this._variance(d)<this.c.threshold)){for(var g=c.search(),g=g?g.substr(1,g.length-2).split("|"):[],m=c.data().unique().sort().toArray(),k=0,l=m.length;k<l;k++)if(m[k]){var n=a("<li/>").html('<span class="'+f.label+'">'+m[k]+"</span>").data("filter",m[k]).append(a("<span/>").addClass(f.count).html(d[m[k]]));if(g.length){var p=m[k].replace?a.fn.dataTable.util.escapeRegex(m[k]):m[k];-1!==a.inArray(p,g)&&n.addClass(f.selected)}e.append(n)}f=a("<div/>").data("column",b).addClass(h.container).addClass(g.length?
|
|
|
|
if(!(this._variance(d)<this.c.threshold)){for(var g=c.search(),g=g?g.substr(1,g.length-2).split("|"):[],m=c.data().unique().sort().toArray(),k=0,l=m.length;k<l;k++)if(m[k]){var n=a("<li/>").html('<span class="'+f.label+'">'+m[k]+"</span>").data("filter",m[k]).append(a("<span/>").addClass(f.count).html(d[m[k]]));if(g.length){var p=m[k].replace?a.fn.dataTable.util.escapeRegex(m[k]):m[k];-1!==a.inArray(p,g)&&n.addClass(f.selected)}e.append(n)}f=a("<div/>").data("column",b).addClass(h.container).addClass(g.length?
|
|
|
|
h.active:"").append(a('<button type="button">×</button>').addClass(this.classes.clear)).append(a("<div/>").addClass(h.title).html(a(c.header()).text())).append(a("<div/>").addClass(h.scroller).append(e));h=this.dom.container;c=h.children().map(function(){if(a(this).data("column")==b)return this});c.length?c.replaceWith(f):a(h).append(f)}},_toggle:function(b){var c=this.classes,f=c.item.selected,e=this.s.dt;b=a(b);var d=b.closest("div."+c.pane.container);b.toggleClass(f,!b.hasClass(f));b=d.find("li."+
|
|
|
|
h.active:"").append(a('<button type="button">×</button>').addClass(this.classes.clear)).append(a("<div/>").addClass(h.title).html(a(c.header()).text())).append(a("<div/>").addClass(h.scroller).append(e));h=this.dom.container;c=h.children().map(function(){if(a(this).data("column")==b)return this});c.length?c.replaceWith(f):a(h).append(f)}},_toggle:function(b){var c=this.classes,f=c.item.selected,e=this.s.dt;b=a(b);var d=b.closest("div."+c.pane.container);b.toggleClass(f,!b.hasClass(f));b=d.find("li."+
|
|
|
|
f);0===b.length?(d.removeClass(c.pane.active),e.column(d.data("column")).search("").draw()):(d.addClass(c.pane.active),e.column(d.data("column")).search("^"+a.map(b,function(b){b=a(b).data("filter").toString();return a.fn.dataTable.util.escapeRegex(b)}).join("|")+"$",!0,!1).draw())},_variance:function(b){b=a.map(b,function(a,b){return a});for(var c=b.length,f=0,d=0,e=c;d<e;d++)f+=b[d];for(var f=f/c,g=0,d=0,e=c;d<e;d++)g+=Math.pow(f-b[d],2);return g/(c-1)}});d.classes={container:"dt-searchPanes",clear:"clear",
|
|
|
|
f);0===b.length?(d.removeClass(c.pane.active),e.column(d.data("column")).search("").draw()):(d.addClass(c.pane.active),e.column(d.data("column")).search("^("+a.map(b,function(b){b=a(b).data("filter").toString();return a.fn.dataTable.util.escapeRegex(b)}).join("|")+")$",!0,!1).draw())},_variance:function(b){b=a.map(b,function(a,b){return a});for(var c=b.length,f=0,d=0,e=c;d<e;d++)f+=b[d];for(var f=f/c,g=0,d=0,e=c;d<e;d++)g+=Math.pow(f-b[d],2);return g/(c-1)}});d.classes={container:"dt-searchPanes",
|
|
|
|
pane:{active:"filtering",container:"pane",title:"title",scroller:"scroller"},item:{selected:"selected",label:"label",count:"count"}};d.defaults={container:function(a){return a.table().container()},columns:g,insert:"prepend",threshold:.5};d.version="0.0.1";a.fn.dataTable.SearchPanes=d;a.fn.DataTable.SearchPanes=d;l.Api.register("searchPanes.rebuild()",function(){return this.iterator("table",function(a){a.searchPane&&a.searchPane.rebuild()})});a(c).on("init.dt",function(b,c,e){"dt"===b.namespace&&(b=
|
|
|
|
clear:"clear",pane:{active:"filtering",container:"pane",title:"title",scroller:"scroller"},item:{selected:"selected",label:"label",count:"count"}};d.defaults={container:function(a){return a.table().container()},columns:g,insert:"prepend",threshold:.5};d.version="0.0.1";a.fn.dataTable.SearchPanes=d;a.fn.DataTable.SearchPanes=d;l.Api.register("searchPanes.rebuild()",function(){return this.iterator("table",function(a){a.searchPane&&a.searchPane.rebuild()})});a(c).on("init.dt",function(b,c,e){"dt"===
|
|
|
|
c.oInit.searchPane,e=l.defaults.searchPane,b||e)&&(e=a.extend({},b,e),!1!==b&&new d(c,e))})});
|
|
|
|
b.namespace&&(b=c.oInit.searchPane,e=l.defaults.searchPane,b||e)&&(e=a.extend({},b,e),!1!==b&&new d(c,e))})});
|
|
|
|