1(function($) 2{ 3 'use strict'; 4 5 // ------------------------------------------------------------------------------------------- 6 // Gallery shortcode javascript 7 // ------------------------------------------------------------------------------------------- 8 9 $.fn.avia_sc_gallery = function(options) 10 { 11 return this.each(function() 12 { 13 var gallery = $(this), 14 images = gallery.find('img'), 15 big_prev = gallery.find('.avia-gallery-big'), 16 prev = gallery.find( '.avia-slideshow-arrows .prev-slide' ), 17 next = gallery.find( '.avia-slideshow-arrows .next-slide' ), 18 thumbs = gallery.find( '.avia-gallery-thumb a' ), 19 no_hover_effect = gallery.hasClass( 'no-hover-effect' ); 20 21 if( next.length ) 22 { 23 gallery.avia_swipe_trigger( {prev:'.prev-slide', next:'.next-slide'} ); 24 } 25 26 //trigger displaying of thumbnails 27 gallery.on( 'avia_start_animation', function() 28 { 29 images.each(function(i) 30 { 31 var image = $(this); 32 setTimeout( function() 33 { 34 image.addClass('avia_start_animation'); 35 }, (i * 110) ); 36 }); 37 }); 38 39 if( gallery.hasClass('deactivate_avia_lazyload') ) 40 { 41 gallery.trigger('avia_start_animation'); 42 } 43 44 //trigger thumbnail hover and big prev image change 45 if( big_prev.length ) 46 { 47 gallery.on( 'mouseenter', '.avia-gallery-thumb a', function() 48 { 49 var _self = $(this), 50 newImgSrc = _self.attr('data-prev-img'), 51 oldImg = big_prev.find('img'), 52 oldImgSrc = oldImg.attr('src'); 53 54 if( no_hover_effect ) 55 { 56 if( ! gallery.hasClass( 'av-force-img-change' ) ) 57 { 58 return; 59 } 60 } 61 62 gallery.removeClass( 'av-force-img-change' ); 63 64 if( newImgSrc == oldImgSrc ) 65 { 66 return; 67 } 68 69 big_prev.height( big_prev.height() ); 70 71 big_prev.attr('data-onclick', _self.attr('data-onclick')); 72 big_prev.attr('href', _self.attr('href')); 73 big_prev.attr('title', _self.attr('title')); 74 75 // copy lightbox attributes 76 if( 'undefined' == typeof _self.data('srcset') ) 77 { 78 big_prev.removeAttr('data-srcset'); 79 big_prev.removeData('srcset'); 80 } 81 else 82 { 83 big_prev.data('srcset', _self.data('srcset')); 84 big_prev.attr('data-srcset', _self.data('srcset')); 85 } 86 87 if( 'undefined' == typeof _self.data('sizes') ) 88 { 89 big_prev.removeAttr('data-sizes'); 90 big_prev.removeData('sizes'); 91 } 92 else 93 { 94 big_prev.data('sizes', _self.data('sizes')); 95 big_prev.attr('data-sizes', _self.data('sizes')); 96 } 97 98 // since 4.8.8.2 we have a hidden img to support scrset and sizes - fallback to old version if missing 99 var newPrev = _self.find( '.big-prev-fake img' ).clone( true ); 100 if( newPrev.length == 0 ) 101 { 102 var next_img = new Image(); 103 next_img.src = newImgSrc; 104 newPrev = $(next_img); 105 } 106 107 if( big_prev.hasClass( 'avia-gallery-big-no-crop-thumb' ) ) 108 { 109// changed 5.4: https://github.com/KriesiMedia/wp-themes/issues/4028 110// newPrev.css( {'height':big_prev.height(),'width':'auto'} ); 111 newPrev.css( {'height':'auto', 'width':'auto', 'max-height':'100%', 'max-width':'100%'} ); 112 } 113 114 big_prev.stop().animate( {opacity:0}, function() 115 { 116 newPrev.insertAfter( oldImg ); 117 oldImg.remove(); 118 big_prev.animate( {opacity:1} ); 119 }); 120 }); 121 122 next.on( 'click', function( e ) 123 { 124 e.preventDefault(); 125 126 if( ! big_prev.length ) 127 { 128 return; 129 } 130 131 let current = big_prev[0].dataset.onclick, 132 next_index = current; 133 134 if( next_index >= thumbs.length ) 135 { 136 next_index = 0; 137 } 138 139 gallery.addClass( 'av-force-img-change' ); 140 $( thumbs[ next_index ] ).trigger( 'mouseenter' ); 141 }); 142 143 prev.on( 'click', function( e ) 144 { 145 e.preventDefault(); 146 147 if( ! big_prev.length ) 148 { 149 return; 150 } 151 152 let current = big_prev[0].dataset.onclick, 153 prev_index = current - 2; 154 155 if( prev_index < 0 ) 156 { 157 prev_index = thumbs.length - 1; 158 } 159 160 gallery.addClass( 'av-force-img-change' ); 161 $( thumbs[ prev_index ] ).trigger( 'mouseenter' ); 162 }); 163 164 big_prev.on( 'click', function( e ) 165 { 166 e.preventDefault(); 167 168 var imagelink = gallery.find('.avia-gallery-thumb a').eq( this.getAttribute('data-onclick') - 1 ); 169 170 if( imagelink && ! imagelink.hasClass('aviaopeninbrowser') ) 171 { 172 imagelink.trigger('click'); 173 } 174 else if( imagelink ) 175 { 176 var imgurl = imagelink.attr('href'); 177 var secure = imagelink.hasClass( 'custom_link' ) ? 'noopener,noreferrer' : ''; 178 179 if( imagelink.hasClass('aviablank') && imgurl != '' ) 180 { 181 window.open( imgurl, '_blank', secure ); 182 } 183 else if( imgurl != '' ) 184 { 185 window.open( imgurl, '_self', secure ); 186 } 187 } 188 return false;
189 }); 190 191 192 $(window).on( 'debouncedresize', function() 193 { 194 big_prev.height('auto'); 195 }); 196 } 197 }); 198 }; 199 200}(jQuery));
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.