home *** CD-ROM | disk | FTP | other *** search
/ Rock County Sheriff's Off…nternet Safety Initative / Rock County Sher.iso / pc / js / jquery.isotope.run.js < prev    next >
Encoding:
JavaScript  |  2012-09-13  |  2.3 KB  |  91 lines

  1. /* Portfolio Sorting */
  2.  
  3. jQuery(document).ready(function () { 
  4.     (function ($) { 
  5.         var container = $('section.portfolio_container');
  6.         
  7.         container.isotope( { 
  8.             itemSelector : 'article.portfolio', 
  9.             layoutMode : 'fitRows', 
  10.             resizable : false, 
  11.             getSortData : { 
  12.                 p_name : function (el) { 
  13.                     return el.find('.entry-title>a').text();
  14.                 }, 
  15.                 p_date : function (el) { 
  16.                     return parseInt(el.find('.meta-date').text());
  17.                 } 
  18.             } 
  19.         } );
  20.         
  21.         $('.pj_sort .p_filter a').click(function () { 
  22.             var selector = $(this).attr('data-filter'), 
  23.                 text = $(this).text(), 
  24.                 filter_el = $(this).parent().parent().parent().find('.p_cat_filter');
  25.             
  26.             $(this).parent().parent().find('>li.current').removeClass('current');
  27.             $(this).parent().addClass('current');
  28.             
  29.             filter_el.attr( { 
  30.                 title : text, 
  31.                 'data-filter' : selector 
  32.             } ).find('>span>span').text(text);
  33.             
  34.             container.isotope( { filter : selector } );
  35.             
  36.             return false;
  37.         } );
  38.         
  39.         $('.pj_sort .p_sort a').click(function () { 
  40.             var type = $(this).attr('name'), 
  41.                 asc = (type === 'p_name') ? true : false, 
  42.                 current = ($(this).hasClass('current')) ? true : false, 
  43.                 reversed = ($(this).hasClass('reversed')) ? true : false;
  44.             
  45.             if (current) { 
  46.                 if (reversed) { 
  47.                     $(this).removeClass('reversed');
  48.                     
  49.                     asc = true;
  50.                 } else { 
  51.                     $(this).addClass('reversed');
  52.                     
  53.                     asc = false;
  54.                 }
  55.             } else { 
  56.                 $(this).parent().find('.current').removeClass('current');
  57.                 $(this).parent().find('.reversed').removeClass('reversed');
  58.                 
  59.                 if (type === 'p_name') { 
  60.                     $(this).addClass('current');
  61.                 } else { 
  62.                     $(this).addClass('current reversed');
  63.                 }
  64.             }
  65.             
  66.             container.isotope( { 
  67.                 sortBy : type, 
  68.                 sortAscending : asc 
  69.             } );
  70.             
  71.             return false;
  72.         } );
  73.         
  74.         $(window).smartresize(function () { 
  75.             var postWidth = container.width();
  76.             
  77.             if (container.hasClass('four_blocks')) { 
  78.                 postWidth = container.width() / 4;
  79.             } else if (container.hasClass('three_blocks')) { 
  80.                 postWidth = container.width() / 3;
  81.             } else if (container.hasClass('two_blocks')) { 
  82.                 postWidth = container.width() / 2;
  83.             }
  84.             
  85.             container.isotope( { 
  86.                 fitRows : { columnWidth : postWidth } 
  87.             } );
  88.         } );
  89.     } )(jQuery);
  90. } );
  91.