forked from EloquentStudio/filter.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
73 lines (64 loc) · 1.94 KB
/
Copy pathindex.js
File metadata and controls
73 lines (64 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
$(document).ready(function(){
initSliders();
var FJS = FilterJS(movies, '#movies', {
template: '#movie-template',
search: {ele: '#searchbox'},
pagination: {
container: '#pagination',
per_page: {
container: '#per_page'
}
},
//search: {ele: '#searchbox', fields: ['runtime']}, // With specific fields
callbacks: {
afterFilter: function(result){
$('#total_movies').text(result.length);
}
}
});
FJS.addCallback('beforeAddRecords', function(){
if(this.recordsCount >= 450){
this.stopStreaming();
}
});
FJS.addCriteria({field: 'year', ele: '#year_filter', type: 'range'});
FJS.addCriteria({field: 'rating', ele: '#rating_filter', type: 'range'});
FJS.addCriteria({field: 'runtime', ele: '#runtime_filter', type: 'range'});
FJS.addCriteria({field: 'genre', ele: '#genre_criteria input:checkbox'});
/*
* Add multiple criterial.
FJS.addCriteria([
{field: 'genre', ele: '#genre_criteria input:checkbox'},
{field: 'year', ele: '#year_filter', type: 'range'}
])
*/
window.FJS = FJS;
});
function initSliders(){
$("#rating_slider").slider({
min: 8,
max: 10,
values:[8, 10],
step: 0.1,
range:true,
slide: function( event, ui ) {
$("#rating_range_label" ).html(ui.values[ 0 ] + ' - ' + ui.values[ 1 ]);
$('#rating_filter').val(ui.values[0] + '-' + ui.values[1]).trigger('change');
}
});
$("#runtime_slider").slider({
min: 50,
max: 250,
values:[0, 250],
step: 10,
range:true,
slide: function( event, ui ) {
$("#runtime_range_label" ).html(ui.values[ 0 ] + ' mins. - ' + ui.values[ 1 ] + ' mins.');
$('#runtime_filter').val(ui.values[0] + '-' + ui.values[1]).trigger('change');
}
});
$('#genre_criteria :checkbox').prop('checked', true);
$('#all_genre').on('click', function(){
$('#genre_criteria :checkbox').prop('checked', $(this).is(':checked'));
});
}