Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Single project gallery
- $('.gallery-image').on('click', function(){
- var bigCurrent = $('.hero-image').attr('src'); //the current large image src
- var bigThumb = $('.hero-image').data('smsrc'); //the thumb version src of the current large image
- var thumbSm = $(this).attr('src'); //the currently being clicked on thumb's src
- var thumbLgSrc = $(this).data('lgsrc'); //the large version src of the currently being clicked on thumb
- var caption = $(this).data('caption');
- $('.hero-image').attr('src', thumbLgSrc); //check the hero image src to the clicked-on thumb's large source data value
- $('.selected').removeClass('selected'); //remove the selected class for all .gallery-image instances
- $(this).addClass('selected'); //add the class back for the one we're clicking on
- var caption = $(this).data('caption');
- if (caption) {
- //document.write(caption);
- $('.caption-overlay').addClass('show');
- $('.caption-overlay').removeClass('hide');
- $('.caption-overlay').html(caption);
- } else {
- $('.caption-overlay').addClass('hide');
- $('.caption-overlay').removeClass('show');
- }
- });
- //The shows and hides the left/right navigation arrows on hover
- $('.gallery-image').mouseenter(function(){
- $('.hovered').removeClass('hovered');
- $(this, 'img').addClass('hovered');
- });
- $('.gallery-image').mouseleave(function(){
- $('.hovered').removeClass('hovered');
- });
- $('.single-hero').hover(function(){
- $('.hero-nav').fadeToggle('slow');
- });
- //This advances to the next slide when the arrows are clicked (or previous slide)
- $('.hero-nav').click(function() {
- var dirClass = $(this).attr('class');
- var findPrev = dirClass.indexOf('prev');
- var loopCount = $('#loopCount').data('loopcount'); //the number of images in the whole gallery
- var selected = parseInt($('.selected').data('thumbcnt')); //the selected image number
- if (findPrev != -1) { //they're clicking the prev button
- selected-=1;
- if (selected == 0) {
- selected = loopCount;
- }
- } else { //they're clicking the next button
- selected+=1;
- if (selected > loopCount) {
- selected = 1;
- }
- }
- var nextLgSrc = $('.gallery-image._'+selected).data('lgsrc');
- $('.hero-image').attr('src', nextLgSrc);
- //document.write(selected);
- $('.selected').removeClass('selected');
- var nextNew = $('.gallery-image._'+selected);
- $(nextNew).addClass('selected');
- var caption = $('.gallery-image.selected').data('caption');
- if (caption) {
- //document.write(caption);
- $('.caption-overlay').addClass('show');
- $('.caption-overlay').removeClass('hide');
- $('.caption-overlay').html = (caption);
- } else {
- $('.caption-overlay').addClass('hide');
- $('.caption-overlay').removeClass('show');
- }
- var caption = '';
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement