Skip to content

Commit 972e0f4

Browse files
committed
Merge pull request EloquentStudio#80 from greg-raven/master
External asset updates
2 parents ba757fb + 03806f5 commit 972e0f4

20 files changed

Lines changed: 521 additions & 423 deletions

README.md

Lines changed: 33 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
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
118

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

1411
### Filter Initialisation
15-
-------------------------
1612

1713
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.
1814
Others are in options like criteria, callbacks, search.
@@ -28,8 +24,7 @@ var FJS = FilterJS(movies, '#movies', {
2824
});
2925
```
3026

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.
27+
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.
3328

3429
```javascript
3530

@@ -45,7 +40,6 @@ var FJS = FilterJS(movies, '#movies', {
4540
```
4641

4742
### JSON data
48-
-------------
4943

5044
Capture the JSON data (maybe using @movies.to_json). i.e
5145

@@ -74,10 +68,8 @@ Capture the JSON data (maybe using @movies.to_json). i.e
7468
```
7569

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

72+
Rendering JSON objects requires a view template. In filter.js micro-templating module inspired by Underscore.js.
8173

8274
```javascript
8375
<script id="movie-template" type="text/html">
@@ -108,17 +100,17 @@ To render each json object require view template. In filter.js micro-templating
108100
```
109101

110102
### Filter Criteria
111-
-------------------
112103

113-
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.
104+
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.
114105
Other options are filter `type`, `event` and `selector`.
106+
115107
- 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`.
116-
- `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`.
108+
- `delimiter`, by default hyphen '-' is used as range separator `val1-val2`. If you want to use a different separator (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`.
117109
- `event` by default for checkbox, radio button is `click`, for text input, select box is `change`.
118110
- `selector` by default for checkbox and radio button is `:checked`, for input field `input` and for select box is `select`.'#genre_criteria input:checkbox' will collect the checkboxes values in html element with `id="genre_criteria"`
119111
- `all` option : if selected values of specific filter criteria contains `all` option value then all record selected for that criteria.
120112

121-
There are two way to add criteria one is add at time of filter object initialisation and other one is add when required
113+
There are two way to add criteria. One is add at time of filter object initialisation and other is add when required.
122114

123115
```javascript
124116
//On create
@@ -139,7 +131,8 @@ There are two way to add criteria one is add at time of filter object initialisa
139131
```
140132
141133
**field**: `genre` this is a JSON attribute defined in JSON objects.
142-
For Range selections,
134+
135+
#### For Range selections
143136
144137
More detail for `range` filter. It is expected to set ranges as values like '20-30'
145138
@@ -151,7 +144,7 @@ More detail for `range` filter. It is expected to set ranges as values like '20-
151144
152145
For nested field selection. In below object to select filter on name `field` option value would be `detail.name`, for city `detail.address.city`.
153146
154-
Json object:
147+
JSON object:
155148
156149
```json
157150

@@ -168,24 +161,23 @@ Using `removeCriteria`, remove criteria dynamically. It take one argument `filed
168161
fjs.removeCriteria('year')
169162
```
170163
171-
### Filtering Callbacks
172-
-------------------
164+
#### Filtering Callbacks
173165
174166
Define callback in settings. Callbacks execute on different events.
175167
176168
- `beforeAddRecords` : Trigger before adding records to filter.
177169
- `afterAddRecords`
178170
- `beforeRender` : Trigger before rendering going to call.
179-
- `beforeRecordRender` : Trigger for each json object record at time of rendering.
171+
- `beforeRecordRender` : Trigger for each JSON object record at time of rendering.
180172
- `afterFilter` : Trigger after filtering event.
181173
182-
i.e
174+
i.e.,
183175
184176
```javascript
185177

186178
var filter_callbacks = {
187179
beforeAddRecords: function(records){
188-
// Process new json data records.
180+
// Process new JSON data records.
189181
// i.e Process data before adding to filter while streaming.
190182
},
191183
afterAddRecords: function(records){
@@ -203,7 +195,7 @@ i.e
203195
};
204196
```
205197
206-
Init Filter object with above callbacks
198+
#### Init Filter object with above callbacks
207199
208200
```javascript
209201

@@ -218,18 +210,16 @@ var fjs = FilterJS(movies, '#movies', {
218210
});
219211
```
220212
221-
222213
### Instant Search integration
223-
---------------------------
224214
225-
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.
215+
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.
226216
227217
```javascript
228218

229219
// Init with search
230220
FilterJS(movies, '#movies', {
231221
template: '#movie-template',
232-
search: {ele: '#searchbox'} // Search in all fields of json object.
222+
search: {ele: '#searchbox'} // Search in all fields of JSON object.
233223
}
234224

235225
// Search in given fields
@@ -251,11 +241,9 @@ Default search will start searching immediately after user types. A timeout can
251241
search: {ele: '#searchbox', fields: ['name', 'runtime'], timeout: 100 }
252242
```
253243
244+
## Add more data to existing filter
254245
255-
Add more data to existing filter
256-
--------------------------------
257-
258-
If you are streaming json data using ajax then you can add data like this
246+
If you are streaming JSON data using ajax then you can add data like this
259247
260248
```javascript
261249

@@ -264,9 +252,7 @@ var fjs = FilterJS(movies, '#movies', { template: '#movie-template'})
264252
fJS.addData(data)
265253
```
266254
267-
268-
Add data using ajax streaming
269-
-----------------------------
255+
### Add data using ajax streaming
270256
271257
Add streaming option to above define 'settings'.
272258
@@ -299,10 +285,9 @@ fjs.setStreaming({
299285
});
300286
```
301287
302-
Remove records from filtering
303-
-----------------------------
288+
## Remove records from filtering
304289
305-
- Remove using ids. ids are records `id` field.
290+
- Remove records using the record's `id` field.
306291
307292
```javascript
308293
fjs.removeRecords([1,2,3]);
@@ -313,55 +298,43 @@ fjs.removeRecords([1,2,3]);
313298
```javascript
314299
fjs.removeRecords({year: 1980});
315300

316-
fjs.removeRecords({'year.$gt': 1980, 'rating': 8.5});
301+
fjs.removeRecords({'year.$gt': 1980, 'rating': 8.5});
317302
```
318303
319-
### Build and Development
320-
-------------------------
304+
## Build and Development
321305
322306
- `npm install gulp -g`
323-
324307
- Install packages `npm install`
325-
326308
- To build `gulp build`
327-
328309
- For development `gulp`. This will start watch on files, also start webserver.
329310
330-
331-
### NOTE
332-
---------
311+
## Note
333312
334313
- Old filter.js in [v1.5.2](https://github.com/jiren/filter.js/tree/v1.5.2) git tag.
335314
315+
## Demo
336316
337-
Demo
338-
----
339317
To see the sample demo, clone this repo and open demo/filterjs.html in your browser
340318
341319
[Filter](http://jiren.github.io/filter.js/index.html)
342320
343-
344-
USED BY
345-
--------
321+
## Used by
346322
347323
[Tischefrei (search page)](http://tischefrei.de)
348324
349325
[Roboty przemysłowe](http://roboty-przemyslowe.pl)
350326
351327
If you use this, please send me an email, I shall add your link here!
352328
353-
354-
Sponsors and Supporters
355-
-----------------------
329+
## Sponsors and Supporters
356330
357331
- [Josh Software](http://www.joshsoftware.com)
358-
359332
- Instant search field filtering sponsored by [W/E consultants](http://www.w-e.nl)
360333
361-
Contributing
362-
------------
334+
## Contributing
335+
363336
Please send me a pull request so that this can be improved.
364337
365-
License
366-
-------
338+
## License
339+
367340
This is released under the MIT license.

examples/assets/css/bootstrap.min.css

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/assets/css/stream.css

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ select:focus, textarea:focus, input:focus{
4343
color: #808080;
4444
padding-left: 0px;
4545
/* border-bottom: 2px solid #e5e5e5;
46-
border-bottom: 2px solid #F08080;
46+
border-bottom: 2px solid #F08080;
4747
padding-bottom: 7px;
4848
*/
4949
}
@@ -76,7 +76,7 @@ select:focus, textarea:focus, input:focus{
7676

7777
.title{
7878
padding: 5px 0 ;
79-
/* color: #b94a48;
79+
/* color: #b94a48;
8080
color: #F08080;*/
8181
color: #D3D3D3;
8282
margin-left: 15px;
@@ -126,7 +126,7 @@ select:focus, textarea:focus, input:focus{
126126
.movie h4{
127127
margin-top: 15px;
128128
margin-bottom: -5px;
129-
border-bottom: 1px solid #A9A9A9;
129+
border-bottom: 1px solid #A9A9A9;
130130
padding-bottom: 7px;
131131
}
132132

@@ -147,20 +147,6 @@ select:focus, textarea:focus, input:focus{
147147
margin-top: 10px;
148148
}
149149

150-
.search-icon{
151-
position: relative;
152-
margin-top: -27px;
153-
display: inline-block;
154-
width: 28px;
155-
height: 14px;
156-
line-height: 14px;
157-
vertical-align: middle;
158-
background-color: transparent;
159-
font-size: 20px;
160-
color: #20B2AA;
161-
float: right;
162-
}
163-
164150
.collection{
165151
margin-right: 1px;
166152
}
@@ -206,14 +192,6 @@ select:focus, textarea:focus, input:focus{
206192
margin-right: 3px;
207193
}
208194

209-
.criteria h4{
210-
border-bottom: 1px solid #A9A9A9;
211-
padding-top: 10px;
212-
padding-bottom: 5px;
213-
margin: 10px;
214-
color: #808080;
215-
}
216-
217195
.ui-widget-header{
218196
background: none;
219197
background-color: #20B2AA;
@@ -233,12 +211,3 @@ select:focus, textarea:focus, input:focus{
233211
text-align: center;
234212
font-weight: 200;
235213
}
236-
237-
.criteria .checkbox{
238-
margin-left: 20px;
239-
}
240-
241-
.criteria select{
242-
margin-left: 10px;
243-
}
244-
19.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)