Advertisement
Guest User

Filterjs.js

a guest
Sep 14th, 2012
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var fJS;
  2. jQuery(document).ready(function($) {
  3.  
  4.    $('#category_all, #nonprofit_all, #price_all').closest('ul').children().find(':checkbox').attr('checked', true);
  5.  
  6.    $('#category_all, #nonprofit_all, #price_all').click(function(){
  7.      $(this).closest('ul').children().find(':checkbox').attr('checked', $(this).is(':checked'));
  8.    });
  9.    fJS = filterInit();
  10. });
  11.  
  12.  
  13. function filterInit(){
  14. var view = function(event_detail){
  15.    clear     = this.div({'class': 'clear'});
  16.    title   = this.div({'class': 'title'}, event_detail.name);
  17.    date    = this.div({'class': 'dates'}, event_detail.date_start);
  18.    event_list  = this.div({'class' : 'event_list'} , [title, date, clear]);
  19.    return this.link('/demo/' + event_detail.event_id ,{'title': event_detail.name}, event_list);
  20.    
  21.   };
  22.  
  23.  
  24.   var filter_callbacks = {
  25.     logger: function(result){
  26.         console.log(result);
  27.     },
  28.  
  29.     show_result_count: function(result){
  30.         $('.result_count').text('Found : ' + result.length);
  31.     },
  32.                      
  33.     tiny_sort: function() {
  34.        $('a[data-fjs]').tsort('.fs_head:visible', {order: 'asc'})
  35.     }
  36.            
  37.   };
  38.  
  39.   var settings = {
  40.       filter_criteria: {
  41.           category: ['#category_list input:checkbox .EVENT.click .SELECT.:checked', 'category_id'],
  42.          
  43.           },
  44.        search: {input: '#search_box' },
  45.        and_filter_on: true, //If any filter selection is zero then select none. For 'OR' filter set 'false'
  46.        callbacks: filter_callbacks //Filter callback execute in filter init and each filtering event.
  47.   };
  48.  
  49.  
  50.  
  51.     return FilterJS(events, "#event_listing", view, settings);
  52.  
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement