diff --git a/features/searchPane/dataTables.searchPane.css b/features/searchPane/dataTables.searchPane.css index d980ea1..d005947 100644 --- a/features/searchPane/dataTables.searchPane.css +++ b/features/searchPane/dataTables.searchPane.css @@ -12,8 +12,7 @@ div.dt-searchPanes div.pane { flex: 1; margin: 1em 0.5%; border: 1px solid #ccc; - /*width: 15.5%; - margin: 0 0.583333333%;*/ + border-radius: 3px; } div.dt-searchPanes div.pane button[type=button] { display: none; @@ -25,7 +24,7 @@ div.dt-searchPanes div.pane.filtering button[type=button] { top: 6px; border: 1px solid #999; background: rgba(0, 0, 0, 0.1); - border-radius: 3px; + border-radius: 16px; cursor: pointer; } div.dt-searchPanes div.pane.filtering button[type=button]:hover { @@ -33,15 +32,15 @@ div.dt-searchPanes div.pane.filtering button[type=button]:hover { } div.dt-searchPanes div.pane div.title { box-sizing: border-box; - height: 30px; - padding: 0.35em; + height: 36px; + padding: 9px 0.35em; font-size: 1.1em; - background-color: rgba(0, 0, 0, 0.075); - border-bottom: 1px solid #ddd; + background-color: #e8e9eb; + border-bottom: 1px solid rgba(0, 0, 0, 0.15); } div.dt-searchPanes div.pane div.scroller { position: absolute; - top: 30px; + top: 36px; bottom: 0; left: 0; right: 0; @@ -80,8 +79,7 @@ div.dt-searchPanes div.pane div.scroller ul li span.count { width: 14%; margin-right: 1%; font-size: 0.8em; - color: white; text-align: center; - background-color: #3276b1; + background-color: rgba(50, 118, 177, 0.5); border-radius: 3px; } diff --git a/features/searchPane/dataTables.searchPane.js b/features/searchPane/dataTables.searchPane.js index 8301e46..42d5d73 100644 --- a/features/searchPane/dataTables.searchPane.js +++ b/features/searchPane/dataTables.searchPane.js @@ -1,8 +1,23 @@ -// TODO -// - Styling for selected -// - Styling for container / header -// - Styling for clear option - +/*! SearchPane 0.0.1 + * 2017 SpryMedia Ltd - datatables.net/license + */ + +/** + * @summary SearchPane + * @description Search Panes for DataTables columns + * @version 0.0.1 + * @author SpryMedia Ltd (www.sprymedia.co.uk) + * @copyright Copyright 2017 SpryMedia Ltd. + * + * This source file is free software, available under the following license: + * MIT license - http://datatables.net/license/mit + * + * This source file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. + * + * For details please refer to: http://www.datatables.net + */ (function(factory) { if (typeof define === 'function' && define.amd) { // AMD @@ -40,7 +55,7 @@ container: $('
').addClass(this.classes.container) }; - this.c = $.extend( true, {}, SearchPanes.defaults, opts ); + this.c = $.extend(true, {}, SearchPanes.defaults, opts); this.s = { dt: table @@ -67,7 +82,7 @@ } $.extend(SearchPanes.prototype, { - rebuild: function () { + rebuild: function() { var that = this; this.s.dt @@ -78,17 +93,15 @@ }); }, - _attach: function () { + _attach: function() { var container = this.c.container; - var host = typeof container === 'function' ? - container( this.s.dt ) : - container; - - if ( this.c.insert === 'prepend' ) { - $(this.dom.container).prependTo( host ); - } - else { - $(this.dom.container).appendTo( host ); + var host = + typeof container === 'function' ? container(this.s.dt) : container; + + if (this.c.insert === 'prepend') { + $(this.dom.container).prependTo(host); + } else { + $(this.dom.container).appendTo(host); } }, @@ -133,16 +146,14 @@ var bins = this._binData(column.data().flatten()); // Don't show the pane if there isn't enough variance in the data - if ( this._variance(bins) < this.c.threshold ) { + if (this._variance(bins) < this.c.threshold) { return; } // On initialisation, do we need to set a filtering value from a // saved state or init option? var search = column.search(); - search = search - ? search.substr(1, search.length - 2).split('|') - : []; + search = search ? search.substr(1, search.length - 2).split('|') : []; var data = column .data() @@ -163,10 +174,10 @@ .html(bins[data[i]]) ); - if ( search.length ) { - var escaped = data[i].replace ? - $.fn.dataTable.util.escapeRegex( data[i] ) : - data[i]; + if (search.length) { + var escaped = data[i].replace + ? $.fn.dataTable.util.escapeRegex(data[i]) + : data[i]; if ($.inArray(escaped, search) !== -1) { li.addClass(itemClasses.selected); @@ -198,19 +209,16 @@ ); var container = this.dom.container; - var replace = container.children().map( function () { - if ( $(this).data('column') == idx ) { + var replace = container.children().map(function() { + if ($(this).data('column') == idx) { return this; } - } ); - - console.log( replace ); + }); - if ( replace.length ) { - replace.replaceWith( pane ); - } - else { - $(container).append( pane ); + if (replace.length) { + replace.replaceWith(pane); + } else { + $(container).append(pane); } }, @@ -236,36 +244,40 @@ table .column(pane.data('column')) .search( - '^'+$.map(filters, function(filter) { - var d = $(filter).data('filter').toString(); - return $.fn.dataTable.util.escapeRegex( d ); - }).join('|')+'$', + '^' + + $.map(filters, function(filter) { + var d = $(filter) + .data('filter') + .toString(); + return $.fn.dataTable.util.escapeRegex(d); + }).join('|') + + '$', true, false ) .draw(); } }, - - _variance: function ( d ) { - var data = $.map( d, function (val, key) { + + _variance: function(d) { + var data = $.map(d, function(val, key) { return val; - } ); + }); var count = data.length; var sum = 0; - for ( var i=0, ien=count ; iSpace for banner etc
-