templates/front/_common/_base.html.twig line 1

Open in your IDE?
  1. {% apply spaceless %}
  2.     {% set STATIC_URL = asset('static/') %}
  3.     {% set ASSET_VERSION = '28.0' %}
  4.     {% set IS_HOME_PAGE = is_home_page|default(false) or info.counterShowAllPages %}
  5.     {% set IS_PROPERTY_DETAIL = IS_PROPERTY_DETAIL|default(false) %}
  6. <!DOCTYPE html>
  7. <html>
  8.     <head>
  9.         <meta charset="utf-8">
  10.         <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" >
  11.         <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  12.         <link rel="preload" href="{{ STATIC_URL }}fonts/PlutoSansW04-Light.ttf" as="font"  crossorigin />
  13.         <link rel="preload" href="{{ STATIC_URL }}fonts/PlutoSansW04-Bold.ttf" as="font"  crossorigin />
  14.         <link rel="preload" href="{{ STATIC_URL }}fonts/icomoon.ttf?c7l5mf" as="font"  crossorigin />
  15.         <link rel="preload" href="{{ STATIC_URL }}fonts/NunitoSans-Regular.ttf" as="font"  crossorigin />
  16.         <link rel="preload" href="{{ STATIC_URL }}fonts/NunitoSans-Bold.ttf" as="font"  crossorigin />
  17.         {% if IS_PROPERTY_DETAIL and detail.popupVideoShow and detail.popupVideoLink %}
  18.         <link rel="preload" href="{{ detail.popupVideoLink }}" as="video"  crossorigin />
  19.         {% endif %}
  20.         {% if info.seoFavicon is defined and info.seoFavicon is not empty %}
  21.             <link rel="icon" type="image/png" href="{{ asset(info.seoFavicon)|sd_azure }}"/>
  22.             <link rel="apple-touch-icon-precomposed" sizes="114x114" href="{{ asset(info.seoFavicon)|sd_azure }}">
  23.             <link rel="apple-touch-icon-precomposed" sizes="72x72" href="{{ asset(info.seoFavicon)|sd_azure }}">
  24.             <link rel="apple-touch-icon-precomposed" href="{{ asset(info.seoFavicon)|sd_azure }}">
  25.         {% endif %}
  26.         {% block linkcanonical %}{% endblock %}
  27.         {% include 'front/_common/_metatags.html.twig' %}
  28.         {% block cssadicional %}
  29.         {% endblock %}
  30.         <style>
  31.             .header_search_btn.hide {
  32.                 display: none;
  33.             }
  34.         </style>
  35.         {% if app.request.get('_route') not in ['home', 'property'] %}
  36.         <link rel="stylesheet" href="{{ STATIC_URL}}js/validationform/validationEngine.jquery.css">
  37.         {% endif %}
  38.         <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}js/simplebar/simple-scrollbar.min.css"/>
  39.         <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/styles.css?v={{ ASSET_VERSION }}"/>
  40.         <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/blocks_styl.css?v={{ ASSET_VERSION }}"/>
  41.         <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/whatsapp.css?v={{ ASSET_VERSION }}"/>
  42.         <style>
  43.             /* Ocultar logo CookieBot */
  44.             /* Branding on the banner */
  45.             a#CybotCookiebotDialogPoweredbyCybot,
  46.             div#CybotCookiebotDialogPoweredByText {
  47.                 display: none !important;
  48.             }
  49.             /* Branding on the widget */
  50.             #CookiebotWidget .CookiebotWidget-body .CookiebotWidget-main-logo {
  51.                 display: none !important;
  52.             }
  53.         </style>
  54.         <script>
  55. {#            {% if show_regionalization_script %}#}
  56. {#            if (navigator.geolocation) {#}
  57. {#                console.log('Sí soporta geolocalización');#}
  58. {#                navigator.geolocation.getCurrentPosition(function (position) {#}
  59. {#                    const url = '{{ app.request.uri }}';#}
  60. {#                    const lat = position.coords.latitude;#}
  61. {#                    const lng = position.coords.longitude;#}
  62. {#                    $.ajax({#}
  63. {#                        url: '{{ path("region") }}',#}
  64. {#                        type: 'get',#}
  65. {#                        dataType: 'json',#}
  66. {#                        data: {lat: lat, lng: lng, url: url}#}
  67. {#                    }).done(function (data) {#}
  68. {#                        if (data.redirect) {#}
  69. {#                            window.location.href = url;#}
  70. {#                        }#}
  71. {#                    }).fail(function (error) {#}
  72. {#                        console.log('Error regionalización: ', error.responseText);#}
  73. {#                    });#}
  74. {#                });#}
  75. {#            } else {#}
  76. {#                console.log('No soporta geolocalización');#}
  77. {#            }#}
  78. {#            {% endif %}#}
  79.         </script>
  80.         <script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-cbid="d187506d-fd80-4158-8815-740f3e5f610b" data-blockingmode="auto" type="text/javascript"></script>        
  81.         
  82.         <!--[if lt IE 9]>
  83.             <script src="{{ STATIC_URL }}js/html5.js"></script>
  84.             <script src="{{ STATIC_URL }}js/respond.js" type="text/javascript"></script>
  85.             <link rel="stylesheet" type="text/css" href=".{{ STATIC_URL }}css/ie.css"/>
  86.         <![endif]-->
  87.         {% set externalScripts = info.getCustomScriptsDomain(app.request.headers.get('host')) %}
  88.         {% if externalScripts.header|default('') %}
  89.             {{ externalScripts.header|raw }}
  90.         {% endif %}
  91.         {% if IS_PROPERTY_DETAIL and detail.seoScriptShow %}
  92.             {% if detail.seoScriptGenerate %}
  93.                 <script type="application/ld+json">
  94.                     {
  95.                         "@context": "https://schema.org",
  96.                         "@type": "House",
  97.                         "name": "{{ detail.title }}",
  98.                         "description": "{{ detail.commonText|striptags }}",
  99.                         "image":"{{ asset(detail.imageListDesktop)|sd_azure }}",
  100.                         "url":"{{ absolute_url(path('property', {'slug': detail.slug})) }}",
  101.                         "logo":"{{ asset(info.headerLogo)|sd_azure }}"
  102.                     }
  103.                 </script>
  104.             {% else %}
  105.                 {% if detail.seoScriptText %}
  106.                     {{ detail.seoScriptText|raw }}
  107.                 {% endif %}
  108.             {% endif %}
  109.         {% endif %}
  110.     </head>
  111.     <body class="{% block classbody %}{% endblock %}">
  112.     {% if externalScripts.body|default('') %}
  113.         {{ externalScripts.body|raw }}
  114.     {% endif %}
  115.     <div class="cnt-wrapper" id="cnt-wrapper-main">
  116.         <!-- HEADER START -->
  117.         {% include "front/_common/_header.html.twig" %}
  118.         <!-- HEADER END -->
  119.         <div class="wrapper">
  120.             <!-- CONTENT START -->
  121.             {% block content %}{% endblock %}
  122.             <!-- CONTENT END -->
  123.         </div>
  124.         <!-- FOOTER START -->
  125.         {% include "front/_common/_footer.html.twig" %}
  126.         <!-- FOOTER END -->
  127.     </div>
  128.     <!-- contenedor del menu responsive -->
  129.     <script type="text/javascript">
  130.         var listados = {{ filter_types|json_encode|raw }};
  131.         var dormitorios = {{ filter_locations|json_encode|raw }};
  132.         var url_change_opt_header = '{{ path("recharge_dropdown_header") }}';
  133.         var header_placeholder_filter_city = "{{ info.headerFilterCityText|default('Proyecto o ciudad') }}";
  134.         var header_placeholder_filter_type = "{{ info.headerFilterTypeText|default('Tipo de inmueble') }}";
  135.     </script>
  136.     <script type="text/javascript">
  137.         //(2, 3, ',', '.')
  138.         //n : cantidad de decimales
  139.         //x : cantidad de digitos para la separación
  140.         //s : separador de miles
  141.         //c : separador de decimales
  142.         Number.prototype.format = function(n, x, s, c) {
  143.             var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')',
  144.                 num = this.toFixed(Math.max(0, ~~n));
  145.             return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (s || ','));
  146.         };
  147.         String.prototype.replaceAll = function(search, replacement) {
  148.             var target = this;
  149.             return target.split(search).join(replacement);
  150.         };
  151.         function isNumberKey(evt){
  152.             var charCode = (evt.which) ? evt.which : event.keyCode
  153.             if (charCode > 31 && (charCode < 48 || charCode > 57))
  154.                 return false;
  155.             return true;
  156.         }
  157.         function isLetterKey(evt) {
  158.             evt = (evt) ? evt : event;
  159.             // var regex = new RegExp("^[a-zA-Z ]+$");
  160.             var regex = new RegExp("^[a-zA-ZäÄëËïÏöÖüÜáéíóúáéíóúÁÉÍÓÚÂÊÎÔÛâêîôûàèìòùÀÈÌÒÙñÑ\ \'\-]+$");
  161.             var key = String.fromCharCode(!evt.charCode ? evt.which : evt.charCode);
  162.             if (!regex.test(key)) {
  163.                 evt.preventDefault();
  164.                 return false;
  165.             }
  166.             return true;
  167.         }
  168.         function isNumberOrLetterKey(event) {
  169.             return isNumberKey(event) || isLetterKey(event);
  170.         }
  171.         function isMaxCharacters(input,n){
  172.             if(input.value.length >= n ){ return false; }
  173.             return true;
  174.         }
  175.         function filterFloat(evt,input){
  176.             // Backspace = 8, Enter = 13, ‘0′ = 48, ‘9′ = 57, ‘.’ = 46, ‘-’ = 43
  177.             var key = window.Event ? evt.which : evt.keyCode;    
  178.             var chark = String.fromCharCode(key);
  179.             var tempValue = input.value+chark;
  180.             if(key >= 48 && key <= 57){
  181.                 if(filterdd(tempValue)=== false){
  182.                     return false;
  183.                 }else{       
  184.                     return true;
  185.                 }
  186.             }else{
  187.                 if(key == 8 || key == 13 || key == 0) {     
  188.                     return true;              
  189.                 }else if(key == 46){
  190.                         if(filterdd(tempValue)=== false){
  191.                             return false;
  192.                         }else{       
  193.                             return true;
  194.                         }
  195.                 }else{
  196.                     return false;
  197.                 }
  198.             }
  199.         }
  200.         function filterdd(__val__){
  201.             var preg = /^([0-9]+\.?[0-9]{0,3})$/; 
  202.             if(preg.test(__val__) === true){
  203.                 return true;
  204.             }else{
  205.             return false;
  206.             }
  207.             
  208.         }
  209.     </script>
  210.     <script src="{{ STATIC_URL }}js/jquery-3.2.1.min.js" type="text/javascript"></script>
  211.     <script src="{{ STATIC_URL }}js/simplebar/simple-scrollbar.js" type="text/javascript"></script>
  212.     <script src="{{ STATIC_URL }}js/selectJS.js?v={{ ASSET_VERSION }}"></script>
  213.     <script src="{{ STATIC_URL }}js/main.js" type="text/javascript"></script>
  214.     <script src="{{ STATIC_URL }}js/countdown.js" type="text/javascript"></script>
  215.     <script src="https://cdn.jsdelivr.net/npm/intersection-observer@0.7.0/intersection-observer.min.js"></script>
  216.     <script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.1.2/dist/lazyload.min.js"></script>
  217.     <script src="https://unpkg.com/current-device/umd/current-device.min.js"></script>
  218.     <script type="text/javascript">
  219.         console.log("{{ app.request.headers.get('host') }}", "<--- domain");
  220.         var lazyLoadInstance = new LazyLoad({});
  221.         var hasPopVideo = document.getElementById('popup-video-mp4');
  222.         function openPopup(event,selector) {
  223.             console.log('event',event)
  224.             if(event){
  225.                 event.preventDefault();
  226.             }
  227.             let modalCurrent = document.querySelector('#'+selector);
  228.             modalCurrent.classList.add("active");
  229.         }
  230.         function closePopup() {
  231.             let popups = document.querySelectorAll(".b28-wrap-modal");
  232.             popups.forEach(btn => {
  233.                 btn.classList.remove('active');
  234.             });
  235.             if (hasPopVideo) {
  236.                 $('#video_container').find('video').get(0).pause();  
  237.                 
  238.                         
  239.             }
  240.             
  241.         }
  242.         // +++ CAMBIOS DE IMAGENES +++
  243.         function processChangeImage(banners, type) {
  244.             let win = window.innerWidth;
  245.             const elementImg = document.querySelectorAll(banners);
  246.             if (type === 'tagHtml') {
  247.                 for (let i = 0; i < elementImg.length; i++) {
  248.                     let forElement = elementImg[i]
  249.                     if (forElement.hasAttribute('data-image')) {
  250.                         let dataImg = forElement.getAttribute('data-image').split(';');
  251.                         if (win > 745) {
  252.                             forElement.setAttribute("src", dataImg[0]);
  253.                         } else if (win <= 745) {
  254.                             forElement.setAttribute("src", dataImg[1]);
  255.                         }
  256.                     } else {
  257.                         return false
  258.                     }
  259.                 }
  260.             } else {
  261.                 for (let i = 0; i < elementImg.length; i++) {
  262.                     let forElement = elementImg[i]
  263.                     if (forElement.hasAttribute('data-image')) {
  264.                         let dataImg = forElement.getAttribute('data-image').split(';');
  265.                         if (win > 745) {
  266.                             forElement.style.backgroundImage = 'url(' + dataImg[0] + ')'
  267.                         } else if (win <= 745) {
  268.                             forElement.style.backgroundImage = 'url(' + dataImg[1] + ')'
  269.                         }
  270.                     } else {
  271.                         return false
  272.                     }
  273.                 }
  274.             }
  275.         }
  276.         function changeImage(selector, type) {
  277.             processChangeImage(selector, type);
  278.             window.onresize = function () {
  279.                 processChangeImage(selector, type);
  280.             };
  281.         }
  282.         function processChangeLazyImage(selector, type) {
  283.             let win = window.innerWidth;
  284.             let elementImg = document.querySelectorAll(selector);
  285.             if (type === 'tagHtml') {
  286.                 for (let i = 0; i < elementImg.length; i++) {
  287.                     let forElement = elementImg[i]
  288.                     forElement.classList.add('lazy');
  289.                     if (forElement.hasAttribute('data-image')) {
  290.                         let dataImg = forElement.getAttribute('data-image').split(';');
  291.                         if (win > 745) {
  292.                             forElement.setAttribute("data-src", dataImg[0]);
  293.                         }
  294.                         if (win <= 745) {
  295.                             forElement.setAttribute("data-src", dataImg[1]);
  296.                         }
  297.                     } else {
  298.                         return false
  299.                     }
  300.                 }
  301.             } else {
  302.                 for (let i = 0; i < elementImg.length; i++) {
  303.                     let forElement = elementImg[i]
  304.                     if (forElement.hasAttribute('data-image')) {
  305.                         let dataImg = forElement.getAttribute('data-image').split(';');
  306.                         forElement.classList.add('lazy');
  307.                         if (win > 745) {
  308.                             forElement.setAttribute('data-bg', dataImg[0]);
  309.                         }
  310.                         if (win <= 745) {
  311.                             forElement.setAttribute('data-bg', dataImg[1]);
  312.                         }
  313.                     } else {
  314.                         return false
  315.                     }
  316.                 }
  317.             }
  318.             lazyLoadInstance.update();
  319.         }
  320.         function changeLazyImage(selector, type) {
  321.             processChangeLazyImage(selector, type);
  322.             window.onresize = function () {
  323.                 processChangeLazyImage(selector, type);
  324.             };
  325.         }
  326.         // <<< END >>>
  327.         // +++ VIDEO POPUP MP4 +++
  328.         if (hasPopVideo) {
  329.             var videoMp4Pop = document.getElementById('video1');
  330.             videoMp4Pop.addEventListener('loadedmetadata', function () {
  331.                 var duration = videoMp4Pop.duration;
  332.                 const durationTimeVideoDefault = $('#video_container').find('video').get(0).duration;
  333.                 const durationTimeVideoAdmin  = parseInt('{{ detail is defined and detail is not null ? detail.popupVideoDuration : 0 }}');
  334.                 const durationTimeVideoSkip  = parseInt('{{ detail is defined and detail is not null ? detail.popupVideoSkipDuration : 0 }}');
  335.                 var durationTimeInitTemp  = durationTimeVideoAdmin > 0 && durationTimeVideoAdmin <= durationTimeVideoDefault ? durationTimeVideoAdmin : durationTimeVideoDefault;
  336.                 var counterTime = setInterval(function(){
  337.                     var durationTime = $('#video_container').find('video').get(0).duration;
  338.                     var currentTime = $('#video_container').find('video').get(0).currentTime;
  339.                     if (currentTime >= durationTime || currentTime >= durationTimeInitTemp) {
  340.                         closePopup();
  341.                         clearInterval(counterTime);
  342.                     }
  343.                     var current_time_data = $('#video_container').find('video').get(0).currentTime;
  344.                     var timeFinished = Math.round(durationTimeInitTemp - current_time_data);
  345.                     $('#currentTime').html(timeFinished);
  346.                     if (durationTimeVideoSkip > 0 && durationTimeVideoSkip < currentTime) {
  347.                         $('#sd_video_counter').hide();
  348.                         $('#sd_skip_video').show();
  349.                     }
  350.                 }, durationTimeInitTemp)
  351.                 openPopup(event,'popup-video-mp4');
  352.                 
  353.             });
  354.             $('.b28-control-unmute').click(function(event) {
  355.                 $(".source-video-p4").prop('muted', false);
  356.                 $(this).hide();
  357.                 $('.b28-control-video').hide();
  358.             });
  359.         }
  360.         // <<< END video popup mp4 >>>
  361.         // <<< VALIDATIONS >>>
  362.         var dni_validation_url = '{{ path("valid_dni") }}';
  363.         var email_validation_url = '{{ path("valid_email") }}';
  364.         var pin_code_validation_url = '{{ path("valid_pin_code") }}';
  365.         function ajaxValidate(url, val, text)
  366.         {
  367.             if( val ){
  368.                 let $return = 'undefined';
  369.                 $.ajax({
  370.                     url : url,
  371.                     type: 'GET',
  372.                     dataType: 'json',
  373.                     data: {fieldValue: val},
  374.                     async: false,
  375.                     cache: false,
  376.                 }).done(function(rpta){
  377.                     $return =  rpta.success;
  378.                 }).fail(function(error){
  379.                     console.log(error.responseText);
  380.                     $return = false;
  381.                 });
  382.                 return $return;
  383.             }else{
  384.                 return true;
  385.             }
  386.         }
  387.         function validateTelefono(field)
  388.         {
  389.             let tlf = field.val();
  390.             let valid = true;
  391.             let value_tlf = tlf.split(' ').join('');
  392.             value_tlf = value_tlf.replace(/\D/g,'');
  393.             field.val(value_tlf);
  394.             
  395.             if (field.val() != "") {
  396.                 if (field.val().length < 9) {
  397.                     valid = false;
  398.                 } else {
  399.                     if( field.val()[0] != '9' ){
  400.                         valid = false;
  401.                     }
  402.                     
  403.                     tlf = field.val();
  404.                     var count = 0;
  405.                     var current = tlf[0];
  406.                     for (var i = 0; i < tlf.length; i++) {
  407.                         var next = tlf[i];
  408.                         if (next == current) {
  409.                             count++;
  410.                         } else {
  411.                             if (count >= 5) {
  412.                                 valid = false;
  413.                             }
  414.                             count = 1;
  415.                             current = tlf[i]
  416.                         }
  417.                     }
  418.                     if (count >= 5) {
  419.                         valid = false;
  420.                     }
  421.                     
  422.                 }
  423.             } else {
  424.                 valid = false
  425.             }
  426.             if (!valid) {
  427.                 let field_id = field.attr('id');
  428.                 $('#'+field_id).validationEngine('showPrompt', '*Celular no válido', 'error')
  429.             }
  430.             return valid;
  431.         }
  432.         function isLetterChange(ev)
  433.         {
  434.             ev.preventDefault();
  435.             var regex = new RegExp("^[a-zA-ZäÄëËïÏöÖüÜáéíóúáéíóúÁÉÍÓÚÂÊÎÔÛâêîôûàèìòùÀÈÌÒÙñÑ\ \'\-]+$");
  436.             const input = ev.target;
  437.             const valid = regex.test(input.value);
  438.             if (!valid) {
  439.                 $('#'+input.id).validationEngine('showPrompt', '*Caracter no válido', 'error')
  440.                 input.value = '';
  441.                 return false;
  442.             }
  443.             return true;
  444.         }
  445.         function ajaxValidateDni(field)
  446.         {
  447.             let dni = field.val();
  448.             let valid = true;
  449.             const is_numeric = /^[0-9]+$/.test(dni);
  450.             if (!is_numeric) {
  451.                 let field_id = field.attr('id');
  452.                 $('#'+field_id).val('');
  453.                 $('#'+field_id).validationEngine('showPrompt', '*DNI no válido', 'error')
  454.                 return false
  455.             }
  456.             const blacklist = {{ info.dniBlacklistParsed|json_encode|raw }};
  457.             if (blacklist.includes(dni)) {
  458.                 let field_id = field.attr('id');
  459.                 $('#'+field_id).val('');
  460.                 $('#'+field_id).validationEngine('showPrompt', '*DNI no válido', 'error')
  461.                 return false
  462.             }
  463.                         
  464.             $.ajax({
  465.                 url : dni_validation_url,
  466.                 method: 'get',
  467.                 async: false,
  468.                 cache: false,
  469.                 data: {fieldValue: dni },
  470.                 success: function (data) {
  471.                     if (!data['exito']) {
  472.                         valid = false;
  473.                     }
  474.                 },
  475.                 error: function (data) {
  476.                     valid = false;
  477.                 }
  478.             })
  479.             if (!valid) {
  480.                 let field_id = field.attr('id');
  481.                 $('#'+field_id).validationEngine('showPrompt', '*DNI no válido', 'error')    
  482.             }
  483.             return valid;
  484.         }
  485.         function ajaxValidateEmail(field)
  486.         {
  487.             const endpoint = '{{ validations.email.endpoint }}';
  488.             const apikey = '{{ validations.email.apikey }}';
  489.             let email = field.val().toLowerCase().trim();
  490.             let valid = true;
  491.             $.ajax({
  492.                 url: endpoint,
  493.                 method: 'get',
  494.                 async: false,
  495.                 cache: false,
  496.                 data: {EmailAddress: email, APIKey: apikey},
  497.                 success: function (data) {
  498.                     if (data.status !== 200) {
  499.                         valid = false;
  500.                     }
  501.                 },
  502.                 error: function (data) {
  503.                     valid = false;
  504.                 }
  505.             })
  506.             if (!valid) {
  507.                 let field_id = field.attr('id');
  508.                 $('#'+field_id).validationEngine('showPrompt', '* Email no válido', 'error')
  509.             }
  510.             field.val(email);
  511.             return valid;
  512.         }
  513.         let smsInterval = null;
  514.         function ajaxValidatePinCode(field)
  515.         {
  516.             const rpta = ajaxValidate(pin_code_validation_url, field.val());
  517.             console.log(rpta, '<-- rpta pin');
  518.             let field_id = field.attr('id');
  519.             if( rpta == false || rpta == 'undefined' ){
  520.                 $('#'+field_id).validationEngine('showPrompt', '* Código PIN no válido', 'error')
  521.                 return false;
  522.             }
  523.             clearInterval(smsInterval);
  524.             $('#'+field_id).closest('.g8-form-pin').find('#btn_msg_code').html('PIN válido');
  525.             return true;
  526.         }
  527.         function ajaxSendSimpleForm(form, btn, loading)
  528.         {
  529.             $.ajax({
  530.                 url : form.attr('action'),
  531.                 type: 'post',
  532.                 data : form.serialize(),
  533.                 dataType: 'json',
  534.                 complete : function(jqXHR,status){
  535.                     //btn.prop('disabled', false);
  536.                 }
  537.             }).done(function(resp){
  538.                 if( resp.success ){
  539.                     window.location.href = resp.url;
  540.                 }else{
  541.                     loading.hide();
  542.                     btn.prop('disabled', false);
  543.                     form.parent().prepend('<p style="color:red;">'+resp.errors+'</p>');
  544.                     closePopup();
  545.                 }
  546.             }).fail(function(error){
  547.                 console.log(error.responseText);
  548.             });
  549.         }
  550.         function onBlurValidate(el, func)
  551.         {
  552.             let $el = $(el);
  553.             if( $el.val().length < 1 ){ 
  554.                 return { 'rules': false, 'ajax': false};
  555.             }
  556.             let valid = $(el).validationEngine('validate');
  557.             let valid_ajax = true;
  558.             if( valid ){
  559.                 valid_ajax = func($el);
  560.             }
  561.             $el.closest('form').find('button').prop('disabled',!valid_ajax);
  562.             if( !valid_ajax ){
  563.                 $el.focus();
  564.             }
  565.             return { 'rules': valid, 'ajax': valid_ajax};
  566.         }
  567.         function onBlurValidateEmail(el)
  568.         {
  569.             valid = onBlurValidate(el, ajaxValidateEmail);
  570.             return valid.rules && valid.ajax;
  571.         }
  572.         function onBlurValidateDni(el)
  573.         {
  574.             valid = onBlurValidate(el, ajaxValidateDni);
  575.             return valid.rules && valid.ajax;
  576.         }
  577.         function onBlurValidateTelefono(el)
  578.         {
  579.             valid = onBlurValidate(el, validateTelefono);
  580.             return valid.rules && valid.ajax;
  581.         }
  582.         function onBlurValidatePinCode(el)
  583.         {
  584.             valid = onBlurValidate(el, ajaxValidatePinCode);
  585.             const is_valid = valid.rules && valid.ajax; 
  586.             if( is_valid ){
  587.                 $('.g8-btn-enviar').prop('disabled', false);
  588.             }
  589.             return is_valid;
  590.         }
  591.         function changeOnLimit(el)
  592.         {
  593.             console.log('teclado', $(el).val(), '<---');
  594.             if( $(el).val().length > 2) {
  595.                 $('#btn_msg_code').trigger('focus');
  596.             }
  597.         }
  598.         function validateMIME(field, rules, i, options)
  599.         {
  600.             var uploadedFile = $(field);  
  601.             if (uploadedFile) {
  602.                 var extensions = rules[i+2]; 
  603.                 var mimeFilter = new RegExp(extensions);
  604.                 if( ! mimeFilter.test($(uploadedFile).val().split('.').reverse()[0]) ){
  605.                     return "Sólo se permiten archivos: "+ extensions.split('|').join(',').toUpperCase();
  606.                 }
  607.             }
  608.         }
  609.         function validateFileSize (field, rules, i, options)
  610.         {
  611.             var uploadedFile = $(field);  
  612.             if (uploadedFile[0].files.length > 0) {
  613.                 const size = uploadedFile[0].files[0].size;
  614.                 const max = rules[i+2] * 1024 * 1024;
  615.                 if( size > max ){
  616.                     return "El peso del archivo debe ser menor o igual que "+rules[i+2]+" MB";
  617.                 }
  618.             }                      
  619.         }
  620.         function sendToAnalytics(data) {
  621.             console.log(data);
  622.             // dataLayer.push(data);
  623.         }
  624.         function getCurrentURL() {
  625.             return window.location.href
  626.         }
  627.         function getPagePath() {
  628.             return window.location.pathname;
  629.         }
  630.         function getCurrentTimestamp() {
  631.             return Date.now();
  632.         }
  633.         function getDeviceType() {
  634.             const type = device.type;
  635.             return type.charAt(0).toUpperCase() + type.slice(1);
  636.         }
  637.     </script>
  638.     <!-- JSADD START -->
  639.     {% block jsfinal %}{% endblock %}
  640.     {% if app.request.get('_route') not in ['home', 'property'] %}
  641.     <script src="{{ STATIC_URL }}js/validationform/jquery.validationEngine.js"></script>
  642.     <script src="{{ STATIC_URL }}js/validationform/jquery.validationEngine-es.js"></script>
  643.     {% endif %}
  644.     <style>
  645.         #formFilter .formErrorContent{
  646.             color : #444548;
  647.             background: #fff;
  648.         }
  649.         #formFilter .formError .formErrorArrow div{
  650.             background: #fff;
  651.         }
  652.         @media(max-width:1025px){
  653.             #formFilter .headerInputJS2formError.parentFormformFilter.formError{
  654.                 top:40px !important;
  655.             }
  656.             #formFilter .headerInputJSformError.parentFormformFilter.formError{
  657.                 top:40px !important;
  658.             }
  659.             #formFilter .formError .formErrorArrowBottom{
  660.                 top:0px;
  661.             }
  662.         }
  663.     </style>
  664.     <!-- JSADD END -->
  665.     <script>
  666.         function sdCheckIfMobile() {
  667.             const device = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
  668.             const width = window.innerWidth <= 1024;
  669.             return device || width;
  670.         }
  671.         function bindHeaderFormValidate() {
  672.             $("#formFilter").validationEngine('attach', {
  673.                 promptPosition: sdCheckIfMobile() ? "bottomLeft" : "topLeft",
  674.                 autoHidePrompt: true,
  675.                 autoPositionUpdate: false,
  676.                 autoHideDelay: 5000,
  677.                 binded: false,
  678.                 scroll: false,
  679.                 validateNonVisibleFields: true,
  680.                 showOneMessage: false,
  681.                 custom_error_messages: {
  682.                     '#headerInputJS2': {
  683.                         'required': {
  684.                             'message': "Selecciona {{ info.headerFilterCityText|default('Proyecto o ciudad') }}"
  685.                         },
  686.                     },
  687.                     '#headerInputJS': {
  688.                         'required': {
  689.                             'message': "Selecciona {{ info.headerFilterTypeText|default('Tipo de inmueble') }}"
  690.                         }
  691.                     }
  692.                 }
  693.             });
  694.         }
  695.         function storeUtms($data) {
  696.             $.ajax({
  697.                 url: '{{ path("store_utms") }}',
  698.                 type: 'get',
  699.                 dataType: 'json',
  700.                 data: $data
  701.             }).done(function (rpta) {
  702.                 console.log(rpta, '<-- store utm');
  703.             }).fail(function (error) {
  704.                 console.log(error.responseText, '<-- store utm');
  705.             });
  706.         }
  707.         $(function () {
  708.             let $utm_data = {};
  709.             {% set utm_params = [
  710.                 'utm_source',
  711.                 'utm_campaign',
  712.                 'utm_medium',
  713.                 'utm_term',
  714.                 'utm_content',
  715.                 'gclid'
  716.             ] %}
  717.             {% for u in utm_params %}
  718.                 {% if app.request.get(u)|default('') %}
  719.                     $utm_data['{{ u }}'] = "{{ app.request.get(u) }}";
  720.                 {% endif %}
  721.             {% endfor %}
  722.             if (!$.isEmptyObject($utm_data)) {
  723.                 storeUtms($utm_data);
  724.             }
  725.         });
  726.         $(document).ready(function () {
  727.             $('.headerOption2').click(function (event) {
  728.                 const options = ['asia', 'chilca', 'chiclayo', 'ica', 'lambayeque', 'piura', 'trujillo'];
  729.                 const value = $(this).data('value');
  730.                 const text = $(this).text();
  731.                 if (options.includes(value)) {
  732.                     $('.header_search_btn').addClass('hide');
  733.                     $('.h-select-inmueble').addClass('hide');
  734.                 } else {
  735.                     $('.header_search_btn').removeClass('hide');
  736.                     $('.h-select-inmueble').removeClass('hide');
  737.                 }
  738.                 // sendClicEnProyectoCiudad(text);
  739.             });
  740.             var sdlocation_units = {{ sdlistcount|json_encode|raw }};
  741.             var sdproperty_url = "{{ path('property', {'slug':'__sd__'}) }}";
  742.             $('.headerOption2[data-value="asia"]').click(function (event) {
  743.                 window.location.href = "{{ path('asia_options', {'sd_location':'asia'}) }}";
  744.             });
  745.             $('.headerOption2[data-value="chilca"]').click(function (event) {
  746.                 window.location.href = "{{ path('chilca_options', {'sd_location':'chilca'}) }}";
  747.             });
  748.             $('.headerOption2[data-value="chiclayo"]').click(function (event) {
  749.                 window.location.href = "{{ path('chiclayo_options', {'sd_location':'chiclayo'}) }}";
  750.             });
  751.             $('.headerOption2[data-value="ica"]').click(function (event) {
  752.                 window.location.href = "{{ path('ica_options', {'sd_location':'ica'}) }}";
  753.             });
  754.             $('.headerOption2[data-value="lambayeque"]').click(function (event) {
  755.                 window.location.href = "{{ path('lambayeque_options', {'sd_location':'lambayeque'}) }}";
  756.             });
  757.             $('.headerOption2[data-value="piura"]').click(function (event) {
  758.                 window.location.href = "{{ path('piura_options', {'sd_location':'piura'}) }}";
  759.             });
  760.             $('.headerOption2[data-value="trujillo"]').click(function (event) {
  761.                 window.location.href = sdproperty_url.replace('__sd__', sdlocation_units['trujillo']);
  762.             });
  763.             $('.header_select').on('click', '.headerOption', function (event) {
  764.                 const text = $(this).text();
  765.                 clicEnNuestrosProductos(text);
  766.                 location.href = $(this).data('url');
  767.             });
  768.             $('.headernew_map a').on('click', function () {
  769.                 sendClicBuscarMapa();
  770.             });
  771.             // function sendClicEnProyectoCiudad(value) {
  772.             //     const data = {
  773.             //         'event': 'clic_en_proyecto_o_Ciudad',
  774.             //         'Proceso': 'Segmentacion',
  775.             //         'Tipo_evento': 'Interaccion',
  776.             //         'Plaza': value,
  777.             //         'Sección': 'Header',
  778.             //         'URL': getCurrentURL(),
  779.             //         'PagePath': getPagePath(),
  780.             //         'TimeStamp': getCurrentTimestamp(),
  781.             //         'TipoDispositivo': getDeviceType(),
  782.             //     };
  783.             //
  784.             //     sendToAnalytics(data);
  785.             // }
  786.             function clicEnNuestrosProductos(value) {
  787.                 const data = {
  788.                     'event': 'clic_en_nuestros_productos',
  789.                     'Proceso': 'Segmentacion',
  790.                     'Tipo_evento': 'Interaccion',
  791.                     'Tipo_vivienda': value,
  792.                     'URL': getCurrentURL(),
  793.                     'Sección': 'Header',
  794.                     'PagePath': getPagePath(),
  795.                     'TimeStamp': getCurrentTimestamp(),
  796.                     'TipoDispositivo': getDeviceType(),
  797.                 };
  798.                 sendToAnalytics(data);
  799.             }
  800.             function sendClicBuscarMapa() {
  801.                 const data = {
  802.                     'event': 'clic_buscar_mapa',
  803.                     'Proceso': 'Busqueda',
  804.                     'Tipo_evento': 'Interaccion',
  805.                     'Sección': 'Header',
  806.                     'URL': getCurrentURL(),
  807.                     'CTA': 'Buscar en mapa',
  808.                     'PagePath': getPagePath(),
  809.                     'TimeStamp': getCurrentTimestamp(),
  810.                     'TipoDispositivo': getDeviceType(),
  811.                 };
  812.                 sendToAnalytics(data);
  813.             }
  814.             bindHeaderFormValidate();
  815.             window.onresize = function () {
  816.                 $("#formFilter").validationEngine('detach');
  817.                 bindHeaderFormValidate();
  818.             };
  819.             var projects = {{ list_autocomplete|json_encode|raw }};
  820.             $('#searchBtn').on('click', function (ev) {
  821.                 ev.preventDefault();
  822.                 let btn = $(this);
  823.                 let form = btn.closest('form');
  824.                 btn.prop('disabled', true);
  825.                 let valid = form.validationEngine('validate');
  826.                 if (!valid) {
  827.                     btn.prop('disabled', false);
  828.                     return false;
  829.                 } else {
  830.                     if ($('#headerInputJS2').val() == 'ica' && $('#headerInputJS').val() == 'lotes-terrenos') {
  831.                         window.location.href = '{{ path("ica_lotes",{"sd_location":"ica", "sd_type":"lotes-terrenos"}) }}'.replace('&amp;', '&');
  832.                         return false;
  833.                     } else if ($('#headerInputJS2').val() == 'chiclayo' && $('#headerInputJS').val() == 'lotes-terrenos') {
  834.                         window.location.href = '{{ path("chiclayo_lotes",{"sd_location":"chiclayo", "sd_type":"lotes-terrenos"}) }}'.replace('&amp;', '&');
  835.                         return false;
  836.                     }
  837.                     form.submit();
  838.                 }
  839.             });
  840.             $('.h-new-search').click(function (event) {
  841.                 event.preventDefault();
  842.                 $('.b30').addClass('active');
  843.                 $('.b30-input-search').focus();
  844.             });
  845.             var numberText = 2;
  846.             var itemsResult = '';
  847.             function filterIt(arr, searchKey) {
  848.                 return arr.filter(function (obj) {
  849.                     return Object.keys(obj).some(function (key) {
  850.                         let text = obj[key].toLowerCase().replace('-', '').trim();
  851.                         return text.includes(searchKey);
  852.                     })
  853.                 });
  854.             }
  855.             $('.b30-input-search').on('keyup', function (e) {
  856.                 var termSearch = e.target.value
  857.                 if (termSearch.length > numberText) {
  858.                     var term = termSearch.toLowerCase().trim();
  859.                     var result = filterIt(projects, term);
  860.                     if (result.length >= 1) {
  861.                         itemsResult = '';
  862.                         for (var i = 0; i < result.length; i++) {
  863.                             var item = result[i];
  864.                             itemsResult = itemsResult +
  865.                                 '<a href="{{ path("home") }}' + item.url + '" class="b30-item">' +
  866.                                     '<div class="b30-categoria">' + item.categoria + '</div>' +
  867.                                     '<div class="b30-nombre">' + item.label + '' +
  868.                                         '<div class="b30-direccion">' +
  869.                                             '<img src="{{ STATIC_URL }}img/ubicacion2.svg" width="21" alt="ubicación">' +
  870.                                             '<p>' +
  871.                                                 '' + item.ubicacion.replace('-', '<br/>') + '' +
  872.                                             '</p>' +
  873.                                         '</div>' +
  874.                                     '</div>' +
  875.                                 '</a>';
  876.                         }
  877.                         $('.b30-list-initial').addClass('hide');
  878.                         $('.b30-not-list').removeClass('show');
  879.                         $('.b30-new-list').html(itemsResult);
  880.                         $('.b30-new-list').addClass('show');
  881.                     } else {
  882.                         $('.b30-new-list').removeClass('show');
  883.                         $('.b30-not-list').addClass('show');
  884.                     }
  885.                 }
  886.             });
  887.             $('.b30-close').click(function (event) {
  888.                 $('.b30-input-search').val('');
  889.                 $('.b30').removeClass('active');
  890.                 $('.b30-list-initial').removeClass('hide');
  891.                 $('.b30-not-list').removeClass('show');
  892.                 $('.b30-new-list').html('');
  893.                 $('.b30-new-list').removeClass('show');
  894.             });
  895.         });
  896.         $(function () {
  897.             $('.ftwspChatOpen').on('click', function () {
  898.                 if (!$(this).hasClass('active')) {
  899.                     $(this).addClass('active');
  900.                     $('.ftwsp_chat').addClass('active');
  901.                 } else {
  902.                     $(this).removeClass('active');
  903.                     $('.ftwsp_chat').removeClass('active');
  904.                 }
  905.             });
  906.         });
  907.         {% if info.counterShow and info.counterDate is not null and IS_HOME_PAGE %}
  908.             $(window).on('load', function (event) {
  909.                 $('.b27-close').click(function (event) {
  910.                     $('.b27').addClass('hide');
  911.                 });
  912.                 var activeCount = true;
  913.                 if (activeCount) {
  914.                     $('.b27').addClass('active');
  915.                     $(".countDown").countdown({
  916.                             date: "{{ info.counterDate|date('j F Y H:i')|lower }}:59",
  917.                             format: "on"
  918.                         },
  919.                         function () {
  920.                             // This will run when the countdown ends
  921.                             console.log('termino el contador');
  922.                             $('.b27').addClass('hide');
  923.                         });
  924.                 }
  925.                 var hasCounter = document.getElementById('b27-counter-main');
  926.                 var cnt_wrapper = document.getElementById('cnt-wrapper-main');
  927.                 if (hasCounter) {
  928.                     cnt_wrapper.classList.add('hasCounter');
  929.                 }
  930.             });
  931.         {% endif %}
  932.         // renderSelectJS(response, '.headerSelectContent', '');
  933.         // var el = document.querySelector('#with-custom-scroll');
  934.         // SimpleScrollbar.initEl(el);
  935.     </script>
  936.     {% if externalScripts.footer|default('') %}
  937.         {{ externalScripts.footer|raw }}
  938.     {% endif %}
  939.     </body>
  940. </html>
  941. {% endapply %}