{% extends 'front/_common/_base.html.twig' %}
{% block linkcanonical %}
<link rel="canonical" href="{{ sd_canonical(path('home')) }}" />
{% endblock %}
{% block cssadicional %}
<link rel="stylesheet" href="{{ STATIC_URL }}css/home-styles.css">
{% endblock %}
{% block classbody %}{% endblock %}
{% block content %}
{% if home.bannerShow %}
<!-- BLOQUE 1 -->
<div class="b1home {% if home.bannerVideoShow %}g1-has-video{% endif %}">
{% if not home.bannerVideoShow %}
<div class="b1home_slider">
<ul class="b1homePitcherSlider">
{% for row in home.bannerItems|arr_item_active('show') %}
<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 }}">
{% if row.only_img %}
<a {% if row.url %}href="{{ row.url }}"{% endif %} {% if row.blank %}target="_blank"{% endif %} class="b1home_block wancho {{ row.property ? 'bannerHomeProperty' }}"
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 : '' }}"
>
<div class="b1home_info">
<div class="b1home_titles">
{% if row.preffix %}
<h4>{{ row.preffix }}</h4>
{% endif %}
{% if row.title %}
<h2>{{ row.title }}</h2>
{% endif %}
{% if row.suffix %}
<h3>{{ row.suffix }}</h3>
{% endif %}
</div>
</div>
</a>
{% else %}
<div class="b1home_block wancho">
<div class="b1home_info">
<div class="b1home_titles">
{% if row.preffix %}
<h4>{{ row.preffix }}</h4>
{% endif %}
{% if row.title %}
<h2>{{ row.title }}</h2>
{% endif %}
{% if row.suffix %}
<h3>{{ row.suffix }}</h3>
{% endif %}
{% if row.url and row.btn_text %}
<div class="g0-ctn-btn">
<a href="{{ row.url }}" class="g0-btn h45" {% if row.blank %}target="_blank"{% endif %}>{{ row.btn_text }}</a>
</div>
{% endif %}
</div>
</div>
</div>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
{% else %}
<!-- video -->
<!-- cuando se video poner una clase en el padre b1home -->
{% if home.bannerVideoBtnShow %}
<div class="g1-video-wrap">
{% else %}
<a {% if home.bannerVideoBtnUrl %}href="{{ home.bannerVideoBtnUrl }}"{% endif %} class="g1-video-wrap" {% if home.bannerVideoBtnBlank %}target="_blank"{% endif %}>
{% endif %}
<div class="g1-banner lazy" {% if home.bannerVideoImg %}data-bg="url('{{ asset(home.bannerVideoImg|default(''))|sd_azure }}')" {% endif %}>
{% if home.bannerVideoText %}
<div class="wancho">
<h3 class="b6-title">{{ home.bannerVideoText }}</h3>
</div>
{% endif %}
</div>
<div class="g1-video">
{% if home.bannerVideoTitle %}
<div class="g1-wrap-text" >
<div class="wancho">
<h3 class="b6-title">{{ home.bannerVideoTitle }}</h3>
</div>
</div>
{% endif %}
<div class="g1-videoinner">
<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 %}>
</video>
</div>
</div>
{% if home.bannerVideoBtnShow %}
<div class="g0-ctn-btn center g1-cnt-button">
<a {% if home.bannerVideoBtnUrl %}href="{{ home.bannerVideoBtnUrl }}"{% endif %} class="g0-btn" {% if home.bannerVideoBtnBlank %}target="_blank"{% endif %}>{{ home.bannerVideoBtnText|default('Ver Proyecto') }}</a>
</div>
</div>
{% else %}
</a>
{% endif %}
<!-- video -->
{% endif %}
</div>
{% endif %}
{% if home.propertyTypesShow and property_types %}
<!-- BLOQUE 2 -->
<section class="b2 g3-anima">
<div class="wancho">
{% if home.propertyTypesTitle %}
<h1 class="b2-title">{{ home.propertyTypesTitle|block_title|raw }}</h1>
{% endif %}
<div class="b2-inner-wrap">
<div class="b2-cnt-tab">
{% for item in filter_types %}
{% set type_url = item.open_in_list ? path('projects', {'sd_type': item.id}) : path('map', {'sd_type': item.id}) %}
<a class="b2-item itemPropertyType" data-type="{{ item.texto }}" href="{{ type_url }}">
<div class="b2item-img" style="background-image: url('{{ asset(item.image|default(''))|sd_azure }}');"></div>
<div class="b2-item-title {{ item.color }} {{ item.logo ? 'techo' }} ">
{% if item.logo %}
<div class="b2-item-icon">
<img src="{{ asset(item.logo|default(''))|sd_azure }}" alt="{{ item.texto }}">
</div>
{% endif %}
<div class="b2-item-text {{ item.color }}">
<p>{{ item.texto }}</p>
</div>
</div>
</a>
{% endfor %}
</div>
</div>
</div>
</section>
{% endif %}
<!-- BLOQUE 3 -->
{% if not home.promoShow %}
<div class="b3-separcion">
<div class="wancho"></div>
</div>
{% else %}
<section class="b3 g3-anima">
<div class="wancho">
{% if home.promoTitle %}
<h3 class="b3-title">{{ home.promoTitle|block_title|raw }}</h3>
{% endif %}
{% if home.activePromoItems %}
<div class="b3-list">
{% for row in home.activePromoItems %}
<a {% if row.url %}href="{{ row.url }}"{% endif %} {% if row.blank %}target="_blank"{% endif %} class="b3-item">
<div class="b3-figura">
<img data-src="{{ asset(row.img|default(''))|sd_azure }}" alt="{{ row.img|default('')|img_alt }}" width="590" height="280" class="lazy">
</div>
</a>
{% endfor %}
</div>
{% endif %}
</div>
</section>
{% endif %}
{% if home.additionalShow and home.additionalImageDesktop and home.additionalLink %}
{% set imageDesktop = home.additionalImageDesktop %}
{% set imageResponsive = home.additionalImageResponsive ?? imageDesktop %}
<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>
{% endif %}
{% if home.blogShow and info.blogShow and info.blogUrl %}
<!-- BLOQUE 4 -->
<section class="b4 g3-anima">
<div class="wancho">
{% if home.blogTitle %}
<h3 class="b4-title">{{ home.blogTitle|block_title|raw }}</h3>
{% endif %}
{% if home.blogBtnText %}
<div class="g0-ctn-btn center">
<a href="{{ info.blogUrl }}" target="_blank" class="g0-btn">{{ home.blogBtnText }}</a>
</div>
{% endif %}
<div class="b4-list" id="blog_ctn">
{# ver Ajax/blog.html.twig #}
</div>
</div>
</section>
{% endif %}
{% if home.formShow %}
<!-- BLOQUE 5 -->
<section class="b5 {% if home.formBackground %}lazy{% endif %}" {% if home.formBackground %}data-bg="{{ asset(home.formBackground)|sd_azure }}"{% endif %}>
<div class="wancho">
{% if home.formTitle %}
<div class="b5-left">
<h3 class="b5-title">{{ home.formTitle|block_title|raw }}</h3>
</div>
{% endif %}
<div class="b5-rigth">
<form action="{{ path('subscribe') }}" method="post" id="form_subscription" novalidate>
<div class="b5-form">
<div class="b5-input">
<div class="g5-input g5-item-input">
<input type="text" autocomplete="off" id="form_email" name="email" class="form-input validate[required,custom[email]]" onblur="onBlurValidateEmail(this)">
<label class="input-label" for="form_email"><span>Email*</span></label>
</div>
</div>
<button class="g0-btn small b5-enviar">
<div class="g0-loading-form" style="display:none">
<img src="{{ STATIC_URL }}img/loading-form.svg" width="30" alt="enviando...">
</div>
{{ info_form.subscribeBtnText|default('Suscribirme') }}
</button>
</div>
<div class="b5check">
<input type="checkbox" name="acepto" id="terminos_1" class="validate[required]">
<label for="terminos_1" class="b5check_wrap">
<span class="b5check_icon"></span>
<div class="b5check_text">
<p>Acepto los <a href="{{ path('privacy_policies') }}" target="_blank">Políticas de privacidad</a></p>
</div>
</label>
</div>
<input type="hidden" name="__token" value="{{ _token }}">
{% include "front/form/_utm.html.twig" %}
</form>
</div>
</div>
</section>
{% endif %}
{% if home.popupShow and home.popupImgDesktop %}
<div>
<a href="#popup-home" class="open-boxlight g0-open-modal" data-custom-class="g0-modal-home"></a>
<div id="popup-home" class="boxlight g0-wrap-modal">
<a {% if home.popupUrl %}href="{{ home.popupUrl }}"{% endif %} class="g0-popup-link" {% if home.popupBlank %}target="_blank"{% endif %}>
<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 }}">
</a>
</div>
</div>
{% endif %}
{% endblock %}
{% block jsfinal %}
<script src="{{ STATIC_URL }}js/home.js"></script>
<script type="text/javascript">
changeLazyImage('.g0-image-popup', 'tagHtml');
function load_properties(type_slug, tab) {
$.post('{{ path("get_properties_by_type_slug") }}',{'slug': type_slug}, function(html){
$(tab).html(html);
changeLazyImage('.g7-item .g7-figura-it', '');
});
}
function load_blog_posts() {
$.post('{{ path("sync_blog") }}', function(html){
$('#blog_ctn').html(html);
});
}
$(function(){
{% if home.blogShow and info.blogShow and info.blogUrl %}
load_blog_posts();
{% endif %}
$('.open-boxlight').boxlight();
$('.g0-open-modal').trigger('click');
changeImage('.homeChangeImages');
changeLazyImage('.g7-item .g7-figura-it','')
//$('.b2 .b2-item-head:first-child').addClass('active');
//$('.b2 .b2-item-tab:first-child').addClass('active');
$('.b2').on('click', '.b2-item-head', function (event) {
if ($(this).attr('href')) {
return true;
}
event.preventDefault();
var idTab = $(this).attr('data-tab');
var slug = $(this).attr('data-slug');
var tab_body = $('.b2 .b2-item-tab[data-tab="' + idTab + '"]');
//load_properties(slug, tab_body);
$('.b2-item-head').removeClass('active');
$(this).addClass('active');
$('.b2 .b2-item-tab').removeClass('active');
tab_body.addClass('active');
});
$('.b2 .b2-item-head:first-child').trigger('click');
$('.bannerHomeProperty').on('click', function () {
sendClicEnBanner($(this));
})
function sendClicEnBanner(element) {
const name = element.data('property-name');
const location = element.data('property-location');
const plaza = element.data('property-plaza');
const type = element.data('property-type');
const data = {
'event': 'clic_en_banner',
'Proceso': 'Informativo',
'Tipo_evento': 'Interacción',
'Nombre_proyecto': name,
'Plaza': plaza,
'Tipo-vivienda': type,
'Nombre_ciudad': location,
'Sección': 'Pagina principal',
'SubSección': 'Banner',
'PagePath': getPagePath(),
'TimeStamp': getCurrentTimestamp(),
'TipoDispositivo': getDeviceType(),
}
sendToAnalytics(data);
}
$('.itemPropertyType').on('click', function (e) {
const propertyType = $(this).data('type');
sendClicEnTipoInmueble(propertyType);
})
function sendClicEnTipoInmueble(value) {
const data = {
'event': 'clic_en_tipo_inmueble',
'Proceso': 'Navegación',
'Tipo_evento': 'Interacción',
'Tipo_vivienda': value,
'Sección': 'Pagina principal',
'SubSección': 'Encuentra el proyecto ideal para ti',
'PagePath': getPagePath(),
'TimeStamp': getCurrentTimestamp(),
'TipoDispositivo': getDeviceType(),
};
sendToAnalytics(data);
}
$('.g7-item').on('click', function (event) {
event.preventDefault();
const $this = $(this);
const link = $this.attr('href');
// sendClicEnProyecto($this);
window.location.href = link;
});
// function sendClicEnProyecto(element) {
// const name = element.data('name');
// const location = element.data('location');
// const plaza = element.data('plaza');
// const type = element.data('type');
//
// const data = {
// 'event': 'clic_en_proyecto',
// 'Proceso': 'Informativo',
// 'Tipo_evento': 'Interaccion',
// 'Nombre_proyecto': name,
// 'Plaza': plaza,
// 'Tipo_vivienda': type,
// 'Nombre_departamento': location,
// 'Sección': 'Pagina principal',
// 'SubSección': 'Encuentra el proyecto ideal para tí',
// 'PagePath': getPagePath(),
// 'TimeStamp': getCurrentTimestamp(),
// 'TipoDispositivo': getDeviceType(),
// };
//
// sendToAnalytics(data);
// }
//- +++ SLIDER BANNER +++
var b1homeItems = $('.b1home_item').length;
if(b1homeItems > 1){
$('.b1homePitcherSlider').on('init', function(e, slick) {
$(this).find('.b1home_item').removeClass('animation');
$(this).find('.b1home_item.slick-active').addClass('animation');
});
$( '.b1homePitcherSlider').slick({
fade: true,
autoplay: true,
autoplaySpeed: 4000,
speed: 1350,
arrows: false,
dots: true,
pauseOnFocus: false,
pauseOnHover: false
});
$('.b1homePitcherSlider').on('beforeChange', function(event, slick, currentSlide, nextSlide){
$(this).find('.b1home_item').removeClass('animation');
});
$('.b1homePitcherSlider').on('afterChange', function(event, slick, currentSlide, nextSlide){
$(this).find('.b1home_item.slick-active').addClass('animation');
});
} else {
$('.b1home_item').addClass('animation');
}
//- <<< END >>>
// /proyectos
var cantidadb2 = $('.b2-item-head').length;
function sliderOwb2(){
$('.b2-slider').removeClass('desktop')
$('.b2-slider').addClass('owl-carousel');
$('.b2-slider').owlCarousel({
loop:true,
margin:9,
nav:true,
autoplay:false,
autoWidth:true,
autoplayTimeout:3000,
navText:['<span class="icon-dropdown-arrow"></span>','<span class="icon-dropdown-arrow"></span>'],
responsive:{
0:{
items:2,
margin:9,
},
425:{
items:3,
margin:9,
},
640:{
items:4,
margin:9,
},
1001:{
items:7,
margin:9,
},
}
})
}
function destroyOwb2(){
$('.b2-slider').trigger('destroy.owl.carousel');
$('.b2-slider').addClass('desktop');
$('.b2-slider').removeClass('owl-carousel');
}
if (matchMedia) {
var mqb2 = window.matchMedia("(max-width: 1000px)");
mqb2.addListener(WidthChangeb2);
WidthChangeb2(mqb2);
}
// media query change
function WidthChangeb2(mqb2) {
if (mqb2.matches ) {
console.log('menor a 1000px');
if ($('.b2-slider').hasClass('owl-carousel')) {
// console.log('slider, ya existe');
}
else{
// console.log('slider, aun no existe')
sliderOwb2()
}
}
else {
console.log('mayor a 1000px');
if (cantidadb2 >= 8) {
destroyOwb2()
sliderOwb2()
}
else{
destroyOwb2()
}
};
}
// /proyectos
//efecto levantar label de formulario
var inputs = document.getElementsByClassName("form-input");
for (var i = 0; i < inputs.length; i++) {
inputs[i].addEventListener("blur", function(e) {
e.currentTarget.closest('.g5-item-input').classList.remove('inFocus');
});
inputs[i].addEventListener("focus", function(e) {
e.currentTarget.closest('.g5-item-input').classList.add('inFocus');
if (this.value.length >= 1) {
this.nextElementSibling.classList.add("fijar");
} else {
this.nextElementSibling.classList.remove("fijar");
}
});
inputs[i].addEventListener("change", function() {
if (this.value == "") {
this.nextElementSibling.classList.remove("fijar");
} else {
this.nextElementSibling.classList.add("fijar");
}
});
}
//efecto levantar label de formulario
$("#form_subscription").validationEngine('attach', {
promptPosition: "topLeft",
autoHidePrompt: true,
autoPositionUpdate: false,
autoHideDelay: 2000,
binded: false,
scroll: false,
validateNonVisibleFields: true,
showOneMessage: false
});
$('.b5-enviar').on('click', function(event) {
event.preventDefault();
let loading = $('.g0-loading-form');
let btn = $(this);
let form = $(this).closest('form');
btn.prop('disabled', true);
loading.show();
const valid = form.validationEngine('validate');
if (!valid) {
loading.hide();
btn.prop('disabled', false);
return false;
}else {
ajaxSendSimpleForm(form,btn,loading);
}
});
// animaciones bloques
var animaseccion = $('.g3-anima')
$(animaseccion).each(function (index, el) {
$(el).waypoint(function (direction) {
if (direction === 'down') {
$(el).addClass('animate');
}
}, {
offset: '85%'
});
});
// animaciones bloques
});
</script>
{% endblock %}