PageSourceSearch

https://www.younghoe.info/wp-content/plugins/fifu-premium/includes/html/js/image.js?ver=5.8.4

js younghoe.info collected 2026-10-05 19:21:56 UTC 12,344 bytes, 338 lines download raw bytes

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

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.