PageSourceSearch

https://hancockslondon.com/static/version1790758212/frontend/Hancocks/London/en_GB/js/hancocks.js

js hancockslondon.com collected 2026-10-02 18:41:42 UTC 20,836 bytes, 495 lines download raw bytes

1require([
2    'jquery',
3    'Mageplaza_LayeredNavigation/js/view/layer',
4    'owlCarousel',
5    'mage/collapsible'
6], function ($, layer, owlCarousel) {
7    $(document).ready(function () {
8        var owl = $('#owlslider');
9        owl.owlCarousel({
10            margin: 2,
11            nav: false,
12            loop: true,
13            autoplay: true,
14            autoplayTimeout: 4000,
15            smartSpeed: 1000,
16            autoplayHoverPause: true,
17            responsive: {
18                0: {
19                    items: 2
20                },
21                769: {
22                    items: 3
23                },
24                1440: {
25                    items: 4
26                }
27            },
28        });
29
30        // $('#banner-widget-desktop').owlCarousel({
31        //     items: 1,
32        //     loop: true,
33        //     autoplay: true,
34        //     autoplayTimeout: 5000,
35        //     smartSpeed: 1000,
36        //     autoplayHoverPause: true,
37        //     nav: false,
38        //     dots: false,
39        //     animateOut: 'fadeOut'
40        // });
41
42        // $('#banner-widget-mobile').owlCarousel({
43        //     items: 1,
44        //     loop: true,
45        //     autoplay: true,
46        //     autoplayTimeout: 5000,
47        //     smartSpeed: 1000,
48        //     autoplayHoverPause: true,
49        //     nav: false,
50        //     dots: false,
51        //     animateOut: 'fadeOut'
52        // });
53
54        $(window).on("resize", function (e) {
55            if (window.outerWidth < 768) {
56                myOwlCarousel();
57            }
58        })
59
60        if (window.outerWidth < 768) {
61            myOwlCarousel();
62        }
63
64        function myOwlCarousel() {
65            $('#owl-carousel-product-detail').owlCarousel({
66                loop: true,
67                margin: 10,
68                nav: true,
69                autoplay: true,
70                autoplayTimeout: 3000,
71                smartSpeed: 1000,
72                autoplayHoverPause: true,
73                responsive: {
74                    0: {
75                        items: 5,
76                        dots: false,
77                        loop: true,
78                        nav: false,
79                        margin: 1,
80                    },
81                    768: {
82
83                    }
84                }
85            })
86        }
87
88        var isMacOS = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
89        if ($(window).width() >= 769) {
90            if (isMacOS) {
91                $('.page-wrapper .header-main .header-top .header-top-right .minicart-wrapper').css("margin-bottom", "4px");
92            } else {
93                $('.page-wrapper .header-main .header-top .header-top-right .minicart-wrapper').css("margin-bottom", "0px");
94            }
95        } else {
96            if (isMacOS) {
97                $('.page-wrapper .header-main .header-top .header-top-right .minicart-wrapper').css("margin-top", "1px");
98            }
99        }
100
101        if ($(window).width() >= 992 && $(window).width() <= 1440) {
102            if (isMacOS) {
103                $('.page-wrapper .header-main .header-top .header-top-right .minicart-wrapper').css("margin-top", "4px");
104            }
105        } else {
106            if (isMacOS) {
107                $('.page-wrapper .header-main .header-top .header-top-right .minicart-wrapper').css("margin-top", "0px");
108            }
109        }
110
111        var fadeInElement = $('.fade-in .heading');
112        var winBottom = $(window).scrollTop() + $(window).height();
113        fadeInElement.each((i, e) => {
114            var elementBottom = $(e).offset().top + $(e).height();
115            if (winBottom > elementBottom) $(e).css({ 'opacity': 1, 'transition': 'opacity 1s ease-in' });
116        });
117        $(window).scroll(() => {
118            var winBottom = $(window).scrollTop() + $(window).height();
119            fadeInElement.each((i, e) => {
120                var elementBottom = $(e).offset().top + $(e).height();
121                if (winBottom > elementBottom) $(e).css({ 'opacity': 1, 'transition': 'opacity 1s ease-in' });
122                else $(e).removeAttr('style');
123            });
124        });
125        $('.cms-index-index .action.showcart, #search').on('click', function () {
126            document.body.scrollTop = 0; // For Safari
127            document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
128        });
129        $('.breadcrumbs .filter-bc-btn').on('click', function (event) {
130            event.preventDefault();
131            $('.block-filters strong[data-role="title"]').trigger('click');
132        });
133
134        $('#layered-filter-block-container .action-close').on('click', function () {
135            $('.block-filters strong[data-role="title"]').trigger('click');
136            $("[data-role=ln_collapsible]").removeClass("active");
137            $("#layered-filter-block .block-content").removeClass("filter-content-50");
138            $("#layered-filter-block .block-content").removeClass("filter-content-100");
139        });
140
141        $('.block-search-mobile').on('click', function (event) {
142            $("form.minisearch").addClass("main");
143            $("body").addClass("minisearch-open");
144        });
145
146        $('.block-search-sticky').on('click', function (event) {
147            event.preventDefault();
148            event.stopPropagation();
149
150            $("form.minisearch").addClass("main active");
151            $("#search").focus();
152            $("body").addClass("minisearch-open");
153            $("form.minisearch").css({
154                "opacity": "1",
155                "transition": "opacity 0.3s"
156            });
157        });
158
159        $('#product-addtocart-button').on('click', function () {
160
161            setTimeout(function () {
162                // $('body').addClass('cart-open');
163                // $('.minicart-wrapper').addClass('active');
164                // $('.action.showcart').addClass('active');
165
166                $(".minicart-wrapper").addClass("admindev");
167                $(".header-top-right .minicart-wrapper").addClass('active');
168                $(".minicart-items-wrapper").addClass("active");
169                $(".minicart-wrapper").addClass("show-mini");
170                $("body").addClass("cart-open");
171                $('.header-top-right [data-block="minicart"]').find('[data-role="dropdownDialog"]').dropdownDialog('close');
172                $("body").addClass("update-minicart");
173                $('.action.primary.tocart').removeClass('active');
174            }, 3500);
175
176            setTimeout(function () {
177                $('#product-addtocart-button').addClass('active');
178            }, 0);
179        });
180
181
182        // $('body').on('click', function () {
183        //     $('body').removeClass('cart-open');
184        //     $('.minicart-wrapper').removeClass('active');
185        //     $('.action.showcart').removeClass('active');
186        //     $('.action.primary.tocart').removeClass('active');
187        //     $('#product-addtocart-button').removeClass('active');
188        // });
189
190        $('.filter-options-item').on('click', function (event) {
191            if ($(window).width() >= 769) {
192                if (!$(this).hasClass("active")) {
193                    $("#layered-filter-block .block-content").removeClass("filter-content-100");
194                }
195                else $("#layered-filter-block .block-content").addClass("filter-content-100");
196                if (!$("#layered-filter-block .block-content").hasClass('filter-content-50'))
197                    $("#layered-filter-block .block-content").addClass("filter-content-50");
198            }
199        });
200
201
202        $('.filter-options-title-custom').on('click', function (event) {
203            if ($(window).width() >= 769) {
204                $("#layered-filter-block .block-content").addClass("filter-content-100");
205            }
206        });
207        $('.block-filters strong[data-role="title"]').on('click', function () {
208            var fillterContent = $("#layered-filter-block .block-content");
209            if ($(window).width() >= 769) {
210                if (fillterContent.hasClass('filter-content-100'))
211                    fillterContent.removeClass("filter-content-100");
212                else {
213                    fillterContent.addClass("filter-content-100");
214                    var isAnyfillter = false;
215                    $('.filter-options-item  #count-checked-checkboxes').each((i, e) => {
216                        if ($(e).text().length > 0) {
217                            $(e).parent().parent().addClass('active allow');
218                            isAnyfillter = true;
219                            return false;
220                        }
221                    });
222                    if (isAnyfillter)
223                        fillterContent.addClass('filter-content-100');
224                    else
225                        fillterContent.removeClass('filter-content-100');
226                }
227                if (fillterContent.hasClass('filter-content-50'))
228                    fillterContent.removeClass("filter-content-50");
229                else fillterContent.addClass("filter-content-50");
230
231
232            }
233        })
234
235        $('.action-close-mobile').off('click').on('click', function () {
236            $("html").removeClass("nav-open");
237            $(".action-close-mobile").removeClass("close-active");
238            setTimeout(function () {
239                $("html").removeClass("nav-before-open");
240            }, 300);
241        })
242
243        $('.filter-options-item.allow.active .title').off('click').on('click', function () {
244            $("[data-role=ln_collapsible]").removeClass("active");
245        })
246
247        $('.filter-options-subtitle .title').off('click').on('click', function () {
248            if ($(window).width() < 769) {
249                var elements = $('.filter-options-item');
250                var elementsActive = $('.filter-options-item.active');
251                var index = elements.index(elementsActive);
252                $('.block-content.filter-content').layer('deactivate', index);
253            }
254        })
255
256        $(".footer-container .container .footer .footer-middle .content .block p").off("click").on("click", function () {
257            if (!$(this).parent().children(".textwidget").hasClass("opened")) {
258                $(this).parent().children(".textwidget").addClass("opened");
259            }
260            else {
261                $(this).parent().children(".textwidget").removeClass("opened");
262            }
263        });
264
265        function showStickyHeader(headerHeight) {
266
267            var scrTop = $(window).scrollTop(),
268                pageMain = $(".page-wrapper #maincontent"),
269                winWidth = $(window).width();
270            header = $('header.page-header');
271            pageMain.css('margin-top', headerHeight);
272            if (scrTop > headerHeight / 2) {
273                header.addClass('header-sticky');
274                if (winWidth > 991) {
275                    header.css("top", -$('header.page-header').height() * (38 / 100));
276                }
277                $(".page-wrapper header.page-header.header-sticky .header-bottom .header-center .logo").css("-webkit-transform", "scale(65%)");
278                $(".page-wrapper header.page-header.header-sticky .header-search-sticky").css("display", "block");
279            } else {
280                header.css('position', 'fixed');
281                header.css("top", 0);
282                if (winWidth > 768)
283                    header.removeClass('header-sticky');
284                else {
285                    header.addClass('header-sticky');
286                    headerHeight = $('.header-sticky').height();
287                }
288                $(".page-wrapper header.page-header .header-bottom .header-center .logo").css("-webkit-transform", "scale(100%)");
289                $(".page-wrapper header.page-header .header-search-sticky").css("display", "none");
290                pageMain.css('margin-top', headerHeight);
291
292
293            }
294            $('.page.messages.TopRight.close_on_click').css('top', headerHeight);
295            $('.messages').css('top', headerHeight);
296            $('.checkout-index-index .message.notice').css('top', headerHeight);
297
298            $("button.button.action.continue.primary").on('click', function (e) {
299                $('.checkout-index-index .notice').addClass('message');
300            });
301
302        }
303        var isIpad = /(iPad)/i.test(navigator.userAgent);
304        if (isIpad) $('.page-wrapper').addClass('ipad-header');
305        function headerRender() {
306            header = $('header.page-header'),
307                headerHeight = header.height();
308            showStickyHeader(headerHeight);
309            $(window).on('scroll', function (e) {
310                var scroll = $(window).scrollTop(),
311                    winWidth = $(window).width();
312
313                if (scroll == 0) {
314                    showStickyHeader(headerHeight);
315                }
316                if (scroll > 0 && !$('.page-header.header-sticky').length > 0) {
317                    showStickyHeader(headerHeight);
318                }
319                filter_container = $('.layered-filter-block-container .filter-title');
320                filter_container
321                    .css('position', 'static')
322                    .css('left', 0)
323                    .css('right', 0)
324                    .css('z-index', 98)
325                    .css('transition', 'all 0.5s ease')
326                if (filter_container.length) {
327                    if (scroll + 60 >= filter_container.offset().top) {
328                        filter_container.addClass('stickey-filter');
329                        var filterMargin = $('.page-header.header-sticky').height();
330                        if (winWidth > 991) {
331                            if (winWidth > 992 && winWidth < 1700) filterMargin = 62;
332                            else filterMargin = 60;
333                        }
334                        else {
335                            filterMargin--;
336                        }
337                        filter_container.css('position', 'fixed').css('top', filterMargin)
338                        $('.breadcrumbs .breakcrumbs-wrap').addClass('show');
339
340
341
342                    } else {
343                        filter_container.removeClass('stickey-filter');
344                        filter_container.css('position', 'static');
345                        $('.breadcrumbs .breakcrumbs-wrap').removeClass('show');
346                    }
347                }
348                if ($('.page-main .img-responsive').length) {
349                    var elementOffset = $('.page-main .img-responsive').offset().top;
350                    var s = scroll - elementOffset;
351                    if (s >= -470) {
352                        $(".founding.i.maker, .line, .title.ani, .brand-short-description.p").css('transition', 'all 0.6s ease 0s');
353                        $(".founding.i.maker, .line, .title.ani, .brand-short-description.p").css('transform', 'translateY(0px)');
354                        $(".founding.i.maker, .line, .title.ani, .brand-short-description.p").css('opacity', '1');
355                    }
356                }
357            });
358
359        }
360        headerRender();
361        $(window).resize(function () {
362            setTimeout(() => {
363                headerRender()
364            }, 100)
365        });
366
367
368        $(document).mouseup(function (e) {
369            var div = $("#layered-filter-block-container .filter-content");
370            if (!div.is(e.target)
371                && div.has(e.target).length === 0) {
372                body = $('.filter-active.page-products');
373                if (body.length !== 0) {
374                    $('.block-filters strong[data-role="title"]').trigger('click');
375                    $("[data-role=ln_collapsible]").removeClass("active");
376                }
377            }
378        });
379
380        window.addEventListener('load', updateMaxHeight);
381        window.addEventListener('resize', updateMaxHeight);
382
383        function updateMaxHeight() {
384            var firstBlockElements = document.querySelectorAll('.first-block-attributes .information-block');
385            var secondBlockElements = document.querySelectorAll('.second-block-attributes .information-block');
386
387            for (var i = 0; i < Math.max(firstBlockElements.length, secondBlockElements.length); i++) {
388                var firstBlockHeight = (firstBlockElements[i]) ? firstBlockElements[i].offsetHeight : 0;
389                var secondBlockHeight = (secondBlockElements[i]) ? secondBlockElements[i].offsetHeight : 0;
390
391                var maxHeight = Math.max(firstBlockHeight, secondBlockHeight);
392
393                if (firstBlockElements[i]) {
394                    firstBlockElements[i].style.minHeight = maxHeight + 'px';
395                }
396
397                if (secondBlockElements[i]) {
398                    secondBlockElements[i].style.minHeight = maxHeight + 'px';
399                }
400            }
401        }
402
403        // function setHeightWidthBySelector(selector, ratio) {
404        //     var updateHeightWidth = function () {
405
406        //         var elements = document.querySelectorAll(selector);
407        //         elements.forEach(function (element) {
408        //             var width = element.offsetWidth;
409        //             var height = width * (ratio[1] / ratio[0]);
410        //             element.style.height = height + "px";
411        //         });
412
413        //     };
414
415        //     window.addEventListener('load', updateHeightWidth);
416        //     window.addEventListener('resize', updateHeightWidth);
417
418        //     updateHeightWidth();
419        // }
420
421        // setHeightWidthBySelector('.bottom-ads-homepage .background-img', [9, 11]);
422        // setHeightWidthBySelector('.bottom-ads-homepage .background-img .product-item-link', [9, 11]);
423        // setHeightWidthBySelector('.bottom-ads-homepage .product-image-photo', [9, 11]);
424
425        // function updateTargetElementsSize() {
426        //     var sampleElement = document.querySelector('.catalog-product-view .block-content.content .owl-item');
427        //     var sampleWidth = sampleElement.offsetWidth;
428
429        //     var targetElements = document.querySelectorAll('.catalog-product-view .block-content.content .product-image-wrapper.figure');
430        //     targetElements.forEach(function (targetElement) {
431        //         targetElement.style.height = ((sampleWidth * 11) / 9) + 'px';
432        //     });
433        //     var targetElements1 = document.querySelectorAll('.catalog-product-view .block-content.content .product-image-photo');
434        //     targetElements1.forEach(function (targetElement) {
435        //         targetElement.style.height = ((sampleWidth * 11) / 9) + 'px';
436        //     });
437        // }
438
439        // window.addEventListener('load', updateTargetElementsSize);
440        // window.addEventListener('resize', updateTargetElementsSize);
441
442        function setHeightByTopAdsHomepage(selector, ratioWidth, ratioHeight) {
443            var elements = document.querySelectorAll(selector);
444            elements.forEach(function (element) {
445                var width = element.offsetWidth;
446                var height = (width * ratioHeight) / ratioWidth;
447                element.style.height = height + 'px';
448            });
449        }
450
451        function updateElementsSize() {
452            setHeightByTopAdsHomepage('.top-ads-homepage .background-img', 9, 11);
453        }
454
455        window.addEventListener('load', updateElementsSize);
456        window.addEventListener('resize', updateElementsSize);
457
458
459        var jewelleryItem = $('.level-top').filter(function () {
460            return $(this).text().trim() === 'Jewellery';
461        }).parent();
462
463        if (jewelleryItem.length > 0) {
464            var ringsItem = jewelleryItem.find('a[href*="/rings"]').parent();
465
466            if (ringsItem.length > 0) {
467                var signetRingsLink = '<li class="ui-menu-item level3"><a href="/jewellery/shop-by-collection/signet-rings"><span>Signet Rings</span></a></li>';
468
469                ringsItem.find('.subchildmenu').append(signetRingsLink);
470            }
471        }
472
473        var activeItem = $("#banner-widget-desktop").find(".owl-item.active");
474        var dataColor = activeItem.find(".item").data("color");
475        var targetClass = $('.page-header');
476        var targetClass1 = $('.page-main');
477        targetClass.addClass('black');
478        targetClass1.addClass('black');
479
480        var owl = $("#banner-widget-desktop");
481        owl.on('changed.owl.carousel', function (e) {
482            if (e.relatedTarget.current() === 3) {
483                targetClass.removeClass('black');
484                targetClass.addClass('white');
485                targetClass1.removeClass('black');
486                targetClass1.addClass('white');
487            } else {
488                targetClass.removeClass('white');
489                targetClass.addClass('black');
490                targetClass1.removeClass('white');
491                targetClass1.addClass('black');
492            }
493        })
494    });
495});

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.