Permalink
Browse files

updates to testQuery and prepareQuery

  • Loading branch information...
1 parent a039a67 commit 841d5a8ba2c09a6354cc2d80ea3cc3a589806914 @riklomas committed Sep 10, 2010
Showing with 24 additions and 23 deletions.
  1. +8 −7 README.markdown
  2. +6 −6 examples/index.html
  3. +1 −1 examples/style.css
  4. +9 −9 jquery.quicksearch.js
View
@@ -84,12 +84,12 @@ the form and input are not build by the script any more.
* #### hide
Function that will add styles to unmatched elements
* #### prepareQuery
- Function that transforms text from input_selector into query used by `test` function
-* #### test
+ Function that transforms text from input_selector into query used by 'test' function
+* #### testQuery
Function that tells if a given item should be hidden
It takes 3 arguments:
- - query prepared by `prepareQuery`
- - stripped text from `selector`
+ - query prepared by 'prepareQuery'
+ - stripped text from 'selector'
- element to be potentially hidden
@@ -117,7 +117,7 @@ For example:
'prepareQuery': function (val) {
return new RegExp(val, "i");
},
- 'test': function (query, txt, _row) {
+ 'testQuery': function (query, txt, _row) {
return query.test(txt);
}
});
@@ -145,7 +145,7 @@ Under the same licenses as the jQuery library itself: <http://docs.jquery.com/Li
jQuery quicksearch is made by [Rik Lomas][rik_site] at [Lomalogue][lomalogue_site]
-Thanks to [Seth F.][thelizardreborn] for fixes
+Thanks to [Seth F.][thelizardreborn] for fixes and [Krzysiek Goj][goj] for the testQuery and prepareQuery option updates
[jquery_site]: http://www.jquery.com
[rik_site]: http://www.riklomas.co.uk
@@ -155,4 +155,5 @@ Thanks to [Seth F.][thelizardreborn] for fixes
[github_watch]: http://github.com/riklomas/quicksearch/toggle_watch
[github_follow]: http://github.com/users/follow?target=riklomas
[twitter_follow]: http://twitter.com/riklomas
-[thelizardreborn]: http://github.com/thelizardreborn
+[thelizardreborn]: http://github.com/thelizardreborn
+[goj]: http://github.com/goj
View
@@ -13,7 +13,7 @@
/*
Example 1
*/
- $('input#id_search').quicksearch('table#table_example tbody tr');
+ $('input#id_search').quicksearch('table tbody tr');
/*
Example 2
@@ -33,7 +33,7 @@
'prepareQuery': function (val) {
return new RegExp(val, "i");
},
- 'test': function (query, txt, _row) {
+ 'testQuery': function (query, txt, _row) {
return query.test(txt);
}
});
@@ -73,10 +73,10 @@ <h2 id="examples">Examples</h2>
<form action="#">
<fieldset>
- <input type="text" name="search" value="" id="id_search" />
+ <input type="text" name="search" value="" id="id_search" placeholder="Search" autofocus />
</fieldset>
</form>
-
+
<table id="table_example">
<thead>
<tr>
@@ -310,7 +310,7 @@ <h2 id="examples">Examples</h2>
$('input#id_search').quicksearch('table#table_example tbody tr');
</pre></code>
-<h3>Example with options &mdash; search with regexp, only on Email (which is selected by &lt;th&gt;)</h3>
+<h3>Example with options &mdash; search with email regexp on &lt;th&gt; only</h3>
<form action="#">
<fieldset>
@@ -563,7 +563,7 @@ <h2 id="examples">Examples</h2>
'prepareQuery': function (val) {
return new RegExp(val, "i");
},
- 'test': function (query, txt, _row) {
+ 'testQuery': function (query, txt, _row) {
return query.test(txt);
}
});
View
@@ -6,7 +6,7 @@ a { color: #005bd8; }
a:hover { text-decoration: none; }
.hr hr { display: none; }
form { margin: 10px 0; }
-table { width: 100%; border-collapse: collapse; }
+table { width: 100%; border-collapse: collapse; margin: 1em 0; }
thead th { background: #f34105; color: #fff; }
tbody th { text-align: left; }
table th, table td { border: 1px solid #ddd; padding: 2px 5px; font-size: 100%; }
View
@@ -21,15 +21,15 @@ jQuery(function ($) {
this.style.display = "none";
},
prepareQuery: function (val) {
- return val.toLowerCase().split(' ');
+ return val.toLowerCase().split(' ');
},
- test: function (query, txt, _row) {
- for (var i = 0; i < query.length; i += 1) {
- if (txt.indexOf(query[i]) === -1) {
- return false;
- }
- }
- return true;
+ testQuery: function (query, txt, _row) {
+ for (var i = 0; i < query.length; i += 1) {
+ if (txt.indexOf(query[i]) === -1) {
+ return false;
+ }
+ }
+ return true;
}
}, opt);
@@ -40,7 +40,7 @@ jQuery(function ($) {
var rowcache_length = rowcache.length;
for (var i = 0; i < rowcache_length; i++)
{
- if (options.test(query, cache[i], rowcache[i])) {
+ if (options.testQuery(query, cache[i], rowcache[i])) {
options.show.apply(rowcache[i]);
noresults = false;
} else {

0 comments on commit 841d5a8

Please sign in to comment.