From c31d3a144783fb067b593f0711fa3f6465c1dcff Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Thu, 10 Oct 2013 17:46:36 +0100 Subject: [PATCH] Dev: Refactor the filtering HTML creation function - save 138 bytes on file size --- .datatables-commit-sync | 2 +- media/css/jquery.dataTables.css | 3 + media/css/jquery.dataTables_themeroller.css | 3 + media/js/jquery.dataTables.js | 101 +++++++++----------- 4 files changed, 50 insertions(+), 59 deletions(-) diff --git a/.datatables-commit-sync b/.datatables-commit-sync index c250c0ab..cbecdf19 100644 --- a/.datatables-commit-sync +++ b/.datatables-commit-sync @@ -1 +1 @@ -9fd084bdae8fa642638c88f15592e3322548c328 +2e8c9ddd5aaf32c42462cef8cdb620654d186068 diff --git a/media/css/jquery.dataTables.css b/media/css/jquery.dataTables.css index 47f3acf9..15b5d60b 100644 --- a/media/css/jquery.dataTables.css +++ b/media/css/jquery.dataTables.css @@ -226,6 +226,9 @@ table.dataTable.sort-column.hover tbody tr.even:hover.selected > .sorting_3 { float: right; text-align: right; } +.dataTables_wrapper .dataTables_filter input { + margin-left: 0.5em; +} .dataTables_wrapper .dataTables_info { clear: both; float: left; diff --git a/media/css/jquery.dataTables_themeroller.css b/media/css/jquery.dataTables_themeroller.css index 7fd4cb88..4783b247 100644 --- a/media/css/jquery.dataTables_themeroller.css +++ b/media/css/jquery.dataTables_themeroller.css @@ -219,6 +219,9 @@ table.dataTable.sort-column.hover tbody tr.even:hover.selected > .sorting_3 { float: right; text-align: right; } +.dataTables_wrapper .dataTables_filter input { + margin-left: 0.5em; +} .dataTables_wrapper .dataTables_info { clear: both; float: left; diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index a57c40d1..2352ad95 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -2187,81 +2187,66 @@ * @param {object} oSettings dataTables settings object * @memberof DataTable#oApi */ - function _fnFeatureHtmlFilter ( oSettings ) + function _fnFeatureHtmlFilter ( settings ) { - var oPreviousSearch = oSettings.oPreviousSearch; + var classes = settings.oClasses; + var tableId = settings.sTableId; + var previousSearch = settings.oPreviousSearch; + var features = settings.aanFeatures; - // @todo Surely this can be cleaned up!?! - var klass = 'class="'+oSettings.oClasses.sFilterInput+'"'; - var sSearchStr = oSettings.oLanguage.sSearch; - sSearchStr = (sSearchStr.indexOf('_INPUT_') !== -1) ? - sSearchStr.replace('_INPUT_', '') : - sSearchStr==="" ? - '' : - sSearchStr+' '; + var str = settings.oLanguage.sSearch; + str = str.match(/_INPUT_/) ? + str.replace('_INPUT_', '') : + str+''; - var nFilter = document.createElement( 'div' ); - nFilter.className = oSettings.oClasses.sFilter; - nFilter.innerHTML = ''; - if ( !oSettings.aanFeatures.f ) - { - nFilter.id = oSettings.sTableId+'_filter'; - } + var filter = $('
', { + 'id': ! features.f ? tableId+'_filter' : null, + 'class': classes.sFilter + } ) + .append( $('