gagiD

Galerija

Jun 17th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready( function() {
  2.     $("#categories>div>img").click( function() {
  3.  
  4.         $('#frame-big-image').show();
  5.         $('#big-image').show();
  6.  
  7.         var imgID = $(this).attr('id');
  8.         var parentID = $(this).parent().attr('id');
  9.         var source = $(this).attr('src');
  10.         var alter = $(this).attr('alt');
  11.         var counter = $('#'+imgID).index();
  12.  
  13.         var max = $("#"+parentID).children().length - 1;
  14.  
  15.         $('#big-image').prepend("<img src="+source+" alt="+alter+">");
  16.  
  17.         $('#big-image').mouseenter( function() {
  18.             $('#close').fadeIn('fast');
  19.             $('#nav-left').fadeIn('fast');
  20.             $('#nav-right').fadeIn('fast');
  21.  
  22.             $('#close').click( function() {
  23.                 $('#close').fadeOut('fast');
  24.                 $('#nav-left').fadeOut('fast');
  25.                 $('#nav-right').fadeOut('fast');
  26.                 $('#frame-big-image').fadeOut('fast');
  27.                 $('#big-image').fadeOut('fast');
  28.                 $('#big-image>img').remove();
  29.             });
  30.  
  31.             $('#nav-left').click( function() {
  32.                 $('#big-image>img').remove();
  33.                 if ( counter == 0 ) counter = max;
  34.                 else counter--;
  35.                 var sourceL = $("#"+parentID+">img").eq(counter).attr('src');
  36.                 var alterL  = $("#"+parentID+">img").eq(counter).attr('alt');
  37.                
  38.                 $('#big-image').prepend("<img src="+sourceL+" alt="+alterL+">");
  39.             });
  40.  
  41.             $('#nav-right').click( function() {
  42.                 $('#big-image>img').remove();
  43.                 if ( counter == max ) counter = 0;
  44.                 else counter++;
  45.                 var sourceR = $("#"+parentID+">img").eq(counter).attr('src');
  46.                 var alterR  = $("#"+parentID+">img").eq(counter).attr('alt');
  47.                
  48.                 $('#big-image').prepend("<img src="+sourceR+" alt="+alterR+">");
  49.             });
  50.         })
  51.         .mouseleave(function() {
  52.             $('#close').fadeOut('fast');
  53.             $('#nav-left').fadeOut('fast');
  54.             $('#nav-right').fadeOut('fast');
  55.         });
  56.     });
  57. });
Advertisement
Add Comment
Please, Sign In to add comment