-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheasyFilter.jquery.js
More file actions
43 lines (31 loc) · 912 Bytes
/
easyFilter.jquery.js
File metadata and controls
43 lines (31 loc) · 912 Bytes
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
(function( $ ){
$.fn.easyFilter = function( options ) {
// Create some defaults, extending them with any options that were provided
var settings = $.extend( {
'items' : '',
'filter' : '',
'filterItem' : ''
}, options);
return this.each(function() {
$(settings.filterItem).click(function() {
$(this).css('outline','none');
var cur = settings.filterItem + '.current';
$(cur).removeClass('current');
$(this).addClass('current');
var filterVal = $(this).attr('rel');
if(filterVal == 'all') {
$(settings.items).fadeIn('slow').removeClass('hidden');
} else {
$(settings.items).each(function() {
if(!$(this).hasClass(filterVal)) {
$(this).fadeOut('normal').addClass('hidden');
} else {
$(this).fadeIn('slow').removeClass('hidden');
}
});
}
return false;
});
});
};
})( jQuery );