1jQuery(function($){ 2 'use strict'; 3 4 $('[data-gallery]').each(function(){ 5 var _this = $(this); 6 var gallery = $('#' + $(this).attr('data-gallery')); 7 var images = $(this).find('.gallery-image'); 8 var slider, currentItem = 0; 9 var opened = false; 10 11 $(document.body).append( gallery ); 12 13 _this.find('[data-gallery-item]').on('click', function(){ 14 var _this = $(this); 15 var image = $(this).find('img.gimg').eq(0); 16 17 slider = $(document.createElement('div')).addClass('slider'); 18 gallery.append(slider); 19 currentItem = 0; 20 21 // Open gallery 22 23 var cloneImg = image.clone().css({ 24 'height': image.outerHeight()+'px', 25 'top': image.offset().top - $(window).scrollTop(), 26 'left': image.offset().left, 27 }).addClass('gallery-tmpimage'); 28 29 $(document.body).append(cloneImg); 30 opened = true; 31 gallery.addClass('open'); 32 33 34 // Generated slider 35 36 images.each(function(){ 37 var div = $(document.createElement('div')); 38 div.append($(this).find('img.gimg').eq(0).clone()); 39 if($(this).find('.gallery-description').length){ 40 div.append($(this).find('.gallery-description').clone()); 41 div.addClass('with-description'); 42 } 43 slider.append(div); 44 }); 45 46 slider.owlCarousel({ 47 items: 1, 48 autoHeight: true, 49 slideBy: 1, 50 nav: true, 51 navText: [ '<span class="ion-ios-arrow-left"></span>', '<span class="ion-ios-arrow-right"></span>' ], 52 dots: false, 53 loop: false, 54 autoplay: false, 55 navSpeed: 600, 56 }).on('changed.owl.carousel', function(event) { 57 currentItem = event.item.index; 58 slider.find('.thumbs img').removeClass('active'); 59 slider.find('.thumbs img').eq(currentItem).addClass('active'); 60 }); 61 62 slider.trigger('to.owl.carousel', [parseInt($(this).attr('data-gallery-item')), 50, true]); 63 64 // Generate thumbnails 65 slider.find('.owl-prev').after('<div class="thumbs"></div>'); 66 var thumbnails = slider.find('.thumbs'); 67 68 images.each(function(index){ 69 thumbnails.append($(this).find('img.gimg').eq(0).clone().on('click', function(){ 70 $(this).parent().find('img').removeClass('active'); 71 $(this).addClass('active'); 72 slider.trigger('to.owl.carousel', [index, 300, true]); 73 })); 74 }); 75 76 slider.find('.thumbs img').eq(parseInt($(this).attr('data-gallery-item'))).addClass('active'); 77 78 setTimeout(function(){ 79 var sliderImg = slider.find('img.gimg').eq(parseInt(_this.attr('data-gallery-item'))); 80 cloneImg.css({ 81 'height': sliderImg.height() + 'px', 82 'top': (sliderImg.offset().top - gallery.offset().top) + 'px', 83 'left': '', 84 'margin-left': '-' + (sliderImg.outerWidth() / 2) + 'px' 85 }).addClass('active'); 86 87 setTimeout(function(){ 88 slider.css('visibility', 'visible'); 89 setTimeout(function(){ 90 cloneImg.remove(); 91 }, 50); 92 }, 350); 93 }, 50); 94 }); 95 96 var close = function(){ 97 if(opened){ 98 opened = false; 99 gallery.removeClass('open'); 100 101 var oldImage = gallery.find('img.gimg').eq(currentItem); 102 var img = oldImage.clone().addClass('gallery-tmpimage active').css({ 103 'margin-left': '-' + oldImage.width()/2 + 'px', 104 'height': oldImage.height() + 'px', 105 'top': (oldImage.offset().top - gallery.offset().top) + 'px' 106 }); 107 108 $(document.body).append(img); 109 110 setTimeout(function(){ 111 var newImage = _this.find('img.gimg').eq(currentItem); 112 img.css({ 113 'left': newImage.offset().left + 'px', 114 'margin-left': '', 115 'height': newImage.height() + 'px', 116 'top': newImage.offset().top - $(window).scrollTop() + 'px', 117 }); 118 }, 50); 119 120 setTimeout(function(){ 121 slider.remove(); 122 img.remove(); 123 }, 350); 124 } 125 }; 126 127 gallery.find('.close').on('click', close); 128 $(window).on('keydown', function(e){ 129 var key = e.which || e.keyCode || e.keyChar; 130 if(key == 27){ 131 close(); 132 } 133 }); 134 }); 135});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.