PageSourceSearch

https://www.coolblades.co.uk/content/magiczoomplus/magiczoomplus.stencil.js

js coolblades.co.uk collected 2026-10-01 03:41:15 UTC 34,451 bytes, 709 lines download raw bytes

1function mtLinkFile(url) {
2    var extention = url.replace(/^.+\.([^.]+)$/, '$1'),
3        targetTag = document.getElementsByTagName('head')[0];
4    if (extention == 'js') {
5        var scriptTag = document.createElement('script');
6        scriptTag.type = 'text/javascript';
7        scriptTag.src = url;
8        scriptTag.async = false;
9        if (arguments.length > 1) {
10            scriptTag.onload = arguments[1];
11        }
12        targetTag.appendChild(scriptTag);
13    }
14    if (extention == 'css') {
15        var linkTag = document.createElement('link');
16        linkTag.type = 'text/css';
17        linkTag.href = url;
18        linkTag.rel = 'stylesheet';
19        linkTag.media = 'screen';
20        targetTag.appendChild(linkTag);
21    }
22}
23
24// document.write('<style type="text/css">.productView--wrapper .productView-images { aspect-ratio:1 / 1; }</style>');
25// document.close();
26
27if (typeof UseMagicScroll == 'undefined') {
28    UseMagicScroll = 'No';
29}
30
31
32if (typeof jQuery == 'undefined') {
33    mtLinkFile('https://code.jquery.com/jquery-2.2.4.min.js');
34}
35
36
37function mzp_docReady(fn) {
38    if (document.readyState === "complete" || document.readyState === "interactive") {
39        setTimeout(fn, 1);
40    } else {
41        document.addEventListener("DOMContentLoaded", fn);
42    }
43}    
44
45if (typeof BCData != 'undefined' && typeof BCData.product_attributes != 'undefined') {
46
47    mtLinkFile('/content/magiczoomplus/magiczoomplus.settings.js');
48    mtLinkFile('/content/magiczoomplus/magiczoomplus.js');
49    mtLinkFile('/content/magiczoomplus/magicscroll.js');
50    mzp_docReady(function() {
51
52        mzpScriptsReady(function() {
53            mtLinkFile('/content/magiczoomplus/magiczoomplus.css');
54            if (UseMagicScroll == 'Yes') {
55                mtLinkFile('/content/magiczoomplus/magicscroll.css');
56            }
57            var $s = '.MagicScroll .mcs-item img { height: 100% !important; max-height: 100% !important; object-fit: contain; } .mcs-item a {vertical-align:top;margin:0 3px !important;} .MagicZoomGallery{position:relative;z-index:1;text-align:center;width:100%}.MagicZoomSelectors{margin:5px;text-align:center}.MagicZoomSelectors a{margin:5px;display:inline-block}.MagicZoomSelectors a img{max-height:60px}.mz-thumb:hover:not(.mz-thumb-selected) img{-webkit-filter:none;filter:none}.mz-thumb-selected img{-webkit-filter:none;filter:none}.no-cssfilters-magic .mz-thumb{background:0 0}.no-cssfilters-magic .mz-thumb:hover:not(.mz-thumb-selected) img{opacity:1;filter:none}.no-cssfilters-magic .mz-thumb-selected img{opacity:1;filter:none}.MagicZoomSelectors a:hover img,.active-magic-selector img{-webkit-filter:brightness(60%)!important;filter:brightness(60%)!important}@media only screen and (min-width:768px){.MagicZoomSelectors .mz-thumb img .MagicZoomSelectors .mz-thumb-selected img,.MagicZoomSelectors a[data-zoom-id] img,.MagicZoomSelectors img{border:1px solid rgba(0,0,0,.1);opacity:.75;padding:2px;aspect-ratio:1;object-fit:contain;height:60px;width:60px;-webkit-filter:none!important;filter:none!important}.MagicZoomSelectors a.x-mz-thumb-selected[data-zoom-id] img, .MagicZoomSelectors .active-magic-selector img,.MagicZoomSelectors a.active-magic-selector[data-zoom-id] img,.MagicZoomSelectors a:hover img{opacity:1!important;border-color:#000!important}a[data-slide-id^=video]{position:relative}a[data-slide-id^=video]:before{content:"";position:absolute;color:#fff;text-shadow:0 1px 10px #000;top:50%!important;left:50%!important;display:inline-block;transform:translateY(-50%) translateX(-50%)!important;-webkit-transform:translateY(-50%) translateX(-50%)!important;z-index:100;width:36px!important;height:36px!important;border-radius:50%;background-repeat:no-repeat;background-color:rgba(0,0,0,.6)!important;background-size:50%;background-position:center center;border:2px solid rgba(255,255,255,.8);z-index:1}a[data-slide-id^=video]:after{position:absolute;content:"";width:12px;height:16px;border-top:8px solid transparent;border-left:12px solid rgba(255,255,255,.8);border-bottom:8px solid transparent;position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);-webkit-transform:translateY(-50%) translateX(-50%);margin-left:1px;box-sizing:border-box!important;z-index:2}
57a[data-slide-id^=video]:hover:before{background-color:rgba(0,0,0,.7)!important;border-color:#fff}a[data-slide-id^=video]:hover:after{border-left-color:#fff}}div[data-slide-id^=video]{position:relative;overflow:hidden;max-width:100%;padding-bottom:56.25%;height:0;height:auto}div[data-slide-id^=video] iframe, div[data-slide-id^=video] video {position:absolute;top:0;left:0;width:100%!important;height:100%!important}@media only screen and (max-width:767px){.MagicZoomSelectors > div:not(.MagicScroll) a img{display:none} .MagicZoomSelectors{> div:not(.MagicScroll) font-size:0px} .MagicZoomSelectors > div:not(.MagicScroll) a{width:12px!important;height:12px!important;border-radius:100%!important;background:none repeat scroll 0 0 #aaa!important;margin:3px!important;cursor:pointer!important;display:inline-block!important;position:relative!important;text-indent:-9999px!important;vertical-align:middle!important;font-size:0px!important;line-height:0!important} .MagicZoomSelectors > div:not(.MagicScroll) a.active-magic-selector:before, .MagicZoomSelectors > div:not(.MagicScroll) a:hover:before{width:10px!important;height:10px!important;border:1px solid transparent!important;border-radius:100%!important;margin:1px!important;content:""!important;position:relative!important;display:block!important;text-indent:-9999px!important;background:#fff!important}}.MZP-Cornerstone .easyzoom-flyout{display:none!important}.MZP-Cornerstone .productView-image{pointer-events:all!important} div[data-slide-id="spin-model"] { width:100%; position:relative; padding-bottom:100%; height:0; line-height:0; } div[data-slide-id="spin-model"] model-viewer { width:100%; position:absolute; height:100%; top:0; left:0; }.mz-zoom-window.mz-magnifier { background: #fff; } div[data-slide-id] { position:relative; z-index:111; }';
58            $s += '.MagicScroll[data-mode="carousel"], .MagicScroll[data-mode="cover-flow"]  {background:#fff !important;}';
59            
60            $s += ' @media screen and (min-width: 768px) { .MagicZoomGallery { display:flex; flex-direction:row;} .MagicZoomSelectors { order:1; flex-basis:75px;} div[data-slide-id] { order:2; flex-basis:100%;} } ' ;
61            jQuery('html > head').append('<style type="text/css">'+$s+'</style>');
62            initMagicZoomPlus();
63        })
64
65    });
66
67}
68
69var $mzp_firstImageIsVideo = false;
70
71function mzpScriptsReady(fnc) {
72    if (typeof MagicZoom == 'undefined' || typeof mzOptions == 'undefined' || typeof jQuery == 'undefined' || UseMagicScroll == 'Yes' && typeof MagicScroll == 'undefined') {
73        setTimeout(function() {
74            mzpScriptsReady(fnc);
75        }, 50);
76        return;
77    }
78    arguments[0]();
79}
80
81var $SirvCache = [];
82
83function SirvShowSpin(spinURL, SirvProductSKU_) {
84    jQuery('div[data-slide-id="spin"]').html('<div class="Sirv" id="sirv-spin" data-src="' + spinURL + '"></div>');
85    jQuery('a[data-slide-id="spin"]').show();
86    if (SirvProductSKU_ != '') {
87        //jQuery('a[data-slide-id="spin"]').trigger('click');
88    }    
89    if (SirvSpinPosition == 'first') {
90        jQuery('a[data-slide-id="spin"]').trigger('click');
91    }
92
93}
94
95function SirvHideSpin(spinURL) {
96    jQuery('div[data-slide-id="spin"], a[data-slide-id="spin"]').remove();
97    jQuery('div[data-slide-id="zoom"]').show();
98}
99
100function initMagicScroll() {
101    if (typeof MagicScroll != 'undefined') {
102       $mjs(document).jAddEvent('domready', function() {
103            MagicScroll.start();
104        });        
105    }
106}
107
108function initSirv(SirvProductSKU_ = '') {
109    var SirvProductID = jQuery('input[name="product_id"]').val(),
110        SirvProductSKU = BCData.product_attributes.sku;
111    if (SirvProductSKU_!='') {
112        SirvProductSKU = SirvProductSKU_;
113    }
114
115
116    if (SirvID == '') {
117        initMagicScroll();
118        return;
119    }
120
121    var spinURL = document.location.protocol.replace('file:', 'http:') + '//' + SirvID + '.sirv.com/' + SirvSpinsPath.replace(/{product\-id}/g, SirvProductID).replace(/{product\-sku}/g, SirvProductSKU).replace(/{product\-name}/g, $('.product-heading__title, h1.productView-title').text());    
122
123    if (jQuery('div[data-slide-id="spin"]').length == 0) {
124
125        jQuery('div[data-slide-id="zoom"]').after('<div style="display:none;" data-slide-id="spin"></div>');
126        jQuery('.MagicZoomSelectors > div').addClass('sirv-enabled').show();
127
128        var $sirvIconHTML = '<a style="display:none;" data-slide-id="spin" class="SirvIcon mz-thumb" href="#"><img id="SirvIcon" src="' + SirvIconURL + '"/></a>';
129
130        if (SirvSpinPosition == 'last') {
131            jQuery('.MagicZoomSelectors > div').append($sirvIconHTML);
132        } else if (SirvSpinPosition == 'first') {
133            jQuery('.MagicZoomSelectors > div').prepend($sirvIconHTML);
134        } else if (SirvSpinPosition == 'second') {
135            jQuery('.MagicZoomSelectors > div a').first().after($sirvIconHTML);
136        }
137        
138        jQuery('.MagicZoomSelectors a[data-zoom-id]').first().addClass('active-magic-selector');
139        initMagicZoomPlusSelectors('a[data-slide-id="spin"]');
140
141        initMagicScroll();
142    }
143
144
145    if (typeof $SirvCache[spinURL] != 'undefined' ) {
146        if ($SirvCache[spinURL]) {
147
148        }
149    }
150
151    jQuery.ajax({
152        url: spinURL,
153        type: 'HEAD',
154        cache: true,
155        timeout: 8000,
156        error: function(data) {
157            SirvHideSpin();
158            $SirvCache[spinURL] = false;
159            initMagicScroll();
160        },
161        success: function(data) {
162
163            if (typeof SirvSpinsProfile != 'undefined') {
164                SirvSpinsProfile = SirvSpinsProfile.trim().replace(/\.profile/gmi,'');
165                if (SirvSpinsProfile!='') {
166                    spinURL += '?profile=' + SirvSpinsProfile;
167                }
168            }
169
170            $SirvCache[spinURL] = true;
171
172            SirvShowSpin(spinURL, SirvProductSKU_);
173
174            initMagicScroll();
175
176            if ($('script[src*="sirv.js"]').length == 0) {
177                var sirv = document.createElement('script');
178                sirv.type = 'text/javascript';
179                sirv.async = true;
180                sirv.src = document.location.protocol.replace('file:', 'http:') + '//scripts.sirv.com/sirvjs/v3/sirv.js';
181                document.getElementsByTagName('script')[0].parentNode.appendChild(sirv);
182            }
183
184        }
185    });
186
187    var SirvModelPath = SirvSpinsPath.replace('.spin', '.glb');
188
189    var modelURL = document.location.protocol.replace('file:', 'http:') + '//' + SirvID + '.sirv.com/' + SirvModelPath.replace(/{product\-id}/g, SirvProductID).replace(/{product\-sku}/g, SirvProductSKU).replace(/{product\-name}/g, $('h1.productView-title').text());    
190
191    jQuery.ajax({
192        url: modelURL,
193        type: 'HEAD',
194        cache: true,
195        timeout: 8000,
196        error: function(data) {},
197        success: function(data) {
198
199            jQuery('[data-slide-id="spin-model"]').remove();
200
201            jQuery('div[data-slide-id="zoom"]').after('<div style="display:none;" data-slide-id="spin-model"><model-viewer shadow-intensity="1" src="'+modelURL+'" camera-controls></model-viewer></div>');
202
203            jQuery('.MagicZoomSelectors').addClass('sirv-enabled').show().append('<a data-slide-id="spin-model" class="SirvIcon mz-thumb" href="#"><img id="SirvIcon" src="' + SirvIconURL + '"/></a>');
204
205            jQuery('.MagicZoomSelectors a[data-zoom-id]').first().addClass('active-magic-selector');
206
207            initMagicZoomPlusSelectors('a[data-slide-id="spin-model"]') 
208
209            var modeljs = document.createElement('script');
210            modeljs.type = 'module';
211            modeljs.src = 'https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js';
212            document.getElementsByTagName('script')[0].parentNode.appendChild(modeljs);
213            
214        }
215    });
216}
217
218
219function initMagicZoomPlusSelectors($s) {
220    jQuery($s).on('keydown', function(e) {
221        if(e.keyCode == 13 && $(this).hasClass('mz-thumb')) {
222           MagicZoom.switchTo('zoom', $(this).get(0))
223        }
224    })
225    jQuery($s).on(mzOptions.selectorTrigger == 'hover' ? 'mouseover click touchend' : 'click touchend', function(e) {
226    //jQuery($s).on('click touchend', function(e) {
227        if ( jQuery('div[data-slide-id]:visible iframe').length ==1 ) {
228          jQuery('div[data-slide-id]:visible iframe')[0].src = jQuery('div[data-slide-id]:visible iframe')[0].src;
229        }
230        jQuery('div[data-slide-id]').hide();
231        jQuery('div[data-slide-id="' + jQuery(this).attr('data-slide-id') + '"]').show();
232        jQuery('a.active-magic-selector').removeClass('active-magic-selector');
233        jQuery(this).addClass('active-magic-selector');
234
235        if ( jQuery('div[data-slide-id]:visible iframe').length == 1 && typeof jQuery('div[data-slide-id]:visible iframe').attr('src') == 'undefined' ) {
236          jQuery('div[data-slide-id]:visible iframe').attr('src', jQuery('div[data-slide-id]:visible iframe').attr('data-src') ).show()
237        }
238
239        e.preventDefault();
240    });
241}
242
243function isVideoSelector($s) {
244    var regex_youtube_short = /https?:\/\/youtu\.be\/([^\/]{1,})\/?/gm,
245        regex_youtube_full = /https?:\/\/www\.youtube\.com\/watch\?v=(.{1,})/gm,
246        regex_youtube_embed = /https?:\/\/www\.youtube\.com\/embed\/(.{1,})/gm,
247        regex_youtube_shorts = /https?:\/\/www\.youtube\.com\/shorts\/(.{1,})/gm,
248        regex_vimeo = /https?:\/\/vimeo\.com\/(.{1,})/gm,
249        regex_mp4 = /\.mp4$/gm,
250        video_id, video_type;
251    var m = regex_youtube_short.exec($s);
252    if (m) {
253        video_id = m[1];
254        video_type = 'youtube';
255    } else {
256        var m = regex_youtube_full.exec($s);
257        if (m) {
258            video_id = m[1];
259            video_type = 'youtube';
260        } else {
261            var m = regex_youtube_embed.exec($s);
262            if (m) {
263                video_id = m[1];
264                video_type = 'youtube';
265            } else {
266                var m = regex_vimeo.exec($s);
267                if (m) {
268                    video_id = m[1];
269                    video_type = 'vimeo';
270                } else {
271                    var m = regex_youtube_shorts.exec($s);
272                    if (m) {
273                        video_id = m[1];
274                        video_type = 'youtube';
275                    } else {
276                    var m = regex_mp4.exec($s);
277                        if (m) {
278                            video_type = 'mp4';
279                        }
280                    }
281                }
282            }  
283        }
284    }
285
286    if (video_type=='youtube') {
287        return '<iframe style="display:none" data-src="https://www.youtube.com/embed/'+video_id+'" frameborder="0" allowfullscreen></iframe>';
288    } else if (video_type=='vimeo') {
289        return '<iframe style="display:none" data-src="https://player.vimeo.com/video/'+video_id+'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
290    } else if (video_type=='mp4') {
291        return '<video controls><source src="' + $s + '" type="video/mp4"></video>';
292    }
293
294    return false;
295}
296
297/*
298var mzp_xhr_open = window.XMLHttpRequest.prototype.open,
299    mzp_xhr_send = window.XMLHttpRequest.prototype.send,
300    mzp_xhr_onReadyStateChangeReplacement;
301
302function mzp_xhr_openReplacement(method, url, async, user, password) {
303    var syncMode = async !== false ? 'async' : 'sync';
304    return mzp_xhr_open.apply(this, arguments);
305}
306function mzp_xhr_sendReplacement(data) {
307    if(this.onreadystatechange) {
308        this._onreadystatechange = this.onreadystatechange;
309    }
310    this.onreadystatechange = mzp_xhr_onReadyStateChangeReplacement;
311    return mzp_xhr_send.apply(this, arguments);
312}
313function mzp_xhr_onReadyStateChangeReplacement() {
314
315    if(this._onreadystatechange) {
316        this._onreadystatechange.apply(this, arguments);
317    }
318    if (this.readyState == 4 && this.responseText.match(/modal\-body quickView/gm)) {
319        setTimeout(initMagicZoomPlus,500);
320    }
321}
322
323
324window.XMLHttpRequest.prototype.open = mzp_xhr_openReplacement;
325window.XMLHttpRequest.prototype.send = mzp_xhr_sendReplacement;
326
327*/
328
329var themes = {
330
331   'juniperflowers': {
332        'imagesList': 'div[data-image-gallery]  img',
333        'galleryContainer': 'div[data-image-gallery] > figure',
334        'elementsToHide': 'ul.product-gallery__thumbnails'
335    },
336
337   'plumblinejewelry': {
338        'imagesList': '.product-images-wrapper  img',
339        'galleryContainer': '.product-images-container',
340        'elementsToHide': '.product-images-pagination-container'
341    },
342
343   'Superkart': {
344        'imagesList': '.productView-nav-inner .slick-slide:not(.slick-cloned) img, .productView-nav-inner  img',
345        'galleryContainer': '.productView-nav-inner',
346        'elementsToHide': '.productView-nav, .productView-for'
347    },
348
349    'Cornerstone_0': {
350        'imagesList': 'section.productView-images img',
351        'galleryContainer': '.ob-image-main-carousel ',
352        'elementsToHide': '.ob-image-below-carousel'
353    },
354    'Cornerstone_': {
355        'imagesList': '.productView__topLeft .productView-images img',
356        'galleryContainer': '.productView__topLeft .productView-images',
357        'elementsToHide': ''
358    },
359    'Cornerstone__': {
360        'imagesList': '.productView-image-wrap .slick-slide:not(.slick-cloned) img, .productView-image-wrap  img',
361        'galleryContainer': '.productView-image-wrap',
362        'elementsToHide': ''
363    },
364
365    'Light002': {
366        'imagesList': 'section.productView-images .productView-images--inner img',
367        'galleryContainer': 'section.productView-images .productView-images--inner',
368        'elementsToHide': ''
369    },
370
371    'Light001': {
372        'imagesList': '.themevale_productView-images .productView-image img',
373        'galleryContainer': '.themevale_productView-images',
374        'elementsToHide': '.themevale_productView-images'
375    },
376    'Light003': {
377        'imagesList': 'figure.productView-image img, .productView-thumbnails:not(.slick-initialized) img, .productView-thumbnails li:not(.slick-cloned) img',
378        'galleryContainer': '.main-image-container',
379        'elementsToHide': '.slider-nav'
380    },
381
382    'Light004': {
383        'imagesList': '.productView-nav:not(.slick-initialized) img, .productView-nav li:not(.slick-cloned) img, .productView-nav img',
384        'galleryContainer': '.productView-image-wrapper',
385        'elementsToHide': '.productView-thumbnail-wrapper'
386    },
387    
388    'Light00': {
389        'imagesList': 'figure.productView-image img, .productView-thumbnails:not(.slick-initialized) img, .productView-thumbnails li:not(.slick-cloned) img, .videoGallery lite-youtube',
390        'galleryContainer': 'figure.productView-image',
391        'elementsToHide': 'ul.productView-thumbnails, div.productView-thumbnails, .videoGallery lite-youtube, .mobile_view-slider'
392    },
393    'Light0': {
394        'imagesList': '.productView-thumbnails li:not(.slick-cloned) img',
395        'galleryContainer': 'figure.productView-image',
396        'elementsToHide': 'ul.productView-thumbnails, div.productView-thumbnails'
397    },
398    'Light': {
399        'imagesList': '.productView .productView-thumbnails .slick-slide:not(.slick-cloned) img',
400        'galleryContainer': 'figure.productView-image',
401        'elementsToHide': 'ul.productView-thumbnails, div.productView-thumbnails'
402    },
403    'Light2': {
404        'imagesList': '.productView .productView-thumbnails img',
405        'galleryContainer': 'ul.productView.productView-image',
406        'elementsToHide': 'ul.productView-thumbnails, div.productView-thumbnails'
407    },
408    // 'Fish': {
409    //     'imagesList': 'section.productView-images img',
410    //     'galleryContainer': 'section.productView-images ',
411    //     'elementsToHide': ''
412    // },
413    'Arcade': {
414        'imagesList': '.template-product .product-images img',
415        'galleryContainer': '.template-product .product-images',
416        'elementsToHide': ''
417    },
418    'Clean': {
419        'imagesList': '.product-wrap .product-thumbnails img',
420        'galleryContainer': '.product-wrap .product-main-image',
421        'elementsToHide': '.product-wrap .product-thumbnails'
422    },
423    'Exhibit': {
424        'imagesList': '.main-product-graphic .product-slides-container img',
425        'galleryContainer': '.main-product-graphic .product-slides-container',
426        'elementsToHide': ''
427    },
428
429    'Cornerstone_': {
430        'imagesList': '.productView__topLeft .productView-images img',
431        'galleryContainer': '.productView__topLeft .productView-images',
432        'elementsToHide': ''
433    },
434    'Cornerstone0': {
435        'imagesList': '.main-image-container img',
436        'galleryContainer': '.main-image-container',
437        'elementsToHide': '#product-images-container .slider-nav, ul.productView-thumbs'
438    },
439    'Cornerstone': {
440        'imagesList': '.productView-images img',
441        'galleryContainer': 'figure.productView-image',
442        'elementsToHide': 'ul.productView-thumbnails, .product-images-container .slider-nav, .productView-thumbs'
443    },
444    'Cornerstone2': {
445        'imagesList': '.productView-images .productView-thumbnails img',
446        'galleryContainer': '.productView-images .productView-image-update',
447        'elementsToHide': '.productView-images .productView-thumbnails'
448    },
449    'Covent': {
450        'imagesList': '.productView-images .productView-thumbs img',
451        'galleryContainer': 'figure.productView-image',
452        'elementsToHide': '.productView-thumbs'
453    },
454    'Covent2': {
455        'imagesList': '.productView-images .productView-img-container img',
456        'galleryContainer': 'figure.productView-image',
457        'elementsToHide': '.productView-thumbs'
458    },
459    'Merchant': {
460        'imagesList': 'body.product .product-slides-container img',
461        'galleryContainer': 'body.product .product-images-container',
462        'elementsToHide': 'body.product .product-images-container .product-images-p
462agination'
463    },
464    'Fortune': {
465        'imagesList': 'body.template-product .product-slideshow-wrapper img',
466        'galleryContainer': 'body.template-product .product-slideshow-wrapper',
467        'elementsToHide': 'body.template-product .single-product-thumbnails'
468    },
469    'Supermarket': {
470        'imagesList': '.productView-detailsWrapper .productView-images .productView-imageCarousel-main img',
471        'galleryContainer': '.productView-detailsWrapper .productView-images .productView-imageCarousel-main',
472        'elementsToHide': '.productView-detailsWrapper .productView-images .productView-imageCarousel-nav'
473    },
474    'Supermarket2': {
475        'imagesList': '.productView-images .productView-imageCarousel-main img',
476        'galleryContainer': '.productView-images .productView-imageCarousel-main',
477        'elementsToHide': '.productView-images .productView-imageCarousel-nav'
478    },
479    'Foundry': {
480        'imagesList': '.template-product .product-slideshow .product-slideshow-images img',
481        'galleryContainer': '.template-product .product-slideshow .product-slideshow-images',
482        'elementsToHide': '.template-product .product-slideshow .product-thumbnails, .template-product .product-slideshow .spinner'
483    },
484    'Eloquence': {
485        'imagesList': '.hero-carousel--product img',
486        'galleryContainer': '.hero-carousel--product',
487        'elementsToHide': '.hero-carousel-navContainer'
488    },
489    'Warm': {
490        'imagesList': 'body.product .product-container .product-images .product-thumbnails img',
491        'galleryContainer': 'body.product .product-container .product-images .product-main-image',
492        'elementsToHide': 'body.product .product-container .product-images .product-thumbnails'
493    },
494    'Solera': {
495        'imagesList': '.page-type-product .productView-images .productView-wrap .productView-image img',
496        'galleryContainer': '.page-type-product .productView-images .productView-wrap',
497        'elementsToHide': '.page-type-product .productView-images .productView-thumbnails'
498    },
499    'Brixton0': {
500        'imagesList': '.product-images .product-image-slide img',
501        'galleryContainer': '.product-view > .product-gallery ',
502        'elementsToHide': '.product-images-pagination'
503    },
504    'Brixton': {
505        'imagesList': '.product-images .product-image-slide img',
506        'galleryContainer': '.product-image-slides-wrap',
507        'elementsToHide': '.product-images-pagination'
508    },
509    'Warm2': // single image page
510    {
511        'imagesList': 'body.product .product-container .product-images .product-main-image img',
512        'galleryContainer': 'body.product .product-container .product-images .product-main-image',
513        'elementsToHide': 'body.product .product-container .product-images .product-thumbnails'
514    },
515     'QeRetail': {
516        'imagesList': '.productView-thumbnails .slick-slide:not(.slick-cloned) img, .productView-images  img',
517        'galleryContainer': '.productView-images-container',
518        'elementsToHide': ''
519    }
520}
521
522
523
524//var themes = {};
525
526// var $s = '<style type="text/css">';
527// for (var th in themes) {
528//     $s += themes[th].galleryContainer+' {visibility:hidden !important; x-aspect-ratio:1;} '+themes[th].elementsToHide+' {visibility:hidden !important; }';
529//     $s += '.modal-content '+themes[th].galleryContainer+' {visibility:visible !important; x-aspect-ratio:auto;} .modal-content '+themes[th].elementsToHide+' {visibility:visible !important; }';
530// }
531// $s += '</style>';
532// document.write($s);
533
534
535
536function initMagicZoomPlus() {
537
538    
539
540    mzOptions.onUpdate = function() {
541        jQuery('a.active-magic-selector').removeClass('active-magic-selector');
542        jQuery('a.mz-thumb-selected').addClass('active-magic-selector');
543    }
544
545    mzOptions.onZoomReady = function(id) {
546        if (!$mzp_firstImageIsVideo) {
547            jQuery('a.mz-thumb-selected').addClass('active-magic-selector');
548        }
549    }
550
551    for (var th in themes) {
552        var theme = themes[th];
553        if (jQuery(theme.imagesList).length && jQuery(theme.galleryContainer).length) {
554
555            var $scrollOptions = '';
556
557
558            if (window.matchMedia("(max-width: 767px)").matches) {
559                $scrollOptions = 'orientation:horizontal;width:100%;';
560            } else {
561                $scrollOptions = 'orientation:vertical;height:100%;';
562            }
563
564
565            var $gallery = jQuery('<div class="MagicZoomGallery ' + th + '"><div class="MagicZoomSelectors"><div' + ( UseMagicScroll == 'Yes' ? ' class="MagicScroll" data-options="'+$scrollOptions+'autostart:false;"' : '' ) + '></div></div></div>');
566
567            var $images = [];
568
569            jQuery(theme.imagesList).each(function(index, el) {
570                var $imageURL = jQuery(this).attr('src');
571
572                if (typeof jQuery(this).attr('data-src') !== typeof undefined && jQuery(this).attr('data-src') !== false) {
573                    $imageURL = jQuery(this).attr('data-src').replace(/(.*)\?.*$/gm, '$1');
574                }
575                if (typeof jQuery(this).attr('data-lazy') !== typeof undefined && jQuery(this).attr('data-lazy') !== false) {
576                    $imageURL = jQuery(this).attr('data-lazy').replace(/(.*)\?.*$/gm, '$1');
577                }
578
579                if (typeof $imageURL == 'undefined') {
580                    $imageURL = '';
581                }
582
583                //$imageURL = $imageURL/*.replace(/(.*)\?.*?$/gm,'$1')*/.replace(/stencil\/[0-9]{1,}x[0-9]{1,}\/products/gm, 'stencil/original/products');//.replace(/\?[^\/]*$/gm,'');//+'?c=2&imbypass=on&imbypass=on';
584                $imageURL = $imageURL/*.replace(/(.*)\?.*?$/gm,'$1')*/.replace(/stencil\/[0-9]{1,}x[0-9]{1,}\/products/gm, 'stencil/original/products').replace(/stencil\/[0-9]{1,}w\/products/gm, 'stencil/original/products');//.replace(/\?[^\/]*$/gm,'');//+'?c=2&imbypass=on&imbypass=on';
585                $imageURL = $imageURL.replace(/(\/\/i\.ytimg\.com\/vi\/.*?\/)(hq)?(default\.jpg)/gmi, '$1$3')
586                $imageURL = $imageURL.replace(/\?c=[0-9]{1,}/gmi, '')
587                $imageURL = $imageURL.replace(/\???imbypass=on/gmi, '')
588                
589
590                $done = true;
591                while($done) {
592                    $imageURL_ = decodeURIComponent($imageURL).replace(/%252/ims,'%2');
593                    $done = $imageURL_ != $imageURL;
594                    $imageURL = $imageURL_;
595                }
596
597               if (typeof $images[$imageURL] != 'undefined' || $imageURL.indexOf('btn-play.png') > 0 ) {
598                    return;
599                }
600                $images[$imageURL] = $imageURL;
601
602                var $alt = jQuery(this).attr('alt'),
603                    $title = jQuery(this).attr('alt');
604
605                if (typeof jQuery(this).attr('videoid') !=' undefined' && jQuery(this).prop("tagName") == 'LITE-YOUTUBE') {
606                    $alt = 'https://www.youtube.com/watch?v=' + jQuery(this).attr('videoid');
607                    $imageURL = 'https://img.youtube.com/vi/'+jQuery(this).attr('videoid')+'/0.jpg';
608                }
609
610                if (jQuery(this).closest('a').attr('data-type') == 'video' && typeof jQuery(this).closest('a').attr('data-video-id') != 'undefined') {
611                    $alt = 'https://www.youtube.com/watch?v=' + jQuery(this).closest('a').attr('data-video-id');
612                }
613                if (jQuery(this).closest('a').attr('data-type') == 'video' && typeof jQuery(this).closest('a').attr('data-modal-content') != 'undefined') {
614                    $alt = 'https://www.youtube.com/watch?v=' + jQuery(this).closest('a').attr('data-modal-content').replace(/.*https?:\/\/www\.youtube\.com\/embed\/(.*?)(\?|$).*/gm,'$1')
615                }
616                if ($imageURL.match(/\/\/i\.ytimg\.com\/vi\/(.*?)\/(hq)?default\.jpg/gmi)) {
617                    $videoCode = $imageURL.replace(/\/\/i\.ytimg\.com\/vi\/(.*?)\/(hq)?default\.jpg/gmi, '$1')
618                        $alt = 'https://www.youtube.com/watch?v=' + $videoCode;
619                }
620                if ($imageURL.match(/\/\/i\.ytimg\.com\/vi\/([^\/]{1,})\/.*$/gm)) {
621                    $alt = 'https://www.youtube.com/watch?v=' + $imageURL.replace(/\/\/i\.ytimg\.com\/vi\/([^\/]{1,})\/.*$/gm, '$1')
622                }
623
624                var $videoCode = isVideoSelector($alt);
625
626                if (index == 0) {
627                    $gallery.prepend(
628                        '<div data-slide-id="zoom" x-style="aspect-ratio:1;">' +
629                        '<a title="' + $title + '" class="MagicZoom" data-options="autostart:false;" id="zoom" href="' + $imageURL + '">' +
630                        '<img style="aspect-ratio:1 / 1; object-fit:contain;" title="' + $title + '" alt="' + $alt + '" src="' + $imageURL.replace(/\/original\//gm, '/1280w/') + '" xsrcset="' + $imageURL.replace(/\/original\//gm, '/1000x1318/') + ' 2x"/>' +
631                        '</a></div>'
632                    );
633                }
634
635                if ($videoCode) {
636                    $gallery.find('.MagicZoomSelectors > div').append('<a data-slide-id="video-' + index + '" href="#"><img src="' + $imageURL.replace(/\/original\//gm, '/100x100/') + '"/></a>');
637                    $gallery.find('div[data-slide-id="zoom"]').after('<div style="display:none" data-slide-id="video-' + index + '">' + $videoCode + '</div>');
638
639                    if (index == 0) {
640                        $mzp_firstImageIsVideo = true;
641                        $gallery.find('div[data-slide-id="zoom"]').hide();
642                        $gallery.find('div[data-slide-id="video-' + index + '"]').show();
643                        $gallery.find('a[data-slide-id="video-' + index + '"]').addClass('active-magic-selector');
644                    }
645
646                } else {
647                    $gallery.find('.MagicZoomSelectors > div').append('<a data-slide-id="zoom" title="' + $title + '" data-zoom-id="zoom" href="' + $imageURL + '" data-image="' + $imageURL.replace(/\/original\//gm, '/1280w/') + '" xdata-image-2x="' + $imageURL.replace(/\/original\//gm, '/1000x1318/') + '"><img data-style="aspect-ratio:1;object-fit:contain;" title="' + $title + '" alt="' + $alt + '" src="' + $imageURL.replace(/\/original\//gm, '/200x60/') + '"/></a>');
648                }
649
650            })
651
652            jQuery(theme.galleryContainer).after($gallery);
653            jQuery(theme.galleryContainer).hide();
654
655            if (jQuery('.MagicZoomSelectors a').length == 1) {
656                jQuery('.MagicZoomSelectors').hide();
657            }
658
659            initMagicZoomPlusSelectors('a[data-slide-id]');
660
661            jQuery(theme.elementsToHide).hide().wrap('<div style="display:none"></div>');
662            jQuery(document.body).addClass('MZP-' + th);
663
664
665            jQuery('.form-option-wrapper, .form-select-option').on('click', function() {
666
667
668
669                setTimeout(function(){
670
671                var data = { }, $formData = $('form[data-cart-item-add]').serializeArray();
672                for (var i in $formData) {
673                    data[$formData[i].name] = $formData[i].value;
674                }
675
676                console.warn('@1')
677
678
679                jQuery.ajax({
680                    dataType: "json",
681                    url: '/remote/v1/product-attributes/' + jQuery('input[name="product_id"]').val(),
682                    headers: { 'stencil-config': '{}', 'stencil-options': '{"render_with":"products/bulk-discount-rates"}', "x-xsrf-token": window.BCData && window.BCData.csrf_token ? window.BCData.csrf_token : "" },
683                    data: data,
684                    type: 'POST',
685                    success: function(response) {
686                        console.warn('@2')
687                        if (response.data.image != null) {
688                            jQuery('div[data-slide-id="spin"]').hide();
689                            jQuery('div[data-slide-id="zoom"]').show();
690                            MagicZoom.update('zoom', response.data.image.data.replace('{:size}', 'original'), response.data.image.data.replace('{:size}', '1280w'))
691                        }
692                        initSirv(response.data.sku);
693                    }
694                });
695
696                },200)
697                
698            });
699
700            $mjs(document).jAddEvent('domready', function() {
701                MagicZoom.start();
702            });
703
704            initSirv();
705
706            break;
707        }
708    }
709}

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.