Advertisement
Guest User

Untitled

a guest
Nov 16th, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* --------------------------------------------------------
  2.     Portfolio
  3.    -------------------------------------------------------- */ 
  4.  
  5.    (function() {
  6.  
  7.         $(window).load(function(){
  8.  
  9.             // container
  10.             var $container = $('#portfolio-items');
  11.  
  12.             function filter_projects(tag)
  13.             {
  14.               // filter projects
  15.               $container.isotope({ filter: tag });
  16.               // clear active class
  17.               $('#portfolio-filter li.active').removeClass('active');
  18.               // add active class to filter selector
  19.               $('#portfolio-filter').find("[data-filter='" + tag + "']").parent().addClass('active');
  20.               // update location hash
  21.               if (tag!='*')
  22.                 window.location.hash=tag.replace('.','');
  23.               if (tag=='*')
  24.                 window.location.hash='';
  25.             }
  26.  
  27.             if ($container.length) {
  28.  
  29.                 // conver data-tags to classes
  30.                 $('.project').each(function(){
  31.                     $this = $(this);
  32.                     var tags = $this.data('tags');
  33.                     if (tags) {
  34.                         var classes = tags.split(',');
  35.                         for (var i = classes.length - 1; i >= 0; i--) {
  36.                             $this.addClass(classes[i]);
  37.                         };
  38.                     }
  39.                 })
  40.  
  41.                 // initialize isotope
  42.                 $container.isotope({
  43.                   // options...
  44.                   itemSelector : '.project',
  45.                   layoutMode   : 'fitRows'
  46.                 });
  47.  
  48.                 // filter items
  49.                 $('#portfolio-filter li a').click(function(){
  50.                     var selector = $(this).attr('data-filter');
  51.                     filter_projects(selector);
  52.                     return false;
  53.                 });
  54.  
  55.                 // filter tags if location.has is available. e.g. http://example.com/work.html#design will filter projects within this category
  56.                 if (window.location.hash!='')
  57.                 {
  58.                     filter_projects( '.' + window.location.hash.replace('#','') );
  59.                 }
  60.  
  61.                 filter_projects('web');
  62.  
  63.             }
  64.         })
  65.  
  66.     })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement