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