(function($) { "use strict"; // ------------------------------------------------------------------------------------------- // gallery shortcode javascript // ------------------------------------------------------------------------------------------- $.fn.avia_sc_gallery = function(options) { return this.each(function() { var gallery = $(this), images = gallery.find('img'), big_prev = gallery.find('.avia-gallery-big'); //trigger displaying of thumbnails gallery.on('avia_start_animation', function() { images.each(function(i) { var image = $(this); settimeout(function(){ image.addclass('avia_start_animation') }, (i * 110)); }); }); if(gallery.hasclass('deactivate_avia_lazyload')) gallery.trigger('avia_start_animation'); //trigger thumbnail hover and big prev image change if(big_prev.length) { gallery.on('mouseenter','.avia-gallery-thumb a', function() { var _self = this; big_prev.attr('data-onclick', _self.getattribute("data-onclick")); big_prev.height(big_prev.height()); big_prev.attr('href', _self.href) var newimg = _self.getattribute("data-prev-img"), oldimg = big_prev.find('img'), oldimgsrc = oldimg.attr('src'); if(newimg != oldimgsrc) { var next_img = new image(); next_img.src = newimg; var $next = $(next_img); if(big_prev.hasclass('avia-gallery-big-no-crop-thumb')) { $next.css({'height':big_prev.height(),'width':'auto'}); } big_prev.stop().animate({opacity:0}, function() { $next.insertafter(oldimg); oldimg.remove(); big_prev.animate({opacity:1}); big_prev.attr('title',$(_self).attr('title')); }); } }); big_prev.on('click', function() { var imagelink = gallery.find('.avia-gallery-thumb a').eq(this.getattribute("data-onclick") - 1); if(imagelink && !imagelink.hasclass('aviaopeninbrowser')) { imagelink.trigger('click'); } else if(imagelink) { var imgurl = imagelink.attr("href"); if(imagelink.hasclass('aviablank') && imgurl != '' ) { window.open(imgurl, '_blank'); } else if( imgurl != '' ) { window.open(imgurl, '_self'); } } return false; }); $(window).on("debouncedresize", function() { big_prev.height('auto'); }); } }); } }(jquery));