;(function($) { $.fn.Gridder = function(options) { var gridder = $('
'); var gridderclose = $('
'); var gridderprev = $(''); var griddernext = $(''); gridder.append(gridderclose,gridderprev,griddernext); return this.each(function() { $('.gridder-list').click(function(e) { e.preventDefault(); $('.gridder-show .content').remove(); $('.gridder-show .image').remove(); $('.gridder-thumb').removeClass("gridctive"); var currentcontent = $(this).find('.gridder-content').html(); var currentimage = $(this).find('.gridder-image').html(); if ($(this).next().hasClass('gridder-show')) { gridder.toggle(); if($(this).hasClass('imactive')){ $(this).removeClass('imactive'); }else{$(this).addClass('imactive');} $('.gridder-show').append("
"+currentimage+"
"); $('.gridder-show').append("
"+currentcontent+"
"); } else { /* Adds the Expander bloc*/ mybloc = gridder.insertAfter(this).css('display', 'block'); $('.gridder-show').append("
"+currentimage+"
"); $('.gridder-show').append("
"+currentcontent+"
"); /* Make sure the correct bloc is active*/ if(!$(this).hasClass('imactive')){ $('.imactive').removeClass('imactive'); $(this).addClass("imactive"); $('.gridder-thumb').removeClass("gridctive"); $(this).find('.gridder-thumb').addClass("gridctive"); } /* ANIMATION */ $('.image').animate({ opacity: 0}, 0); $('.gridder-show').animate({ height: 'auto' }, { easing: 'swing', duration: 300, complete: function(){ $('.image').animate({ opacity: 1 }, { easing: 'swing', duration: 500, complete: function(){ } }); } }); } /* Scrolls to the current row $('html, body').animate({ scrollTop: $(this).position().top }, 0);*/ }); /* Close */ $('.gridder').on('click', '.gridder-close', function() { $('.imactive').removeClass('imactive'); $('.gridder-show .content').remove(); $('.gridder-show .image').remove(); $('.gridder-show').remove(); $('.gridder-thumb').removeClass("gridctive"); }); }); }; })(jQuery);