Advertisement
Cornerstone

Untitled

Feb 3rd, 2016
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. //Single project gallery
  2.  
  3. $('.gallery-image').on('click', function(){
  4. var bigCurrent = $('.hero-image').attr('src'); //the current large image src
  5. var bigThumb = $('.hero-image').data('smsrc'); //the thumb version src of the current large image
  6. var thumbSm = $(this).attr('src'); //the currently being clicked on thumb's src
  7. var thumbLgSrc = $(this).data('lgsrc'); //the large version src of the currently being clicked on thumb
  8. var caption = $(this).data('caption');
  9.  
  10. $('.hero-image').attr('src', thumbLgSrc); //check the hero image src to the clicked-on thumb's large source data value
  11.  
  12. $('.selected').removeClass('selected'); //remove the selected class for all .gallery-image instances
  13.  
  14. $(this).addClass('selected'); //add the class back for the one we're clicking on
  15.  
  16. var caption = $(this).data('caption');
  17. if (caption) {
  18. //document.write(caption);
  19. $('.caption-overlay').addClass('show');
  20. $('.caption-overlay').removeClass('hide');
  21. $('.caption-overlay').html(caption);
  22.  
  23. } else {
  24. $('.caption-overlay').addClass('hide');
  25. $('.caption-overlay').removeClass('show');
  26. }
  27. });
  28.  
  29. //The shows and hides the left/right navigation arrows on hover
  30. $('.gallery-image').mouseenter(function(){
  31. $('.hovered').removeClass('hovered');
  32. $(this, 'img').addClass('hovered');
  33. });
  34. $('.gallery-image').mouseleave(function(){
  35. $('.hovered').removeClass('hovered');
  36. });
  37.  
  38. $('.single-hero').hover(function(){
  39. $('.hero-nav').fadeToggle('slow');
  40. });
  41.  
  42. //This advances to the next slide when the arrows are clicked (or previous slide)
  43. $('.hero-nav').click(function() {
  44. var dirClass = $(this).attr('class');
  45. var findPrev = dirClass.indexOf('prev');
  46. var loopCount = $('#loopCount').data('loopcount'); //the number of images in the whole gallery
  47.  
  48. var selected = parseInt($('.selected').data('thumbcnt')); //the selected image number
  49. if (findPrev != -1) { //they're clicking the prev button
  50. selected-=1;
  51. if (selected == 0) {
  52. selected = loopCount;
  53. }
  54. } else { //they're clicking the next button
  55. selected+=1;
  56. if (selected > loopCount) {
  57. selected = 1;
  58. }
  59. }
  60. var nextLgSrc = $('.gallery-image._'+selected).data('lgsrc');
  61. $('.hero-image').attr('src', nextLgSrc);
  62.  
  63. //document.write(selected);
  64. $('.selected').removeClass('selected');
  65. var nextNew = $('.gallery-image._'+selected);
  66. $(nextNew).addClass('selected');
  67.  
  68. var caption = $('.gallery-image.selected').data('caption');
  69. if (caption) {
  70. //document.write(caption);
  71. $('.caption-overlay').addClass('show');
  72. $('.caption-overlay').removeClass('hide');
  73. $('.caption-overlay').html = (caption);
  74.  
  75. } else {
  76. $('.caption-overlay').addClass('hide');
  77. $('.caption-overlay').removeClass('show');
  78.  
  79. }
  80. var caption = '';
  81. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement