Skip to content

Commit 3ac7edf

Browse files
author
Greg Raven
committed
Minor edits
Fix a typo, and normalize the styling.
1 parent ba757fb commit 3ac7edf

2 files changed

Lines changed: 38 additions & 64 deletions

File tree

README.md

Lines changed: 32 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
Filter.js
2-
=============
1+
# Filter.js
32

43
Filter.js is client-side JSON objects filter and render html elements.
54
Multiple filter criteria can be specified and used in conjunction with
65
each other.
76

8-
9-
Usage
10-
-----
7+
## Usage
8+
***
119

1210
Basic requirement to implement filtering using filter.js are JSON data, View template and filter criteria.
1311

1412
### Filter Initialisation
15-
-------------------------
1613

1714
It takes three arguments one is movies, second is container in which html element going to append, third one is options. Options must have template element selector.
1815
Others are in options like criteria, callbacks, search.
@@ -28,8 +25,7 @@ var FJS = FilterJS(movies, '#movies', {
2825
});
2926
```
3027

31-
To append in each item in different container use option `appendToContainer`. This option is a function with two arguments
32-
one is html element content and second is record object.
28+
To append in each item in different container use option `appendToContainer`. This option is a function with two arguments, one is html element content and second is record object.
3329

3430
```javascript
3531

@@ -45,7 +41,6 @@ var FJS = FilterJS(movies, '#movies', {
4541
```
4642

4743
### JSON data
48-
-------------
4944

5045
Capture the JSON data (maybe using @movies.to_json). i.e
5146

@@ -74,10 +69,8 @@ Capture the JSON data (maybe using @movies.to_json). i.e
7469
```
7570

7671
### View
77-
--------
78-
79-
To render each json object require view template. In filter.js micro-templating module inspired by Underscopre.js.
8072

73+
To render each json object require view template. In filter.js micro-templating module inspired by Underscore.js.
8174

8275
```javascript
8376
<script id="movie-template" type="text/html">
@@ -108,10 +101,10 @@ To render each json object require view template. In filter.js micro-templating
108101
```
109102

110103
### Filter Criteria
111-
-------------------
112104

113105
It required two mandatory options are `field` which is name of any property from json data and other is HTML `ele` element on which filter will be trigger by click,change etc events.
114106
Other options are filter `type`, `event` and `selector`.
107+
115108
- filter `type`, by default it is equal but if you want to search in range you can set it `range`. For `range` html element value should be in format of `val1-val2`. i.e `100-200`.
116109
- `delimiter`, by default hyphen '-' is used as range seperator `val1-val2`. If you want to use a different seperator (if data contains hyphen e.g: ' 2012-02-02 ') it can be specified using `delimiter: ','` and html element value should be in format `val1<delimiter>val2`. i.e.`2012-02-02,2015-02-02`.
117110
- `event` by default for checkbox, radio button is `click`, for text input, select box is `change`.
@@ -139,7 +132,8 @@ There are two way to add criteria one is add at time of filter object initialisa
139132
```
140133
141134
**field**: `genre` this is a JSON attribute defined in JSON objects.
142-
For Range selections,
135+
136+
#### For Range selections
143137
144138
More detail for `range` filter. It is expected to set ranges as values like '20-30'
145139
@@ -168,8 +162,7 @@ Using `removeCriteria`, remove criteria dynamically. It take one argument `filed
168162
fjs.removeCriteria('year')
169163
```
170164
171-
### Filtering Callbacks
172-
-------------------
165+
#### Filtering Callbacks
173166
174167
Define callback in settings. Callbacks execute on different events.
175168
@@ -179,7 +172,7 @@ Define callback in settings. Callbacks execute on different events.
179172
- `beforeRecordRender` : Trigger for each json object record at time of rendering.
180173
- `afterFilter` : Trigger after filtering event.
181174
182-
i.e
175+
i.e.,
183176
184177
```javascript
185178

@@ -203,7 +196,7 @@ i.e
203196
};
204197
```
205198
206-
Init Filter object with above callbacks
199+
#### Init Filter object with above callbacks
207200
208201
```javascript
209202

@@ -218,9 +211,7 @@ var fjs = FilterJS(movies, '#movies', {
218211
});
219212
```
220213
221-
222214
### Instant Search integration
223-
---------------------------
224215
225216
For search needed textbox element selector. By default search will work on all json object fields. If needed search in particular fields then set `fields` option.
226217
@@ -251,10 +242,8 @@ Default search will start searching immediately after user types. A timeout can
251242
search: {ele: '#searchbox', fields: ['name', 'runtime'], timeout: 100 }
252243
```
253244
254-
255-
Add more data to existing filter
256-
--------------------------------
257-
245+
## Add more data to existing filter
246+
***
258247
If you are streaming json data using ajax then you can add data like this
259248
260249
```javascript
@@ -264,9 +253,7 @@ var fjs = FilterJS(movies, '#movies', { template: '#movie-template'})
264253
fJS.addData(data)
265254
```
266255
267-
268-
Add data using ajax streaming
269-
-----------------------------
256+
### Add data using ajax streaming
270257
271258
Add streaming option to above define 'settings'.
272259
@@ -299,10 +286,9 @@ fjs.setStreaming({
299286
});
300287
```
301288
302-
Remove records from filtering
303-
-----------------------------
304-
305-
- Remove using ids. ids are records `id` field.
289+
## Remove records from filtering
290+
***
291+
- Remove records using the record's `id` field.
306292
307293
```javascript
308294
fjs.removeRecords([1,2,3]);
@@ -313,55 +299,43 @@ fjs.removeRecords([1,2,3]);
313299
```javascript
314300
fjs.removeRecords({year: 1980});
315301

316-
fjs.removeRecords({'year.$gt': 1980, 'rating': 8.5});
302+
fjs.removeRecords({'year.$gt': 1980, 'rating': 8.5});
317303
```
318304
319-
### Build and Development
320-
-------------------------
321-
305+
## Build and Development
306+
***
322307
- `npm install gulp -g`
323-
324308
- Install packages `npm install`
325-
326309
- To build `gulp build`
327-
328310
- For development `gulp`. This will start watch on files, also start webserver.
329311
330-
331-
### NOTE
332-
---------
333-
312+
## Note
313+
***
334314
- Old filter.js in [v1.5.2](https://github.com/jiren/filter.js/tree/v1.5.2) git tag.
335315
336-
337-
Demo
338-
----
316+
## Demo
317+
***
339318
To see the sample demo, clone this repo and open demo/filterjs.html in your browser
340319
341320
[Filter](http://jiren.github.io/filter.js/index.html)
342321
343-
344-
USED BY
345-
--------
346-
322+
## Used by
323+
***
347324
[Tischefrei (search page)](http://tischefrei.de)
348325
349326
[Roboty przemysłowe](http://roboty-przemyslowe.pl)
350327
351328
If you use this, please send me an email, I shall add your link here!
352329
353-
354-
Sponsors and Supporters
355-
-----------------------
356-
330+
## Sponsors and Supporters
331+
***
357332
- [Josh Software](http://www.joshsoftware.com)
358-
359333
- Instant search field filtering sponsored by [W/E consultants](http://www.w-e.nl)
360334
361-
Contributing
362-
------------
335+
## Contributing
336+
***
363337
Please send me a pull request so that this can be improved.
364338
365-
License
366-
-------
339+
## License
340+
***
367341
This is released under the MIT license.

examples/basic.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<!DOCTYPE HTML>
2-
<html xmlns="http://www.w3.org/1999/xhtml">
1+
<!DOCTYPE html>
2+
<html lang="en">
33
<head>
4-
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
4+
<meta charset="UTF-8">
55
<link href="assets/css/jquery-ui-1.10.2.custom.min.css" media="screen" rel="stylesheet" type="text/css">
66
<script src="assets/js/jquery-1.11.1.min.js" type="text/javascript"></script>
77
<script src="assets/js/jquery-ui-1.10.2.custom.min.js" type="text/javascript"></script>
@@ -17,15 +17,15 @@
1717
<div class="sidebar_left_find">
1818
<div class="sidebar_list">
1919
<h3>Search</h3>
20-
<input type="text" id="search_box" class="searchbox" placeholder="Type here...."/>
20+
<input type="text" id="search_box" class="searchbox" placeholder="Type here &hellip;" />
2121
</div>
2222
</div>
2323
<div class="sidebar_left_find">
2424
<div class="sidebar_list">
2525
<h3>Filter by Price</h3>
2626
<span id="price_range_label" style="margin:50px;">$0-$500</span>
2727
<div id="price_slider"></div>
28-
<input type="hidden" id="price_filter" value="100-500"/>
28+
<input type="hidden" id="price_filter" value="100-500" />
2929
</div>
3030
</div>
3131
<div class="sidebar_left_find">
@@ -40,7 +40,7 @@ <h3>Filter by Status</h3>
4040
<input id="inactive" value="inactive" type="checkbox">
4141
<span>Inactive</span>
4242
</li>
43-
<ul>
43+
</ul>
4444
</div>
4545
</div>
4646
</div>

0 commit comments

Comments
 (0)