Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* --------------------------------------------------------
- Portfolio
- -------------------------------------------------------- */
- (function() {
- $(window).load(function(){
- // container
- var $container = $('#portfolio-items');
- function filter_projects(tag)
- {
- // filter projects
- $container.isotope({ filter: tag });
- // clear active class
- $('#portfolio-filter li.active').removeClass('active');
- // add active class to filter selector
- $('#portfolio-filter').find("[data-filter='" + tag + "']").parent().addClass('active');
- // update location hash
- if (tag!='*')
- window.location.hash=tag.replace('.','');
- if (tag=='*')
- window.location.hash='';
- }
- if ($container.length) {
- // conver data-tags to classes
- $('.project').each(function(){
- $this = $(this);
- var tags = $this.data('tags');
- if (tags) {
- var classes = tags.split(',');
- for (var i = classes.length - 1; i >= 0; i--) {
- $this.addClass(classes[i]);
- };
- }
- })
- // initialize isotope
- $container.isotope({
- // options...
- itemSelector : '.project',
- layoutMode : 'fitRows'
- });
- // filter items
- $('#portfolio-filter li a').click(function(){
- var selector = $(this).attr('data-filter');
- filter_projects(selector);
- return false;
- });
- // filter tags if location.has is available. e.g. http://example.com/work.html#design will filter projects within this category
- if (window.location.hash!='')
- {
- filter_projects( '.' + window.location.hash.replace('#','') );
- }
- filter_projects('web');
- }
- })
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement