Debian Codegraph @

README.md

raw symbols SCIP
1 # jQuery quicksearch plug-in
2
3 A [jQuery][jquery_site] based plug-in for filtering large data sets with user input
4
5 This is an improved fork of the original work of riklomas <https://github.com/riklomas/quicksearch>.
6 This plugin is now maintained by [@DeuxHuitHuit][288]
7
8 ## Project pages
9
10 * <http://deuxhuithuit.github.io/quicksearch/>
11 * <http://plugins.jquery.com/jquery.quicksearch/>
12
13 ## Examples
14
15 * <http://deuxhuithuit.github.io/quicksearch/r/examples/>
16 * <http://deuxhuithuit.github.io/quicksearch/r/examples/super_table.html>
17
18 ## Usage
19
20 Note that the usage has changed in the latest version of quicksearch, the code is *not* backwards compatible,
21 the form and input are not build by the script any more.
22 ```js
23 $(input_selector).quicksearch(elements_to_search, options);
24 ```
25
26 #### Example on table rows
27 ```html
28 /* Example form */
29 <form>
30 <input type="text" id="search">
31 </form>
32
33 /* Example table */
34 <table>
35 <tbody>
36 <tr>
37 <td>Test cell</td>
38 <td>Another test cell</td>
39 </tr>
40 </tbody>
41 </table>
42
43 <script src="jquery.js"></script>
44 <script src="jquery.quicksearch.js"></script>
45 <script>
46 $('input#search').quicksearch('table tbody tr');
47 </script>
48 ```
49
50 #### Example on the `<th>` elements on a table row
51 ```js
52 $('input#search').quicksearch('table tbody tr', {
53 selector: 'th'
54 });
55 ```
56 #### Example of how to use with JS
57 ```js
58 var qs = $('input#id_search_list').quicksearch('ul#list_example li');
59 $('ul#list_example').append('<li>Loaded with Ajax</li>');
60 qs.cache();
61 ```
62 #### Example of how to use with Ajax
63 ```js
64 var qs = $('input#search').quicksearch('table tbody tr');
65 $.ajax({
66 'type': 'GET',
67 'url': 'index.html',
68 'success': function (data) {
69 $('table tbody tr').append(data);
70 qs.cache();
71 }
72 });
73 ```
74
75 ## Options
76
77 * **delay**
78 Delay of trigger in milliseconds
79 * **selector**
80 A query selector on sibling elements to test
81 * **stripeRows**
82 An array of class names to go on each row
83 * **loader**
84 A query selector to find a loading element
85 * **noResults**
86 A query selector to show if there's no results for the search
87 * **bind**
88 Event that the trigger is tied to. Defaults to 'keyup search'
89 * **resetBind**
90 Event that the reset event is tied to. Defaults to 'reset'
91 * **removeDiacritics**
92 Remove diacritics from the search input. Defaults to false.
93 * **minValLength**
94 Establish a minimum length that the search value must have in order to perform the search. Defaults to 0.
95 * **onBefore**
96 Function to call before trigger is called
97 * **onAfter**
98 Function to call after trigger is called
99 * **onValTooSmall**
100 Function to call when the value does not exceeds the `minValLength` option.
101 * **show**
102 Function that will add styles to matched elements
103 * **hide**
104 Function that will add styles to unmatched elements
105 * **prepareQuery**
106 Function that transforms text from input_selector into query used by 'testQuery' function
107 * **testQuery**
108 Function that tells if a given item should be hidden
109 It takes 3 arguments:
110 - query prepared by 'prepareQuery'
111 - stripped text from 'selector'
112 - element to be potentially hidden
113
114 ### Callbacks
115 Functions are always `call`'d or `apply`'d, so except `this` to be the plugin object.
116
117 For example:
118 ```js
119 $('input#search').quicksearch('table tbody tr', {
120 'delay': 100,
121 'selector': 'th',
122 'stripeRows': ['odd', 'even'],
123 'loader': 'span.loading',
124 'noResults': 'tr#noresults',
125 'bind': 'keyup keydown',
126 'minValLength': 2,
127 'removeDiacritics': true,
128 'onBefore': function () {
129 console.log('on before');
130 },
131 'onAfter': function () {
132 console.log('on after');
133 },
134 'onValTooSmall': function (val) {
135 console.log('value ' + val + ' is too small');
136 },
137 'show': function () {
138 $(this).addClass('show');
139 },
140 'hide': function () {
141 $(this).removeClass('show');
142 }
143 'prepareQuery': function (val) {
144 return new RegExp(val, "i");
145 },
146 'testQuery': function (query, txt, _row) {
147 return query.test(txt);
148 }
149 });
150 ```
151 ## Help make quicksearch better!
152
153 If you have a bug fix, the best way to help would be to:
154
155 * Fork the project by clicking "Fork this project" at the top of this page
156 * Clone your version of quicksearch from your Github account to your computer
157 * Fix and commit the bugs, then push your version to your Github account
158 * Click "pull request" at the top of my Github page
159
160 I can't promise to answer every question about quicksearch,
161 but please do [report bugs here][issues].
162
163 ## License
164
165 Now licensed under the MIT License: <http://deuxhuithuit.mit-license.org>
166
167 ## Credits
168
169 jQuery quicksearch was made by [Rik Lomas][rik_site] at [Lomalogue][lomalogue_site].
170 It is now maintain by [Deux Huit Huit][288]
171
172 Thanks to [Seth F.][thelizardreborn] for fixes and [Krzysiek Goj][goj] for the testQuery and prepareQuery option updates
173
174 [jquery_site]: http://www.jquery.com
175 [rik_site]: http://www.riklomas.co.uk
176 [lomalogue_site]: http://www.lomalogue.com
177 [issues]: http://github.com/deuxhuithuit/quicksearch/issues
178 [thelizardreborn]: http://github.com/thelizardreborn
179 [goj]: http://github.com/goj
180 [288]: http://deuxhuithuit.com/