Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3. * 2007-2016 PrestaShop
  4.  
  5. *
  6.  
  7. * NOTICE OF LICENSE
  8.  
  9. *
  10.  
  11. * This source file is subject to the Academic Free License (AFL 3.0)
  12.  
  13. * that is bundled with this package in the file LICENSE.txt.
  14.  
  15. * It is also available through the world-wide-web at this URL:
  16.  
  17. * http://opensource.org/licenses/afl-3.0.php
  18.  
  19. * If you did not receive a copy of the license and are unable to
  20.  
  21. * obtain it through the world-wide-web, please send an email
  22.  
  23. * to license@prestashop.com so we can send you a copy immediately.
  24.  
  25. *
  26.  
  27. * DISCLAIMER
  28.  
  29. *
  30.  
  31. * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
  32.  
  33. * versions in the future. If you wish to customize PrestaShop for your
  34.  
  35. * needs please refer to http://www.prestashop.com for more information.
  36.  
  37. *
  38.  
  39. *  @author PrestaShop SA <contact@prestashop.com>
  40.  
  41. *  @copyright  2007-2016 PrestaShop SA
  42.  
  43. *  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  44.  
  45. *  International Registered Trademark & Property of PrestaShop SA
  46.  
  47. */
  48.  
  49. //global variables
  50.  
  51. var responsiveflag = false;
  52.  
  53.  
  54.  
  55. $(document).ready(function(){
  56.  
  57.     highdpiInit();
  58.  
  59.     responsiveResize();
  60.  
  61.     $(window).resize(responsiveResize);
  62.  
  63.     if (navigator.userAgent.match(/Android/i))
  64.  
  65.     {
  66.  
  67.         var viewport = document.querySelector('meta[name="viewport"]');
  68.  
  69.         viewport.setAttribute('content', 'initial-scale=1.0,maximum-scale=1.0,user-scalable=0,width=device-width,height=device-height');
  70.  
  71.         window.scrollTo(0, 1);
  72.  
  73.     }
  74.  
  75.     if (typeof quickView !== 'undefined' && quickView)
  76.  
  77.         quick_view();
  78.  
  79.     dropDown();
  80.  
  81.  
  82.  
  83.     if (typeof page_name != 'undefined' && !in_array(page_name, ['index', 'product']))
  84.  
  85.     {
  86.  
  87.         bindGrid();
  88.  
  89.  
  90.  
  91.         $(document).on('change', '.selectProductSort', function(e){
  92.  
  93.             if (typeof request != 'undefined' && request)
  94.  
  95.                 var requestSortProducts = request;
  96.  
  97.             var splitData = $(this).val().split(':');
  98.  
  99.             var url = '';
  100.  
  101.             if (typeof requestSortProducts != 'undefined' && requestSortProducts)
  102.  
  103.             {
  104.  
  105.                 url += requestSortProducts ;
  106.  
  107.                 if (typeof splitData[0] !== 'undefined' && splitData[0])
  108.  
  109.                 {
  110.  
  111.                     url += ( requestSortProducts.indexOf('?') < 0 ? '?' : '&') + 'orderby=' + splitData[0];
  112.  
  113.                     if (typeof splitData[1] !== 'undefined' && splitData[1])
  114.  
  115.                         url += '&orderway=' + splitData[1];
  116.  
  117.                 }
  118.  
  119.                 document.location.href = url;
  120.  
  121.             }
  122.  
  123.         });
  124.  
  125.  
  126.  
  127.         $(document).on('change', 'select[name="n"]', function(){
  128.  
  129.             $(this.form).submit();
  130.  
  131.         });
  132.  
  133.  
  134.  
  135.         $(document).on('change', 'select[name="currency_payment"]', function(){
  136.  
  137.             setCurrency($(this).val());
  138.  
  139.         });
  140.  
  141.     }
  142.  
  143.  
  144.  
  145.     $(document).on('change', 'select[name="manufacturer_list"], select[name="supplier_list"]', function(){
  146.  
  147.         if (this.value != '')
  148.  
  149.             location.href = this.value;
  150.  
  151.     });
  152.  
  153.  
  154.  
  155.     $(document).on('click', '.back', function(e){
  156.  
  157.         e.preventDefault();
  158.  
  159.         history.back();
  160.  
  161.     });
  162.  
  163.  
  164.  
  165.     jQuery.curCSS = jQuery.css;
  166.  
  167.     if (!!$.prototype.cluetip)
  168.  
  169.         $('a.cluetip').cluetip({
  170.  
  171.             local:true,
  172.  
  173.             cursor: 'pointer',
  174.  
  175.             dropShadow: false,
  176.  
  177.             dropShadowSteps: 0,
  178.  
  179.             showTitle: false,
  180.  
  181.             tracking: true,
  182.  
  183.             sticky: false,
  184.  
  185.             mouseOutClose: true,
  186.  
  187.             fx: {
  188.  
  189.                 open:       'fadeIn',
  190.  
  191.                 openSpeed:  'fast'
  192.  
  193.             }
  194.  
  195.         }).css('opacity', 0.8);
  196.  
  197.  
  198.  
  199.     if (typeof(FancyboxI18nClose) !== 'undefined' && typeof(FancyboxI18nNext) !== 'undefined' && typeof(FancyboxI18nPrev) !== 'undefined' && !!$.prototype.fancybox)
  200.  
  201.         $.extend($.fancybox.defaults.tpl, {
  202.  
  203.             closeBtn : '<a title="' + FancyboxI18nClose + '" class="fancybox-item fancybox-close" href="javascript:;"></a>',
  204.  
  205.             next     : '<a title="' + FancyboxI18nNext + '" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
  206.  
  207.             prev     : '<a title="' + FancyboxI18nPrev + '" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
  208.  
  209.         });
  210.  
  211.  
  212.  
  213.     // Close Alert messages
  214.  
  215.     $(".alert.alert-danger").on('click', this, function(e){
  216.  
  217.         if (e.offsetX >= 16 && e.offsetX <= 39 && e.offsetY >= 16 && e.offsetY <= 34)
  218.  
  219.             $(this).fadeOut();
  220.  
  221.     });
  222.  
  223. });
  224.  
  225.  
  226.  
  227. function highdpiInit()
  228.  
  229. {
  230.  
  231.     if (typeof highDPI === 'undefined')
  232.  
  233.         return;
  234.  
  235.     if(highDPI && $('.replace-2x').css('font-size') == "1px")
  236.  
  237.     {
  238.  
  239.         var els = $("img.replace-2x").get();
  240.  
  241.         for(var i = 0; i < els.length; i++)
  242.  
  243.         {
  244.  
  245.             src = els[i].src;
  246.  
  247.             extension = src.substr( (src.lastIndexOf('.') +1) );
  248.  
  249.             src = src.replace("." + extension, "2x." + extension);
  250.  
  251.  
  252.  
  253.             var img = new Image();
  254.  
  255.             img.src = src;
  256.  
  257.             img.height != 0 ? els[i].src = src : els[i].src = els[i].src;
  258.  
  259.         }
  260.  
  261.     }
  262.  
  263. }
  264.  
  265.  
  266.  
  267.  
  268.  
  269. // Used to compensante Chrome/Safari bug (they don't care about scroll bar for width)
  270.  
  271. function scrollCompensate()
  272.  
  273. {
  274.  
  275.     var inner = document.createElement('p');
  276.  
  277.     inner.style.width = "100%";
  278.  
  279.     inner.style.height = "200px";
  280.  
  281.  
  282.  
  283.     var outer = document.createElement('div');
  284.  
  285.     outer.style.position = "absolute";
  286.  
  287.     outer.style.top = "0px";
  288.  
  289.     outer.style.left = "0px";
  290.  
  291.     outer.style.visibility = "hidden";
  292.  
  293.     outer.style.width = "200px";
  294.  
  295.     outer.style.height = "150px";
  296.  
  297.     outer.style.overflow = "hidden";
  298.  
  299.     outer.appendChild(inner);
  300.  
  301.  
  302.  
  303.     document.body.appendChild(outer);
  304.  
  305.     var w1 = inner.offsetWidth;
  306.  
  307.     outer.style.overflow = 'scroll';
  308.  
  309.     var w2 = inner.offsetWidth;
  310.  
  311.     if (w1 == w2) w2 = outer.clientWidth;
  312.  
  313.  
  314.  
  315.     document.body.removeChild(outer);
  316.  
  317.  
  318.  
  319.     return (w1 - w2);
  320.  
  321. }
  322.  
  323.  
  324.  
  325. function responsiveResize()
  326.  
  327. {
  328.  
  329.     compensante = scrollCompensate();
  330.  
  331.     if (($(window).width()+scrollCompensate()) <= 767 && responsiveflag == false)
  332.  
  333.     {
  334.  
  335.         accordion('enable');
  336.  
  337.         accordionFooter('enable');
  338.  
  339.         responsiveflag = true;
  340.  
  341.     }
  342.  
  343.     else if (($(window).width()+scrollCompensate()) >= 768)
  344.  
  345.     {
  346.  
  347.         accordion('disable');
  348.  
  349.         accordionFooter('disable');
  350.  
  351.         responsiveflag = false;
  352.  
  353.         if (typeof bindUniform !=='undefined')
  354.  
  355.             bindUniform();
  356.  
  357.     }
  358.  
  359.     blockHover();
  360.  
  361. }
  362.  
  363.  
  364.  
  365. function blockHover(status)
  366.  
  367. {
  368.  
  369.     var screenLg = $('body').find('.container').width() == 1170;
  370.  
  371.  
  372.  
  373.     if ($('.product_list').is('.grid'))
  374.  
  375.         if (screenLg)
  376.  
  377.             $('.product_list .button-container').hide();
  378.  
  379.         else
  380.  
  381.             $('.product_list .button-container').show();
  382.  
  383.  
  384.  
  385.     $(document).off('mouseenter').on('mouseenter', '.product_list.grid li.ajax_block_product .product-container', function(e){
  386.  
  387.         if (screenLg)
  388.  
  389.         {
  390.  
  391.             var pcHeight = $(this).parent().outerHeight();
  392.  
  393.             var pcPHeight = $(this).parent().find('.button-container').outerHeight() + $(this).parent().find('.comments_note').outerHeight() + $(this).parent().find('.functional-buttons').outerHeight();
  394.  
  395.             $(this).parent().addClass('hovered').css({'height':pcHeight + pcPHeight, 'margin-bottom':pcPHeight * (-1)});
  396.  
  397.             $(this).find('.button-container').show();
  398.  
  399.         }
  400.  
  401.     });
  402.  
  403.  
  404.  
  405.     $(document).off('mouseleave').on('mouseleave', '.product_list.grid li.ajax_block_product .product-container', function(e){
  406.  
  407.         if (screenLg)
  408.  
  409.         {
  410.  
  411.             $(this).parent().removeClass('hovered').css({'height':'auto', 'margin-bottom':'0'});
  412.  
  413.             $(this).find('.button-container').hide();
  414.  
  415.         }
  416.  
  417.     });
  418.  
  419. }
  420.  
  421.  
  422.  
  423. function quick_view()
  424.  
  425. {
  426.  
  427.     $(document).on('click', '.quick-view:visible, .quick-view-mobile:visible', function(e){
  428.  
  429.         e.preventDefault();
  430.  
  431.         var url = this.rel;
  432.  
  433.         var anchor = '';
  434.  
  435.  
  436.  
  437.         if (url.indexOf('#') != -1)
  438.  
  439.         {
  440.  
  441.             anchor = url.substring(url.indexOf('#'), url.length);
  442.  
  443.             url = url.substring(0, url.indexOf('#'));
  444.  
  445.         }
  446.  
  447.  
  448.  
  449.         if (url.indexOf('?') != -1)
  450.  
  451.             url += '&';
  452.  
  453.         else
  454.  
  455.             url += '?';
  456.  
  457.  
  458.  
  459.         if (!!$.prototype.fancybox)
  460.  
  461.             $.fancybox({
  462.  
  463.                 'padding':  0,
  464.  
  465.                 'width':    1087,
  466.  
  467.                 'height':   610,
  468.  
  469.                 'type':     'iframe',
  470.  
  471.                 'href':     url + 'content_only=1' + anchor
  472.  
  473.             });
  474.  
  475.     });
  476.  
  477. }
  478.  
  479.  
  480.  
  481. function bindGrid()
  482.  
  483. {
  484.  
  485.     var storage = false;
  486.  
  487.     if (typeof(getStorageAvailable) !== 'undefined') {
  488.  
  489.         storage = getStorageAvailable();
  490.  
  491.     }
  492.  
  493.     if (!storage) {
  494.  
  495.         return;
  496.  
  497.     }
  498.  
  499.  
  500.  
  501.     var view = $.totalStorage('display');
  502.  
  503.  
  504.  
  505.     if (!view && (typeof displayList != 'undefined') && displayList)
  506.  
  507.         view = 'list';
  508.  
  509.  
  510.  
  511.     if (view && view != 'grid')
  512.  
  513.         display(view);
  514.  
  515.     else
  516.  
  517.         $('.display').find('li#grid').addClass('selected');
  518.  
  519.  
  520.  
  521.     $(document).on('click', '#grid', function(e){
  522.  
  523.         e.preventDefault();
  524.  
  525.         display('grid');
  526.  
  527.     });
  528.  
  529.  
  530.  
  531.     $(document).on('click', '#list', function(e){
  532.  
  533.         e.preventDefault();
  534.  
  535.         display('list');
  536.  
  537.     });
  538.  
  539. }
  540.  
  541.  
  542.  
  543. function display(view)
  544. {
  545.  if (view == 'list')
  546.  {
  547. $('.product_list > li').removeClass('col-xs-12 col-sm-6 col-md-3')
  548. .addClass('col-xs-12 col-sm-6 col-md-12');
  549. }
  550.  else
  551.  {
  552.  $('.product_list > li').removeClass('col-xs-12 col-md-12').addClass('col-xs-12 col-sm-6 col-md-3');
  553. }}
  554.  
  555.  
  556.  
  557. function dropDown()
  558.  
  559. {
  560.  
  561.     elementClick = '#header .current';
  562.  
  563.     elementSlide =  'ul.toogle_content';
  564.  
  565.     activeClass = 'active';
  566.  
  567.  
  568.  
  569.     $(elementClick).on('click', function(e){
  570.  
  571.         e.stopPropagation();
  572.  
  573.         var subUl = $(this).next(elementSlide);
  574.  
  575.         if(subUl.is(':hidden'))
  576.  
  577.         {
  578.  
  579.             subUl.slideDown();
  580.  
  581.             $(this).addClass(activeClass);
  582.  
  583.         }
  584.  
  585.         else
  586.  
  587.         {
  588.  
  589.             subUl.slideUp();
  590.  
  591.             $(this).removeClass(activeClass);
  592.  
  593.         }
  594.  
  595.         $(elementClick).not(this).next(elementSlide).slideUp();
  596.  
  597.         $(elementClick).not(this).removeClass(activeClass);
  598.  
  599.         e.preventDefault();
  600.  
  601.     });
  602.  
  603.  
  604.  
  605.     $(elementSlide).on('click', function(e){
  606.  
  607.         e.stopPropagation();
  608.  
  609.     });
  610.  
  611.  
  612.  
  613.     $(document).on('click', function(e){
  614.  
  615.         e.stopPropagation();
  616.  
  617.         var elementHide = $(elementClick).next(elementSlide);
  618.  
  619.         $(elementHide).slideUp();
  620.  
  621.         $(elementClick).removeClass('active');
  622.  
  623.     });
  624.  
  625. }
  626.  
  627.  
  628.  
  629. function accordionFooter(status)
  630.  
  631. {
  632.  
  633.     if(status == 'enable')
  634.  
  635.     {
  636.  
  637.         $('#footer .footer-block h4').on('click', function(e){
  638.  
  639.             $(this).toggleClass('active').parent().find('.toggle-footer').stop().slideToggle('medium');
  640.  
  641.             e.preventDefault();
  642.  
  643.         })
  644.  
  645.         $('#footer').addClass('accordion').find('.toggle-footer').slideUp('fast');
  646.  
  647.     }
  648.  
  649.     else
  650.  
  651.     {
  652.  
  653.         $('.footer-block h4').removeClass('active').off().parent().find('.toggle-footer').removeAttr('style').slideDown('fast');
  654.  
  655.         $('#footer').removeClass('accordion');
  656.  
  657.     }
  658.  
  659. }
  660.  
  661.  
  662.  
  663. function accordion(status)
  664.  
  665. {
  666.  
  667.     if(status == 'enable')
  668.  
  669.     {
  670.  
  671.         var accordion_selector = '#right_column .block .title_block, #left_column .block .title_block, #left_column #newsletter_block_left h4,' +
  672.  
  673.                                 '#left_column .shopping_cart > a:first-child, #right_column .shopping_cart > a:first-child';
  674.  
  675.  
  676.  
  677.         $(accordion_selector).on('click', function(e){
  678.  
  679.             $(this).toggleClass('active').parent().find('.block_content').stop().slideToggle('medium');
  680.  
  681.         });
  682.  
  683.         $('#right_column, #left_column').addClass('accordion').find('.block .block_content').slideUp('fast');
  684.  
  685.         if (typeof(ajaxCart) !== 'undefined')
  686.  
  687.             ajaxCart.collapse();
  688.  
  689.     }
  690.  
  691.     else
  692.  
  693.     {
  694.  
  695.         $('#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');
  696.  
  697.         $('#left_column, #right_column').removeClass('accordion');
  698.  
  699.     }
  700.  
  701. }
  702.  
  703.  
  704.  
  705. function bindUniform()
  706.  
  707. {
  708.  
  709.     if (!!$.prototype.uniform)
  710.  
  711.         $("select.form-control,input[type='radio'],input[type='checkbox']").not(".not_uniform").uniform();
  712.  
  713. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement