Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Refactor filter search from input[text] to input[search] #160

Merged
merged 7 commits into from

2 participants

@zeitiger

Small change to use input[search] within DataTable filter search.

@DataTables
Owner

I've actually rejected a pull request or two for this in the past as I felt HTML5 wasn't sufficiently 'deployed' (marketshare), but I think that's totally outdated now and this is a really good idea - thanks for the pull request!

Could you possibly add the DT namespace to the search event and I'll merge this in?

@zeitiger

I add the namespace suffix as requested

@DataTables DataTables merged commit 8d9e620 into from
@DataTables
Owner

Super - thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 28, 2013
  1. replace input[text] with HTML5 input[search]

    David Steinkopff authored
  2. replace input[text] with HTML5 input[search]

    David Steinkopff authored
  3. Merge branch 'master' of https://github.com/zeitiger/DataTables

    David Steinkopff authored
Commits on Mar 4, 2013
  1. Merge branch 'master' of https://github.com/zeitiger/DataTables

    David Steinkopff authored
    Add requested changes
  2. remove hacking

    David Steinkopff authored
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 17 deletions.
  1. +13 −13 media/js/jquery.dataTables.js
  2. +4 −4 media/src/core/core.filter.js
View
26 media/js/jquery.dataTables.js
@@ -2134,12 +2134,12 @@
function _fnFeatureHtmlFilter ( oSettings )
{
var oPreviousSearch = oSettings.oPreviousSearch;
-
+
var sSearchStr = oSettings.oLanguage.sSearch;
sSearchStr = (sSearchStr.indexOf('_INPUT_') !== -1) ?
- sSearchStr.replace('_INPUT_', '<input type="text" />') :
- sSearchStr==="" ? '<input type="text" />' : sSearchStr+' <input type="text" />';
-
+ sSearchStr.replace('_INPUT_', '<input type="search" />') :
+ sSearchStr==="" ? '<input type="search" />' : sSearchStr+' <input type="search" />';
+
var nFilter = document.createElement( 'div' );
nFilter.className = oSettings.oClasses.sFilter;
nFilter.innerHTML = '<label>'+sSearchStr+'</label>';
@@ -2147,19 +2147,19 @@
{
nFilter.id = oSettings.sTableId+'_filter';
}
-
- var jqFilter = $('input[type="text"]', nFilter);
-
+
+ var jqFilter = $('input[type="search"]', nFilter);
+
// Store a reference to the input element, so other input elements could be
// added to the filter wrapper if needed (submit button for example)
nFilter._DT_Input = jqFilter[0];
-
+
jqFilter.val( oPreviousSearch.sSearch.replace('"','&quot;') );
- jqFilter.bind( 'keyup.DT', function(e) {
+ jqFilter.bind( 'keyup.DT search.DT', function(e) {
/* Update all other filter input elements for the new display */
var n = oSettings.aanFeatures.f;
var val = this.value==="" ? "" : this.value; // mental IE8 fix :-(
-
+
for ( var i=0, iLen=n.length ; i<iLen ; i++ )
{
if ( n[i] != $(this).parents('div.dataTables_filter')[0] )
@@ -2167,7 +2167,7 @@
$(n[i]._DT_Input).val( val );
}
}
-
+
/* Now do the filter */
if ( val != oPreviousSearch.sSearch )
{
@@ -2179,7 +2179,7 @@
} );
}
} );
-
+
jqFilter
.attr('aria-controls', oSettings.sTableId)
.bind( 'keypress.DT', function(e) {
@@ -2190,7 +2190,7 @@
}
}
);
-
+
return nFilter;
}
View
8 media/src/core/core.filter.js
@@ -11,8 +11,8 @@ function _fnFeatureHtmlFilter ( oSettings )
var sSearchStr = oSettings.oLanguage.sSearch;
sSearchStr = (sSearchStr.indexOf('_INPUT_') !== -1) ?
- sSearchStr.replace('_INPUT_', '<input type="text" />') :
- sSearchStr==="" ? '<input type="text" />' : sSearchStr+' <input type="text" />';
+ sSearchStr.replace('_INPUT_', '<input type="search" />') :
+ sSearchStr==="" ? '<input type="search" />' : sSearchStr+' <input type="search" />';
var nFilter = document.createElement( 'div' );
nFilter.className = oSettings.oClasses.sFilter;
@@ -22,14 +22,14 @@ function _fnFeatureHtmlFilter ( oSettings )
nFilter.id = oSettings.sTableId+'_filter';
}
- var jqFilter = $('input[type="text"]', nFilter);
+ var jqFilter = $('input[type="search"]', nFilter);
// Store a reference to the input element, so other input elements could be
// added to the filter wrapper if needed (submit button for example)
nFilter._DT_Input = jqFilter[0];
jqFilter.val( oPreviousSearch.sSearch.replace('"','&quot;') );
- jqFilter.bind( 'keyup.DT', function(e) {
+ jqFilter.bind( 'keyup.DT search.DT', function(e) {
/* Update all other filter input elements for the new display */
var n = oSettings.aanFeatures.f;
var val = this.value==="" ? "" : this.value; // mental IE8 fix :-(
Something went wrong with that request. Please try again.