PageSourceSearch

https://www.divento.com/themes/diventodesign/js/global.js?v=20260817c

js divento.com collected 2026-09-24 22:50:07 UTC 20,487 bytes, 534 lines download raw bytes

1/*
2 * 2007-2016 PrestaShop
3 *
4 * NOTICE OF LICENSE
5 *
6 * This source file is subject to the Academic Free License (AFL 3.0)
7 * that is bundled with this package in the file LICENSE.txt.
8 * It is also available through the world-wide-web at this URL:
9 * http://opensource.org/licenses/afl-3.0.php
10 * If you did not receive a copy of the license and are unable to
11 * obtain it through the world-wide-web, please send an email
12 * to [email protected] so we can send you a copy immediately.
13 *
14 * DISCLAIMER
15 *
16 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
17 * versions in the future. If you wish to customize PrestaShop for your
18 * needs please refer to http://www.prestashop.com for more information.
19 *
20 *  @author PrestaShop SA <[email protected]>
21 *  @copyright  2007-2016 PrestaShop SA
22 *  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
23 *  International Registered Trademark & Property of PrestaShop SA
24 */
25//global variables
26var responsiveflag = false;
27
28$(document).ready(function () {
29
30    highdpiInit();
31    responsiveResize();
32    $(window).resize(responsiveResize);
33    if (navigator.userAgent.match(/Android/i))
34    {
35        var viewport = document.querySelector('meta[name="viewport"]');
36        viewport.setAttribute('content', 'initial-scale=1.0,maximum-scale=1.0,user-scalable=0,width=device-width,height=device-height');
37        window.scrollTo(0, 1);
38    }
39    if (typeof quickView !== 'undefined' && quickView)
40        quick_view();
41    dropDown();
42
43    if (typeof page_name != 'undefined' && !in_array(page_name, ['index', 'product']))
44    {
45        bindGrid();
46
47        $(document).on('change', '.selectProductSort', function (e) {
48            if (typeof request != 'undefined' && request)
49                var requestSortProducts = request;
50            var splitData = $(this).val().split(':');
51            var url = '';
52            if (typeof requestSortProducts != 'undefined' && requestSortProducts)
53            {
54                url += requestSortProducts;
55                if (typeof splitData[0] !== 'undefined' && splitData[0])
56                {
57                    url += (requestSortProducts.indexOf('?') < 0 ? '?' : '&') + 'orderby=' + splitData[0];
58                    if (typeof splitData[1] !== 'undefined' && splitData[1])
59                        url += '&orderway=' + splitData[1];
60                }
61                document.location.href = url;
62            }
63        });
64
65        $(document).on('change', 'select[name="n"]', function () {
66            $(this.form).submit();
67        });
68
69        $(document).on('change', 'select[name="currency_payment"]', function () {
70            setCurrency($(this).val());
71        });
72    }
73
74    $(document).on('change', 'select[name="manufacturer_list"], select[name="supplier_list"]', function () {
75        if (this.value != '')
76            location.href = this.value;
77    });
78
79    $(document).on('click', '.back', function (e) {
80        e.preventDefault();
81        history.back();
82    });
83
84    jQuery.curCSS = jQuery.css;
85    if (!!$.prototype.cluetip)
86        $('a.cluetip').cluetip({
87            local: true,
88            cursor: 'pointer',
89            dropShadow: false,
90            dropShadowSteps: 0,
91            showTitle: false,
92            tracking: true,
93            sticky: false,
94            mouseOutClose: true,
95            fx: {
96                open: 'fadeIn',
97                openSpeed: 'fast'
98            }
99        }).css('opacity', 0.8);
100
101    if (typeof (FancyboxI18nClose) !== 'undefined' && typeof (FancyboxI18nNext) !== 'undefined' && typeof (FancyboxI18nPrev) !== 'undefined' && !!$.prototype.fancybox)
102        $.extend($.fancybox.defaults.tpl, {
103            closeBtn: '<a title="' + FancyboxI18nClose + '" class="fancybox-item fancybox-close" href="javascript:;"></a>',
104            next: '<a title="' + FancyboxI18nNext + '" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
105            prev: '<a title="' + FancyboxI18nPrev + '" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
106        });
107
108    // Close Alert messages
109    $(".alert.alert-danger").on('click', this, function (e) {
110        if (e.offsetX >= 16 && e.offsetX <= 39 && e.offsetY >= 16 && e.offsetY <= 34)
111            $(this).fadeOut();
112    });
113
114    setElementFillWidth("#search_block_top", ".navbar-header", ["#header_logo", "#userblock_top", ".navbar-toggle"]);
115
116    $(window).resize(function () {
117        setElementFillWidth("#search_block_top", ".navbar-header", ["#header_logo", "#userblock_top", ".navbar-toggle"]);
118    });
119});
120
121function highdpiInit()
122{
123    if (typeof highDPI === 'undefined')
124        return;
125    if (highDPI && $('.replace-2x').css('font-size') == "1px")
126    {
127        var els = $("img.replace-2x").get();
128        for (var i = 0; i < els.length; i++)
129        {
130            src = els[i].src;
131            extension = src.substr((src.lastIndexOf('.') + 1));
132            src = src.replace("." + extension, "2x." + extension);
133
134            var img = new Image();
135            img.src = src;
136            img.height != 0 ? els[i].src = src : els[i].src = els[i].src;
137        }
138    }
139}
140
141// Used to compensante Chrome/Safari bug (they don't care about scroll bar for width)
142function scrollCompensate()
143{
144    var inner = document.createElement('p');
145    inner.style.width = "100%";
146    inner.style.height = "200px";
147
148    var outer = document.createElement('div');
149    outer.style.position = "absolute";
150    outer.style.top = "0px";
151    outer.style.left = "0px";
152    outer.style.visibility = "hidden";
153    outer.style.width = "200px";
154    outer.style.height = "150px";
155    outer.style.overflow = "hidden";
156    outer.appendChild(inner);
157
158    document.body.appendChild(outer);
159    var w1 = inner.offsetWidth;
160    outer.style.overflow = 'scroll';
161    var w2 = inner.offsetWidth;
162    if (w1 == w2)
163        w2 = outer.clientWidth;
164
165    document.body.removeChild(outer);
166
167    return (w1 - w2);
168}
169
170function responsiveResize()
171{
172    compensante = scrollCompensate();
173    if (($(window).width() + scrollCompensate()) <= 767 && responsiveflag == false)
174    {
175        accordion('enable');
176        // accordionFooter('enable');
177        responsiveflag = true;
178    } else if (($(window).width() + scrollCompensate()) >= 768)
179    {
180        accordion('disable');
181        accordionFooter('disable');
182        responsiveflag = false;
183        if (typeof bindUniform !== 'undefined')
184            bindUniform();
185    }
186    blockHover();
187}
188
189function blockHover(status)
190{
191    var screenLg = $('body').find('.container').width() == 1170;
192
193    if ($('.product_list').is('.grid'))
194        if (screenLg)
195            $('.product_list .button-container').hide();
196        else
197            $('.product_list .button-container').show();
198
199    $(document).off('mouseenter').on('mouseenter', '.product_list.grid li.ajax_block_product .product-container', function (e) {
200        if (screenLg)
201        {
202            var pcHeight = $(this).parent().outerHeight();
203            var pcPHeight = $(this).parent().find('.button-container').outerHeight() + $(this).parent().find('.comments_note').outerHeight() + $(this).parent().find('.functional-buttons').outerHeight();
204            $(this).parent().addClass('hovered').css({'height': pcHeight + pcPHeight, 'margin-bottom': pcPHeight * (-1)});
205            $(this).find('.button-container').show();
206        }
207    });
208
209    $(document).off('mouseleave').on('mouseleave', '.product_list.grid li.ajax_block_product .product-container', function (e) {
210        if (screenLg)
211        {
212            $(this).parent().removeClass('hovered').css({'height': 'auto', 'margin-bottom': '0'});
213            $(this).find('.button-container').hide();
214        }
215    });
216}
217
218function quick_view()
219{
220    $(document).on('click', '.quick-view:visible, .quick-view-mobile:visible', function (e) {
221        e.preventDefault();
222        var url = this.rel;
223        var anchor = '';
224
225        if (url.indexOf('#') != -1)
226        {
227            anchor = url.substring(url.indexOf('#'), url.length);
228            url = url.substring(0, url.indexOf('#'));
229        }
230
231        if (url.indexOf('?') != -1)
232            url += '&';
233        else
234            url += '?';
235
236        if (!!$.prototype.fancybox)
237            $.fancybox({
238                'padding': 0,
239                'width': 1087,
240                'height': 610,
241                'type': 'iframe',
242                'href': url + 'content_only=1' + anchor
243            });
244    });
245}
246
247function bindGrid()
248{
249    var storage = false;
250    if (typeof (getStorageAvailable) !== 'undefined') {
251        storage = getStorageAvailable();
252    }
253    if (!storage) {
254        return;
255    }
256
257    var view = $.totalStorage('display');
258    view = 'grid';
259    if (!view && (typeof displayList != 'undefined') && displayList)
260        view = 'list';
261
262    if (view && view != 'grid')
263        display(view);
264    else
265        $('.display').find('li#grid').addClass('selected');
266
267    $(document).on('click', '#grid', function (e) {
268        e.preventDefault();
269        display('grid');
270    });
271
272    $(document).on('click', '#list', function (e) {
273        e.preventDefault();
274        display('list');
275    });
276}
277
278function display(view)
279{
280    if (view == 'list')
281    {
282        $('ul.product_list').removeClass('grid').addClass('list row');
283        $('.product_list > li').removeClass('col-xs-12 col-sm-6 col-md-4').addClass('col-xs-12');
284        $('.product_list > li').each(function (index, element) {
285            var html = '';
286            html = '<div class="product-container"><div class="row">';
287            html += '<div class="left-block col-xs-4 col-sm-5 col-md-4">' + $(element).find('.left-block').html() + '</div>';
288            html += '<div class="center-block col-xs-4 col-sm-7 col-md-4">';
289            html += '<div class="product-flags">' + $(element).find('.product-flags').html() + '</div>';
290            html += '<h5 itemprop="name">' + $(element).find('h5').html() + '</h5>';
291            var hookReviews = $(element).find('.hook-reviews');
292            if (hookReviews.length) {
293                html += hookReviews.clone().wrap('<div>').parent().html();
294            }
295            html += '<p class="product-desc">' + $(element).find('.product-desc').html() + '</p>';
296            var colorList = $(element).find('.color-list-container').html();
297            if (colorList != null) {
298                html += '<div class="color-list-container">' + colorList + '</div>';
299            }
300            var availability = $(element).find('.availability').html();	// check : catalog mode is enabled
301            if (availability != null) {
302                html += '<span class="availability">' + availability + '</span>';
303            }
304            html += '</div>';
305            html += '<div class="right-block col-xs-4 col-sm-12 col-md-4"><div class="right-block-content row">';
306            var price = $(element).find('.content_price').html();       // check : catalog mode is enabled
307            if (price != null) {
308                html += '<div class="content_price col-xs-5 col-md-12">' + price + '</div>';
309            }
310            html += '<div class="button-container col-xs-7 col-md-12">' + $(element).find('.button-container').html() + '</div>';
311            html += '<div class="functional-buttons clearfix col-sm-12">' + $(element).find('.functional-buttons').html() + '</div>';
312            html += '</div>';
313            html += '</div></div>';
314            $(element).html(html);
315        });
316        $('.display').find('li#list').addClass('selected');
317        $('.display').find('li#grid').removeAttr('class');
318        $.totalStorage('display', 'list');
319    } else
320    {
321        $('ul.product_list').removeClass('list').addClass('grid row');
322        $('.product_list > li').removeClass('col-xs-12').addClass('col-xs-12 col-sm-6 col-md-4');
323        $('.product_list > li').each(function (index, element) {
324            var html = '';
325            html += '<div class="product-container">';
326            html += '<div class="left-block">' + $(element).find('.left-block').html() + '</div>';
327            html += '<div class="right-block">';
328            html += '<div class="product-flags">' + $(element).find('.product-flags').html() + '</div>';
329            html += '<h5 itemprop="name">' + $(element).find('h5').html() + '</h5>';
330            var hookReviews = $(element).find('.hook-reviews');
331            if (hookReviews.length) {
332                html += hookReviews.clone().wrap('<div>').parent().html();
333            }
334            html += '<p itemprop="description" class="product-desc">' + $(element).find('.product-desc').html() + '</p>';
335            var price = $(element).find('.content_price').html(); // check : catalog mode is enabled
336            if (price != null) {
337                html += '<div class="content_price">' + price + '</div>';
338            }
339            html += '<div itemprop="offers" itemscope itemtype="https://schema.org/Offer" class="button-container">' + $(element).find('.button-container').html() + '</div>';
340            var colorList = $(element).find('.color-list-container').html();
341            if (colorList != null) {
342                html += '<div class="color-list-container">' + colorList + '</div>';
343            }
344            var availability = $(element).find('.availability').html(); // check : catalog mode is enabled
345            if (availability != null) {
346                html += '<span class="availability">' + availability + '</span>';
347            }
348            html += '</div>';
349            html += '<div class="functional-buttons clearfix">' + $(element).find('.functional-buttons').html() + '</div>';
350            html += '</div>';
351            $(element).html(html);
352        });
353        $('.display').find('li#grid').addClass('selected');
354        $('.display').find('li#list').removeAttr('class');
355        $.totalStorage('display', 'grid');
356    }
357}
358
359function dropDown()
360{
361    elementClick = '#header .current';
362    elementSlide = 'ul.toogle_content';
363    activeClass = 'active';
364
365    $(elementClick).on('click', function (e) {
366        e.stopPropagation();
367        var subUl = $(this).next(elementSlide);
368        if (subUl.is(':hidden'))
369        {
370            subUl.slideDown();
371            $(this).addClass(activeClass);
372        } else
373        {
374            subUl.slideUp();
375            $(this).removeClass(activeClass);
376        }
377        $(elementClick).not(this).next(elementSlide).slideUp();
378        $(elementClick).not(this).removeClass(activeClass);
379        e.preventDefault();
380    });
381
382    $(elementSlide).on('click', function (e) {
383        e.stopPropagation();
384    });
385
386    $(document).on('click', function (e) {
387        e.stopPropagation();
388        var elementHide = $(elementClick).next(elementSlide);
389        $(elementHide).slideUp();
390        $(elementClick).removeClass('active');
391    });
392}
393
394function accordionFooter(status)
395{
396    if (status == 'enable')
397    {
398        $('#footer .footer-block h4').on('click', function (e) {
399            $(this).toggleClass('active').parent().find('.toggle-footer').stop().slideToggle('medium');
400            e.preventDefault();
401        })
402        $('#footer').addClass('accordion').find('.toggle-footer').slideUp('fast');
403    } else
404    {
405        $('.footer-block h4').removeClass('active').off().parent().find('.toggle-footer').removeAttr('style').slideDown('fast');
406        $('#footer').removeClass('accordion');
407    }
408}
409
410function accordion(status)
411{
412    if (status == 'enable')
413    {
414        var accordion_selector = '#right_column .block .title_block, #left_column .block .title_block, #left_column #newsletter_block_left h4,' +
415                '#left_column .shopping_cart > a:first-child, #right_column .shopping_cart > a:first-child';
416
417        $(accordion_selector).on('click', function (e) {
418            $(this).toggleClass('active').parent().find('.block_content').stop().slideToggle('medium');
419        });
420        $('#right_column, #left_column').addClass('accordion').find('.block .block_content').slideUp('fast');
421        if (typeof (ajaxCart) !== 'undefined')
422            ajaxCart.collapse();
423    } else
424    {
425        $('#right_column .block .title_block, #left_column .block .title_block, #left_column #newsletter_block_left h4').removeClass('active').off().parent().find('.block_content').removeAttr('style').slideDown('fast');
426        $('#left_column, #right_column').removeClass('accordion');
427    }
428}
429
430function bindUniform()
431{
432    if (!!$.prototype.uniform)
433        $("select.form-control,input[type='radio'],input[type='checkbox']").not(".not_uniform").uniform();
434}
435
436function setElementsEqualHeight(elementSelector, additionalElementHeightSelector = null) {
437    var maxHeight = 0;
438    $(elementSelector).height('auto');
439    $(elementSelector).each(function () {
440        var thisHeight = $(this).height();
441        if (thisHeight > maxHeight) {
442            maxHeight = thisHeight;
443        }
444    });
445
446    var additionalHeight = 0;
447    if (additionalElementHeightSelector) {
448        additionalHeight = $(elementSelector + " " + additionalElementHeightSelector).first().outerHeight();
449    }
450
451    $(elementSelector).height(maxHeight + additionalHeight);
452}
453
454function setElementFillWidth(elementSelector, containerSelector, siblingsSelectors) {
455    $(elementSelector).width('1em');
456
457    const containerWidth = $(containerSelector).innerWidth();
458
459    var siblingsWidth = 0;
460    siblingsSelectors.forEach((siblingSelector) => {
461        if ($(siblingSelector)) {
462            siblingsWidth += $(siblingSelector).outerWidth();
463        }
464    });
465
466    $(elementSelector).width(containerWidth - (siblingsWidth * 1.2));
467}
468
469$('a[href*="#"], #diventoplanmytrip-backtotop a')
470        .click(function (event) {
471            // On-page links
472            if (
473                    location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
474                    &&
475                    location.hostname == this.hostname
476                    ) {
477                // Figure out element to scroll to
478                var target = $(this.hash);
479                target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
480                // Does a scroll target exist?
481                if (target.length) {
482                    // Only prevent default if animation is actually gonna happen
483                    event.preventDefault();
484                    $('html, body').animate({
485                        scrollTop: target.offset().top
486                    }, 1000, function () {
487                        // Callback after animation
488                        // Must change focus!
489                        var $target = $(target);
490                        $target.focus();
491                        if ($target.is(":focus")) { // Checking if the target was focused
492                            return false;
493                        } else {
494                            $target.attr('tabindex', '-1'); // Adding tabindex for elements not focusable
495                            $target.focus(); // Set focus again
496                        }
497                        ;
498                    });
499                }
500            }
501        });
502
503(function ($) {
504    "use strict";
505
506    $(document).ready(function () {
507
508        // Custom Select Boxes
509        //----------------------------------------//
510
511        $('.orderby').selectric();
512
513
514        var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? true : false;
515
516        $(".variables select").each(function () {
517            if (!isMobile) {
518                var sb = new SelectBox({
519                    selectbox: $(this)
520                });
521                void(sb);
522
523            }
524        });
525
526        if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
527            $(".variables select").css({'display': 'block'});
528        }
529
530
531        // ------------------ End Document ------------------ //
532    });
533
534})(this.jQuery);

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.