templates/front/default/home.html.twig line 1

Open in your IDE?
  1. {% extends 'front/_common/_base.html.twig' %}
  2. {% block linkcanonical %}
  3. <link rel="canonical" href="{{ sd_canonical(path('home')) }}" />
  4. {% endblock %}
  5. {% block cssadicional %}
  6. <link rel="stylesheet" href="{{ STATIC_URL }}css/home-styles.css">
  7. {% endblock %}
  8. {% block classbody %}{% endblock %}
  9. {% block content %}
  10. {% if home.bannerShow %}
  11. <!-- BLOQUE 1 -->
  12. <div class="b1home {% if home.bannerVideoShow %}g1-has-video{% endif %}">
  13.     {% if not home.bannerVideoShow %}
  14.     <div class="b1home_slider">
  15.         <ul class="b1homePitcherSlider">
  16.             {% for row in home.bannerItems|arr_item_active('show') %}
  17.                 <li class="b1home_item homeChangeImages {{ row.with_opacity is defined and row.with_opacity ? '' : 'no-shadow' }}" data-image="{{ asset(row.img_desktop|default(''))|sd_azure }};{{ asset(row.img_mobile|default(''))|sd_azure }}">
  18.                     {% if row.only_img %}
  19.                     <a {% if row.url %}href="{{ row.url }}"{% endif %} {% if row.blank %}target="_blank"{% endif %} class="b1home_block wancho {{ row.property ? 'bannerHomeProperty' }}"
  20.                         data-property="{{ row.property }}" data-property-name="{{ row.propertyInfo ? row.propertyInfo.name : '' }}" data-property-location="{{ row.propertyInfo ? row.propertyInfo.location : '' }}" data-property-plaza="{{ row.propertyInfo ? row.propertyInfo.plaza : '' }}" data-property-type="{{ row.propertyInfo ? row.propertyInfo.type : '' }}"
  21.                     >
  22.                         <div class="b1home_info">
  23.                             <div class="b1home_titles">
  24.                                 {% if row.preffix %}
  25.                                 <h4>{{ row.preffix }}</h4>
  26.                                 {% endif %}
  27.                                 {% if row.title %}
  28.                                 <h2>{{ row.title }}</h2>
  29.                                 {% endif %}
  30.                                 {% if row.suffix %}
  31.                                 <h3>{{ row.suffix }}</h3>
  32.                                 {% endif %}
  33.                             </div>
  34.                         </div>
  35.                     </a>
  36.                     {% else %}
  37.                     <div class="b1home_block wancho">
  38.                         <div class="b1home_info">
  39.                             <div class="b1home_titles">
  40.                                 {% if row.preffix %}
  41.                                 <h4>{{ row.preffix }}</h4>
  42.                                 {% endif %}
  43.                                 {% if row.title %}
  44.                                 <h2>{{ row.title }}</h2>
  45.                                 {% endif %}
  46.                                 {% if row.suffix %}
  47.                                 <h3>{{ row.suffix }}</h3>
  48.                                 {% endif %}
  49.                                 {% if row.url and row.btn_text %}
  50.                                 <div class="g0-ctn-btn">
  51.                                     <a href="{{ row.url }}" class="g0-btn h45" {% if row.blank %}target="_blank"{% endif %}>{{ row.btn_text }}</a>
  52.                                 </div>
  53.                                 {% endif %}
  54.                             </div>
  55.                         </div>
  56.                     </div>
  57.                     {% endif %}
  58.                 </li>
  59.             {% endfor %}
  60.         </ul>
  61.     </div>
  62.     {% else %}
  63.     <!-- video -->
  64.     <!-- cuando se video poner una clase en el padre b1home -->
  65.         {% if home.bannerVideoBtnShow %}
  66.         <div class="g1-video-wrap">
  67.         {% else %}
  68.         <a {% if home.bannerVideoBtnUrl %}href="{{ home.bannerVideoBtnUrl }}"{% endif %} class="g1-video-wrap" {% if home.bannerVideoBtnBlank %}target="_blank"{% endif %}>
  69.         {% endif %}
  70.       
  71.         <div class="g1-banner lazy" {% if home.bannerVideoImg %}data-bg="url('{{ asset(home.bannerVideoImg|default(''))|sd_azure }}')" {% endif %}>
  72.             {% if home.bannerVideoText %}
  73.             <div class="wancho">
  74.                 <h3 class="b6-title">{{ home.bannerVideoText }}</h3>
  75.             </div>
  76.             {% endif %}
  77.         </div>
  78.         <div class="g1-video">
  79.             {% if home.bannerVideoTitle %}
  80.             <div class="g1-wrap-text" >
  81.                 <div class="wancho">
  82.                     <h3 class="b6-title">{{ home.bannerVideoTitle }}</h3>
  83.                 </div>
  84.             </div>
  85.             {% endif %}
  86.             <div class="g1-videoinner">
  87.                 <video width="100%" height="100%" class="g1-video-html lazy" autoplay muted playsinline loop data-src="{{ home.bannerVideoUrl }}" {% if home.bannerVideoImg %}data-poster="{{ asset(home.bannerVideoImg)|sd_azure }}"{% endif %}>
  88.                 </video>
  89.             </div>
  90.         </div>
  91.         {% if home.bannerVideoBtnShow %}
  92.             <div class="g0-ctn-btn center g1-cnt-button">
  93.                 <a {% if home.bannerVideoBtnUrl %}href="{{ home.bannerVideoBtnUrl }}"{% endif %} class="g0-btn" {% if home.bannerVideoBtnBlank %}target="_blank"{% endif %}>{{ home.bannerVideoBtnText|default('Ver Proyecto') }}</a>
  94.             </div>
  95.         </div>  
  96.         {% else %}
  97.         </a>
  98.         {% endif %}  
  99.     <!-- video -->
  100.     {% endif %}
  101. </div>
  102. {% endif %}
  103. {% if home.propertyTypesShow and property_types %}
  104. <!-- BLOQUE 2 -->
  105. <section class="b2 g3-anima">
  106.     <div class="wancho">
  107.         {% if home.propertyTypesTitle %}
  108.             <h1 class="b2-title">{{ home.propertyTypesTitle|block_title|raw }}</h1>
  109.         {% endif %}
  110.         <div class="b2-inner-wrap">
  111.             <div class="b2-cnt-tab">
  112.                 {% for item in filter_types %}
  113.                     {% set type_url = item.open_in_list ? path('projects', {'sd_type': item.id}) : path('map', {'sd_type': item.id}) %}
  114.                     <a class="b2-item itemPropertyType" data-type="{{ item.texto }}" href="{{ type_url }}">
  115.                         <div class="b2item-img" style="background-image: url('{{ asset(item.image|default(''))|sd_azure }}');"></div>
  116.                         <div class="b2-item-title {{ item.color }} {{ item.logo ? 'techo' }} ">
  117.                             {% if item.logo %}
  118.                                 <div class="b2-item-icon">
  119.                                     <img src="{{ asset(item.logo|default(''))|sd_azure }}" alt="{{ item.texto }}">
  120.                                 </div>
  121.                             {% endif %}
  122.                             <div class="b2-item-text {{ item.color }}">
  123.                                 <p>{{ item.texto }}</p>
  124.                             </div>
  125.                         </div>
  126.                     </a>
  127.                 {% endfor %}
  128.             </div>
  129.         </div>
  130.     </div>
  131. </section>
  132. {% endif %}
  133. <!-- BLOQUE 3 -->
  134. {% if not home.promoShow %}
  135. <div class="b3-separcion">
  136.     <div class="wancho"></div>
  137. </div>
  138. {% else %}
  139. <section class="b3 g3-anima">
  140.     <div class="wancho">
  141.         {% if home.promoTitle %}
  142.         <h3 class="b3-title">{{ home.promoTitle|block_title|raw }}</h3>
  143.         {% endif %}
  144.         {% if home.activePromoItems %}
  145.         <div class="b3-list">
  146.             {% for row in home.activePromoItems %}
  147.             <a {% if row.url %}href="{{ row.url }}"{% endif %} {% if row.blank %}target="_blank"{% endif %} class="b3-item">
  148.                 <div class="b3-figura">
  149.                     <img data-src="{{ asset(row.img|default(''))|sd_azure }}" alt="{{ row.img|default('')|img_alt }}" width="590" height="280" class="lazy">
  150.                 </div>
  151.             </a>
  152.             {% endfor %}
  153.         </div>
  154.         {% endif %}
  155.     </div>
  156. </section>
  157. {% endif %}
  158. {% if home.additionalShow and home.additionalImageDesktop and home.additionalLink %}
  159.     {% set imageDesktop = home.additionalImageDesktop %}
  160.     {% set imageResponsive = home.additionalImageResponsive ?? imageDesktop %}
  161.     <a href="{{ home.additionalLink }}" target="{{ home.additionalTarget|url_target }}" class="homebg homeChangeImages" data-image="{{ asset(imageDesktop|default(''))|sd_azure }};{{ asset(imageResponsive|default(''))|sd_azure }}"></a>
  162. {% endif %}
  163. {% if home.blogShow and info.blogShow and info.blogUrl %}
  164. <!-- BLOQUE 4 -->
  165. <section class="b4 g3-anima">
  166.     <div class="wancho">
  167.         {% if home.blogTitle %}
  168.         <h3 class="b4-title">{{ home.blogTitle|block_title|raw }}</h3>
  169.         {% endif %}
  170.         {% if home.blogBtnText %}
  171.         <div class="g0-ctn-btn center">
  172.             <a href="{{ info.blogUrl }}" target="_blank" class="g0-btn">{{ home.blogBtnText }}</a>
  173.         </div>
  174.         {% endif %}
  175.         <div class="b4-list" id="blog_ctn">
  176.             {# ver Ajax/blog.html.twig #}
  177.         </div>
  178.     </div>
  179. </section>
  180. {% endif %}
  181. {% if home.formShow %}
  182. <!-- BLOQUE 5 -->
  183. <section class="b5 {% if home.formBackground %}lazy{% endif %}" {% if home.formBackground %}data-bg="{{ asset(home.formBackground)|sd_azure }}"{% endif %}>
  184.     <div class="wancho">
  185.         {% if home.formTitle %}
  186.         <div class="b5-left">
  187.             <h3 class="b5-title">{{ home.formTitle|block_title|raw }}</h3>
  188.         </div>
  189.         {% endif %}
  190.         <div class="b5-rigth">
  191.             <form action="{{ path('subscribe') }}" method="post" id="form_subscription" novalidate>
  192.                 <div class="b5-form">
  193.                     <div class="b5-input">
  194.                         <div class="g5-input g5-item-input">
  195.                             <input type="text" autocomplete="off" id="form_email" name="email" class="form-input validate[required,custom[email]]" onblur="onBlurValidateEmail(this)">
  196.                             <label class="input-label" for="form_email"><span>Email*</span></label>
  197.                         </div>
  198.                     </div>
  199.                     <button class="g0-btn small b5-enviar">
  200.                         <div class="g0-loading-form" style="display:none">
  201.                             <img src="{{ STATIC_URL }}img/loading-form.svg" width="30" alt="enviando...">
  202.                         </div>
  203.                         {{ info_form.subscribeBtnText|default('Suscribirme') }}
  204.                     </button>
  205.                 </div>
  206.                 <div class="b5check">
  207.                     <input type="checkbox"  name="acepto" id="terminos_1" class="validate[required]">
  208.                     <label for="terminos_1" class="b5check_wrap">
  209.                         <span class="b5check_icon"></span>
  210.                         <div class="b5check_text">
  211.                             <p>Acepto los <a href="{{ path('privacy_policies') }}" target="_blank">Políticas de privacidad</a></p>
  212.                         </div>
  213.                     </label>
  214.                 </div>
  215.                 <input type="hidden" name="__token" value="{{ _token }}">
  216.                 {% include "front/form/_utm.html.twig" %}
  217.             </form>
  218.         </div>
  219.     </div>
  220. </section>
  221. {% endif %}
  222. {% if home.popupShow and home.popupImgDesktop %}
  223. <div>
  224.     <a href="#popup-home" class="open-boxlight g0-open-modal" data-custom-class="g0-modal-home"></a>
  225.     <div id="popup-home" class="boxlight g0-wrap-modal">
  226.         <a {% if home.popupUrl %}href="{{ home.popupUrl }}"{% endif %} class="g0-popup-link" {% if home.popupBlank %}target="_blank"{% endif %}>
  227.             <img class="g0-image-popup" data-image="{{ asset(home.popupImgDesktop)|sd_azure }};{{ asset(home.popupImgMobile|default(home.popupImgDesktop))|sd_azure}}" alt="{{ home.popupImgDesktop|img_alt }}">
  228.         </a>
  229.     </div>
  230. </div>
  231. {% endif %}
  232. {% endblock %}
  233. {% block jsfinal %}
  234. <script src="{{ STATIC_URL }}js/home.js"></script>
  235. <script type="text/javascript">
  236.     changeLazyImage('.g0-image-popup', 'tagHtml');
  237.     function load_properties(type_slug, tab) {
  238.         $.post('{{ path("get_properties_by_type_slug") }}',{'slug': type_slug}, function(html){
  239.             $(tab).html(html);
  240.             changeLazyImage('.g7-item .g7-figura-it', '');
  241.         });
  242.     }
  243.     function load_blog_posts() {
  244.         $.post('{{ path("sync_blog") }}', function(html){
  245.             $('#blog_ctn').html(html);
  246.         });
  247.     }
  248.     $(function(){
  249.         {% if home.blogShow and info.blogShow and info.blogUrl %}
  250.         load_blog_posts();
  251.         {% endif %}
  252.         $('.open-boxlight').boxlight();
  253.         $('.g0-open-modal').trigger('click');
  254.         changeImage('.homeChangeImages');
  255.         changeLazyImage('.g7-item .g7-figura-it','')
  256.         //$('.b2 .b2-item-head:first-child').addClass('active');
  257.         //$('.b2 .b2-item-tab:first-child').addClass('active');
  258.         $('.b2').on('click', '.b2-item-head', function (event) {
  259.             if ($(this).attr('href')) {
  260.                 return true;
  261.             }
  262.             event.preventDefault();
  263.             var idTab = $(this).attr('data-tab');
  264.             var slug = $(this).attr('data-slug');
  265.             var tab_body = $('.b2 .b2-item-tab[data-tab="' + idTab + '"]');
  266.             //load_properties(slug, tab_body);
  267.             $('.b2-item-head').removeClass('active');
  268.             $(this).addClass('active');
  269.             $('.b2 .b2-item-tab').removeClass('active');
  270.             tab_body.addClass('active');
  271.         });
  272.         $('.b2 .b2-item-head:first-child').trigger('click');
  273.         $('.bannerHomeProperty').on('click', function () {
  274.             sendClicEnBanner($(this));
  275.         })
  276.         function sendClicEnBanner(element) {
  277.             const name = element.data('property-name');
  278.             const location = element.data('property-location');
  279.             const plaza = element.data('property-plaza');
  280.             const type = element.data('property-type');
  281.             const data = {
  282.                 'event': 'clic_en_banner',
  283.                 'Proceso': 'Informativo',
  284.                 'Tipo_evento': 'Interacción',
  285.                 'Nombre_proyecto': name,
  286.                 'Plaza': plaza,
  287.                 'Tipo-vivienda': type,
  288.                 'Nombre_ciudad': location,
  289.                 'Sección': 'Pagina principal',
  290.                 'SubSección': 'Banner',
  291.                 'PagePath': getPagePath(),
  292.                 'TimeStamp': getCurrentTimestamp(),
  293.                 'TipoDispositivo': getDeviceType(),
  294.             }
  295.             sendToAnalytics(data);
  296.         }
  297.         $('.itemPropertyType').on('click', function (e) {
  298.             const propertyType = $(this).data('type');
  299.             sendClicEnTipoInmueble(propertyType);
  300.         })
  301.         function sendClicEnTipoInmueble(value) {
  302.             const data = {
  303.                 'event': 'clic_en_tipo_inmueble',
  304.                 'Proceso': 'Navegación',
  305.                 'Tipo_evento': 'Interacción',
  306.                 'Tipo_vivienda': value,
  307.                 'Sección': 'Pagina principal',
  308.                 'SubSección': 'Encuentra el proyecto ideal para ti',
  309.                 'PagePath': getPagePath(),
  310.                 'TimeStamp': getCurrentTimestamp(),
  311.                 'TipoDispositivo': getDeviceType(),
  312.             };
  313.             sendToAnalytics(data);
  314.         }
  315.         $('.g7-item').on('click', function (event) {
  316.             event.preventDefault();
  317.             const $this = $(this);
  318.             const link = $this.attr('href');
  319.             // sendClicEnProyecto($this);
  320.             window.location.href = link;
  321.         });
  322.         // function sendClicEnProyecto(element) {
  323.         //     const name = element.data('name');
  324.         //     const location = element.data('location');
  325.         //     const plaza = element.data('plaza');
  326.         //     const type = element.data('type');
  327.         //
  328.         //     const data = {
  329.         //         'event': 'clic_en_proyecto',
  330.         //         'Proceso': 'Informativo',
  331.         //         'Tipo_evento': 'Interaccion',
  332.         //         'Nombre_proyecto': name,
  333.         //         'Plaza': plaza,
  334.         //         'Tipo_vivienda': type,
  335.         //         'Nombre_departamento': location,
  336.         //         'Sección': 'Pagina principal',
  337.         //         'SubSección': 'Encuentra el proyecto ideal para tí',
  338.         //         'PagePath': getPagePath(),
  339.         //         'TimeStamp': getCurrentTimestamp(),
  340.         //         'TipoDispositivo': getDeviceType(),
  341.         //     };
  342.         //
  343.         //     sendToAnalytics(data);
  344.         // }
  345.         //- +++ SLIDER BANNER +++
  346.         var b1homeItems = $('.b1home_item').length;
  347.         if(b1homeItems > 1){
  348.             $('.b1homePitcherSlider').on('init', function(e, slick) {
  349.                 $(this).find('.b1home_item').removeClass('animation');
  350.                 $(this).find('.b1home_item.slick-active').addClass('animation');
  351.             });
  352.             $( '.b1homePitcherSlider').slick({
  353.                 fade: true,
  354.                 autoplay: true,
  355.                 autoplaySpeed: 4000,
  356.                 speed: 1350,
  357.                 arrows: false,
  358.                 dots: true,
  359.                 pauseOnFocus: false,
  360.                 pauseOnHover: false
  361.             });
  362.             $('.b1homePitcherSlider').on('beforeChange', function(event, slick, currentSlide, nextSlide){
  363.                 $(this).find('.b1home_item').removeClass('animation');
  364.             });
  365.             $('.b1homePitcherSlider').on('afterChange', function(event, slick, currentSlide, nextSlide){
  366.                 $(this).find('.b1home_item.slick-active').addClass('animation');
  367.             });
  368.         } else {
  369.             $('.b1home_item').addClass('animation');
  370.         }
  371.         //- <<< END >>>
  372.     // /proyectos
  373.         var cantidadb2 = $('.b2-item-head').length;
  374.         function sliderOwb2(){
  375.             $('.b2-slider').removeClass('desktop')
  376.             $('.b2-slider').addClass('owl-carousel');
  377.             $('.b2-slider').owlCarousel({
  378.                 loop:true,
  379.                 margin:9,
  380.                 nav:true,
  381.                 autoplay:false,
  382.                 autoWidth:true,
  383.                 autoplayTimeout:3000,
  384.                 navText:['<span class="icon-dropdown-arrow"></span>','<span class="icon-dropdown-arrow"></span>'],
  385.                 responsive:{
  386.                     0:{
  387.                         items:2,
  388.                         margin:9,
  389.                     },
  390.                     425:{
  391.                         items:3,
  392.                         margin:9,
  393.                     },
  394.                     640:{
  395.                         items:4,
  396.                         margin:9,
  397.                     },
  398.                     1001:{
  399.                         items:7,
  400.                         margin:9,
  401.                     },
  402.                 }
  403.             })
  404.         }
  405.         function destroyOwb2(){
  406.             $('.b2-slider').trigger('destroy.owl.carousel');
  407.             $('.b2-slider').addClass('desktop');
  408.             $('.b2-slider').removeClass('owl-carousel');
  409.         }
  410.         if (matchMedia) {
  411.             var mqb2 = window.matchMedia("(max-width: 1000px)");
  412.             mqb2.addListener(WidthChangeb2);
  413.             WidthChangeb2(mqb2);
  414.         }
  415.         // media query change
  416.         function WidthChangeb2(mqb2) {
  417.             if (mqb2.matches ) {
  418.                     console.log('menor a 1000px');
  419.                     if ($('.b2-slider').hasClass('owl-carousel')) {
  420.                         // console.log('slider, ya existe');
  421.                     }
  422.                     else{
  423.                         // console.log('slider, aun no existe')
  424.                         sliderOwb2()
  425.                 }
  426.             }
  427.             else {
  428.                 console.log('mayor a 1000px');
  429.                 if (cantidadb2 >= 8) {
  430.                     destroyOwb2()
  431.                     sliderOwb2()
  432.                 }
  433.                 else{
  434.                     destroyOwb2()
  435.                 }
  436.             };
  437.         }
  438.         // /proyectos
  439.           //efecto levantar label de formulario
  440.           var inputs = document.getElementsByClassName("form-input");
  441.           for (var i = 0; i < inputs.length; i++) {
  442.             inputs[i].addEventListener("blur", function(e) {
  443.                 e.currentTarget.closest('.g5-item-input').classList.remove('inFocus');
  444.             });
  445.             inputs[i].addEventListener("focus", function(e) {
  446.                 e.currentTarget.closest('.g5-item-input').classList.add('inFocus');
  447.               if (this.value.length >= 1) {
  448.                 this.nextElementSibling.classList.add("fijar");
  449.               } else {
  450.                 this.nextElementSibling.classList.remove("fijar");
  451.               }
  452.             });
  453.             inputs[i].addEventListener("change", function() {
  454.               if (this.value == "") {
  455.                 this.nextElementSibling.classList.remove("fijar");
  456.               } else {
  457.                 this.nextElementSibling.classList.add("fijar");
  458.               }
  459.             });
  460.           }
  461.           //efecto levantar label de formulario
  462.         
  463.         $("#form_subscription").validationEngine('attach', {
  464.             promptPosition: "topLeft",
  465.             autoHidePrompt: true,
  466.             autoPositionUpdate: false,
  467.             autoHideDelay: 2000,
  468.             binded: false,
  469.             scroll: false,
  470.             validateNonVisibleFields: true,
  471.             showOneMessage: false
  472.         });
  473.         
  474.         $('.b5-enviar').on('click', function(event) {
  475.             event.preventDefault();
  476.             let loading = $('.g0-loading-form');
  477.             let btn = $(this);
  478.             let form = $(this).closest('form');
  479.             btn.prop('disabled', true);
  480.             loading.show();
  481.             const valid = form.validationEngine('validate');
  482.             if (!valid) {
  483.                 loading.hide();
  484.                 btn.prop('disabled', false);
  485.                 return false;
  486.             }else {
  487.                ajaxSendSimpleForm(form,btn,loading);
  488.             }
  489.         });
  490.         // animaciones bloques
  491.         var animaseccion = $('.g3-anima')
  492.         $(animaseccion).each(function (index, el) {
  493.             $(el).waypoint(function (direction) {
  494.                 if (direction === 'down') {
  495.                     $(el).addClass('animate');
  496.                 }
  497.             }, {
  498.                 offset: '85%'
  499.             });
  500.         });
  501.         // animaciones bloques
  502.     });
  503. </script>
  504. {% endblock %}