1jQuery(document).ready(function ($) { 2 if (fifuImageVars.fifu_block) { 3 jQuery('body').on('contextmenu', 'img', function (e) { 4 return false; 5 }); 6 } 7 8 // lazy load 9 if (fifuImageVars.fifu_lazy) 10 fifu_lazy(); 11 else { 12 // dont lazy the top images 13 jQuery('img').each(function (index) { 14 if (jQuery(this).offset().top < jQuery(window).height()) { 15 jQuery(this).removeAttr('loading'); 16 } 17 }); 18 } 19 20 // for all images on home/shop 21 if (fifuImageVars.fifu_should_crop) { 22 setTimeout(function () { 23 cropImage(); 24 }, parseInt(fifuImageVars.fifu_crop_delay)); 25 } 26 27 // hover effects 28 if (fifuImageVars.fifu_hover_selected) 29 addHoverEffect($); 30 31 // woocommerce lightbox/zoom 32 disableClick($); 33 disableLink($); 34 35 // zoomImg 36 setTimeout(function () { 37 jQuery('img.zoomImg').css('z-index', ''); 38 }, 1000); 39 40 jQuery('img[height=1]').each(function (index) { 41 if (jQuery(this).attr('width') != 1) 42 jQuery(this).css('position', 'relative'); 43 }); 44}); 45 46jQuery(document).ajaxComplete(function ($) { 47 if (fifuImageVars.fifu_hover_selected) 48 addHoverEffect($); 49 50 // image not found 51 jQuery('div.woocommerce-product-gallery img').on('error', function () { 52 jQuery(this)[0].src = fifuImageVars.fifu_error_url; 53 }); 54}); 55 56jQuery(window).on('ajaxComplete', function () { 57 if (fifuImageVars.fifu_lazy) 58 fifu_lazy(); 59 60 // timeout necessary (load more button of Bimber) 61 setTimeout(function () { 62 if (fifuImageVars.fifu_slider) 63 fifu_slider = fifu_load_slider(); 64 }, 300); 65}); 66 67function addHoverEffect($) { 68 var selector = fifuImageVars.fifu_hover_selector; 69 70 jQuery('.post-thumbnail, .featured-image > a > img, div.thumbnail > a > img, .featured-media > a > img' + (selector ? ',' + selector : '')).each(function (index) { 71 if (fifuImageVars.fifu_is_front_page) 72 jQuery(this).replaceWith('<div id="hover" class="' + fifuImageVars.fifu_hover + '"><div><figure>'.concat(jQuery(this).parent().html()).concat('</figure></div></div>')); 73 }); 74 75 jQuery('img.attachment-woocommerce_thumbnail').each(function (index) { 76 // ignore if the image is not in main area 77 if (jQuery(this).parent().parent().html().search('woocommerce-LoopProduct-link') < 0) 78 return; 79 if (fifuImageVars.fifu_is_shop) 80 jQuery(this).replaceWith('<div id="hover" class="' + fifuImageVars.fifu_hover + '"><div><figure>'.concat(jQuery(this).context.outerHTML).concat('</figure></div></div>')); 81 }); 82 83 // selector for shop 84 if (selector) { 85 jQuery(selector).each(function (index) { 86 if (fifuImageVars.fifu_is_shop) 87 jQuery(this).replaceWith('<div id="hover" class="' + fifuImageVars.fifu_hover + '"><div><figure>'.concat(jQuery(this).parent().html()).concat('</figure></div></div>')); 88 }); 89 } 90} 91 92function cropImage(selector) { 93 if (!selector) 94 selector = fifuImageVars.fifu_crop_default + fifuImageVars.fifu_crop_selectors; 95 96 // get selectors and set individual ratios in a dictionary 97 sel = selector.split(','); 98 dictRatio = {}; 99 dicFit = {}; 100 selector = ''; 101 for (i = 0; i < sel.length; i++) { 102 arr = sel[i].split('|'); 103 if (arr.length > 1) { 104 dictRatio[i] = arr[1]; 105 if (arr.length > 2) 106 dicFit[i] = arr[2]; 107 } 108 selector += arr[0]; 109 if (i + 1 < sel.length) 110 selector += ', '; 111 } 112 113 fit = fifuImageVars.fifu_fit; 114 115 // get global ratio 116 global_ratio = fifuImageVars.fifu_crop_ratio; 117 global_ratio_w = global_ratio.split(':')[0]; 118 global_ratio_h = global_ratio.split(':')[1]; 119 120 // for each selector 121 sel = selector.split(','); 122 for (i = 0; i < sel.length; i++) { 123 124 // define which ratio will be used 125 if (dictRatio) { 126 local_ratio = dictRatio[i]; 127 ratio_w = local_ratio ? local_ratio.split(':')[0] : global_ratio_w; 128 ratio_h = local_ratio ? local_ratio.split(':')[1] : global_ratio_h; 129 } 130 131 // define which fit will be used 132 if (dicFit) { 133 local_fit = dicFit[i]; 134 fit = local_fit ? local_fit : fit; 135 } 136 137 jQuery(sel[i]).each(function (index) { 138 // ignore fifu slider 139 if (sel[i].trim() === '.fifu-slider') 140 return; 141 142 var width; 143 var backend = false;
144 // a.g1-frame-inner is for bimber theme 145 jQuery(this).find('img, a.g1-frame').each(function (index) { 146 // ignore 147 ignoreSelectors = fifuImageVars.fifu_crop_ignore_parent.split(','); 148 skip = false; 149 for (j = 0; j < ignoreSelectors.length; j++) { 150 if (jQuery(this).parent().is(ignoreSelectors[j])) { 151 skip = true; 152 break 153 } 154 } 155 if (skip) 156 return; 157 158 // from backend 159 theme_width = jQuery(this).attr('theme-width'); 160 theme_height = jQuery(this).attr('theme-height'); 161 162 // from frontend 163 if (!width) { 164 width = jQuery(this).parent().css('width').replace('px', ''); 165 width = width != 0 ? width : jQuery(this).parent().parent().css('width').replace('px', ''); 166 width = width != 0 ? width : jQuery(this).parent().parent().parent().css('width').replace('px', ''); 167 } 168 if (width == '100%') { 169 width = jQuery(this).parent()[0].clientWidth; 170 width = width != 0 ? width : jQuery(this).parent().parent()[0].clientWidth; 171 width = width != 0 ? width : jQuery(this).parent().parent().parent()[0].clientWidth; 172 } 173 174 if (isValidImgClass(jQuery(this).attr('class'))) { 175 if (fifuImageVars.fifu_should_crop_with_theme_sizes && (backend || (theme_width && theme_height && theme_height != 9999))) { 176 backend = true; 177 // backend 178 jQuery(this).attr('style', jQuery(this).attr('style') + ';height: ' + (width * theme_height / theme_width) + 'px !important'); 179 } else { 180 // frontend 181 jQuery(this).attr('style', jQuery(this).attr('style') + ';height: ' + (width * ratio_h / ratio_w) + 'px !important'); 182 } 183 if (jQuery(this)[0].clientHeight > jQuery(this)[0].clientWidth) 184 jQuery(this).css('width', '100%'); 185 else 186 jQuery(this).css('width', width + 'px !important'); 187 188 jQuery(this).css('object-fit', fit ? fit : 'cover'); 189 190 // position 191 position = jQuery(this).attr('fifu-position'); 192 if (position) { 193 jQuery(this).css('object-position', position); 194 jQuery(this).removeAttr('fifu-position'); 195 } 196 } 197 }); 198 }); 199 } 200 201 jQuery('a.woocommerce-LoopProduct-link').css('width', '100%'); 202} 203 204function isValidImgClass(className) { 205 // bimber 206 return !className || !className.includes('avatar'); 207} 208 209function disableClick($) { 210 if (!fifuImageVars.fifu_woo_lbox_enabled) { 211 firstParentClass = ''; 212 parentClass = ''; 213 jQuery('figure.woocommerce-product-gallery__wrapper').find('div.woocommerce-product-gallery__image').each(function (index) { 214 parentClass = jQuery(this).parent().attr('class').split(' ')[0]; 215 if (!firstParentClass) 216 firstParentClass = parentClass; 217 218 if (parentClass != firstParentClass) 219 return false; 220 221 jQuery(this).children().click(function () { 222 return false; 223 }); 224 jQuery(this).children().children().css("cursor", "default"); 225 }); 226 } 227} 228 229function disableLink($) { 230 if (!fifuImageVars.fifu_woo_lbox_enabled) { 231 firstParentClass = ''; 232 parentClass = ''; 233 jQuery('figure.woocommerce-product-gallery__wrapper').find('div.woocommerce-product-gallery__image').each(function (index) { 234 parentClass = jQuery(this).parent().attr('class').split(' ')[0]; 235 if (!firstParentClass) 236 firstParentClass = parentClass; 237 238 if (parentClass != firstParentClass) 239 return false;
240 241 jQuery(this).children().attr("href", ""); 242 }); 243 } 244} 245 246jQuery(document).ajaxSuccess(function () { 247 if (fifuImageVars.fifu_should_crop) { 248 setTimeout(function () { 249 cropImage(); 250 }, parseInt(fifuImageVars.fifu_crop_delay)); 251 } 252}); 253 254jQuery(document).click(function ($) { 255 fifu_fix_gallery_height(); 256}) 257 258function fifu_fix_gallery_height() { 259 if (fifuImageVars.fifu_is_flatsome_active) { 260 mainImage = jQuery('.woocommerce-product-gallery__wrapper div.flickity-viewport').find('img')[0]; 261 if (mainImage) 262 jQuery('.woocommerce-product-gallery__wrapper div.flickity-viewport').css('height', mainImage.clientHeight + 'px'); 263 } 264} 265 266// var resizeWindowTimeout; 267// jQuery(window).on('resize', function (e) { 268// clearTimeout(resizeWindowTimeout); 269// resizeWindowTimeout = setTimeout(fifu_resize_slider, 100); 270// }); 271 272// for infinite scroll 273jQuery(document.body).on('post-load', function () { 274 if (fifuImageVars.fifu_lazy) 275 fifu_lazy(); 276 277 setTimeout(function () { 278 if (fifuImageVars.fifu_slider) 279 fifu_slider = fifu_load_slider(); 280 }, 300); 281}); 282 283jQuery('img.lazy').on('appear', function () { 284 if (fifuImageVars.fifu_should_crop) 285 cropImage(); 286}); 287 288// fix conflict between lazyload and slider (height:0px) 289jQuery('ul#image-gallery > li > img').on('load', function () { 290 if (fifuImageVars.fifu_lazy) { 291 if (jQuery(this).parent().hasClass('active')) 292 jQuery(this).parent().parent().css('height', this.clientHeight); 293 } 294});
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.