PageSourceSearch

https://www.rajapack.co.uk/blog-uk/wp-content/plugins/wp-image-zoooom/assets/js/image_zoom-init.js?ver=1.60

js rajapack.co.uk collected 2026-09-24 23:00:30 UTC 17,062 bytes, 418 lines download raw bytes

1;window.mobilecheck = function() {
2    var check = false;
3    (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
4          return check;
5};
6
7
8jQuery(document).ready(function( $ ){
9
10    if(window.mobilecheck() && IZ.enable_mobile != '1' ) {
11        return;
12    }
13
14	var url = (window.location != window.parent.location) ? window.parent.location.href: window.location.href;
15
16	// Is this an Elementor editor iframe.
17	if ( $('body.elementor-editor-active').length > 0
18			|| $('body.fl-builder-edit').length > 0
19			|| url.indexOf('vc_action=vc_inline') > 0
20			|| url.indexOf('vc_editable=true') > 0
21			|| url.indexOf('et_fb=') > 0 ) {
22		return;
23	}
24
25    var options = IZ.options;
26
27    // Fix for the Lazy Load plugin with jQuery.sonar
28    $("img[data-lazy-src]").each(function(){
29        $(this).attr('data-zoom-image', $(this).data('lazy-src'));
30    });
31
32    // Fix for the lazy load functionality from the SG Optimizer plugin
33    $("img[data-src].lazyload").each(function() {
34        $(this).attr('data-zoom-image', $(this).data('src'));
35    });
36 
37
38    // Add "zoooom" for the "is-style-zoooom" images added with Gutenberg
39    $(".is-style-zoooom").each(function(){
40        $(this).addClass('zoooom');
41    });
42
43    // Get the image url from data-large_image
44    $("img[data-large_image]").each(function(){
45        $(this).attr('data-zoom-image', $(this).data('large_image'));
46    });
47
48    // Attach the .zoooom class to the IMG children
49    $(".zoooom").each(function(){
50      if ( this.tagName !== 'IMG' ) {
51        $(this).find("img").addClass('zoooom');
52        $(this).removeClass('zoooom');
53      }
54    });
55
56    // Start the zoom for the normal images
57    options.zIndex = 112400;
58	setTimeout( function() {
59    	$("img.zoooom.jetpack-lazy-image").image_zoom(options);
60	}, 300 );
61	$("img.zoooom:not(.jetpack-lazy-image)").image_zoom( options );
62
63    // WooCommerce category pages
64    if ( IZ.woo_categories == '1' ) {
65        var cat_class = '.tax-product_cat .products img:not(.woocommerce-placeholder), .post-type-archive-product .products img:not(.woocommerce-placeholder)'; 
66        $(cat_class).image_zoom(options);
67        $(document).on('yith-wcan-ajax-filtered', function() {
68            $('.zoomContainer').remove();
69            $(cat_class).image_zoom(options);
70        } );
71    }
72
73    // Fix for the LazyLoad (unveil.js) plugins
74    if (typeof $.unveil === "function") {
75        $("img.unveil").unveil(0, function() {
76            $(this).load(function() {
77                $("img.zoooom").image_zoom(options);
78            });
79        });
80    }
81
82
83    // Resize the zoom windows when resizing the page
84    $(window).on('resize', function(e) {
85        window.resizeEvt;
86        $(window).on('resize', function() {
87            clearTimeout(window.resizeEvt);
88            window.resizeEvt = setTimeout(function() {
89                $(".zoomContainer").remove();
90				var image_selector = 'img.zoooom, .zoooom img';
91                if ( IZ.with_woocommerce == '1' ) {
92        			image_selector += 
93						', .attachment-shop_single' +
94						', .attachment-shop_thumbnail.flex-active-slide img:not(.woocommerce-placeholder)';
95				}
96				if ( IZ.woo_categories == '1' ) {
97					image_selector +=
98						', .tax-product_cat .products img:not(.woocommerce-placeholder)' +
99						', .post-type-archive-product .products img:not(.woocommerce-placeholder)';
100				}
101                $( image_selector ).image_zoom(options);
102            }, 500);
103        });
104    });
105
106
107    // Remove the zoom when hovering on the submenu
108    function restart_on_hover( elem ) {
109        elem.on('mouseenter', function(){
110            if ( $('.zoomContainer').length === 0 ) {
111                $(this).image_zoom(IZ.options);
112            }
113        });
114    };
115    $('.sub-menu li').on('mouseenter', function(){
116        $('.zoomContainer').remove();
117    });
118    restart_on_hover($('img.zoooom'));
119
120
121    // Show zoom on the WooCommerce gallery
122    if ( IZ.with_woocommerce == '1' ) {
123    $(".attachment-shop_single").image_zoom(options);
124    restart_on_hover($('.attachment-shop_single'));
125
126    $("a[data-rel^='zoomImage']").each(function(index){
127        $(this).on('click', function(event){
128            // If there are more than one WooCommerce gallery, exchange the thumbnail with the closest .attachment-shop_single
129            var obj1 = $(".attachment-shop_single");
130            if ( obj1.length > 1 ) {
131                var obj1 = $(this).closest('.images').find( $(".attachment-shop_single") );
132            }
133            var obj2 = $(this).find("img");
134
135            event.preventDefault();
136
137            if ( obj2.hasClass('attachment-shop_single') === false ) {
138
139                // Remove the srcset and sizes
140                obj1.removeAttr('srcset').removeAttr('sizes');
141                obj2.removeAttr('srcset').removeAttr('sizes');
142
143                var thumb_src = obj2.attr('src');
144
145                // Exchange the attributes
146                $.each(['src', 'alt', 'title'], function(key,attr) {
147                    var temp;
148                    if ( obj1.attr( attr ) ) temp = obj1.attr( attr );
149                    if ( obj2.attr( attr ) ) {
150                        obj1.attr(attr, obj2.attr(attr) );
151                    } else {
152                        obj1.removeAttr( attr );
153                    }
154                    if ( IZ.exchange_thumbnails == '1' ) {
155                        if ( temp && temp.length > 0 ) {
156                            obj2.attr(attr, temp);
157                        } else {
158                            obj2.removeAttr( attr );
159                        }
160                    }
161                });
162
163                // Exchange the link sources
164                var temp;
165                temp = obj2.parent().attr('href');
166                if ( IZ.exchange_thumbnails == '1' ) {
167                    obj2.parent().attr('href', obj1.parent().attr('href'));
168                }
169                obj1.parent().attr('href', temp );
170
171                // Set the obj1.src = the link source
172                obj1.attr('src', temp );
173
174                // Set the obj2.src = data-thumbnail-src
175                if ( obj1.data('thumbnail-src') && IZ.exchange_thumbnails == '1' ) {
176                    obj2.attr( 'src', obj1.attr('data-thumbnail-src'));
177                }
178
179                // Set the obj1.data-thumbnail-src
180                obj1.attr('data-thumbnail-src', thumb_src );
181
182                // Replace the data-zoom-image
183                temp = obj1.data('zoom-image');
184                if ( !obj2.data('zoom-image') ) obj2.data('zoom-image', '');
185                obj1.data('zoom-image', obj2.data('zoom-image'));
186                if( ! temp ) temp = '';
187                obj2.data('zoom-image', temp);
188
189                // Remove the old zoom and reactive the new zoom
190                $(".zoomContainer").remove();
191                $(".attachment-shop_single").image_zoom(options);
192                restart_on_hover($('.attachment-shop_single'));
193            }
194
195            });
196        });
197    }
198
199
200    // Show zoom on the WooCommerce 3.0.+ gallery with slider
201    if ( IZ.with_woocommerce == '1' && (IZ.woo_slider == '1' || $('.woo_product_slider_enabled').length > 0 ) && $(".woocommerce-product-gallery img").length > 0 ) {
202
203			// Zoom on the first image
204            var first_img = ".woocommerce-product-gallery__wrapper img";
205            setTimeout( function() {
206                if ( $(".woocommerce-product-gallery .flex-viewport").length > 0 ) {
207                    first_img = ".woocommerce-product-gallery__wrapper .flex-active-slide img";
208                }
209                $(first_img).first().image_zoom( options );
210             //   restart_on_hover($(first_img).first());
211            }, 500 );
212
213			// Change the zoom when the image in the gallery changes
214			const galleryObserver = new MutationObserver( function(mutationList, observer) {
215				for (const mutation of mutationList) {
216					if ( mutation.type !== "attributes" || mutation.attributeName !== "class" ) continue;
217					if ( ! mutation.target.getAttribute( "class" ).includes( "flex-active-slide" ) ) continue;
218
219					$(".zoomContainer").remove();
220					setTimeout( function() {
221						$(first_img).first().image_zoom(options);
222						restart_on_hover($(first_img).first());
223					}, 550);
224				}
225			});
226			galleryObserver.observe(document.querySelector(".woocommerce-product-gallery__wrapper"), { attributes: true, subtree: true });
227
228			// Remove the zoom when opening the lightbox 
229			const lightboxObserver = new MutationObserver( function(mutationList, observer) {
230				for (const mutation of mutationList) {
231					if ( mutation.type !== "attributes" || mutation.attributeName !== "class" ) continue;
232					if ( ! mutation.target.getAttribute( "class" ) === "pswp__ui pswp__ui--fit" ) continue;
233
234					$(".zoomContainer").remove();
235				}
236			});
237			lightboxObserver.observe(document.querySelector(".pswp"), { attributes: true, subtree: true });
238
239
240            // Resize the zoom windows when resizing the page
241            $(window).on('resize', function(e) {
242                window.resizeEvt;
243                $(window).resize(function() {
244                    clearTimeout(window.resizeEvt);
245                    window.resizeEvt = setTimeout(function() {
246                        $(".zoomContainer").remove();
247                        restart_on_hover($(first_img).first());
248                    }, 300);
249                });
250            });
251
252            // Remove the click action on the images
253            $(".woocommerce-product-gallery img").on('click', function(e){
254                e.preventDefault();
255            });
256    }
257
258
259
260
261    // Show zoom on the WooCommerce 3.0.+ gallery without slider
262    if ( IZ.with_woocommerce == '1' && (IZ.woo_slider == '0' || $('.woo_product_slider_disabled').length > 0)) {
263        var first_img = $('.woocommerce-product-gallery__image:first-child img');
264
265        // Zoom on the first image
266        first_img.image_zoom(options);
267        restart_on_hover(first_img);
268
269        // Remove the click action on the images
270        $('.woocommerce-product-gallery__image img').on('click', function(e){
271            e.preventDefault();
272        });
273
274
275        $('.woocommerce-product-gallery__image img').each(function(i) {
276            $(this).removeAttr('data-large_image');
277            $(this).removeAttr('data-large_image_width');
278            $(this).removeAttr('data-large_image_height');
279            $(this).removeAttr('srcset');
280            $(this).removeAttr('sizes');
281        });
282
283        // Switch the thumbnail with the main image
284        $(".woocommerce-product-gallery__image:nth-child(n+2) img").each(function(i){
285            $(this).on('click', function(e){
286                var this_thumb = $(this);
287                // Exchange the attributes
288                $.each(['alt', 'title', 'data-src'], function(key,attr) {
289                    var temp;
290                    if ( first_img.attr( attr ) ) temp = first_img.attr( attr );
291                    if ( this_thumb.attr( attr ) ) {
292                        first_img.attr(attr, this_thumb.attr(attr) );
293                    } else {
294                        first_img.removeAttr( attr );
295                    }
296                    if ( IZ.exchange_thumbnails == '1' ) {
297                        if ( temp && temp.length > 0 ) {
298                            this_thumb.attr(attr, temp);
299                        } else {
300                            this_thumb.removeAttr( attr );
301                        }
302                    }
303
304                });
305
306                var thumb_src = this_thumb.attr('src');
307
308
309                // Exchange the link sources
310                var temp;
311                temp = this_thumb.parent().attr('href');
312                if ( IZ.exchange_thumbnails == '1' ) {
313                    this_thumb.parent().attr('href', first_img.parent().attr('href'));
314                }
315                first_img.parent().attr('href', temp );
316
317                // Set the first_img.src = the link source
318                first_img.attr('src', temp );
319
320                // Set the this_thumb.src = data-thumbnail-src
321                if ( first_img.data('thumbnail-src') && IZ.exchange_thumbnails == '1' ) {
322                    this_thumb.attr( 'src', first_img.attr('data-thumbnail-src'));
323                }
324
325                // Set the first_img.data-thumbnail-src
326                first_img.attr('data-thumbnail-src', thumb_src );
327
328                // Replace the data-zoom-image
329                temp = first_img.data('zoom-image');
330                if ( !this_thumb.data('zoom-image') ) this_thumb.data('zoom-image', '');
331                first_img.data('zoom-image', this_thumb.data('zoom-image'));
332                if( ! temp ) temp = '';
333                this_thumb.data('zoom-image', temp);
334
335
336                // Remove the old zoom and reactive the new zoom
337                $(".zoomContainer").remove();
338                first_img.image_zoom(options);
339                restart_on_hover(first_img);
340
341            });
342        });
343    }
344
345
346    // Show zoom on the SureCart gallery 
347    if ( IZ.enable_surecart == '1' && $( "body.single-sc_product").length > 0 ) {
348
349		IZ.options.zIndex = 5;
350
351		let removeLightboxInert = function() {
352			const lightboxObserver = new MutationObserver(() => {
353				$('div[inert]').removeAttr('inert');
354			});
355			lightboxObserver.observe(document.querySelector(".sc-lightbox-overlay"), {
356				attributes: true
357			});
358		}
359
360		let imageContainer = "figure.wp-block-surecart-product-media";
361		if ( $( imageContainer ).length > 0 ) {
362			// A single static image.
363			
364			IZ.options.onComplete = function() {
365				$( ".zoomContainer" ).on("click", function() {
366					$( imageContainer + " button.lightbox-trigger" ).trigger( 'click' );
367				} );
368			};
369			$( imageContainer + " img" ).image_zoom( IZ.options );
370			removeLightboxInert();
371		} else {
372			// Gallery with multiple images.
373
374			let galleryContainer = ".sc-image-slider > .swiper";
375			IZ.options.onMouseMove = true;
376
377			let triggerLightbox = function() {
378				$( ".zoomContainer" ).on( "click", function() {
379					$( ".swiper-slide-active button.lightbox-trigger" ).trigger( 'click' );
380				});
381			}
382
383			let startZoom = function() {
384				$( galleryContainer + " .swiper-slide-active img" ).image_zoom( IZ.options );
385				setTimeout( triggerLightbox, 400 );
386
387				const lightboxObserver = new MutationObserver(() => {
388					$('div[inert]').removeAttr('inert');
389				});
390				lightboxObserver.observe(document.querySelector(".sc-lightbox-overlay"), {
391					attributes: true
392				});
393			}
394
395			setTimeout( startZoom, 300 );
396
397			let changeTimestamp = 0;
398			const galleryObserver = new MutationObserver(() => {
399				if ( Date.now() - changeTimestamp < 200 ) {
400					return;
401				}
402				changeTimestamp = Date.now();
403				$( ".zoomContainer" ).remove();
404				setTimeout(
405					function() {
406						$( galleryContainer + " .swiper-slide-active img" ).image_zoom( IZ.options );
407						setTimeout( triggerLightbox, 400 );
408					},
409					400
410				);
411			});
412			galleryObserver.observe(document.querySelector(galleryContainer + " .swiper-wrapper"), {
413				attributes: true
414			});
415		}
416	}
417
418});

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.