1/* logica extra del motor -- INICIO */ 2const backDropEngine = (engine, header) => { 3 const observer = new MutationObserver(() => { 4 if (window.innerWidth < 1024) return; 5 6 const hasOverlay = document.getElementById("backDropOverlay") !== null; 7 const isFixed = engine.classList.contains("sta-fixedEnginePosition"); 8 const isActive = hasOverlay || isFixed; 9 10 engine.classList.toggle('sta-zIndex361', isActive); 11 header.classList.toggle('sta-whiteBackground', isActive); 12 engine.classList.toggle('sta-relativeEngie', hasOverlay && !isFixed); 13 }); 14 15 observer.observe(document.body, { childList: true, subtree: true }); 16}; 17 18const portalDesignV2Manager = () => { 19 const header = document.getElementById('tpl-header2-eh-container'); 20 const trueInput = document.getElementById('tpl-header2-eh_menu'); 21 const engine = document.getElementById("default_sygy_element_engine"); 22 const closeMenu = document.querySelectorAll(".closeNavMenu"); 23 24 if (!header || !trueInput || !engine) { 25 console.warn('Elementos no encontrados: header, input o engine.'); 26 return; 27 } 28 29 const resetHeaderStates = () => { 30 engine.classList.remove('sta-whiteBackground'); 31 header.classList.remove('sta-transparentBackground'); 32 }; 33 34 trueInput.addEventListener('change', (event) => { 35 const isChecked = event.target.checked; 36 const engineFixed = engine?.classList.contains('sta-fixedEnginePosition'); 37 engine.classList.toggle('sta-whiteBackground', isChecked); 38 header.classList.toggle('sta-transparentBackground',isChecked && engineFixed); 39 }); 40 41 closeMenu.forEach(btn => { 42 btn.addEventListener("click", () => { 43 trueInput.checked = false; 44 resetHeaderStates(); 45 }); 46 }); 47 48 backDropEngine(engine, header); 49}; 50 51portalDesignV2Manager(); 52/* logica extra del motor -- FIN */ 53(function (o) { 54 if (!o) return false; 55 document.addEventListener('DOMContentLoaded', function () { 56 o.classList.remove('hideBody'); 57 window.dispatchEvent(new Event('showBody')); 58 }); 59})(document.body); 60 61 62 63 64var Galeria = (function () { 65 function G(param) { 66 if ( 67 typeof param != 'object' || 68 typeof param.o == 'undefined' || 69 !Array.isArray(param.photos) || 70 param.photos.length < 1 71 ) return false; 72 73 var dParam = { 74 //o : Object, //----------------obligatorio 75 type: 'opacity', //carrusel, carruselMargin 76 infinity: !0, //false 77 //photos : [], //----------------obligatorio que sea Array con minimo 1 78 callback: !!0,//function 79 automatic: !!0, //false 80 act: 0, 81 time: 5e3, 82 buttons: !0, 83 dedo: !0, 84 cursor: !!0, 85 aniTime: 500, 86 template: !!0, 87 tradus: !!0 88 }; 89 param = hotusa().controlDefecto(dParam, param); 90 param.dedo = $('html').hasClass('sf5') ? false : param.dedo; 91 92 var that = this; 93 that.$o = $(param.o); 94 that.name = "galeria2-eh"; 95 that.t = param.type; 96 that.infinity = param.infinity; 97 that.photos = param.photos.slice();//clonar array 98 that.photos = []; 99 for (var i = 0; i < param.photos.length; i++) { 100 var _t = { 101 src: param.photos[i] 102 }; 103 that.photos.push(_t); 104 }; 105 that.callback = param.callback; 106 that.automatic = param.automatic; 107 that.controlAuto = null; 108 that.act = param.act; 109 that.time = param.time; 110 that.aniTime = param.aniTime; 111 that.buttons = param.buttons; 112 that.dedo = param.dedo; 113 that.cursor = param.cursor; 114 that.load = !!0; 115 that.$tpl = (function () { 116 if (param.template) { 117 var _p = $(param.template).clone().addClass('sta-' + that.name + '_p'); 118 119 if (!$('<div></div>').append(_p).find('.sta-' + that.name + '_image').length) _p.addClass('sta-' + that.name + '_image'); 120 }; 121 122 switch (that.t) { 123 case 'opacity': 124 that.$cont = that.$o; 125 return param.template ? _p.hide() : $('<div></div>', { 126 "class": "sta-" + that.name + "_p sta-" + that.name + "_image" 127 }).hide(); 128 break; 129 case 'carrusel': 130 that.$cont = that.$o; 131 return param.template ? _p.css('left', '100%') : $('<div></div>', { 132 "class": "sta-" + that.name + "_p sta-" + that.name + "_image" 133 }).css('left', '100%'); 134 break; 135 case 'carruselMargin': 136 that.$cont = $('<div></div>', { 'class': 'sta-' + that.name + '_o' }).appendTo(that.$o); 137 return param.template ? _p : $('<div></div>', { 138 "class": "sta-" + that.name + "_p sta-" + that.name + "_image" 139 }); 140 141 default: 142 break; 143 }; 144 })(); 145 that.orderCarrusel = !!0; 146 that.tradus = param.tradus && Array.isArray(param.tradus) && param.tradus.length == param.ph
146otos.length ? param.tradus.slice() : false; 147 148 that.cargaInicial(); 149 150 if (that.buttons && that.photos.length > 1) that.generarButtons(); 151 }; 152 G.prototype.interval = function () { 153 var _t = this; 154 if (_t.automatic) { 155 clearInterval(_t.controlAuto); 156 switch (_t.t) { 157 case 'opacity': 158 _t.controlAuto = setInterval(function () { 159 160 if (_t.plus()) { 161 _t.cargaOpacidad(); 162 } else { 163 clearInterval(_t.controlAuto); 164 }; 165 }, _t.time); 166 break; 167 case 'carrusel': 168 _t.controlAuto = setInterval(function () { 169 if (_t.plus()) { 170 _t.cargaCarrusel(); 171 } else { 172 clearInterval(_t.controlAuto); 173 }; 174 }, _t.time); 175 break; 176 case 'carruselMargin': 177 _t.controlAuto = setInterval(function () { 178 179 if (_t.load) { 180 _t.load = !!0; 181 if (_t.plus()) { 182 _t.cargaCarruselMargin(); 183 } else { 184 clearInterval(_t.controlAuto); 185 }; 186 }; 187 188 }, _t.time); 189 break; 190 191 default: 192 break; 193 }; 194 }; 195 }; 196 G.prototype.removePhoto = function (src) { 197 var _t = this, 198 _p = _t.photos, 199 _n = _p.findIndex(function (e) { return e.src == src }); 200 201 _p.splice(_n, 1); 202 if (_t.tradus) _t.tradus.splice(_n, 1); 203 204 if (_p.length > 0) { 205 return !0 206 } else { 207 console.trace("Imagenes insuficientes"); 208 return !!0; 209 }; 210 }; 211 G.prototype.less = function () { 212 var _t = this; 213 214 if (_t.buttons && !_t.infinity) { 215 _t.$bR.removeClass('sta-fin'); 216 217 _t.act < 2 ? 218 _t.$bL.addClass('sta-fin') : 219 _t.$bL.removeClass('sta-fin'); 220 }; 221 222 if (_t.act > 0) { 223 _t.act--; 224 return !0; 225 } else if (_t.infinity) { 226 _t.act = _t.photos.length - 1; 227 return !0; 228 }; 229 return !!0; 230 }; 231 G.prototype.plus = function () { 232 var _t = this; 233 234 if (_t.buttons && !_t.infinity) { 235 _t.$bL.removeClass('sta-fin'); 236 237 _t.act > _t.photos.length - 3 ? 238 _t.$bR.addClass('sta-fin') : 239 _t.$bR.removeClass('sta-fin'); 240 }; 241 242 if (_t.act < _t.photos.length - 1) { 243 _t.act++; 244 return !0; 245 } else if (_t.infinity) { 246 _t.act = 0; 247 return !0; 248 }; 249 return !!0; 250 }; 251 G.prototype.cargaInicial = function () { 252 var _t = this, 253 _elem = _t.photos[_t.act], 254 img = new Image(); 255 256 _t.$o.addClass('tpl-' + _t.name); 257 if (_t.t == 'carruselMargin') _t.$o.addClass('v2'); 258 259 img.src = _elem.src; 260 img.onload = function () { 261 var _src = this.src; 262 263 _elem.$tpl = _t.remplace(_t.t == 'carrusel' ? _t.$tpl.clone().css('left', '0') : _t.$tpl.clone().show(), _src); 264 265 _t.$cont.append(_elem.$tpl); 266 267 _t.load = !0; 268 269 if (_t.callback) _t.callback(_src); 270 if (_t.photos.length > 1) _t.interval(); 271 }; 272 img.onerror = function () { 273 if (_t.removePhoto(this.src)) _t.cargaInicial(); 274 }; 275 }; 276 G.prototype.cargaOpacidad = function () { 277 var _t = this, 278 _elem = _t.photos[_t.act]; 279 280 if (_elem.$tpl) { 281 var h = $('.sta-' + _t.name + '_p', _t.$cont), 282 c = _elem.$tpl.clone().hide(); 283 284 _t.$cont.append(c); 285 c.fadeIn(_t.aniTime, function () { 286 h.remove(); 287 }); 288 289 if (_t.callback) _t.callback(_elem.src); 290 } 291 else { 292 var img = new Image(); 293 294 img.src = _elem.src; 295 296 img.onload = function () { 297 var _src = this.src, 298 h = $('.sta-' + _t.name + '_p', _t.$cont); 299 300 _elem.$tpl = _t.remplace(_t.$tpl.clone(), _src); 301 302 _t.$cont.append(_elem.$tpl); 303 _elem.$tpl.fadeIn(_t.aniTime, function () { 304 h.remove(); 305 }); 306 307 if (_t.callback) _t.callback(_src); 308 }; 309 img.onerror = function () { 310 if (_t.removePhoto(this.src)) _t.cargaOpacidad(); 311 }; 312 }; 313 }; 314 G.prototype.cargaCarrusel = function () { 315 var _t = this, 316 _elem = _t.photos[_t.act]; 317 318 if (_elem.$tpl) { 319 var h = $('.sta-' + _t.name + '_p', _t.$cont); 320 321 _t.cargaCarruselAni(h, _elem); 322 323 if (_t.callback) _t.callback(_elem.src); 324 } 325 else { 326 var img = new Image(); 327 328 img.src = _elem.src; 329 330 img.onload = function () { 331 var _src = this.src, 332 h = $('.sta-' + _t.name + '_p', _t.$cont); 333 334 _elem.$tpl = _t.remplace(_t.$tpl.clone(), _src); 335 336 _t.cargaCarruselAni(h, _elem); 337 }; 338 img.onerror = function () { 339 if (_t.removePhoto(this.src)) _t.cargaCarrusel(); 340 }; 341 }; 342 343 }; 344 G.prototype.cargaCarruselAni = function (h, e) { 345 var _t = this, 346 c = e.$tpl.clone(), 347 _m1 = _t.orderCarrusel ? '' : '-', 348 _m2 = _t.orderCarrusel ? '-' : ''; 349 350 c.css('left', _m1 + '100%') 351 _t.$cont.append(c); 352 h.animate({ 'left': _m2 + '100%' }, _t.aniTime); 353 354 c.animate({ 'left': 0 }, _t.aniTime, function () { 355 h.remove(); 356 }); 357 358 if (_t.callback) _t.callback(e.src); 359 }; 360 G.prototype.cargaCarruselMargin = function () { 361 var _t = this, 362 _elem = _t.photos[_t.act]; 363 364 if (_elem.$tpl) { 365 366 _t.cargaCarruselMarginAni(_elem, $('.sta-' + _t.name + '_p', _t.$cont), _t.$o.innerHeight()); 367 368 } 369 else { 370 var img = new Image(); 371 372 img.src = _elem.src; 373 374 img.onload = function () { 375 var _src = this.src; 376 377 _elem.$tpl = _t.remplace(_t.$tpl.clone(), _src); 378 379 _t.cargaCarruselMarginAni(_elem, $('.sta-' + _t.name + '_p', _t.$cont), _t.$o.innerHeight()); 380 381 }; 382 383 img.onerror = function () { 384 if (_t.removePhoto(this.src)) _t.cargaCarruselMargin(); 385 }; 386 387 }; 388 }; 389 G.prototype.cargaCarruselMarginAni = function (j, rem, oldH) { 390 var _t = this, 391 _nHeight = 0; 392 393 if (_t.orderCarrusel) { 394 395 _t.$cont.css('margin-left', '-100%'); 396 _nHeight = j.$tpl.prependTo(_t.$cont).innerHeight(); 397 398 j.$tpl.css('height', oldH + 'px'); 399 400 //movimiento horizontal 401 _t.$cont.animate({ 'margin-left': '0' }, _t.aniTime, function () { 402 _t.$cont.css('margin-left', ''); 403 }); 404 405 } 406 else { 407 408 _nHeight = j.$tpl.appendTo(_t.$cont).innerHeight(); 409 410 j.$tpl.css('height', oldH + 'px'); 411 412 //movimiento horizontal 413 _t.$cont.animate({ 'margin-left': '-100%' }, _t.aniTime, function () { 414 _t.$cont.css('margin-left', ''); 415 }); 416 }; 417 418 //altura del que entra 419 j.$tpl.animate({ 'height': _nHeight + 'px' }, _t.aniTime, function () { 420 j.$tpl.css('height', ''); 421 }); 422 //altura del que se va 423 rem.animate({ 'height': _nHeight + 'px' }, _t.aniTime, function () { 424 _t.load = !0; 425 rem.css('height', '') 426 rem.remove(); 427 }); 428 429 if (_t.callback) _t.callback(j.src); 430 }; 431 G.prototype.generarButtons = function () { 432 var _t = this; 433 _t.$bL = $('<button></button>', { 434 'class': 'sta-' + _t.name + '_bL' 435 }).appendTo(_t.$o); 436 _t.$bR = $('<button></button>', { 437 'class': 'sta-' + _t.name + '_bR' 438 }).appendTo(_t.$o); 439
440 if (!_t.infinity) _t.$bL.addClass('sta-fin'); 441 442 function _l() { 443 _t.interval(); 444 if (_t.load && _t.plus()) { 445 switch (_t.t) { 446 case 'opacity': 447 _t.cargaOpacidad(); 448 break; 449 case 'carrusel': 450 _t.orderCarrusel = !!0; 451 _t.cargaCarrusel(); 452 break; 453 case 'carruselMargin': 454 _t.load = !!0; 455 _t.orderCarrusel = !!0; 456 _t.cargaCarruselMargin(); 457 break; 458 459 default: 460 break; 461 }; 462 }; 463 }; 464 function _r() { 465 _t.interval(); 466 if (_t.load && _t.less()) { 467 switch (_t.t) { 468 case 'opacity': 469 _t.cargaOpacidad(); 470 break; 471 case 'carrusel': 472 _t.orderCarrusel = !0; 473 _t.cargaCarrusel(); 474 break; 475 case 'carruselMargin': 476 if (_t.load) { 477 _t.load = !!0; 478 _t.orderCarrusel = !0; 479 _t.cargaCarruselMargin(); 480 }; 481 break; 482 483 default: 484 break; 485 }; 486 }; 487 }; 488 489 _t.$bL.click(_l); 490 _t.$bR.click(_r); 491 492 if (_t.dedo) { 493 _t.$o.on('swipeleft', _l); 494 _t.$o.on('swiperight', _r); 495 }; 496 497 if (_t.cursor) { 498 $(document).keydown(function (t) { 499 if (t.keyCode == 37 || t.keyCode == 39) { 500 var _top = _t.$o.offset().top, 501 _hei = _t.$o.innerHeight(), 502 _wTop = $(window).scrollTop(), 503 _wHei = $(window).innerHeight(); 504 if ( 505 _top + (_hei * 2 / 3) > _wTop && 506 _wTop + _wHei > _top + _hei - (_hei * 2 / 3) 507 ) { 508 switch (t.keyCode) { 509 case 37: 510 _l(); 511 break; 512 case 39: 513 _r(); 514 break; 515 }; 516 }; 517 }; 518 }); 519 }; 520 }; 521 G.prototype.remplace = function (obj, url) { 522 var _t = this, 523 _a = $('<div></div>').append(obj); 524 _a.find('.sta-' + _t.name + '_image').css("background-image", "url(" + url + ")") 525 var _p = _a.html(); 526 527 if (_t.tradus) $.each(_t.tradus[_t.act], function (i, e) { _p = _p.replace(new RegExp('{' + i + '}', "g"), e); }); 528 529 return $(_p); 530 }; 531 return G; 532})(), 533 modalLogin = (function (o, h) { 534 if (!o || !h) return false; 535 var isJson = function (str) { 536 try { 537 JSON.parse(str); 538 } catch (e) { 539 return false; 540 }; 541 return true; 542 }, 543 open = function () { 544 focus = document.querySelector(':focus'); 545 if (_rellenar) { 546 _rellenar(); 547 } else { 548 formLogin.user.value = ''; 549 formLogin.user.classList.remove('sta-full'); 550 formLogin.pass.value = ''; 551 formLogin.pass.classList.remove('sta-full'); 552 }; 553 o.style.display = "block"; 554 document.documentElement.classList.add('sta-noScroll'); 555 _open = true; 556 formLogin.user.focus(); 557 }, 558 close = function () { 559 o.style.display = 'none'; 560 let estilos = window.getComputedStyle(document.body); 561 if(estilos.overflow === 'hidden'){ 562 document.body.style.overflow = 'auto'; 563 } 564 if (formForget.act) { 565 form2.style.display = 'none'; 566 formForget.act = false; 567 form.style.display = 'block'; 568 formLogin.act = true; 569 } 570 571 formLogin.error.o.classList.remove('sta-ko'); 572 formForget.error.o.innerHTML = ''; 573 formForget.error.o.classList.remove('sta-ok', 'sta-ko'); 574 form2.reset(); 575 576 _open = false; 577 document.documentElement.classList.remove('sta-noScroll'); 578 focus.focus(); 579 }, 580 max = o.querySelector('.sta-modalLogin-eh_max'), 581 form = o.querySelector('.sta-modalLogin-eh_form'), 582 form2 = o.querySelector('.sta-modalLogin-eh_formForget'), 583 formLogin = { 584 act: true, 585 user: form["modulo[login_V2][usuario]"], 586 pass: form["modulo[login_V2][password]"], 587 remember: form.querySelector('.sta-modalLogin-eh_remember'), 588 button: form.querySelector('.sta-modalLogin-eh_submit'), 589 error: { 590 o: form.querySelector('.sta-modalLogin-eh_form_error') 591 }, 592 datos: { 593 ok: form.querySelector('.sta-modalLogin-eh_form_ok').value.trim(), 594 urlPlantilla: form.querySelector('.sta-modalLogin-eh_form_urlPlantilla').value.trim() 595 }, 596 rememberLocal: h.getStorageJSON('sesionRemmember') 597 }, 598 formForget = { 599 act: false, 600 user: form2["modulo[login_V2][email]"], 601 button: o.querySelector('.sta-modalLogin-eh_formForget .sta-modalLogin-eh_submit'), 602 error: { 603 o: form2.querySelector('.sta-modalLogin-eh_error'), 604 ok: form2.querySelector('.sta-modalLogin-eh_error .sta-modalLogin-eh_error_ok').value.trim(), 605 ko: form2.querySelector('.sta-modalLogin-eh_error .sta-modalLogin-eh_error_ko').value.trim() 606 }, 607 datos: { 608 ok: form2.querySelector('.sta-modalLogin-eh_formForget_ok').value.trim(), 609 urlPlantilla: form2.querySelector('.sta-modalLogin-eh_formForget_urlPlantilla').value.trim() 610 } 611 }, 612 _rellenar = false, 613 _open = false, 614 focus = null; 615 616 //login 617 form.addEventListener('submit', function (e) { 618 e.preventDefault(); 619 620 formLogin.error.o.classList.remove('sta-ko'); 621 var inp1 = formLogin.user.value.trim(), 622 inp2 = formLogin.pass.value.trim(), 623 remember = formLogin.remember.checked; 624 625 if (!h.mail(inp1) || !inp2) { 626 formLogin.error.o.classList.add('sta-ko'); 627 dataLayer.push({ 'event': 'passworderror' }); 628 } else { 629 formLogin.button.classList.add('sta-loadding'); 630 formLogin.button.disabled = true; 631 632 h.ajax({ 633 url: formLogin.datos.urlPlantilla, 634 type: 'post', 635 data: new FormData(form), 636 header: false, 637 success: function (data) { 638 formLogin.button.classList.remove('sta-loadding'); 639 formLogin.button.disabled = false;
640 if (!isJson(data)) { 641 if (remember) { 642 var _tmp = { 643 user: btoa(inp1), 644 pass: btoa(inp2) 645 }; 646 h.setStorageJSON('sesionRemmember', btoa(JSON.stringify(_tmp))); 647 } 648 window.location = formLogin.datos.ok; 649 dataLayer.push({ 'event': 'loginstcorrect' }); 650 } else { 651 formLogin.error.o.classList.add('sta-ko'); 652 dataLayer.push({ 'event': 'passworderror' }); 653 }; 654 }, 655 error: function (data) { 656 formLogin.button.classList.remove('sta-loadding'); 657 formLogin.button.disabled = false; 658 dataLayer.push({ 'event': 'passworderror' }); 659 console.trace(data); 660 } 661 }); 662 } 663 }); 664 665 //change pass 666 form2.addEventListener('submit', function (e) { 667 e.preventDefault(); 668 669 formForget.error.o.textContent = ''; 670 formForget.error.o.classList.remove('sta-ok', 'sta-ko'); 671 672 var inp1 = formForget.user.value.trim(); 673 674 if (!inp1 || !h.mail(inp1)) { 675 formForget.error.o.appendChild(document.createTextNode(formForget.error.ko)); 676 formForget.error.o.classList.add('sta-ko'); 677 } else { 678 formForget.button.classList.add('sta-loadding'); 679 formForget.button.disabled = true; 680 var formData = new FormData(form2); 681 682 //ajax 683 h.ajax({ 684 url: formForget.datos.urlPlantilla, 685 type: 'post', 686 data: formData, 687 header: false, 688 success: function (data) { 689 formForget.button.classList.remove('sta-loadding'); 690 formForget.button.disabled = false; 691 692 if (isJson(data) && JSON.parse(data).isValid) { 693 formForget.error.o.innerHTML = formForget.error.ok; 694 formForget.error.o.classList.add('sta-ok'); 695 form2.reset(); 696 } else { 697 formForget.error.o.innerHTML = formForget.error.ko; 698 formForget.error.o.classList.add('sta-ko'); 699 } 700 }, 701 error: function (data) { 702 formForget.button.classList.remove('sta-loadding'); 703 formForget.button.disabled = false; 704 console.trace(data); 705 } 706 }); 707 } 708 }); 709 //complete 710 [formLogin.user, formLogin.pass, formForget.user].forEach(function (elem) { 711 elem.addEventListener('change', function () { 712 this.value.trim() 713 ? this.classList.add('sta-full') 714 : this.classList.remove('sta-full'); 715 }); 716 }); 717 718 //atras 719 o.querySelector('.sta-modalLogin-eh_back').addEventListener('click', function () { 720 if (formForget.act) { 721 form2.style.display = 'none'; 722 formForget.act = false; 723 form.style.display = 'block'; 724 formLogin.act = true; 725 }; 726 }); 727 728 //delante 729 o.querySelector('.sta-modalLogin-eh_forget').addEventListener('click', function () { 730 if (formLogin.act) { 731 form2.style.display = 'block'; 732 formForget.act = true; 733 form.style.display = 'none'; 734 formLogin.act = false; 735 }; 736 }); 737 738 //close 739 o.querySelector('.sta-modalLogin-eh_modalCerrar').addEventListener('click', close); 740 o.addEventListener('click', function (e) { 741 if (e.target === o || e.target === max) close(); 742 }); 743 document.addEventListener('keyup', function (e) { 744 if (e.keyCode == 27 && _open) close(); 745 }); 746 747 //remember 748 if (formLogin.rememberLocal) { 749 var _tmp1 = JSON.parse(atob(formLogin.rememberLocal)); 750 if (_tmp1.user && _tmp1.pass) { 751 _rellenar = function () { 752 formLogin.user.value = atob(_tmp1.user); 753 formLogin.user.classList.add('sta-full'); 754 formLogin.pass.value = atob(_tmp1.pass); 755 formLogin.pass.classList.add('sta-full'); 756 }; 757 }; 758 }; 759 760 return open; 761 762 })(document.querySelector('.tpl-modalLogin-eh'), window.hotusa && window.hotusa && hotusa()), 763 openReservasGeneric = (function (o, $) { 764 if (o) { 765 var open = function () { 766 $focus = $(document.querySelector(':focus')); 767 _open = true; 768 $o.fadeIn(); 769 $scroll.addClass('sta-noScroll'); 770 $(fill[0]).focus(); 771 }, 772 close = function () { 773 _open = false;
774 $o.fadeOut(); 775 $scroll.removeClass('sta-noScroll'); 776 form.reset(); 777 $(fill).removeClass('sta-fill'); 778 $focus.focus(); 779 }, 780 $o = $(o), 781 _open = false, 782 $scroll = $('html'), 783 form = o.querySelector('.sta-modalReserva-eh_form'), 784 fill = o.querySelectorAll('.sta-modalReserva-eh_input input'), 785 $focus = null; 786 787 for (var i = 0; i < fill.length; i++) { 788 (function ($inp) { 789 $inp.change(function () { 790 this.value.trim() 791 ? $inp.addClass('sta-fill') 792 : $inp.removeClass('sta-fill'); 793 }); 794 })($(fill[i])); 795 }; 796 797 $(o.querySelector('.sta-fondomodal-eh_modalCerrar')).click(close) 798 799 $(document).keyup(function (e) { 800 if (_open) { 801 switch (e.keyCode) { 802 case 27: 803 close(); 804 break; 805 default: 806 break; 807 }; 808 }; 809 }); 810 811 return open; 812 813 } else { 814 return false; 815 }; 816 })(document.querySelector('.tpl-modalReserva-eh'), window.jQuery), 817 modal_ruta = ''; 818 819 820// ------ FUNCION GENERALES ----- // 821//Abrir modal generica propia 822function _staOpenModal(event) { 823 var param1 = event.data.param1,// Param1 : nombre id/class/objeto capa. Estos deben coincidir para facilitar 824 param2 = event.data.param2,// Param2 : nombre efecto 825 param3 = event.data.param3,// Param3 : (opcional) callback para despues de la función 826 param4 = event.data.param4,// Param4 : (opcional) HTML inferior (banner) 827 param5 = event.data.param5;// Param5 : (opcional) donde guardar el contenido despues de mostrarlo 828 829 if (modal_ruta != '' && $('#sta-modal .sta-content > *').length) { 830 $(modal_ruta).append($('#sta-modal .sta-content > *')); 831 } 832 833 if (param5) { 834 modal_ruta = param5; 835 } 836 if (!jQuery.isFunction(param3)) { 837 param3 = function () { 838 // console.trace('Sin Callback'); 839 } 840 } 841 842 if (param1 && param2 || param1 && param2 == '') { 843 if (!param5) { 844 // Borramos contenido anterior 845 $('#sta-modal .sta-content').html(''); 846 // Ponemos contenido dentro contenedor modal 847 $('#sta-modal .sta-content').prepend($(param1).clone()); 848 modal_ruta = ''; 849 } else { 850 $('#sta-modal .sta-content').prepend($(param1)); 851 } 852 853 //si hay parametro 4 lo ponemos 854 if (param4) { 855 $('#sta-modal .sta-content').append($(param4).clone()); 856 } 857 858 // CallBack de la funcion 859 param3(); 860 861 // Mostramos modal 862 switch (param2) { 863 case 'fadein': 864 $('#sta-modal').fadeIn() 865 break; 866 default: 867 console.trace('Sin efecto.') 868 } 869 870 $('body').addClass('sta-noScroll'); 871 872 } else { 873 console.trace('[openModal] Error! Faltan los param1 y param2!'); 874 } 875}; 876 877(function (o, json, $, h) { 878 879 if (!o || !$ || !json || !h) return false; 880 881 var j = { 882 o: o.querySelector('.sta-newFunctional-eh_galeria'), 883 photos: json.slice(), 884 buttons: !!0 885 }, 886 $video = $(o.querySelector('.sta-newFunctional-eh_fondoVideo')), 887 id_wistia = $video.data('wistia'); 888 new Galeria(j); 889 890 if (id_wistia) { 891 892 var html = $('<div></div>', { 'class': 'wistia_embed wistia_async_' + id_wistia, 'id': 'idWistia_' + id_wistia }), 893 _tmp = true; 894 895 $video.append(html); 896 h.cargarFicheroJS('https://fast.wistia.net/assets/external/E-v1.js', function () { 897 $(o).addClass('sta-showVideo'); 898 }); 899 900 window._wq = window._wq || []; 901 902 _wq.push({ 903 id: 'idWistia_' + id_wistia, 904 options: { 905 endVideoBehavior: "loop", 906 autoPlay: true, 907 videoFoam: false, 908 playButton: false, 909 playbar: false, 910 smallPlayButton: false, 911 fullscreenButton: false, 912 volumeControl: false, 913 volume: 0 914 }, 915 onReady: function (video) { 916 video.bind("play", function () { 917 if (_tmp) { 918 $(o).addClass("sta-showVideo"); 919 _tmp = false; 920 }; 921 }); 922 } 923 }); 924 }; 925})(document.querySelector('.tpl-newFunctional-eh'), window.json_newFunctional, window.jQuery, window.hotusa && hotusa()); 926 927(function (o) { 928 if (!o) return false;
929 930 var cont = o.querySelector('.sta-footer1-eh_rrss'); 931 const options = document.querySelectorAll('.sta-footer1-eh_options input'); 932 933 options.forEach(option => { 934 option.addEventListener('change', (event) => { 935 if (event.target.checked) { 936 options.forEach(otherOption => { 937 if (otherOption !== event.target) { 938 otherOption.checked = false; 939 } 940 }); 941 } 942 }); 943 }); 944 945 function closeInput(newWidth) { 946 if (document.visibilityState === 'hidden' || actualWidth != newWidth) { 947 options.forEach(option => { 948 option.checked = false; 949 }); 950 actualWidth = newWidth; 951 } 952 } 953 document.addEventListener('visibilitychange', closeInput); 954 let actualWidth = window.innerWidth; 955 const resizeObserver = new ResizeObserver(entries => { 956 for (let entry of entries) { 957 const { width } = entry.contentRect; 958 closeInput(width); 959 } 960 }); 961 resizeObserver.observe(o); 962 963 if (!cont) return false; 964 965 var as = cont.querySelectorAll('a'), 966 removeCont = 0; 967 for (var i = as.length - 1; i >= 0; i--) { 968 if (!as[i].getAttribute('href').trim()) { 969 as[i].remove(); 970 removeCont++; 971 } 972 } 973 if (as.length === removeCont) { 974 cont.setAttribute('data-title', ''); 975 cont.classList.add('sta-remove'); 976 } 977 o.querySelector(".sta-reservButton").addEventListener('click', () => { 978 if (window.openReservasGeneric) 979 openReservasGeneric(); 980 }); 981})(document.querySelector('.tpl-footer1-eh')); 982 983(function (o, $, h) { 984 if (o) { 985 986 var e = o.querySelectorAll(".sta-beneficios-eh_lista"), 987 callback = function (li) { 988 li.addClass("sta-active"); 989 }; 990 991 for (var i = 0; i < e.length; i++) { 992 (function (e) { 993 h.cargaScrollAuto({ obj: e, before: -100, dual: true }, function () { callback(e) }) 994 })(e[i]); 995 }; 996 997 }; 998})(document.querySelector(".tpl-beneficios-eh"), window.jQuery, hotusa()); 999 1000 1001(function (o, $, h) { 1002 if (!o || !$ || !h) return false; 1003 1004 var $o = $(o), 1005 id_video = $("> input", o).val(), 1006 version = $o.hasClass("tpl-functional7_v2-eh") ? 2 : 1, 1007 $backg = $('.sta-functional7-eh_backg', o), 1008 backV = $o.data('img'); 1009 1010 h.cargaScrollAuto({ obj: o, dual: true }, function () { 1011 if ($backg.length) { 1012 $backg.css('background-image', 'url("' + $backg.data('img') + '")'); 1013 } 1014 if (backV) { 1015 $o.css('background-image', 'url("' + backV + '")'); 1016 } 1017 }); 1018 1019 if (id_video) { 1020 var $html = $('<iframe></iframe>', { 1021 'src': '//fast.wistia.net/embed/iframe/' + id_video + '?videoFoam=true&autoPlay=true&endVideoBehavior=loop&playbar=false&playButton&smallPlayButton=false', 1022 'frameborder': '0', 1023 'allowtransparency': 'true', 1024 'scrolling': 'no', 1025 'name': 'wistia_embed', 1026 'width': '100%', 1027 'height': '100%' 1028 }); 1029 $("> div:nth-of-type(1)", o).append($html); 1030 1031 (function () { 1032 var funcionesWistia = function (v) { 1033 v.bind("secondchange", function (s) { 1034 if (s === 5) { 1035 // do something at exactly 5 seconds 1036 v.time(0); 1037 } 1038 }); 1039 }; 1040 1041 window._wq = window._wq || []; 1042 _wq.push({ 1043 "_all": function (video) { 1044 //after load the video, do that 1045 video.volume(0); 1046 1047 if (version == 1) funcionesWistia(video); 1048 1049 } 1050 }); 1051 })(); 1052 } else { 1053 $o.addClass("sta-only_photo"); 1054 }; 1055})(document.querySelector('.tpl-functional7-eh'), window.jQuery, window.hotusa && hotusa()); 1056 1057 1058(function (o, $, json) { 1059 if (!o && !$ && !json) return false; 1060 1061 $('> form', o).submit(function () { 1062 //function IGM 1063 applyContactDepartmentSubmitForm(); 1064 return false; 1065 }); 1066 1067 var elem = $('#contact_hot_select', o); 1068 1069 $('form.sta-validation input', o).each(function () { 1070 var $o = $(this), 1071 $o_parent = $o.parent(); 1072 if (!$o_parent.hasClass('.sta-noPlaceholder')) { 1073 $o.change(function () { 1074 this.value.trim() ? $o_parent.addClass('sta-validate') : $o_parent.removeClass('sta-validate'); 1075 }); 1076 } 1077 }); 1078 1079 if (elem.length) { 1080 var _array = []; 1081 for (var n1 in json) { 1082 for (var n2 in json[n1]) { 1083 _array.push(json[n1][n2].Name); 1084 }; 1085 }; 1086 _array.sort(); 1087 for (var a1 in _array) { 1088 var s = $('<option></option>', { value: _array[a1] }).html(_array[a1]); 1089 elem.append(s); 1090 }; 1091 }; 1092 1093})(document.querySelector('.tpl-form7-eh'), window.jQuery, window.form7_hotels); 1094 1095(function (a, $, h) { 1096 if (!a || !$ || !h) return false;
1097 1098 a.forEach(function (o) { 1099 1100 var loops = o.querySelectorAll('.sta-boxes14-eh_loop'); 1101 1102 for (var i = 0; i < loops.length; i++) { 1103 (function (loop) { 1104 var backF = loop.querySelector('figure'); 1105 if (backF) { 1106 h.cargaScrollAuto({ obj: loop, dual: true }, function () { 1107 var dataBackF = backF.dataset.img; 1108 backF.style.backgroundImage = 'url("' + dataBackF + '")'; 1109 var img = backF.querySelector('img'); 1110 if (img) img.setAttribute('src', dataBackF); 1111 }); 1112 } 1113 })(loops[i]); 1114 } 1115 1116 $("> div > div", o).each(function () { 1117 h.enlace_blank($("> a", this)); 1118 }); 1119 }); 1120})(document.querySelectorAll('.tpl-boxes14-eh'), window.jQuery, window.hotusa && hotusa()); 1121 1122(function (o, $, h) { 1123 if (!o || !$ || !h) return false; 1124 1125 var $o = $(o), 1126 $backg = $('.sta-login2-eh_back', o), 1127 modalContent = $('#sta-content-modalUnica'), 1128 irRegistro = function () { 1129 if ($(".tpl-form3-eh").length) { 1130 var n = $(".tpl-form3-eh").position().top; 1131 $('html, body').animate({ scrollTop: n - 200 }, 1200); 1132 }; 1133 }; 1134 1135 if ($o.hasClass('sta-wsocial')) $("#panel_login #usuario").removeAttr("pattern"); 1136 1137 if ($('#mensajes_login', o).length && $('#mensajes_login', o).css('display') == 'block') 1138 setTimeout(function () { o.addClass('sta-mensaje') }, 3e3); 1139 1140 h.cargaScrollAuto({ obj: o, dual: true }, function () { 1141 if ($backg.length) { 1142 var dataBackg = $backg.data('img'); 1143 $backg.css('background-image', 'url("' + dataBackg + '")'); 1144 } 1145 }); 1146 1147 1148 $(".sta-noCorporate .sta-scroll", o).click(irRegistro); 1149 //Modal olvidar contraseña 1150 if ($('.tpl-form9-eh').length) { 1151 $(' > form > div:nth-of-type(1) > a:nth-of-type(1)', o) 1152 .bind('click', { param1: '.tpl-form9-eh', param2: 'fadein', param5: modalContent }, _staOpenModal); 1153 }; 1154})(document.querySelector('.tpl-login2-eh'), window.jQuery, window.hotusa && hotusa()); 1155 1156 1157(function (a, $, h) { 1158 if (!a.length || !$ || !h) return false; 1159 1160 var callback = function (o) { 1161 $(o).iFrameSizer({ 1162 //log: true, 1163 contentWindowBodyMargin: 8, 1164 doHeight: true, 1165 doWidth: false, 1166 interval: 250 1167 }); 1168 }; 1169 1170 for (var i = 0; i < a.length; i++) { 1171 (function (o) { 1172 h.cargaScrollAuto({ obj: o }, function () { 1173 h.cargarFicheroJS('/js/libraries/iframe/jquery.iframeResizer.min.js', function () { 1174 callback(o) 1175 }); 1176 }) 1177 })(a[i]); 1178 const idioma = document.documentElement.lang; 1179 const titleIframe = { 1180 es: 'Formulario para reservar salones de eventos y reuniones', 1181 en: 'Form to book event and meeting rooms', 1182 fr: "Formulaire pour réserver des salles de réunion et d'événements", 1183 it: 'Modulo per prenotare sale per eventi e riunioni', 1184 pt: 'Formulário para reservar salas de eventos e reuniões', 1185 de: 'Formular zur Buchung von Veranstaltungs- und Besprechungsräumen', 1186 ru: 'ФоÑма Ð´Ð»Ñ Ð±ÑониÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ð·Ð°Ð»Ð¾Ð² Ð´Ð»Ñ Ð¼ÐµÑопÑиÑÑий и вÑÑÑеÑ', 1187 nl: 'Formulier om vergader- en evenementruimtes te boeken' 1188 }; 1189 const title = titleIframe[idioma] || titleIframe['es']; 1190 a[i].setAttribute('title', title); 1191 }; 1192 1193})(document.querySelectorAll('.tpl-iframe-eh'), window.jQuery, window.hotusa && hotusa()); 1194 1195 1196(function (o, $) { 1197 if (!o && !$) return false; 1198 1199 var abrir = function (n, b) { 1200 if ($('> div > ul:eq(' + b + ') > li.sta-open', o).index() != n) { 1201 //NO el mismo 1202 $('> div > ul > li.sta-open > div', o).slideToggle(); 1203 $('> div > ul > li.sta-open', o).toggleClass('sta-open'); 1204 }; 1205 $('> div > ul:eq(' + b + ') > li:eq(' + n + ') > div', o).slideToggle(); 1206 $('> div > ul:eq(' + b + ') > li:eq(' + n + ')', o).toggleClass('sta-open'); 1207 }; 1208 1209 $('> div > ul > li > button', o).click(function () { 1210 var n = $(this).parent(), 1211 ul = $(this).parent().parent().index(); 1212 1213 abrir(n.index(), ul); 1214 }); 1215 1216})(document.querySelector('.tpl-boxes18-eh'), window.jQuery); 1217 1218 1219(function (o, $) { 1220 if (!o || !$) return false; 1221 1222 var $b = $('>div>button', o), 1223 href = $b.data('href'); 1224 1225 if (href) { 1226 $b.click(function () { 1227 window.location = href; 1228 }); 1229 }; 1230 1231})(document.querySelector('.tpl-functional8-eh'), window.jQuery); 1232 1233 1234(function (o, $) { 1235 if (!o || !$) return false;
1236 1237 var p1 = $(' #NewPassword', o), 1238 p2 = $(' #NewPassword2', o), 1239 error = $(' #sta-passIgual', o), 1240 controlPass = function () { 1241 p1.val() != p2.val() 1242 ? error.removeClass('sta-none') 1243 : error.addClass('sta-none'); 1244 } 1245 1246 $(o.querySelector('form')).submit( 1247 function () { 1248 controlPass(); 1249 return false; 1250 } 1251 ); 1252})(document.querySelector('.tpl-form6-eh'), window.jQuery); 1253 1254 1255(function (o, $) { 1256 if (!o || !$) return false; 1257 1258 var as = o.querySelectorAll('a'), 1259 $o = $(o); 1260 1261 for (var i = 0; i < as.length; i++) 1262 if ($(as[i]).attr('href') != "") $o.addClass('sta-enlace' + i); 1263 1264})(document.querySelector('.tpl-boxes2-eh'), window.jQuery); 1265 1266 1267 1268 1269 1270(function (o, $, h) { 1271 if (!o || !$ || !h) return false; 1272 1273 var ul = o.querySelector('.sta-slideHome-eh_list'), 1274 cargaImg = function (li) { 1275 var $bck = $(li.querySelector('.sta-slide-eh_back')), 1276 src = $bck.data('lazy'); 1277 1278 if (src && window.innerWidth > 801) { 1279 h.cargaScrollAuto({ obj: o, dual: true }, function () { 1280 $bck.css('background-image', "url('" + src + "')").data('lazy', ''); 1281 }); 1282 } 1283 }, 1284 callback = function () { 1285 const dotsMax = o.querySelector('.sta-slideHome-eh_dotsMax'); 1286 1287 new MutationObserver(function () { 1288 const dotsWrap = dotsMax.querySelector('ul.slick-dots'), 1289 activeDot = dotsWrap && dotsWrap.querySelector('li.slick-active'); 1290 if (!activeDot) return; 1291 1292 const wrapRect = dotsWrap.getBoundingClientRect(), 1293 dotRect = activeDot.getBoundingClientRect(), 1294 maxScroll = dotsWrap.scrollWidth - dotsWrap.clientWidth, 1295 wrapCenter = wrapRect.left + wrapRect.width / 2, 1296 dotCenter = dotRect.left + dotRect.width / 2; 1297 1298 let target = dotsWrap.scrollLeft + (dotCenter - wrapCenter); 1299 1300 target = Math.max(0, Math.min(maxScroll, target)); 1301 1302 const delta = target - dotsWrap.scrollLeft, 1303 threshold = dotRect.width / 2; 1304 1305 if (Math.abs(delta) > threshold) { 1306 dotsWrap.scrollTo({ left: target, behavior: 'smooth' }); 1307 } 1308 }).observe(dotsMax, { attributes: true, attributeFilter: ['class'], subtree: true }); 1309 1310 $(ul).slick({ 1311 dots: true, 1312 appendDots: o.querySelector('.sta-slideHome-eh_dotsMax'), 1313 arrows: false, 1314 autoplay: true, 1315 // autoplaySpeed: 3000, 1316 speed: 1000, 1317 fade: true, 1318 cssEase: 'linear', 1319 1320 customPaging: function (slider, i) { 1321 return '<button type="button"></button>'; 1322 } 1323 }); 1324 }; 1325 1326 switch (ul.children.length) { 1327 case 0: 1328 $(o).addClass('sta-hide'); 1329 $(o).remove(); 1330 break; 1331 case 1: 1332 cargaImg(ul.children[0]); 1333 return false; 1334 break; 1335 1336 default: 1337 h.cargaScrollAuto({ obj: o }, function () { 1338 h.cargarFicheroJS('/js/libraries/slick/slick.min.js?_=202405290837', callback) 1339 }); 1340 break; 1341 }; 1342 1343})(document.querySelector('.tpl-slideHome-eh'), window.jQuery, window.hotusa && hotusa()); 1344 1345 1346(function (o, $, LoginUser, h) { 1347 if (!o || !$ || !h) return false; 1348 if (LoginUser.tipo_perfil === '1' || LoginUser.tipo_perfil === '2') { 1349 o.remove(); 1350 return false; 1351 } 1352 var max = o.querySelector('.sta-textCorp-eh_max'), 1353 $bkg = $(max), 1354 bkg = $bkg.data('bkg'); 1355 h.cargaScrollAuto({ obj: o }, function () { 1356 $bkg.css('background-image', "url('" + bkg + "')"); 1357 }); 1358})(document.querySelector('.tpl-textCorp-eh'), window.jQuery, window.LoginUser, window.hotusa && hotusa()); 1359 1360 1361(function (o, $, h) { 1362 if (!o || !$ || !h) return false; 1363 1364 h.cargarFicheroJS("https://www.youtube.com/iframe_api"); 1365 var $o = $(o), 1366 $backV = $('.sta-video-eh_back', o); 1367 1368 h.cargaScrollAuto({ obj: o, dual: true }, function () { 1369 if ($backV.length) { 1370 var dataBackV = $backV.data('img'); 1371 $backV.css('background-image', 'url("' + dataBackV + '")'); 1372 } 1373 }) 1374 1375 $o.on('click', function (e) { 1376 if (e.target !== this) return; 1377 1378 if ($('> div:last-of-type', o).hasClass('sta-ocultar')) stopVideo_EH(); 1379 }); 1380 1381 $("> div:last-of-type > div > button", o).click(function () { 1382 $(" > iframe", o).addClass("sta-mostrar"); 1383 $(" > div:last-of-type", o).addClass("sta-ocultar"); 1384 player_video_eh.playVideo(); 1385 }); 1386 1387})(document.querySelector('.tpl-video-eh'), window.jQuery, window.hotusa && hotusa()); 1388 1389 1390(function (o, $) { 1391 if (!o) return false;
1392 1393 var $btn = $('.sta-buttonUrl', o); 1394 1395 if ($btn.length && $btn.data('url')) { 1396 $btn.click(function () { 1397 document.location = $(o).data('url'); 1398 }); 1399 }; 1400 if ($('> article > section > div:first-child', o).prop('scrollHeight') > 108) 1401 $('> article > section .ver_mas', o).css({ 'visibility': 'visible' }); 1402 1403})(document.querySelector('.tpl-info-eh'), window.jQuery); 1404 1405 1406(function (o, $, h) { 1407 if (!o || !$ || !h) return false; 1408 1409 var staSlideOnlyClass = function (contenedor_slides, btn_derecha, btn_izquierda, contenedor_flechas, autoslide) { 1410 var cantidad_slides = $(" > div", contenedor_slides).length, 1411 cont = 0, 1412 intervalo_autoslide; 1413 1414 if (cantidad_slides > 1) 1415 contenedor_flechas.addClass("sta-mostrar_flechas"); 1416 1417 $(">div", contenedor_slides).eq(0).addClass("sta-mostrar_slide"); 1418 1419 btn_derecha.click(function () { 1420 cont == cantidad_slides - 1 ? cont = 0 : cont++; 1421 moverSlide(); 1422 if (autoslide === true && cantidad_slides > 1) { 1423 clearInterval(intervalo_autoslide); 1424 setAutoslide(); 1425 } 1426 }); 1427 btn_izquierda.click(function () { 1428 cont == 0 ? cont = cantidad_slides - 1 : cont--; 1429 moverSlide(); 1430 if (autoslide === true && cantidad_slides > 1) { 1431 clearInterval(intervalo_autoslide); 1432 setAutoslide(); 1433 } 1434 }); 1435 function moverSlide() { 1436 $(">div", contenedor_slides).removeClass("sta-mostrar_slide"); 1437 $(">div", contenedor_slides).eq(cont).addClass("sta-mostrar_slide"); 1438 } 1439 1440 function setAutoslide() { 1441 intervalo_autoslide = setInterval(function () { 1442 btn_derecha.click(); 1443 }, 5000); 1444 } 1445 1446 if (autoslide === true && cantidad_slides > 1) { 1447 setAutoslide(); 1448 } 1449 }, 1450 contSlide = $('> div:nth-of-type(1)', o), 1451 cont_flechas = $('> div:nth-of-type(2)', o), 1452 bnt_dere = $('> button:eq(0)', cont_flechas), 1453 bnt_izqu = $('> button:eq(1)', cont_flechas); 1454 1455 staSlideOnlyClass(contSlide, bnt_dere, bnt_izqu, cont_flechas, true); 1456 1457 if ($('> div', contSlide).length < 2) 1458 cont_flechas.addClass('sta-ocultar'); 1459 1460 var loops = o.querySelectorAll('.sta-headslide-eh_back'); 1461 for (var i = 0; i < loops.length; i++) { 1462 (function (loop) { 1463 h.cargaScrollAuto({ obj: loop, dual: true }, function () { 1464 var dataBackHS = loop.dataset.img; 1465 loop.style.backgroundImage = 'url("' + dataBackHS + '")' 1466 }) 1467 })(loops[i]); 1468 } 1469 1470 1471})(document.querySelector('.tpl-headslide-eh'), window.jQuery, window.hotusa && hotusa()); 1472 1473//tpl-boxes27-eh 1474(function (o, h) { 1475 if (!o || !h) return false; 1476 1477 var datas = o.querySelectorAll('.sta-boxes27-eh_back'); 1478 1479 document.addEventListener('DOMContentLoaded', function () { 1480 for (var i = 0; i < datas.length; i++) { 1481 (function (data) { 1482 h.cargaScrollAuto({ obj: data, dual: true }, function () { 1483 data.style.backgroundImage = 'url("' + data.dataset.img + '")' 1484 }); 1485 })(datas[i]); 1486 } 1487 }) 1488})(document.querySelector('.tpl-boxes27-eh'), window.hotusa && hotusa()); 1489 1490 1491(function (o, $, h) { 1492 if (!o || !$ || !h) return false; 1493 1494 var loops = o.querySelectorAll('.sta-boxes28-eh_back'); 1495 for (var i = 0; i < loops.length; i++) { 1496 (function (loop) { 1497 h.cargaScrollAuto({ obj: loop, dual: true }, function () { 1498 var dataBackHS = loop.dataset.img; 1499 loop.style.backgroundImage = 'url("' + dataBackHS + '")' 1500 }) 1501 })(loops[i]); 1502 } 1503 1504 1505 $('> div > div > div > article', o).each(function () { 1506 h.enlace_blank($('> footer > a', this)); 1507 }); 1508})(document.querySelector('.tpl-boxes28-eh'), window.jQuery, window.hotusa && hotusa()); 1509 1510 1511(function (o, $, h) { 1512 if (!o || !$ || !h) return false; 1513 1514 var staContenedorSlides2 = function (contSli, left, right, dedo, bucle, contDos) { 1515 function go_left() { 1516 var select = $('> .sta-selected:not(.sta-ant):not(.sta-pos)', contSli), 1517 index = select.index(); 1518 1519 //si hay posterior 1520 if (index < $('> div', contSli).length - 1) { 1521 //anterior pasa a normal si habia 1522 if (index >= 1) { 1523 $('> div:eq(' + (index - 1) + ')', contSli).removeClass('sta-selected sta-ant'); 1524 } 1525 //actual pasa a anterior 1526 select.addClass('sta-ant').removeClass('sta-act'); 1527 //posterior pasa a actual 1528 $('> div:eq(' + (index + 1) + ')', contSli).removeClass('sta-pos').addClass('sta-selected sta-act'); 1529 //normal futuro pasa a posterior si hay 1530 if (index < $('> div', contSli).length - 2) { 1531 $('> div:eq(' + (index + 2) + ')', contSli).addClass('sta-selected sta-pos'); 1532 } 1533 } 1534 1535 bucle ? $('> div:first-of-type', contSli).appendTo(contSli) : botones(); 1536 }; 1537 function go_right() { 1538 var select = $('> .sta-selected:not(.sta-ant):not(.sta-pos)', contSli), 1539 index = select.index(); 1540 //si hay anterior 1541 if (index >= 1) { 1542 //posterior si hay a normal 1543 if (index < $('> div', contSli).length - 1) { 1544 $('> div:eq(' + (index + 1) + ')', contSli).removeClass('sta-selected sta-pos'); 1545 } 1546 //actual a posterior 1547 select.addClass('sta-pos').removeClass('sta-act'); 1548 //anterior a actual 1549 $('> div:eq(' + (index - 1) + ')', contSli).addClass('sta-selected sta-act').removeClass('sta-ant'); 1550 //normal anterior pasa a anterior si hay 1551 if (index > 1) { 1552 $('> div:eq(' + (index - 2) + ')', contSli).addClass('sta-selected sta-ant'); 1553 } 1554 }; 1555 if (bucle) { 1556 $('> div:last-of-type', contSli).prependTo(contSli); 1557 $('> div:first-of-type', contSli).addClass('sta-selected sta-ant'); 1558 } else { 1559 botones(); 1560 } 1561 } 1562 function botones() { 1563 if ($('> .sta-selected.sta-ant', contSli).length == 0) { 1564 left.addClass('sta-oculto'); 1565 } else { 1566 left.removeClass('sta-oculto'); 1567 } 1568 if ($('> .sta-selected.sta-pos', contSli).length == 0) { 1569 right.addClass('sta-oculto'); 1570 } else { 1571 right.removeClass('sta-oculto'); 1572 } 1573 } 1574 1575 //dato por defecto 1576 if (bucle == undefined) { bucle = true; } 1577 if (dedo == undefined) { dedo = true; } 1578 1579 if (contSli == undefined || left == undefined || right == undefined) { 1580 console.trace('datos insuficientes'); 1581 } else { 1582 if ($('> div', contSli).length < 4) { 1583 $('> div:first-of-type', contSli).addClass('sta-selected sta-act'); 1584 left.addClass('sta-oculto'); 1585 right.addClass('sta-oculto'); 1586 console.trace('minimo de fotos no alcanzado') 1587 } else { 1588 if (!contSli.hasClass('sta-preparado')) { 1589 $('> div:first-of-type', contSli).addClass('sta-selected sta-ant'); 1590 $('> div:nth-of-type(2)', contSli).addClass('sta-selected sta-act'); 1591 $('> div:nth-of-type(3)', contSli).addClass('sta-selected sta-pos'); 1592 //por si viene preparado --> modales 1593 contSli.addClass('sta-preparado'); 1594 } 1595 1596 left.click(go_right); 1597 right.click(go_left); 1598 1599 //quitar en dedo 1600 if (dedo) { 1601 contSli.on('swipeleft', go_left); 1602 contSli.on('swiperight', go_right); 1603 if (contDos != undefined) { 1604 contDos.on('swipeleft', go_left); 1605 contDos.on('swiperight', go_right); 1606 } 1607 } 1608 } 1609 } 1610 }, 1611 paddingHeader = function (obj) { 1612 var header = $('.tpl-header2-eh').length ? $('.tpl-header2-eh > div').innerHeight() : false;
1613 1614 if (header) { 1615 obj.css('padding-top', header); 1616 $(window).resize(function () { 1617 obj.css('padding-top', header); 1618 }) 1619 }; 1620 }, 1621 $o = $(o), 1622 contSli = $('> div:first-of-type > .sta-fondo > div:first-of-type', o), 1623 left = $('> div:first-of-type > .sta-fondo > div:last-of-type > button:eq(0)', o), 1624 right = $('> div:first-of-type > .sta-fondo > div:last-of-type > button:eq(1)', o), 1625 dedo = !$('html').hasClass('sf5'), 1626 contSli2 = $('> div:last-of-type > div:nth-of-type(2)', o); 1627 1628 1629 if ($('> div', contSli).length > 1) { 1630 $o.addClass('sta-slide'); 1631 staContenedorSlides2(contSli, left, right, dedo, true, contSli2); 1632 }; 1633 1634 paddingHeader($o); 1635})(document.querySelector('.tpl-functional5-eh'), window.jQuery, window.hotusa && hotusa()); 1636 1637 1638(function (o, $, h, _staOpenModal) { 1639 if (!o || !$ || !h || !_staOpenModal) return false; 1640 1641 //Añadir un video iframe a una modal y abrir dicha modal 1642 var iframeModal = function (click, iframe, clase) { 1643 if (!clase) clase = 'sta-iframeYoutube'; 1644 1645 var html = $('<iframe></iframe>', { 1646 'class': clase, 1647 'type': 'text/html', 1648 'src': iframe, 1649 'frameborder': '0', 1650 'allowfullscreen': 'true', 1651 }); 1652 1653 click.bind('click', { param1: html, param2: 'fadein' }, _staOpenModal); 1654 }, 1655 paddingHeader = function (obj) { 1656 var header = $('.tpl-header2-eh').length ? $('.tpl-header2-eh > div').innerHeight() : false; 1657 1658 if (header) { 1659 obj.css('padding-top', header); 1660 $(window).resize(function () { 1661 obj.css('padding-top', header); 1662 }) 1663 }; 1664 }, 1665 $o = $(o), 1666 li = $('> div:first-of-type > div > ul > li', o); 1667 1668 paddingHeader($o); 1669 1670 li.each(function () { 1671 var o2 = $(this); 1672 o2.hover(function () { 1673 li.addClass('sta-NOhover'); 1674 o2.removeClass('sta-NOhover'); 1675 }) 1676 .mouseleave(function () { 1677 li.removeClass('sta-NOhover'); 1678 }) 1679 }); 1680 1681 if ($o.hasClass('sta-modal')) { 1682 li.each(function () { 1683 var a = $('> a', this), 1684 url = a.attr('href'); 1685 1686 a.click(function (e) { 1687 e.preventDefault(); 1688 }); 1689 iframeModal(a, url); 1690 }); 1691 }; 1692 1693 backHB = o.querySelector('sta-headbanner3-eh_back'); 1694 h.cargaScrollAuto({ obj: o, dual: true }, function () { 1695 if (o) { 1696 var dataBackHB = o.dataset.img; 1697 o.style.backgroundImage = 'url("' + dataBackHB + '")'; 1698 } 1699 if (backHB) { 1700 backHB.style.backgroundImage = 'url("' + dataBackHB + '")'; 1701 } 1702 }); 1703 1704})(document.querySelector('.tpl-headbanner3-eh'), window.jQuery, window.hotusa && hotusa(), window._staOpenModal); 1705 1706 1707 1708(function (o, $) { 1709 if (!o || !$) return false; 1710 1711 var staContenedorSlides2 = function (contSli, left, right, dedo, bucle, contDos) { 1712 function go_left() { 1713 var select = $('> .sta-selected:not(.sta-ant):not(.sta-pos)', contSli), 1714 index = select.index(); 1715 1716 //si hay posterior 1717 if (index < $('> div', contSli).length - 1) { 1718 //anterior pasa a normal si habia 1719 if (index >= 1) { 1720 $('> div:eq(' + (index - 1) + ')', contSli).removeClass('sta-selected sta-ant'); 1721 } 1722 //actual pasa a anterior 1723 select.addClass('sta-ant').removeClass('sta-act'); 1724 //posterior pasa a actual 1725 $('> div:eq(' + (index + 1) + ')', contSli).removeClass('sta-pos').addClass('sta-selected sta-act'); 1726 //normal futuro pasa a posterior si hay 1727 if (index < $('> div', contSli).length - 2) { 1728 $('> div:eq(' + (index + 2) + ')', contSli).addClass('sta-selected sta-pos'); 1729 } 1730 } 1731 1732 bucle ? $('> div:first-of-type', contSli).appendTo(contSli) : botones(); 1733 }; 1734 function go_right() { 1735 var select = $('> .sta-selected:not(.sta-ant):not(.sta-pos)', contSli), 1736 index = select.index(); 1737 //si hay anterior 1738 if (index >= 1) { 1739 //posterior si hay a normal 1740 if (index < $('> div', contSli).length - 1) { 1741 $('> div:eq(' + (index + 1) + ')', contSli).removeClass('sta-selected sta-pos'); 1742 } 1743 //actual a posterior 1744 select.addClass('sta-pos').removeClass('sta-act'); 1745 //anterior a actual 1746 $('> div:eq(' + (index - 1) + ')', contSli).addClass('sta-selected sta-act').removeClass('sta-ant'); 1747 //normal anterior pasa a anterior si hay 1748 if (index > 1) { 1749 $('> div:eq(' + (index - 2) + ')', contSli).addClass('sta-selected sta-ant'); 1750 } 1751 }; 1752 if (bucle) { 1753 $('> div:last-of-type', contSli).prependTo(contSli); 1754 $('> div:first-of-type', contSli).addClass('sta-selected sta-ant'); 1755 } else { 1756 botones(); 1757 } 1758 } 1759 function botones() { 1760 if ($('> .sta-selected.sta-ant', contSli).length == 0) { 1761 left.addClass('sta-oculto'); 1762 } else { 1763 left.removeClass('sta-oculto'); 1764 } 1765 if ($('> .sta-selected.sta-pos', contSli).length == 0) { 1766 right.addClass('sta-oculto'); 1767 } else { 1768 right.removeClass('sta-oculto'); 1769 } 1770 } 1771 1772 //dato por defecto 1773 if (bucle == undefined) { bucle = true; } 1774 if (dedo == undefined) { dedo = true; } 1775 1776 if (contSli == undefined || left == undefined || right == undefined) { 1777 console.trace('datos insuficientes'); 1778 } else { 1779 if ($('> div', contSli).length < 4) { 1780 $('> div:first-of-type', contSli).addClass('sta-selected sta-act'); 1781 left.addClass('sta-oculto'); 1782 right.addClass('sta-oculto'); 1783 console.trace('minimo de fotos no alcanzado') 1784 } else { 1785 if (!contSli.hasClass('sta-preparado')) { 1786 $('> div:first-of-type', contSli).addClass('sta-selected sta-ant'); 1787 $('> div:nth-of-type(2)', contSli).addClass('sta-selected sta-act'); 1788 $('> div:nth-of-type(3)', contSli).addClass('sta-selected sta-pos'); 1789 //por si viene preparado --> modales 1790 contSli.addClass('sta-preparado'); 1791 } 1792 1793 left.click(go_right); 1794 right.click(go_left); 1795 1796 //quitar en dedo 1797 if (dedo) { 1798 contSli.on('swipeleft', go_left); 1799 contSli.on('swiperight', go_right); 1800 if (contDos != undefined) { 1801 contDos.on('swipeleft', go_left); 1802 contDos.on('swiperight', go_right); 1803 } 1804 } 1805 } 1806 } 1807 }, 1808 flag_modal = $(".tpl-fondomodal-eh").length ? true : false, 1809 ev = function (o) { 1810 var banner = '', 1811 btnRight = $('> div:first-of-type > div:nth-of-type(2) > button:eq(0)', o), 1812 btnLeft = $('> div:first-of-type > div:nth-of-type(2) > button:eq(1)', o), 1813 contSlide = $('> div:nth-of-type(2)', o), 1814 dedo = !$('html').hasClass('sf5'),
1815 boton = $('> div:first-of-type > div:nth-of-type(3)', o), 1816 iframe360, 1817 contenedor_video, 1818 callback = function () { 1819 ev($('#sta-modal')); 1820 }; 1821 1822 if ($('.tpl-boxes3-v2-eh').length) banner = $('.tpl-boxes3-v2-eh:eq(0)'); 1823 1824 if ($('> input[name=video]', o).val() != '') { 1825 contenedor_video = $(" > div:nth-of-type(3)", o); 1826 $('> .sta-video', boton).removeClass('sta-oculto'); 1827 funcionVideo(); 1828 } 1829 1830 if ($('> input[name=v360]', o).val() != '') { 1831 $('> .sta-360', boton).removeClass('sta-oculto'); 1832 iframe360 = $('<iframe></iframe>', { 1833 'class': 'sta-frame360', 1834 'src': $('> input[name=v360]', o).val() 1835 }); 1836 funcion360(); 1837 } 1838 if (!o.hasClass("sta-slide-galeria")) 1839 staContenedorSlides2(contSlide, btnLeft, btnRight, dedo); 1840 1841 $('> .sta-ampliar', boton).bind('click', { param1: o, param2: 'fadein', param3: callback, param4: banner }, _staOpenModal); 1842 1843 function funcion360() { 1844 //compruebo si hay modal, para evitar errores en el futuro 1845 if (flag_modal) { 1846 $('> .sta-360', boton).bind('click', { param1: iframe360, param2: 'fadein', param3: funcionVideo, param4: banner }, _staOpenModal); 1847 $('.tpl-fondomodal-eh .tpl-boxes3-v2-eh > button:eq(2)').bind('click', { param1: iframe360, param2: 'fadein', param3: funcionVideo, param4: banner }, _staOpenModal); 1848 } 1849 } 1850 function funcionVideo() { 1851 if (flag_modal) { 1852 $('> .sta-video', boton).bind('click', { param1: contenedor_video, param2: 'fadein', param3: funcion360, param4: banner }, _staOpenModal); 1853 $('.tpl-fondomodal-eh .tpl-boxes3-v2-eh > button:eq(0)').bind('click', { param1: contenedor_video, param2: 'fadein', param3: funcion360, param4: banner }, _staOpenModal); 1854 } 1855 } 1856 1857 }; 1858 1859 ev($(o)); 1860 1861})(document.querySelector('.tpl-slide2-eh'), window.jQuery); 1862 1863(function (o, $, h) { 1864 if (!o || !$ || !h) return false; 1865 1866 var callback = function () { 1867 1868 var swiperSup = new Swiper(navHeader, { 1869 speed: 1000, 1870 navigation: { 1871 nextEl: ".swiper-button-next", 1872 prevEl: ".swiper-button-prev", 1873 }, 1874 freeMode: true, 1875 slidesPerView: 'auto', 1876 breakpoints: { 1877 1100: { 1878 centeredSlides: false, 1879 } 1880 }, 1881 on: { 1882 init: function () { 1883 navHeader.querySelector('li').classList.add('sta-active'); 1884 }, 1885 click: function (swiper, event) { 1886 var li = event.target.parentElement, 1887 siblings = Array.from(li.parentElement.children), 1888 n = siblings.indexOf(li); 1889 1890 if (swiperInf.realIndex == n) return false; 1891 1892 swiperInf.slideTo(n); 1893 1894 var remove = navHeader.querySelector('.sta-active'); 1895 if (remove) remove.classList.remove('sta-active'); 1896 li.classList.add('sta-active'); 1897 } 1898 } 1899 }); 1900 1901 var swiperInf = new Swiper(navSection, { 1902 speed: 1000, 1903 effect: "fade", 1904 fadeEffect: { 1905 crossFade: true 1906 }, 1907 navigation: false, 1908 autoHeight: true, 1909 lazyLoading: true, 1910 lazy: true, 1911 on: { 1912 slideChange: function (swiper,) { 1913 var activeIndex = swiper.activeIndex, 1914 remove = navHeader.querySelector('.sta-active'), 1915 siblings = Array.from(remove.parentElement.children); 1916 1917 if (remove) remove.classList.remove('sta-active'); 1918 1919 siblings[activeIndex].classList.add('sta-active'); 1920 1921 swiperSup.slideTo(activeIndex); 1922 1923 } 1924 } 1925 }); 1926 1927 }, 1928 navHeader = o.querySelector('div header .sta-slideGrupos-eh_slide'), 1929 navSection = o.querySelector('.sta-slideGrupos-eh_sectionNav'), 1930 articles = navSection.querySelector('.swiper-wrapper').children; 1931 1932 for (var i = 0; i < articles.length; i++) { 1933 (function (art) { 1934 h.enlace_blank(art.querySelector('.sta-slideGrupos-eh_anchor')); 1935 1936 var bck = art.querySelector('.sta-slideGrupos-eh_bck'); 1937 bck.dataset.background; 1938 })(articles[i]); 1939 } 1940 1941 1942 h.cargaScrollAuto({ obj: o }, function () { 1943 var load = 2, 1944 fn = function () { 1945 load--; 1946 if (!load) { 1947 callback(); 1948 } 1949 } 1950 1951 h.cargarFicheroCSS('/js/libraries/swiper/swiper.min.css?_=202405290837', fn) 1952 1953 h.cargarFicheroJS('/js/libraries/swiper/swiper.js?_=202405290837', fn); 1954 1955 }); 1956 1957})(document.querySelector('.tpl-slideGrupos-eh'), window.jQuery, window.hotusa && hotusa()); 1958 1959 1960(function (a, $, h) { 1961 1962 if (!a.length || !$ || !h) return false;
1963 1964 var ev = function ($o) { 1965 var src = $o.data('bkg'); 1966 1967 if (src) { 1968 h.cargaScrollAuto({ obj: $o[0] }, function () { 1969 $o.css('background-image', "url('" + src + "')"); 1970 }); 1971 }; 1972 }; 1973 1974 for (var i = 0; i < a.length; i++) ev($(a[i])); 1975 1976})(document.querySelectorAll('.tpl-introText-eh'), window.jQuery, window.hotusa); 1977 1978 1979(function (o, $, h) { 1980 if (!o || !$ || !h) return false; 1981 1982 var lis = o.querySelectorAll('.sta-moments-eh_bck'), 1983 dimen = null; 1984 1985 h.cargaScrollAuto({ obj: o }, function () { 1986 for (var i = 0; i < lis.length; i++) { 1987 (function ($bck) { 1988 $bck.css('background-image', "url('" + $bck.data('bck') + "')"); 1989 $('img', $bck).attr('src', $bck.data('bck')); 1990 })($(lis[i])); 1991 }; 1992 }); 1993 1994})(document.querySelector('.tpl-moments-eh'), window.jQuery, window.hotusa && hotusa()); 1995 1996 1997(function (o, $, h) { 1998 if (!o || !$ || !h) return false; 1999 2000 var lis = o.querySelectorAll('.sta-boxArticle-eh_indi'), 2001 dimen = null; 2002 2003 2004 for (var i = 0; i < lis.length; i++) { 2005 (function (li) { 2006 var $bck = $(li.querySelector('.sta-boxArticles-eh_bck')), 2007 $img = $(li.querySelector('.sta-boxArticles-eh_bck img')), 2008 alt = li.querySelector('header').textContent.trim(), 2009 src = $bck.data('bkg'); 2010 if (src) { 2011 h.cargaScrollAuto({ obj: $bck[0] }, function () { 2012 $bck.css('background-image', "url('" + src + "')"); 2013 $img.attr({ 'src': src, 'alt': alt }); 2014 }); 2015 }; 2016 })(lis[i]); 2017 }; 2018 2019})(document.querySelector('.tpl-boxArticles-eh'), window.jQuery, window.hotusa && hotusa()); 2020 2021 2022 2023 2024 2025(function (desta, $, h) { 2026 if (!desta || !$ || !h) return false; 2027 2028 var tot = desta.querySelectorAll('.slide-home-eh_boxElement'), 2029 totMvl = desta.querySelectorAll('.slide-home-eh_boxElement.sta-active'); 2030 2031 if (!tot.length) return false; 2032 2033 //$o.addClass('sta-destaDesk_' + tot.length + ' sta-destaMvl_' + totMvl.length); 2034 2035 for (var i = 0; i < tot.length; i++) { 2036 (function ($indi) { 2037 var $cntImg = $('.slide-home-eh_boxImage', $indi), 2038 rutaImg = $cntImg.data('src') && $cntImg.data('src').trim(); 2039 2040 if (!rutaImg) $indi.addClass('sta-sinFoto'); 2041 2042 var fn = function (boo) { 2043 if ($indi.css('display') == 'none') { 2044 if (!boo) { 2045 $(window).on('resize', fn); 2046 }; 2047 } else { 2048 $(window).off('resize', fn); 2049 h.cargaScrollAuto({ obj: $indi[0], dual: true }, function () { 2050 $indi.addClass('sta-visible'); 2051 if (rutaImg) $cntImg.css("background-image", "url('" + rutaImg + "')") 2052 }); 2053 }; 2054 }; 2055 fn(false); 2056 2057 })($(tot[i])); 2058 }; 2059})(document.querySelector('.tpl-alertBox-eh'), window.jQuery, window.hotusa && hotusa()); 2060 2061(function (a, $, h) { 2062 if (!a.length || !$ || !h) return false; 2063 2064 var ev = function (o) { 2065 var lat = o.querySelector('.sta-lat').value, 2066 lon = o.querySelector('.sta-lon').value; 2067 2068 if (!lat || !lon) return false; 2069 2070 h.cargaScrollAuto({ obj: o }, function () { 2071 $.getJSON('/api/weather/getAll/' + lat + '/' + lon, function (timeWeather) { 2072 if (!timeWeather || !timeWeather.temp || !timeWeather.tz || !timeWeather.tz.time) { 2073 return false; 2074 console.trace('Error: Error Weather'); 2075 }; 2076 2077 $(o.querySelector('.sta-weather-temp')) 2078 .html(timeWeather.temp + " ºC") 2079 .addClass('sta-weather-icon' + timeWeather.weatherIcon); 2080 2081 var hora = timeWeather.tz.time, 2082 h = hora.substring(hora.length - 5, hora.length); 2083 $(o.querySelector('.sta-weather-time')).text(h); 2084 }); 2085 }) 2086 }; 2087 2088 for (var i = 0; i < a.length; i++) ev(a[i]); 2089 2090})(document.querySelectorAll('.sta-weather'), window.jQuery, window.hotusa && hotusa()); 2091 2092 2093 2094(function (o, LoginUser, h) { 2095 2096 if (!o || !h) return false; 2097 const contImg = o.querySelector('.sta-textStarTravBanner-eh_max'), 2098 src = contImg.dataset.back; 2099 if (LoginUser && LoginUser.tipo_perfil === '1') { 2100 o.remove(); 2101 return false; 2102 } 2103 o.querySelector('._fn-openModal').addEventListener('click', function (e) { 2104 var scrollToModal = window.scrollY > 0; 2105 if (scrollToModal) { 2106 window.scrollTo({ top: 0, behavior: "smooth" }); 2107 document.addEventListener("scrollend", (e) => { 2108 e.stopPropagation(); 2109 if (scrollToModal) { 2110 scrollToModal = window.scrollY > 0; 2111 document.dispatchEvent( 2112 new CustomEvent("toggleLogin", { 2113 detail: { alias: "cms-login", open: true }, 2114 }) 2115 ); 2116 } 2117 }); 2118 } else { 2119 document.dispatchEvent( 2120 new CustomEvent("toggleLogin", { 2121 detail: { alias: "cms-login", open: true }, 2122 }) 2123 ); 2124 } 2125 }); 2126 if (parseInt(window.getComputedStyle(contImg).backgroundSize)) { 2127 h.cargaScrollAuto({ obj: contImg, dual: true }, function () { 2128 contImg.style.backgroundImage = "url('" + src + "')"; 2129 }) 2130 } 2131})(document.querySelector('.tpl-textStarTravBanner-eh_v2'), window.LoginUser, window.hotusa && hotusa()); 2132 2133 2134 2135(function (o, h) { 2136 2137 if (!o || !h) return false;
2138 var backF = o.querySelector('img'), 2139 dimenBox = h.dimensionImg(backF); 2140 if (backF) { 2141 h.cargaScrollAuto({ obj: backF, dual: true }, function () { 2142 backF.src = backF.src + '?width=' + dimenBox.w; 2143 2144 }); 2145 } 2146})(document.querySelector('.tpl-textStarTravBanner-eh'), window.hotusa && hotusa()); 2147 2148 2149 2150(function (labs, $) { 2151 if (!labs.length) return false; 2152 2153 $(window).keypress(function (t) { 2154 switch (t.keyCode) { 2155 case 13: 2156 var $e = $('.fn-tabIndex:focus'); 2157 if ($e.length) $e.click(); 2158 break; 2159 2160 default: 2161 break; 2162 }; 2163 }); 2164})(document.querySelectorAll('.fn-tabIndex'), window.jQuery); 2165 2166 2167(function (o, h, l, m) { 2168 if (!o || !h) return false; 2169 2170 var a = o.querySelectorAll('a'), 2171 url = l.origin + l.pathname; 2172 2173 for (var i = 0; i < a.length; i++) { 2174 (function ($a) { 2175 if (url == $a[0].href) { 2176 $a.parent().addClass('sta-active'); 2177 $a.parent().append($a.html()); 2178 $a.remove(); 2179 } else { 2180 h.enlace_blank($a); 2181 $a.attr('rel', 'noopener'); 2182 } 2183 })($(a[i])); 2184 }; 2185 2186 if (m == 'aurea') { 2187 var $a_aurea = $(o.querySelector('.aurea a')); 2188 2189 if ($a_aurea.length) { 2190 $a_aurea.parent().addClass('sta-active'); 2191 $a_aurea.parent().append($a_aurea.html()); 2192 $a_aurea.remove(); 2193 }; 2194 }; 2195 2196})(document.querySelector('.tpl-slidePartners-eh'), window.hotusa && hotusa(), window.location, window.marca); 2197 2198 2199// Editadas 2200(function (o, $) { 2201 if (!o || !$) return false; 2202 2203 var ul = o.querySelector('ul'); 2204 2205 if (!ul) return false; 2206 2207 var lis = ul.querySelectorAll('li'), 2208 $o = $(o), 2209 abrir = function (eq) { 2210 $(eq.querySelector('div.sta-datos')).slideToggle(function () { 2211 $(eq).toggleClass('sta-open') 2212 }); 2213 }, 2214 printHijo = function (eq) { 2215 $o.clone().remove('> ul > li').append($(eq).clone()).addClass('print'); 2216 } 2217 2218 2219 for (var i = 0; i < lis.length; i++) { 2220 (function (li) { 2221 var eq = li; 2222 2223 $(li.lastElementChild.querySelector('div > button')).click(function () { 2224 abrir(eq); 2225 }); 2226 2227 $(li.querySelector('.sta-botones > button')).click(function () { 2228 printHijo(eq); 2229 }); 2230 2231 })(lis[i]); 2232 }; 2233 2234})(document.querySelector('.tpl-boxes17-eh'), window.jQuery); 2235 2236 2237(function (a, $) { 2238 if (!a.length || !$) return false; 2239 2240 var ev = function (o) { 2241 $('> div > div:nth-of-type(2) > form', o).submit(function () { 2242 var u = $(this), 2243 id = u.attr('id').replace('applyWineBookForm', ''); 2244 //function IGM 2245 applyWineBookSubmitForm(id); 2246 return false; 2247 }); 2248 }; 2249 for (var i = 0; i < a.length; i++) ev(a[i]); 2250 2251})(document.querySelectorAll('.tpl-form12-eh'), window.jQuery); 2252 2253 2254(function (o, $) { 2255 if (!o || !$) return false; 2256 var a = $(o.querySelector(':scope > div > article > footer > a')); 2257 hotusa().enlace_blank(a); 2258})(document.querySelector('.tpl-info11-eh'), window.jQuery); 2259 2260 2261(function (o, $) { 2262 if (!o || !$) return false; 2263 2264 $('> div > form', o).submit(function () { 2265 //function IGM 2266 applyWineBookContactSubmitForm(); 2267 return false; 2268 }); 2269})(document.querySelector('.tpl-form13-eh'), window.jQuery); 2270 2271 2272//#region | .tpl-modalFotos-d Galeria wineandbooks 2273var openModalFotos = (function (o, $, h) { 2274 if (!o || !$ || !h) return 2275 if (o) { 2276 function close() { 2277 $(o).fadeOut(1e3, function () { 2278 $('html').removeClass('sta-noScroll'); 2279 $(".sta-modalFotos-d_overflow", o).empty(); 2280 $(".sta-modalFotos-d_lista", o).empty(); 2281 }); 2282 $focus.focus(); 2283 } 2284 var obj = { 2285 fotos: { 2286 up: $(".sta-modalFotos-d_lista .sta-modalFotos-d_fotosLi", o).clone(), 2287 down: $(".sta-modalFotos-d_rel", o).clone() 2288 }, 2289 video: { 2290 up: $(".sta-modalFotos-d_lista .sta-modalFotos-d_videosLi", o).clone(), 2291 down: $(".sta-modalFotos-d_videoCont", o).clone() 2292 }, 2293 360: { 2294 up: $(".sta-modalFotos-d_lista .sta-modalFotos-d_360Li", o).clone(), 2295 down: $(".sta-modalFotos-d_360Cont", o).clone() 2296 } 2297 }, 2298 $focus = null, 2299 $cont_down = $(o.querySelector(".sta-modalFotos-d_overflow")), 2300 $cont_up = $(o.querySelector(".sta-modalFotos-d_lista")), 2301 dimen = null; 2302 2303 $cont_up.empty(); 2304 $cont_down.empty(); 2305 2306 $(document).keyup(function (e) { 2307 if ($(o).css('display') != 'none' && $(".sta-modalFotos-d_rel", o).length) { 2308 switch (e.keyCode) { 2309 case 39: 2310 $('.sta-modalFotos-d_rel .sta-modalFotos-d_buttons .sta-modalFotos-d_topBu', o).click(); 2311 break; 2312 2313 case 37: 2314 $('.sta-modalFotos-d_rel .sta-modalFotos-d_buttons .sta-modalFotos-d_bottomBu', o).click(); 2315 break; 2316 default: 2317 }; 2318 }; 2319 }); 2320 2321 $(".sta-modalFotos-d_closeBu", o).click(close); 2322 $(document).keyup(function (e) { 2323 if (e.keyCode == 27 && $(o).css('display') != 'none') close(); 2324 }); 2325 $(".sta-modalFotos-d_cell", o).click(function (e) { 2326 if (this === e.target) close(); 2327 }); 2328
2329 //Funcion para desplazarse a traves de la galeria 2330 function caroussel(o2, arr, obj) { 2331 var $bLeft = $(".sta-modalFotos-d_topBu", o2), 2332 $bRight = $(".sta-modalFotos-d_bottomBu", o2), 2333 $carr = $(".sta-modalFotos-d_carousel", o2), 2334 $clone = $(".sta-modalFotos-d_image", o2).clone(), 2335 n = obj.act, 2336 bool = true; 2337 2338 $(".sta-modalFotos-d_image", o2).css("background-image", "url('" + arr[n] + "')"); 2339 2340 if (arr.length <= 1) { 2341 $(o).addClass("sta-noButtons"); 2342 } else { 2343 function left() { 2344 if (bool) { 2345 bool = !!0; 2346 var inser = $clone.clone(), 2347 img = new Image(), 2348 out = $(".sta-modalFotos-d_image", o2); 2349 n++; 2350 if (arr.length - 1 < n) n = 0; 2351 2352 $('.sta-modalFotos-d_subtitulo span:eq(0)', obj.fotos.up).text(n + 1); 2353 img.src = arr[n]; 2354 img.onload = function () { 2355 inser.css("background-image", "url('" + this.src + "')"); 2356 }; 2357 inser.css("left", "100%"); 2358 $carr.append(inser); 2359 2360 out.animate({ left: "-100%" }, 1e3, function () { 2361 out.remove(); 2362 bool = true; 2363 }); 2364 inser.animate({ left: 0 }, 1e3); 2365 2366 }; 2367 }; 2368 function right() { 2369 if (bool) { 2370 bool = false;
2371 var inser = $clone.clone(), 2372 img = new Image(), 2373 out = $(".sta-modalFotos-d_image", o2); 2374 n--; 2375 if (n < 0) n = arr.length - 1; 2376 2377 $('.sta-modalFotos-d_subtitulo span:eq(0)', obj.fotos.up).text(n + 1); 2378 2379 img.src = arr[n]; 2380 img.onload = function () { 2381 inser.css("background-image", "url('" + this.src + "')"); 2382 }; 2383 inser.css("left", "-100%"); 2384 $carr.append(inser); 2385 out.animate({ left: "100%" }, 1e3, function () { 2386 out.remove(); 2387 bool = true; 2388 }); 2389 inser.animate({ left: "0" }, 1e3); 2390 }; 2391 }; 2392 $(o).removeClass("sta-noButtons"); 2393 2394 $bLeft.click(left); 2395 $bRight.click(right); 2396 2397 if (!$("html").hasClass("sf5") && (typeof jQuery.ui != 'undefined')) { 2398 $carr.on('swipeleft', left); 2399 $carr.on('swiperight', right); 2400 } 2401 } 2402 }; 2403 function oModal(json) { 2404 2405 $focus = $(document.querySelector(':focus')); 2406 2407 function automatic(obj3, pa) { 2408 $cont_down.html(""); 2409 pa.siblings().removeClass("sta-activa"); 2410 pa.addClass("sta-activa"); 2411 $cont_down.append(obj3); 2412 }; 2413 2414 $('.sta-modalFotos-d_titleHabi', o).text(json.name ? json.name : ''); 2415 2416 var obj2 = {}; 2417 if (($.type(json.fotos) == "array") && (json.fotos.length > 0)) { 2418 obj2.fotos = { 2419 up: obj.fotos.up.clone(), 2420 down: obj.fotos.down.clone() 2421 }; 2422 obj2.act = json.act ? json.act : 0; 2423 2424 $cont_up.append(obj2.fotos.up); 2425 2426 $('.sta-modalFotos-d_subtitulo span:eq(0)', obj2.fotos.up).text(obj2.act + 1); 2427 $('.sta-modalFotos-d_subtitulo span:eq(1)', obj2.fotos.up).text(json.fotos.length); 2428 2429 $(".sta-modalFotos-d_foto", obj2.fotos.up).click(function () { 2430 caroussel(obj2.fotos.down, json.fotos, obj2); 2431 automatic(obj2.fotos.down, $(this).parent()); 2432 }); 2433 }; 2434 if ($.trim(json.video)) { 2435 obj2.video = { 2436 up: obj.video.up.clone(), 2437 down: obj.video.down.clone() 2438 }; 2439 $cont_up.append(obj2.video.up); 2440 $("iframe", obj2.video.down).attr("src", json.video); 2441 $(".sta-modalFotos-d_video", obj2.video.up).click(function () { 2442 automatic(obj2.video.down, $(this).parent()); 2443 }); 2444 } 2445 if ($.trim(json[360])) { 2446 obj2[360] = { 2447 up: obj[360].up.clone(), 2448 down: obj[360].down.clone() 2449 }; 2450 $cont_up.append(obj2[360].up); 2451 $("iframe", obj2[360].down).attr("src", json[360]); 2452 $(".sta-modalFotos-d_360", obj2[360].up).click(function () { 2453 automatic(obj2[360].down, $(this).parent()); 2454 }); 2455 }; 2456 2457 $(o).fadeIn(); 2458 $('html').addClass('sta-noScroll'); 2459 2460 json.select && $(".sta-modalFotos-d_lista > li:eq(" + json.select + ")", o).length ? 2461 $(".sta-modalFotos-d_lista > li:eq(" + json.select + ") button", o).addClass("sta-activa").click() : 2462 $(".sta-modalFotos-d_lista > li:eq(0) button", o).addClass("sta-activa").click(); 2463 2464 2465 $(".sta-modalFotos-d_lista > li:eq(0) button", o).focus(); 2466 }; 2467 2468 return oModal; 2469 } else { 2470 return false; 2471 }; 2472})(document.querySelector(".tpl-modalFotos-d"), window.jQuery, window.hotusa && hotusa()); 2473// #endregion | .tpl-modalFotos-d Galeria wineandbooks 2474 2475 2476(function (o, $, h, json, openModalGallery) { 2477 if (o && json && json.length) { 2478 function cargarFotos() { 2479 var obj = elem.sec2.obj, 2480 s = (function (long, load) { 2481 if (long <= elem.sec2.max) { 2482 return 500 / (long - 1); 2483 } else if (long - load < 10) { 2484 return 500 / (long - load - 1); 2485 } else { 2486 return 500 / (10 - 1); 2487 } 2488 })(obj.length, elem.sec2.load); 2489 2490 for (var i = 0; i < elem.sec2.max && elem.sec2.load < obj.length; elem.sec2.load++, i++) { 2491 2492 (function (src, _i, _load) { 2493 var $html = elem.sec2.$tpl.clone(), 2494 $btn = $('button', $html); 2495 2496 elem.sec2.$ul.append($html); 2497 2498 $btn.click(function () { 2499 if (openModalGallery) { 2500 openModalGallery({ fotos: obj, act: _load }); 2501 } 2502 }); 2503
2504 h.cargaScrollAuto({ obj: $btn[0], dual: true }, function () { 2505 $btn.css('background-image', "url('" + src + "')"); 2506 }) 2507 2508 $html.delay(_i * s).animate({ opacity: '1' }, 500, function () { 2509 if (_i >= obj.length - 1 || _load >= obj.length - 1 || _i >= elem.sec2.max - 1) { 2510 elem.botonesB = true; 2511 } 2512 }); 2513 elem.sec2.$fotos.push($html); 2514 })(obj[elem.sec2.load], i, elem.sec2.load); 2515 2516 }; 2517 2518 if (obj.length <= elem.sec2.load && elem.sec2.verMasb) { 2519 elem.sec2.$vermas.addClass('sta-hide'); 2520 elem.sec2.verMasb = false; 2521 } else if (obj.length > elem.sec2.load && !elem.sec2.verMasb) { 2522 elem.sec2.$vermas.removeClass('sta-hide'); 2523 elem.sec2.verMasb = true; 2524 } 2525 } 2526 2527 function cargarBoxes() { 2528 for (var i = 0; i < elem.sec1.$lis.length; i++) { 2529 (function ($box, a) { 2530 $box.delay(a * elem.sec1.s).animate({ opacity: '1' }, 500, function () { 2531 if (a >= elem.sec1.$lis.length - 1) { 2532 elem.botonesB = true; 2533 } 2534 }); 2535 })(elem.sec1.$lis[i], i); 2536 } 2537 } 2538 2539 function mostrarGaleria() { 2540 var s = elem.sec1.s; 2541 for (var a = elem.sec1.$lis.length - 1, i = 0; a >= 0; a--, i++) { 2542 (function ($box, n) { 2543 $box.delay(s * n).animate({ opacity: '0' }, 500, function () { 2544 if (n == elem.sec1.$lis.length - 1) { 2545 elem.sec1.$o.hide(); 2546 elem.sec2.$o.show().addClass('sta-active'); 2547 cargarFotos(); 2548 }; 2549 }); 2550 })(elem.sec1.$lis[i], a); 2551 2552 } 2553 }; 2554 2555 function mostrarBoxes() { 2556 var s = 500 / (elem.sec2.load - 1); 2557 elem.sec2.$o.removeClass('sta-active'); 2558 for (var a = elem.sec2.$fotos.length - 1, i = 0; a >= 0; a--, i++) { 2559 (function ($box, n) { 2560 $box.delay(s * n).animate({ opacity: '0' }, 500, function () { 2561 if (n == elem.sec2.$fotos.length - 1) { 2562 elem.sec2.$o.hide(); 2563 elem.sec1.$o.show(); 2564 cargarBoxes(); 2565 }; 2566 }); 2567 })(elem.sec2.$fotos[i], a); 2568 } 2569 } 2570 2571 function ev(box, obj) { 2572 var $box = $(box), 2573 valor = $(box.querySelector('input')).val(); 2574 2575 elem.sec1.$lis.push($box); 2576 2577 h.cargaScrollAuto({ obj: $box[0] }, function () { 2578 $box.css('background-image', "url('" + valor + "')"); 2579 }); 2580 if (box && obj) { 2581 $(box.querySelector('button')).click(function () { 2582 if (elem.botonesB) { 2583 elem.botonesB = false; 2584 elem.sec2.$ul.empty(); 2585 elem.sec2.obj = obj; 2586 elem.sec2.load = 0; 2587 elem.sec2.$fotos = []; 2588 mostrarGaleria(); 2589 } 2590 }); 2591 } else { 2592 console.trace('Error'); 2593 } 2594 }; 2595 json = JSON.parse(JSON.stringify(json)); 2596 var elem = { 2597 botonesB: true, 2598 sec1: { 2599 o: o.querySelector('.sta-galeriaBoxes-eh_1'), 2600 $o: null, 2601 lis: null, 2602 $lis: [], 2603 s: null 2604 }, 2605 sec2: { 2606 max: 12, 2607 load: 0, 2608 obj: null, 2609 $fotos: [], 2610 $vermas: null, 2611 verMasb: false, 2612 $volver: null, 2613 o: o.querySelector('.sta-galeriaBoxes-eh_galeria'), 2614 $o: null, 2615 $ul: null, 2616 $tpl: $('<li></li>', { class: 'sta-galeriaBoxes-eh_foto' }).append($('<button></button>')) 2617 } 2618 }, 2619 dimenSmall = null 2620 dimenBig = null; 2621 2622 elem.sec1.lis = elem.sec1.o.querySelectorAll('.sta-galeriaBoxes-eh_box'); 2623 elem.sec1.$o = $(elem.sec1.o); 2624 elem.sec2.$ul = $(elem.sec2.o.querySelector('.sta-galeriaBoxes-eh_fotos')); 2625 elem.sec2.$o = $(elem.sec2.o); 2626 elem.sec2.$vermas = $(elem.sec2.o.querySelector('.sta-galeriaBoxes-eh_vermas')); 2627 elem.sec2.$volver = $(elem.sec2.o.querySelector('.sta-galeriaBoxes-eh_volver')); 2628 2629 for (var i = 0; i < elem.sec1.lis.length; i++) { 2630 ev(elem.sec1.lis[i], json[i]); 2631 } 2632 2633 elem.sec1.s = 500 / (elem.sec1.$lis.length - 1); 2634 2635 elem.sec2.$vermas.click(function () { 2636 if (elem.botonesB) { 2637 elem.botonesB = false;
2638 cargarFotos(); 2639 } 2640 }); 2641 elem.sec2.$volver.click(function () { 2642 if (elem.botonesB) { 2643 elem.botonesB = false; 2644 mostrarBoxes() 2645 } 2646 }); 2647 } 2648})(document.querySelector('.tpl-galeriaBoxes-eh'), jQuery, hotusa(), window.tplGaleriaBoxesEh, window.openModalFotos); 2649 2650//#region | .tpl-modalFotos-d Galeria wineandbooks 2651(function (o, $) { 2652 if (!o || !$) return false; 2653 2654 var $o = $(o), 2655 o2 = $(':scope > div > article', $o); 2656 2657 if ($('> section > a:not(.sta-modal)', o2).attr('href') != '') { 2658 hotusa().enlace_blank($('> section > a', o2)); 2659 } 2660 if ($('> section > a.sta-modal', o2).attr('href')) { 2661 var str = $('> section > a.sta-modal', o2).attr('href'); 2662 if (str.slice(0, 1) == '#') { 2663 $('> section > a.sta-modal', o2).click(function (e) { 2664 e.preventDefault(); 2665 $(str).click(); 2666 }); 2667 }; 2668 }; 2669})(document.querySelector(".tpl-modalFotos-d"), window.jQuery); 2670//#endregion | .tpl-modalFotos-d Galeria wineandbooks 2671 2672(function (o, $, h) { 2673 if (!o || !$ || !h) return false; 2674 2675 var youtube = $(o.querySelector('div > div > div > .sta-oculto > input[name=youtube]')).val(), 2676 boton = $(o.querySelector('div > div > div > button.sta-BotonVer')), 2677 backBox1 = o.querySelector('.sta-banners-eh_box1'), 2678 backBox2 = o.querySelector('.sta-banners-eh_box2') 2679 2680 if (backBox1 || backBox2) { 2681 var dataBox1 = backBox1.dataset.img, 2682 dataBox2 = backBox2.dataset.img; 2683 backBox1.style.backgroundImage = 'url("' + dataBox1 + '")'; 2684 backBox2.style.backgroundImage = 'url("' + dataBox2 + '")'; 2685 } 2686 2687 if (youtube != '') { 2688 youtubeModal(boton, youtube); 2689 } 2690 2691})(document.querySelector(".tpl-banners-eh"), window.jQuery, window.hotusa && hotusa()); 2692 2693 2694(function (a, h) { 2695 if (!a.length || !h) return false; 2696 2697 var validacion_form = function (_o) { 2698 $('form.sta-validation input', _o).each(function () { 2699 var $o = $(this), 2700 $o_parent = $o.parent(); 2701 if (!$o_parent.hasClass('.sta-noPlaceholder')) { 2702 $o.change(function () { 2703 this.value.trim() ? $o_parent.addClass('sta-validate') : $o_parent.removeClass('sta-validate'); 2704 }); 2705 } 2706 }); 2707 }; 2708 2709 2710 for (var i = 0; i < a.length; i++) { 2711 (function (o) { 2712 var backW = o.querySelector('.sta-form12-eh_back'); 2713 if (backW) { 2714 h.cargaScrollAuto({ obj: o, dual: true }, function () { 2715 var dataBackW = backW.dataset.img; 2716 backW.style.backgroundImage = 'url("' + dataBackW + '")'; 2717 }); 2718 } 2719 validacion_form(o); 2720 })(a[i]); 2721 } 2722})(document.querySelectorAll('.tpl-form12-eh'), window.hotusa && hotusa()); 2723 2724(function (a) { 2725 if (!a.length) return false; 2726 2727 var validacion_form = function (_o) { 2728 $('form.sta-validation input', _o).each(function () { 2729 var $o = $(this), 2730 $o_parent = $o.parent(); 2731 if (!$o_parent.hasClass('.sta-noPlaceholder')) { 2732 $o.change(function () { 2733 this.value.trim() ? $o_parent.addClass('sta-validate') : $o_parent.removeClass('sta-validate'); 2734 }); 2735 } 2736 }); 2737 } 2738 2739 for (var i = 0; i < a.length; i++) { 2740 (function (o) { 2741 validacion_form(o); 2742 })(a[i]); 2743 } 2744})(document.querySelectorAll('.tpl-form13-eh')); 2745 2746 2747 2748// RELACIONADAS 2749function youtubeModal(click, id, param, clase) { 2750 if (!param) { 2751 param = '?autoplay=1&rel=0&controls=0&showinfo=0'; 2752 } 2753 if (!clase) { 2754 clase = 'sta-iframeYoutube'; 2755 } 2756 2757 var html = $('<iframe></iframe>', { 2758 'class': clase, 2759 'type': 'text/html', 2760 'src': 'https://www.youtube.com/embed/' + id + param, 2761 'frameborder': '0', 2762 'allowfullscreen': 'true', 2763 }); 2764 2765 click.bind('click', { param1: html, param2: 'fadein' }, _staOpenModal); 2766} 2767 2768var cargarMapa = (function ($, h) { 2769 var apiCargada = false, 2770 apiCargando = false, 2771 acumulador = [], 2772 iconMarker = {}, 2773 tradu_verHotel = false, 2774 styles = [{ featureType: "landscape", stylers: [{ "visibility": "off" }] }, { featureType: "poi.business", elementType: "labels", stylers: [{ visibility: "off" }] }]; 2775 function cargarApi(c) { 2776 // AIzaSyCdeeh07lKHZO2EHfS7DPURWWy-U9U6SMc
2777 var s1 = "https://maps.googleapis.com/maps/api/js?key=AIzaSyCFjphb_g3Yjn-ommmOkc9FlVDgHcvxY4A&language=" + $('html').attr('lang'); 2778 h.cargarFicheroJS(s1, c); 2779 }; 2780 function c(b) { 2781 if (b.tradu_verHotel) tradu_verHotel = b.tradu_verHotel; 2782 if (!apiCargada && !apiCargando) { 2783 apiCargando = true; 2784 cargarApi(function () { 2785 apiCargada = true; 2786 apiCargando = false; 2787 crearMapa(b); 2788 2789 //recorrer acumulador 2790 for (var i = 0; i < acumulador.length; i++) acumulador[i](); 2791 }); 2792 } else if (apiCargando) { 2793 acumulador.push(function () { crearMapa(b); }); 2794 } else { 2795 crearMapa(b); 2796 }; 2797 }; 2798 function createMarker(color) { 2799 if (typeof color == "undefined") color = "#847648"; 2800 2801 if (!iconMarker[color]) { 2802 var c = document.createElement("canvas"), 2803 b; 2804 c.width = 55; 2805 c.height = 60; 2806 2807 var ejeX = 27, 2808 ejeY = 27, 2809 ejeY2 = 22; 2810 2811 b = c.getContext("2d"); 2812 2813 b.beginPath(); 2814 b.arc(ejeX, ejeY, 17, 8.2, Math.PI * 2.4); // CÃrculo externo 2815 b.lineTo(ejeX, ejeY + ejeY2 + 4); 2816 b.closePath(); 2817 b.fillStyle = "#fff"; 2818 2819 b.shadowBlur = 12; 2820 b.shadowColor = "#000"; 2821 b.fill(); 2822 b.shadowBlur = 0; 2823 2824 b.beginPath(); 2825 b.arc(ejeX, ejeY, 15, 8.2, Math.PI * 2.4); // CÃrculo externo 2826 b.lineTo(ejeX, ejeY + ejeY2); 2827 b.closePath(); 2828 b.fillStyle = color; 2829 b.fill(); 2830 2831 b.beginPath(); 2832 b.arc(ejeX, ejeY, 6, 8.2, Math.PI * 2.5); 2833 b.fillStyle = "#fff"; 2834 b.fill(); 2835 2836 iconMarker[color] = c.toDataURL(); 2837 }; 2838 2839 return iconMarker[color]; 2840 } 2841 function latRad(lat) { 2842 var sin = Math.sin(lat * Math.PI / 180); 2843 var radX2 = Math.log((1 + sin) / (1 - sin)) / 2; 2844 return Math.max(Math.min(radX2, Math.PI), -Math.PI) / 2; 2845 } 2846 function calcularCentroZoom(array, elem) { 2847 if (array.length == 1) { 2848 return { c: new google.maps.LatLng(array[0].lat, array[0].long), z: 14 }; 2849 } else { 2850 var WORLD_DIM = { height: 256, width: 256 }, 2851 ZOOM_MAX = 21, 2852 bounds = new google.maps.LatLngBounds(); 2853 2854 for (var i = 0; i < array.length; i++) { 2855 bounds.extend( 2856 new google.maps.Marker( 2857 { position: new google.maps.LatLng(array[i].lat, array[i].long) } 2858 ).getPosition() 2859 ); 2860 }; 2861 2862 var ne = bounds.getNorthEast(),
2863 sw = bounds.getSouthWest(), 2864 latFraction = (latRad(ne.lat()) - latRad(sw.lat())) / Math.PI, 2865 lngDiff = ne.lng() - sw.lng(), 2866 lngFraction = ((lngDiff < 0) ? (lngDiff + 360) : lngDiff) / 360, 2867 latZoom = Math.floor(Math.log(($(elem).height() - 200) / WORLD_DIM.height / latFraction) / Math.LN2), 2868 lngZoom = Math.floor(Math.log(($(elem).width() - 200) / WORLD_DIM.width / lngFraction) / Math.LN2); 2869 2870 return { c: bounds.getCenter(), z: Math.min(latZoom, lngZoom, ZOOM_MAX) }; 2871 }; 2872 }; 2873 function insertMarker(m, json, arrayMarkers, openMarkers) { 2874 var colorMarker = "#847648"; 2875 if (window.dataSeo && dataSeo.hotel && dataSeo.hotel.marca) { 2876 switch (dataSeo.hotel.marca) { 2877 case "crisol": 2878 colorMarker = "#1C3155"; 2879 break; 2880 case "ikonikhotels": 2881 colorMarker = "#1F1F1F"; 2882 break; 2883 case "exehotels": 2884 colorMarker = "#8E1414"; 2885 break; 2886 2887 case "eurostarshotels": 2888 default: 2889 colorMarker = "#132A3B"; 2890 break; 2891 }; 2892 }; 2893 let nombre = json.nombre; 2894 if(window.location.pathname.includes('hotels-in-united-states-of-america')){ 2895 nombre = nombre.replace(/\s*\d+\*$/, ''); 2896 } 2897 //especificamos posicion del marker 2898 var marker = new google.maps.Marker({ 2899 position: { lat: json.lat, lng: json.long }, 2900 map: m, 2901 title: nombre, //title al hacer hover 2902 icon: createMarker(colorMarker) 2903 }); 2904 //metemos html en modal de maps 2905 var infoWindow = new google.maps.InfoWindow({ 2906 //obtenemos html // Añadimos info 2907 content: "<div class='tpl-infoWindow-eh'><figure><div class='sta-imagenMapa' style='background-image:url(" + json.imagen + ");'></div></figure><div><div class='sta-infoMapa'><div class='sta-nombreHotel'>" + nombre + "</div><div class='sta-direccionHotel'>" + json.direccion + "</div></div><a href='" + json.url + "' class='sta-enlaceHotel'>" + (tradu_verHotel ? tradu_verHotel : 'See Hotel') + "</a></div></div></div>" 2908 }); 2909 2910 arrayMarkers.push(infoWindow); 2911 2912 if (openMarkers) { 2913 //click sobre marker 2914 marker.addListener('click', function () { 2915 for (var i = 0; i < arrayMarkers.length; i++) arrayMarkers[i].close(); 2916 2917 infoWindow.open(this.map, marker); 2918 }); 2919 2920 //hover sobre icono 2921 marker.addListener('mouseover', function () { 2922 marker.setIcon(createMarker('#000')); 2923 }); 2924 marker.addListener('mouseout', function () { 2925 marker.setIcon(createMarker(colorMarker)); 2926 }); 2927 }; 2928 2929 } 2930 function crearMapa(opt) { 2931 if (opt.cont && opt.markers.length) { 2932 var zoomCentroMap = calcularCentroZoom(opt.markers, opt.cont), 2933 dOpt = { 2934 panControl: false, 2935 gestureHandling: 'cooperative', 2936 zoomControl: false, 2937 mapTypeControl: false, 2938 scaleControl: false, 2939 streetViewControl: false, 2940 overviewMapControl: false, 2941 overviewMapControl: false, 2942 disableDefaultUI: true, 2943 clickableIcons: false, 2944 zoom: zoomCentroMap.z, 2945 openMarkers: true 2946 }; 2947 //_.merge(dOpt, opt); 2948 Object.assign(dOpt, opt); 2949 var map_options = { 2950 zoom: dOpt.zoom, 2951 center: zoomCentroMap.c, 2952 panControl: dOpt.panControl, 2953 zoomControl: dOpt.zoomControl, 2954 mapTypeControl: dOpt.mapTypeControl, 2955 scaleControl: dOpt.scaleControl, 2956 streetViewControl: dOpt.streetViewControl, 2957 overviewMapControl: dOpt.overviewMapControl, 2958 scrollwheel: dOpt.scrollwheel, 2959 disableDefaultUI: dOpt.disableDefaultUI, 2960 clickableIcons: dOpt.clickableIcons, 2961 mapTypeControlOptions: { 2962 mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'map_style'] 2963 }, 2964 zoomControlOptions: { 2965 position: google.maps.ControlPosition.LEFT_TOP 2966 }, 2967 }, 2968 markersCreados = [], 2969 map = new google.maps.Map(dOpt.cont, map_options), 2970 styled_map = new google.maps.StyledMapType(styles, { name: "Styled Map" }); 2971 2972 map.mapTypes.set('map_style', styled_map); 2973 map.setMapTypeId('map_style'); 2974 2975 for (var i = 0; i < dOpt.markers.length; i++) { 2976 insertMarker(map, dOpt.markers[i], markersCreados, dOpt.openMarkers); 2977 }; 2978 }; 2979 }; 2980 2981 setTimeout(() => { 2982 window.dispatchEvent(new Event('loadMaps')); 2983 }, 5); 2984 2985 return c; 2986})(jQuery, hotusa()); 2987 2988// function slidesOpacityJson(json) { 2989// function cargarOtraMenos() { 2990// n = n - 1 < 0 ? json.sectionImg.length - 1 : n - 1; 2991// appendDiv(); 2992// }; 2993// function cargarOtra() { 2994// n = n + 1 > json.sectionImg.length - 1 ? 0 : n + 1; 2995// appendDiv(); 2996// }; 2997// function autoSlide() { 2998// auto = setTimeout(cargarOtra, 5e3); 2999// }; 3000// function appendDiv() { 3001// var img = new Image(), 3002// d = $('<div></div>'); 3003// img.src = json.sectionImg[n].src; 3004// img.onload = function () { 3005// $('> div:not(.' + json.clase + ')', json.padre).remove(); 3006// json.padre.append(d.css("background-image", "url('" + this.src + "')")); 3007// setTimeout(function () { 3008// $('> .' + json.clase, json.padre).removeClass(json.clase); 3009// d.addClass(json.clase); 3010// cntrlBoton = true; 3011// }, 30); 3012// if (json.auto) autoSlide(); 3013// }; 3014// img.onerror = function () { 3015// json.sectionImg.splice(n, 1); 3016// json.sectionText.splice(n, 1); 3017// appendDiv(); 3018// }; 3019 3020// if (json.html !== '') { 3021// var h = json.html.clone(); 3022// if (typeof json.sectionText[n] != 'undefined') { 3023// for (var a in json.sectionText[n]) { 3024// $(a, h).html(json.sectionText[n][a]); 3025// }; 3026// d.append(h); 3027// }; 3028// }; 3029// }; 3030// var dJson = { 3031// padre: '', 3032// html: '',//html interno 3033// auto: true, 3034// sectionImg: [ 3035// { 3036// src: '' 3037// } 3038// ], 3039// sectionText: [], //texto interno 3040// dedo: !$('html').hasClass('sf5'),
3041// dedoCuerpo: null, 3042// bLeft: undefined, 3043// bRight: undefined, 3044// bClase: 'mostrar_flechas', 3045// clase: 'mostrar_slide', 3046// }, 3047// n = 0, 3048// auto, 3049// cntrlBoton = true; 3050// json = hotusa().controlDefecto(dJson, json); 3051 3052// if (mobile || json.sectionImg.length == 1) json.auto = false; 3053// appendDiv(); 3054 3055// if (json.dedo && json.sectionImg.length > 1) { 3056// if (json.dedoCuerpo == null) json.dedoCuerpo = json.padre; 3057// json.dedoCuerpo.on('swipeleft', function () { 3058// if (cntrlBoton) { 3059// clearTimeout(auto); 3060// cntrlBoton = false; 3061// cargarOtra(); 3062// }; 3063// }); 3064// json.dedoCuerpo.on('swiperight', function () { 3065// if (cntrlBoton) { 3066// clearTimeout(auto); 3067// cntrlBoton = false; 3068// cargarOtraMenos(); 3069// }; 3070// }); 3071// }; 3072// if (typeof json.bLeft !== "undefined" && json.sectionImg.length > 1) { 3073// json.bLeft.parent().addClass(json.bClase); 3074// json.bLeft.click(function () { 3075// if (cntrlBoton) { 3076// clearTimeout(auto); 3077// cntrlBoton = false; 3078// cargarOtra(); 3079// }; 3080// }); 3081// json.bRight.click(function () { 3082// if (cntrlBoton) { 3083// clearTimeout(auto); 3084// cntrlBoton = false; 3085// cargarOtraMenos(); 3086// }; 3087// }); 3088// }; 3089// }; 3090 3091//Cerrar modales 3092(function (o, $, h) { 3093 if (o) { 3094 $('.modalCerrar', o).click(function () { 3095 $(this).parent().fadeOut(function () { 3096 if (modal_ruta != '') { 3097 $(modal_ruta).append($('#sta-modal .sta-content > div')); 3098 } else { 3099 $('#sta-modal .sta-content').html(''); 3100 } 3101 modal_ruta = ''; 3102 }); 3103 $('body').removeClass('sta-noScroll'); 3104 }) 3105 }; 3106})(document.querySelector('#sta-modal'), jQuery, hotusa()); 3107 3108(function (o, $, h) { 3109 if (o) { 3110 $(o).each(function () { 3111 var o = $(this), 3112 elementoMovil = $('> article > section > div > article', o), 3113 contenedor = $('> article > section > div', o), 3114 display; 3115 3116 if (!$('> article > header > ul > li', o).length) { 3117 $('> header > button', elementoMovil).each(function () { 3118 3119 var nodo = $(this).clone(); 3120 $('<li>').appendTo('.tpl-info4-eh > article > header > ul'); 3121 nodo.appendTo('.tpl-info4-eh > article > header > ul > li:last-of-type'); 3122 }); 3123 3124 } 3125 3126 $('> article:eq(0)', contenedor).addClass('sta-visible'); 3127 $('> article > header > ul > li:eq(0)', o).addClass('sta-visible'); 3128 if ($(document).width() > 601) { 3129 var back = contenedor[0].querySelector('article section div') 3130 back.style.backgroundImage = 'url("' + back.dataset.img + '")'; 3131 back.dataset.img = ''; 3132 } 3133 acordeon(); 3134 listado(); 3135 3136 3137 $(window).resize(function () { 3138 $('> article > header > ul > li', o).unbind(); 3139 if ($(document).width() < 601) { 3140 3141 $('> article > section > div > article > header > button', o).each(function () { 3142 if ($(this).data('tocado')) { 3143 $('> header > button', elementoMovil).not($(this)).removeClass('sta-abierto'); 3144 $(this).addClass('sta-abierto'); 3145 propio = $(this).parent().next('section'); 3146 $('> section:visible', elementoMovil).not(propio).slideUp(); 3147 $(this).parent().next('section').slideDown(); 3148 } 3149 3150 }); 3151 } else { 3152 $('> section', elementoMovil).removeAttr('style'); 3153 elementoMovil.removeAttr('style'); 3154 } 3155 3156 3157 var pasar = $('article.sta-visible').index(); 3158 contenedor.scrollLeft(pasar * $('article.sta-visible').outerWidth(true)); 3159 3160 3161 listado(); 3162 }); 3163 3164 function listado() { 3165 3166 $('> article > header > ul > li', o).on('click', function () { 3167 3168 $('> header > button', elementoMovil).removeData(); 3169 $('> article > section > div > article > header > button:eq(' + $(this).index() + ')', o).data('tocado', true); 3170 3171 if ($(document).width() < 801) { 3172 slide($(this).index() + 1) 3173 } else { 3174 fadeInOut($(this).index() + 1) 3175 } 3176 3177 }); 3178 } 3179 3180 function acordeon() { 3181 $('> header > button', elementoMovil).click(function () { 3182 3183 $('> header > button', elementoMovil).removeData(); 3184 $(this).data('tocado', true); 3185 3186 $('> header > button', elementoMovil).not($(this)).removeClass('sta-abierto'); 3187 $(this).toggleClass('sta-abierto'); 3188 propio = $(this).parent().next('section'); 3189 $('> section:visible', elementoMovil).not(propio).slideUp(); 3190 $(this).parent().next('section').slideToggle(function () { 3191 var back = this.querySelector('div'); 3192 if (!back.dataset.img) return false;
3193 back.style.backgroundImage = 'url("' + back.dataset.img + '")'; 3194 back.dataset.img = ''; 3195 }); 3196 3197 3198 3199 altura = $('> section:visible', elementoMovil).height(); 3200 header = $('.tpl-header3-eh > div').outerHeight(); 3201 3202 if (altura < 50) { 3203 ha = $(this).offset().top - header - altura; 3204 } else { 3205 ha = $(this).parent().parent().parent().parent().offset().top - header; 3206 } 3207 3208 $('body,html').animate({ scrollTop: ha }, 500); 3209 3210 $('> article > header > ul > li:eq(' + $(this).parent().parent().index() + ')', o).click(); 3211 3212 }); 3213 } 3214 3215 function slide(posi) { 3216 3217 for (var i = 0; i < $('> article > header > ul > li', o).length; i++) { 3218 if ($('> article > section > div > article:nth-of-type(' + (i + 1) + ')', o).hasClass('sta-visible')) { 3219 display = i + 1; 3220 break; 3221 } 3222 } 3223 3224 //Boton seleccionado 3225 $('> article > header > ul > li', o).removeClass('sta-visible'); 3226 $('> article > header > ul > li:nth-of-type(' + posi + ')', o).addClass('sta-visible'); 3227 3228 //Movimiento del slide 3229 if (display < posi) { 3230 $('> article:nth-of-type(' + posi + ')', contenedor).addClass('sta-visible'); 3231 contenedor.animate({ 'scrollLeft': ((posi - 1) * $('article.sta-visible').outerWidth(true)) }, 800, function () { 3232 $('> article:not(:nth-of-type(' + posi + '))', contenedor).removeClass('sta-visible'); 3233 }) 3234 } else { 3235 $('> article:nth-of-type(' + posi + ')', contenedor).addClass('sta-visible'); 3236 contenedor.scrollLeft((posi) * $('article.sta-visible').outerWidth(true)); 3237 contenedor.animate({ 'scrollLeft': ((posi - 1) * $('article.sta-visible').outerWidth(true)) }, 800, function () { 3238 $('> article:not(:nth-of-type(' + posi + '))', contenedor).removeClass('sta-visible'); 3239 }) 3240 } 3241 3242 3243 } 3244 function fadeInOut(posi) { 3245 3246 //Boton seleccionado 3247 $('> article > header > ul > li', o).removeClass('sta-visible'); 3248 $('> article > header > ul > li:nth-of-type(' + posi + ')', o).addClass('sta-visible'); 3249 3250 //Mostrar el elemento 3251 $('> article:not(:nth-of-type(' + posi + '))', contenedor).fadeOut(500).removeClass('sta-visible'); 3252 $('> article:nth-of-type(' + posi + ')', contenedor).fadeIn(500, function () { 3253 3254 var back = this.querySelector('section div'); 3255 if (!back.dataset.img) return false; 3256 back.style.backgroundImage = 'url("' + back.dataset.img + '")'; 3257 back.dataset.img = ''; 3258 }).addClass('sta-visible'); 3259 3260 } 3261 3262 }); 3263 } 3264})(document.querySelector(".tpl-info4-eh"), window.jQuery, window.hotusa && hotusa()); 3265 3266 3267 3268(function (a, $) { 3269 if (a.length) { 3270 for (var i = 0; i < a.length; i++) { 3271 (function (o) { 3272 var $c = $(o.querySelector(".sta-tool_cont")); 3273 3274 $(o).click(function () { 3275 $c.toggleClass('sta-show'); 3276 }); 3277 })(a[i]); 3278 } 3279 }; 3280})(document.querySelectorAll('.sta-tooltip'), jQuery); 3281 3282 3283(function (o, $, h) { 3284 if (!o || !$ || !h) return false; 3285 3286 var articles = o.querySelectorAll('div > article'); 3287 3288 for (var i = 0; i < articles.length; i++) { 3289 (function (art) { 3290 var href = $('section > a.sta-modal', art).attr('href'), 3291 dataBackDiv = art.querySelector('.sta-boxes8-eh_back'), 3292 dataBackH = dataBackDiv.dataset.img, 3293 img = new Image(); 3294 img.src = dataBackH; 3295 3296 img.onload = function () { 3297 dataBackDiv.classList.add('sta-load'); 3298 dataBackDiv.style.backgroundImage = 'url("' + dataBackH + '")'; 3299 } 3300 3301 img.onerror = function (e) { 3302 console.trace('ERROR: Not load image', e) 3303 } 3304 3305 if (dataBackDiv) { 3306 h.cargaScrollAuto({ obj: art, dual: true }, function () { 3307 img.src = dataBackH; 3308 }); 3309 } 3310 if ($('section > a:not(.sta-modal)', art).attr('href') != '') h.enlace_blank($('> section > a', art)); 3311 3312 if (href && href.slice(0, 1) == '#') { 3313 $('section > a.sta-modal', art).click(function (e) { 3314 e.preventDefault(); 3315 $(href).click(); 3316 }); 3317 } 3318 3319 })(articles[i]); 3320 } 3321})(document.querySelector('.tpl-boxes8-eh'), window.jQuery, window.hotusa && hotusa()); 3322 3323(function (o, $) { 3324 if (o) { 3325 var idiomas = { o: o.querySelector(".sta-topHeader-eh_lang"), remove: 0 }, 3326 telef = o.querySelector(".sta-topHeader-eh_tlfn"), 3327 check2 = telef.querySelector("input"), 3328 login = o.querySelector('.sta-topHeader-eh_login'), 3329 _b1 = !!0, 3330 _b2 = !!0; 3331 3332 idiomas.check = idiomas.o.querySelector(" input"); 3333 idiomas.lis = idiomas.o.querySelectorAll('ul li'); 3334 3335 if (!$(telef.querySelector('ul li:nth-of-type(2)')).data('display').trim()) $(telef).addClass('onlyOne'); 3336 3337 3338 $(check2).change(function () { 3339 _b2 = this.checked; 3340 }); 3341 3342 $(document).click(function () { 3343 if (_b1) idiomas.check.click(); 3344 if (_b2) check2.click(); 3345 }); 3346 3347 $(o).click(function (e) { 3348 e.stopPropagation(); 3349 }); 3350 3351 // if( modalReservas ) $(o.querySelector('.sta-reservButton')).click(modalReservas); 3352 3353 if (login && modalLogin) $(login.querySelector('.sta-topHeader-eh_login_button')).click(modalLogin); 3354 3355 for (var i = 0; i < idiomas.lis.length; i++) { 3356 (function ($li) { 3357 var url = $('a', $li).attr('href'); 3358 if (url) { 3359 var _arr = url.split('/'); 3360 _arr.splice(0, 3); 3361 if (_arr.join('/') == 'index.php') { 3362 $li.remove(); 3363 idiomas.remove++; 3364 }; 3365 } else { 3366 $li.remove(); 3367 idiomas.remove++; 3368 }; 3369 })($(idiomas.lis[i])); 3370 }; 3371 if (idiomas.lis.length == idiomas.remove) { 3372 $(idiomas.o).addClass('sta-notIdiomas'); 3373 } else { 3374 $(idiomas.check).change(function () { 3375 _b1 = this.checked; 3376 }); 3377 }; 3378 3379 $(window) 3380 .resize(function () { 3381 if (_b1) idiomas.check.click(); 3382 if (_b2) check2.click(); 3383 }) 3384 .scroll(function () { 3385 if (_b1) idiomas.check.click(); 3386 if (_b2) check2.click(); 3387 }); 3388 3389 }; 3390})(document.querySelector('.tpl-topHeader-eh'), jQuery); 3391 3392 3393 3394(function (a, json, $, h) { 3395 if (!a.length || !$ || !h) return false;
3396 3397 (function (elems) { 3398 if (!elems.length || !json || !json.countHotels || !json.countCountries) return false; 3399 3400 for (var i = 0; i < elems.length; i++) { 3401 $('.countHotels', elems[i]).text(json.countHotels); 3402 $('.countCountries', elems[i]).text(json.countCountries); 3403 } 3404 })(document.querySelectorAll('.tpl-boxes15-eh .fn-contarHoteles')); 3405 var ev = function (o) { 3406 var imgs = o.querySelectorAll('header[data-img]') 3407 for (var i = 0; i < imgs.length; i++) { 3408 (function ($header) { 3409 var img = $header.data('img') 3410 h.cargaScrollAuto({ obj: $header[0] }, function () { 3411 $header.css('background-image', "url('" + img + "')"); 3412 }); 3413 })($(imgs[i])); 3414 } 3415 } 3416 for (var i = 0; i < a.length; i++) ev(a[i]); 3417 3418})(document.querySelectorAll('.tpl-boxes15-eh'), window.json_boxes15, window.jQuery, window.hotusa && hotusa()); 3419 3420(function (o, $, h) { 3421 if (!o || !$ || !h) return false; 3422 3423 var cargaImg = function () { 3424 var $bck = $(o.querySelector('.sta-error404-eh_imgContainer')), 3425 src = $bck.data('lazy'); 3426 if (src) { 3427 $bck 3428 .css('background-image', "url('" + src + "')") 3429 .data('lazy', ''); 3430 } 3431 } 3432 3433 h.cargaScrollAuto({ obj: o }, cargaImg); 3434 3435})(document.querySelector('.tpl-error404-eh'), window.jQuery, window.hotusa && hotusa()); 3436 3437 3438//favicon darkmode 3439(function (favicons) { 3440 if (!favicons.length) return false; 3441 3442 for (var i = 0; i < favicons.length; i++) { 3443 (function (favicon) { 3444 var linkDefault = favicon.href, 3445 linkDark = favicon.dataset.dark, 3446 matcher = window.matchMedia('(prefers-color-scheme:dark)'), 3447 changeDark = function () { 3448 favicon.href = (matcher.matches) ? linkDark : linkDefault 3449 }; 3450 3451 matcher.addListener(changeDark); 3452 changeDark(); 3453 })(favicons[i]); 3454 }; 3455 3456})(document.head.querySelectorAll('.changeFaviconDark')); 3457 3458//viewport in safary 3459(function (meta) { 3460 if (!meta || !/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) return false 3461 3462 var contentOld = meta.content; 3463 meta.content = meta.attributes.saf.value; 3464 3465})(document.head.querySelector('.metaViewport')); 3466 3467/* .tpl-startraveler_header2-eh */ 3468(function (o) { 3469 if (!o) return false; 3470 o.querySelector(".sta-st_btnRegister").addEventListener("click", function () { 3471 const registerForm = document.getElementById("loyalty-register"); 3472 if (registerForm) 3473 window.scrollTo({ top: registerForm.offsetTop, behavior: "smooth" }); 3474 }); 3475 o.querySelector(".sta-st_btnLogin").addEventListener("click", function () { 3476 document.dispatchEvent( 3477 new CustomEvent("toggleLogin", { 3478 detail: { alias: "cms-login", open: true }, 3479 }) 3480 ); 3481 }); 3482})(document.querySelector(".tpl-startraveler_header2-eh")); 3483 3484/* .tpl-nav-st_header *//* .tpl-nav-st_header */ 3485(function (o, h) { 3486 if (!o || !h) return false; 3487 o.querySelector(".fn-register").addEventListener("click", function () { 3488 const registerForm = document.getElementById("loyalty-register"); 3489 if (registerForm) 3490 window.scrollTo({ top: registerForm.offsetTop, behavior: "smooth" }); 3491 }); 3492 o.querySelector(".fn-login").addEventListener("click", function () { 3493 document.dispatchEvent( 3494 new CustomEvent("toggleLogin", { 3495 detail: { alias: "cms-login", open: true }, 3496 }) 3497 ); 3498 }); 3499})(document.querySelector(".tpl-nav-st_header"), window.hotusa && hotusa()); 3500/* end .tpl-nav-st_header */ 3501 3502/* hide/show star traveler info */ 3503var hideshowStInfo = (function (h) { 3504 const bannerStarTravelerBtns = document.querySelectorAll('.sta-textStarTravBanner-eh_btn'), 3505 starTravelerHeader = document.querySelector('.tpl-startraveler_header2-eh'), 3506 pathname = window.location.pathname, 3507 isStarTraveler = /^(\/[a-z]{2})?\/startraveler\/?$/i.test(pathname), 3508 loyaltyUser = JSON.parse(localStorage.getItem("login_user")) || JSON.parse(sessionStorage.getItem("login_user")) || null; 3509 guidoBtn = document.querySelector('.fn-guidoBtn'); 3510 var urlParams = null; 3511 document.addEventListener('setSessionLoyalty', () => { 3512 /* hide buttons in star traveler banner */ 3513 if (bannerStarTravelerBtns) { 3514 bannerStarTravelerBtns.forEach(function (item) { 3515 item.style.visibility = 'hidden'; 3516 }); 3517 } 3518 /* hide star traveler header */ 3519 if (starTravelerHeader) { 3520 starTravelerHeader.classList.add('sta-hide'); 3521 guidoBtn?.classList.add('sta-hide'); 3522 } 3523 }); 3524 document.addEventListener('destroySession', () => { 3525 /* show buttons in star traveler banner */ 3526 if (bannerStarTravelerBtns) { 3527 bannerStarTravelerBtns.forEach(function (item) { 3528 /* item.style.visibility = 'hidden' */ 3529 item.removeAttribute('style'); 3530 }); 3531 } 3532 /* show star traveler header */ 3533 if (starTravelerHeader) { 3534 starTravelerHeader.classList.remove('sta-hide'); 3535 guidoBtn?.classList.remove('sta-hide'); 3536 } 3537 }); 3538 if (isStarTraveler) {
3539 urlParams = new URLSearchParams(window.location.search) 3540 } 3541 /* if exist star traveler session */ 3542 if (loyaltyUser || (urlParams && urlParams.get('user_id'))) { 3543 /* hide buttons in star traveler banner */ 3544 if (bannerStarTravelerBtns) { 3545 bannerStarTravelerBtns.forEach(function (item) { 3546 item.style.visibility = 'hidden' 3547 }); 3548 } 3549 /* hide star traveler header */ 3550 if (starTravelerHeader) { 3551 starTravelerHeader.classList.add('sta-hide'); 3552 guidoBtn?.classList.add('sta-hide'); 3553 } 3554 } else { 3555 /* show buttons in star traveler banner */ 3556 if (bannerStarTravelerBtns) { 3557 bannerStarTravelerBtns.forEach(function (item) { 3558 item.removeAttribute('style') 3559 }); 3560 } 3561 /* show star traveler header */ 3562 if (starTravelerHeader) { 3563 starTravelerHeader.classList.remove('sta-hide'); 3564 guidoBtn?.classList.remove('sta-hide'); 3565 } 3566 } 3567})(window.hotusa && hotusa()); 3568/* end hide/show star traveler info */ 3569 3570/* end .tpl-startraveler_header-eh */ 3571 3572/* manejo tooltips businesspro */ 3573(function (list) { 3574 if (!list) return false; 3575 const tooltips = list.querySelectorAll('.sta-dto-tooltip_text'); 3576 const lis = list.querySelectorAll('.li-icon .sta-dto-tooltip'); 3577 const mediaQuery = window.matchMedia('(min-width: 601px)'); 3578 const mediaQueryDesk = window.matchMedia('(min-width: 1101px)'); 3579 3580 function handleMediaQueryDesk(event) { 3581 tooltips.forEach((item) => { 3582 if (event.matches) { 3583 item.style.left = '50%'; 3584 } else if (!event.matches) { 3585 tooltipPosition(mediaQuery); 3586 } 3587 }); 3588 } 3589 3590 function tooltipPosition(event) { 3591 tooltips.forEach((item) => { 3592 const tooltipRect = item.getBoundingClientRect(); 3593 if (event.matches && (tooltipRect.width >= 220) && mediaQuery) { 3594 item.style.left = '-40px'; 3595 } else if (tooltipRect.right > window.right) { 3596 item.style.left = '50%'; 3597 } 3598 }); 3599 } 3600 3601 function toggleLi(event) { 3602 if (!event.matches) { 3603 lis.forEach((item) => { 3604 item.addEventListener('click', handleClick); 3605 }); 3606 } else { 3607 lis.forEach((item) => { 3608 item.classList.remove('hidden'); 3609 item.removeEventListener('click', handleClick); 3610 }); 3611 } 3612 } 3613 3614 let next = null; 3615 function handleClick(event) { 3616 const currentEvent = event.currentTarget; 3617 if (currentEvent.classList.contains('hidden')) { 3618 currentEvent.classList.remove('hidden'); 3619 } else { 3620 lis.forEach((item) => { 3621 item.classList.remove('hidden'); 3622 }); 3623 currentEvent.classList.add('hidden'); 3624 } 3625 next = currentEvent; 3626 }; 3627 3628 function clickOutEvent(event) { 3629 lis.forEach((item) => { 3630 item.classList.remove('hidden'); 3631 }); 3632 } 3633 3634 function handleScroll(event) { 3635 if (next && window.scrollY > 0) { 3636 next.classList.remove('hidden'); 3637 next = null; 3638 } 3639 } 3640 3641 function handleMediaQuery(event) { 3642 tooltipPosition(event); 3643 toggleLi(event); 3644 } 3645 document.addEventListener('click', function (event) { 3646 if (!next.contains(event.target)) { 3647 clickOutEvent(event); 3648 }; 3649 }); 3650 window.addEventListener('scroll', handleScroll); 3651 window.addEventListener('resize', tooltipPosition); 3652 mediaQuery.addEventListener('change', handleMediaQuery); 3653 mediaQueryDesk.addEventListener('change', handleMediaQueryDesk); 3654 toggleLi(mediaQuery); 3655 tooltipPosition(mediaQuery); 3656 handleMediaQueryDesk(mediaQueryDesk); 3657})(document.querySelector('.tpl-list3-eh')); 3658 3659 3660 3661(function () { 3662 function getHeadingTextWithoutScript(heading) { 3663 if (!heading) return ""; 3664 3665 // Clona el nodo para no modificar el DOM original 3666 const clone = heading.cloneNode(true); 3667 3668 // Elimina todos los scripts dentro del encabezado 3669 clone.querySelectorAll("script").forEach(script => script.remove()); 3670 3671 return clone.textContent.replace(/\s+/g, ' ').trim(); 3672 } 3673 3674 function generateAltText(img) { 3675 const domain = window.location.origin; 3676 const imgSrc = img.getAttribute("src") || img.getAttribute("data-src") || ""; 3677 if (!imgSrc) return ""; 3678 3679 // Buscar el encabezado más cercano en la jerarquÃa de ancestros
3680 let currentElement = img.closest("section, article, div") || document.body; 3681 let heading = null; 3682 3683 while (currentElement && !heading) { 3684 heading = currentElement.querySelector("h1, h2, h3"); 3685 currentElement = currentElement.parentElement; 3686 } 3687 3688 let hText = heading 3689 ? getHeadingTextWithoutScript(heading) 3690 : document.querySelector("h1") 3691 ? getHeadingTextWithoutScript(document.querySelector("h1")) 3692 : ""; 3693 3694 let urlPath = window.location.pathname.split("/").filter(Boolean); 3695 let firstSection = urlPath.length > 0 3696 ? urlPath[0].replace(/-/g, " ").replace(/\.html$/, "") 3697 : ""; 3698 let lastSection = urlPath.length > 1 3699 ? urlPath[urlPath.length - 1].replace(/-/g, " ").replace(/\.html$/, "") 3700 : ""; 3701 3702 let fileName = imgSrc.split("/").pop() 3703 .split("?")[0] 3704 .split("#")[0] 3705 .replace(/-/g, " ") 3706 .replace(/\.html$/, "") 3707 .replace(/\.[^/.]+$/, ""); 3708 3709 if (firstSection && (firstSection === lastSection || firstSection === fileName)) { 3710 firstSection = ""; 3711 } 3712 3713 return [hText, firstSection, fileName] 3714 .filter(part => part.trim()) 3715 .join(", ") 3716 .replace(/"/g, ""); 3717 } 3718 3719 function processImage(img) { 3720 const altText = generateAltText(img); 3721 if (altText) img.setAttribute("alt", altText); 3722 } 3723 3724 document.addEventListener("DOMContentLoaded", function () { 3725 document.querySelectorAll("img").forEach(processImage); 3726 3727 const observer = new MutationObserver(mutations => { 3728 mutations.forEach(mutation => { 3729 mutation.addedNodes.forEach(node => { 3730 if (node.nodeName === 'IMG') processImage(node); 3731 3732 if (node instanceof Element) { 3733 node.querySelectorAll('img').forEach(processImage); 3734 } 3735 }); 3736 }); 3737 }); 3738 3739 observer.observe(document.body, { 3740 childList: true, 3741 subtree: true 3742 }); 3743 }); 3744})(); 3745// Eliminar atributos target vacÃos 3746window.addEventListener('DOMContentLoaded', () => { 3747 const elementosConTarget = document.querySelectorAll('[target]'); 3748 elementosConTarget.forEach(el => { 3749 if (el.getAttribute('target').trim() === '') { 3750 el.removeAttribute('target'); 3751 } 3752 }); 3753}); 3754 3755 3756(function () { 3757 var forms = document.querySelectorAll('form'); 3758 for (var i = 0; i < forms.length; i++) { 3759 (function (form) { 3760 var formAction = form.getAttribute('action'); 3761 if (formAction === '' || formAction === window.location.href) { 3762 form.removeAttribute('action'); 3763 } 3764 })(forms[i]); 3765 } 3766})(); 3767 3768// PopLogin 3769(function(popup){ 3770 if (!popup) return; 3771 3772 // Solo mostrar si no se ha mostrado en esta sesión 3773 if (sessionStorage.getItem('popupMostrado')) return; 3774 3775 const popupBox = popup.querySelector('.sta-popLogin-eh_popup'); 3776 const closeBtn = popup.querySelector('.sta-popLogin-eh_close'); 3777 const loginBtn = popup.querySelector('.sta-popLogin-eh_btn'); 3778 const header = document.querySelector('.tpl-header2-eh'); 3779 const motor = document.querySelector('#default_sygy_element_engine'); 3780 3781 //Refuerzo accesibilidad 3782 var isVisible = false, 3783 previousFocusedElement = null, 3784 focusableSelector = 'button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]):not([tabindex="-1"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])', 3785 getFocusableElements = function() { 3786 return Array.prototype.slice.call(popupBox.querySelectorAll(focusableSelector)) 3787 .filter(function(el) { return el.offsetParent !== null; }); 3788 }, 3789 focusDialog = function() { 3790 if (document.activeElement && !popup.contains(document.activeElement)) { 3791 previousFocusedElement = document.activeElement; 3792 } 3793 popupBox.focus(); 3794 }, 3795 restoreFocus = function() { 3796 if (previousFocusedElement && typeof previousFocusedElement.focus === 'function') { 3797 previousFocusedElement.focus(); 3798 } 3799 previousFocusedElement = null; 3800 }, 3801 trapFocus = function(e) { 3802 if (e.key !== 'Tab' || !isVisible) return; 3803 var focusable = getFocusableElements(); 3804 if (!focusable.length) { e.preventDefault(); popupBox.focus(); return; }
3805 var first = focusable[0], last = focusable[focusable.length - 1]; 3806 if (e.shiftKey && document.activeElement === first) { 3807 e.preventDefault(); last.focus(); 3808 } else if (!e.shiftKey && document.activeElement === last) { 3809 e.preventDefault(); first.focus(); 3810 } 3811 }, 3812 showPopup = function() { 3813 popup.style.display = 'flex'; 3814 popupBox.style.outline = 'none'; 3815 popup.classList.add('visible'); 3816 popup.classList.remove('hidden', 'anim'); 3817 sessionStorage.setItem('popupMostrado', 'true'); 3818 isVisible = true; 3819 setTimeout(focusDialog, 0); 3820 }, 3821 hidePopup = function(delay) { 3822 delay = typeof delay !== 'undefined' ? delay : 0; 3823 isVisible = false; 3824 restoreFocus(); 3825 setTimeout(function() { 3826 popup.classList.add('anim'); 3827 requestAnimationFrame(function() { 3828 popup.classList.remove('visible'); 3829 popup.classList.add('hidden'); 3830 }); 3831 }, delay); 3832 }; 3833 3834 popup.addEventListener('keydown', function(e) { 3835 if (e.key === 'Escape' && isVisible) { hidePopup(); return; } 3836 trapFocus(e); 3837 }); 3838 3839 popup.addEventListener('transitionend', function(e) { 3840 if (e.propertyName === 'opacity' && popup.classList.contains('hidden')) { 3841 popup.style.display = 'none'; 3842 popup.classList.remove('anim'); 3843 } 3844 }); 3845 3846 // Mostrar popup 1s después de cargar 3847 setTimeout(showPopup, 1000); 3848 3849 // Cierres 3850 closeBtn && closeBtn.addEventListener('click', function() { hidePopup(); }); 3851 popup.addEventListener('click', function(e) { 3852 if (!popupBox.contains(e.target) && isVisible) hidePopup(); 3853 }); 3854 header && header.addEventListener('click', function() { hidePopup(); }); 3855 motor && motor.addEventListener('click', function() { hidePopup(); }); 3856 loginBtn && loginBtn.addEventListener('click', function(e) { 3857 e.stopPropagation(); 3858 document.dispatchEvent(new CustomEvent('toggleLogin', { 3859 detail: { alias: 'cms-login', open: true } 3860 })); 3861 hidePopup(); 3862 }); 3863 3864 window.addEventListener('scroll', function() { if (isVisible) hidePopup(); }); 3865 window.addEventListener('resize', function() { if (isVisible) hidePopup(); }); 3866 3867})(document.querySelector('.tpl-popLogin-eh')); 3868 3869 3870 3871 3872 3873 3874/** 3875 * booking area 3876 */ 3877((buscador) => { 3878 if (!buscador.length) return false; 3879 3880 let data = []; 3881 // Elementos del DOM 3882 const dom = { 3883 openBuscador: document.querySelector('.tpl-buttonSearchME-eh'), 3884 html: document.documentElement, 3885 body: document.body, 3886 closeModal: document.querySelector('.sta-buscadorME-eh_sta-close'), 3887 }; 3888 3889 // ========== FUNCIONES DE UTILIDAD ========== 3890 const utils = { 3891 // Normalizar texto para búsquedas 3892 normalize: (text) => { 3893 return text.toLowerCase().normalize("NFD") 3894 .replace(/[\u0300-\u036f]/g, "") 3895 .trim(); 3896 }, 3897 3898 // Función para mostrar notificaciones 3899 showNotification: (message, type) => { 3900 console.log(`[${type.toUpperCase()}] ${message}`); 3901 }, 3902 // idioma de la web 3903 language: () => { 3904 return document.documentElement.lang || 'es'; 3905 }, 3906 // normalizar para constructores de URL 3907 slugify: (nameHotel) => { 3908 const tradu_salones = { 3909 'es': 'salones', 3910 'en': 'lounges', 3911 'it': 'saloni', 3912 'fr': 'salles', 3913 'de': 'lounge', 3914 'pt': 'saloes', 3915 'ru': 'lounges', 3916 'nl': 'salon' 3917 }; 3918 const tradu = `${tradu_salones[utils.language()]}`; 3919 const clean = (str) => str 3920 .normalize("NFD") 3921 .replace(/[\u0300-\u036f]/g, "") 3922 .replace(/\s+/g, '-') 3923 .trim() 3924 .toLowerCase(); 3925 3926 // si la pagina actual vive bajo un directorio de idioma (ej. /fr/), se respeta en el link generado 3927 const pathSegments = window.location.pathname.split('/').filter(Boolean); 3928 const langPrefix = pathSegments.length && /^[a-z]{2}$/.test(pathSegments[0]) ? `/${pathSegments[0]}` : ''; 3929 3930 const path = `${window.location.origin}${langPrefix}/${clean(nameHotel)}/${clean(tradu)}.html`; 3931 return path; 3932 }, 3933 // obtener la primera imagen valida de salones 3934 getFirstValidImage: (hotel) => { 3935 // Buscar el primer salon con foto valida 3936 const primerSalonValido = hotel?.Salones?.find(salon => {
3937 const imagen = salon?.image; 3938 return imagen && !imagen.endsWith('/.jpeg') && imagen.includes('.jpeg'); 3939 }); 3940 3941 return primerSalonValido?.image || null; 3942 3943 } 3944 }; 3945 3946 // ========== MANEJO DEL DOM Y EVENTOS ========== 3947 const eventHandlers = { 3948 // Configurar eventos del buscador 3949 setupBuscadorEvents: (b) => { 3950 if (b.classList.contains('mobile') && dom.openBuscador) { 3951 dom.openBuscador.addEventListener('click', () => { 3952 b.classList.add('openModal'); 3953 dom.html.classList.add('sta-noScroll'); 3954 }); 3955 } 3956 3957 if (dom.closeModal) { 3958 dom.closeModal.addEventListener('click', () => { 3959 b.classList.remove('openModal'); 3960 dom.html.classList.remove('sta-noScroll'); 3961 }); 3962 } 3963 3964 // Evento para cerrar al hacer clic fuera 3965 document.addEventListener('click', (e) => { 3966 if (!b.contains(e.target) && !dom.openBuscador.contains(e.target)) { 3967 b.classList.remove('openModal'); 3968 dom.html.classList.remove('sta-noScroll'); 3969 } 3970 }); 3971 3972 // Evento de teclado (ESC para cerrar) 3973 document.addEventListener('keydown', (e) => { 3974 if (e.key === 'Escape' && b.classList.contains('openModal')) { 3975 b.classList.remove('openModal'); 3976 dom.html.classList.remove('sta-noScroll'); 3977 } 3978 }); 3979 }, 3980 3981 // Configurar selects 3982 setupSelects: () => { 3983 const selectInputs = document.querySelectorAll('.sta-buscadorME-eh_input.select'); 3984 3985 selectInputs.forEach(select => { 3986 const fillInput = select.querySelector('.fillInput'); 3987 const fillDestino = select.querySelector('.hotel_destino'); 3988 const ul = select.querySelector('.resultsME'); 3989 3990 select.addEventListener('click', (e) => { 3991 e.stopPropagation(); 3992 select.classList.toggle('open'); 3993 }); 3994 3995 if (ul) { 3996 ul.addEventListener('click', (event) => { 3997 const li = event.target.closest('li'); 3998 if (!li) return; 3999 4000 if (li.classList.contains('li-items')) { 4001 fillDestino.textContent = li.textContent; 4002 } else { 4003 fillInput.textContent = li.textContent; 4004 } 4005 }); 4006 } 4007 }); 4008 4009 // Cerrar selects al hacer clic fuera 4010 document.addEventListener('click', () => { 4011 selectInputs.forEach(select => select.classList.remove('open')); 4012 }); 4013 }, 4014 // Cargar form con los datos del hotel seleccionado 4015 openForm: () => { 4016 document.querySelectorAll('.sta-resultsModuleME-eh_selection').forEach(button => { 4017 button.addEventListener('click', () => { 4018 const modalForm = document.querySelector('.tpl-contactModal-eh'); 4019 if (modalForm) { 4020 modalForm.classList.add('open'); 4021 dom.body.classList.add('sta-noScroll'); 4022 } 4023 }); 4024 }); 4025 } 4026 }; 4027 // ========== MANEJO DE API ========== 4028 const api = { 4029 // Función para obtener hoteles con salas de reuniones 4030 getHotelsWithMeetingRooms: async () => { 4031 try { 4032 const response = await fetch('https://synergy.booking-channel.com/api/cms/hotels_with_meeting_rooms', { 4033 method: 'GET', 4034 headers: { 'Accept': 'application/json' } 4035 }); 4036 4037 if (!response.ok) { 4038 throw new Error(`HTTP ${response.status}: ${response.statusText}`); 4039 } 4040 4041 const responseData = await response.json(); 4042 4043 data = responseData; 4044 4045 return data; 4046 4047 } catch (error) { 4048 console.error('Error al obtener hoteles con salas de reuniones:', error); 4049 throw error; 4050 } 4051 } 4052 }; 4053 // ========== VARIABLES GLOBALES PARA SCROLL INFINITO ========== 4054 let globalScrollHandler = null; 4055 let globalCurrentPage = 0; 4056 let globalIsLoading = false; 4057 let globalAllItemsLoaded = false; 4058 let globalHoteles = []; 4059 let globalContainer = null; 4060 // ========== AUTOCOMPLETADO Y BÃSQUEDA ========== 4061 const search = { 4062 setupAutocomplete: () => { 4063 // Obtenemos ambos inputs 4064 const inputDesktop = document.getElementById('hotel_destino'); 4065 const inputMobile = document.getElementById('hotel_destino_mobile'); 4066 const inputs = [inputDesktop, inputMobile].filter(input => input); // Filtrar elementos null 4067 const lang = utils.language(); 4068 // Configuramos eventos para ambos inputs
4069 inputs.forEach(input => { 4070 const resultsList = input.parentElement.querySelector('.resultsME.destino'); 4071 if (!resultsList) return; 4072 4073 // ========== Evento focus para reiniciar buscador ========== 4074 input.addEventListener('focus', (e) => { 4075 // Limpiar ambos inputs 4076 inputs.forEach(i => { 4077 i.value = ''; 4078 delete i.dataset.hotelData; 4079 }); 4080 4081 // Limpiar lista de autocompletado 4082 resultsList.innerHTML = ''; 4083 4084 }); 4085 const handleInput = () => { 4086 const query = utils.normalize(input.value); 4087 4088 // Sincronizamos el valor en ambos inputs 4089 inputs.forEach(i => { 4090 if (i !== input) i.value = input.value; 4091 }); 4092 4093 resultsList.innerHTML = ''; 4094 4095 if (query.length < 2) return; 4096 4097 // Verificar que data tenga contenido 4098 if (!data || data.length === 0) { 4099 console.warn('No hay datos disponibles para la búsqueda'); 4100 return; 4101 } 4102 4103 const matches = data.filter(hotel => 4104 utils.normalize(hotel.HotelName).includes(query) || 4105 utils.normalize(hotel.HotelCity[lang]?.name || hotel.HotelCity['es']?.name || hotel.HotelCity[Object.keys(hotel.HotelCity)[0]]?.name || '').includes(query) 4106 ); 4107 4108 if (matches.length === 0) { 4109 const li = document.createElement('li'); 4110 const lang = utils.language(); 4111 const tradu_notFound = { 4112 "es": "No se encontraron coincidencias", 4113 "en": "No matches found", 4114 "it": "Nessuna corrispondenza trovata", 4115 "fr": "Aucune correspondance trouvée", 4116 "de": "Keine Ãbereinstimmungen gefunden", 4117 "pt": "Nenhuma correspondência encontrada", 4118 "ru": "Cовпадений не найдено", 4119 "nl": "Geen overeenkomsten gevonden" 4120 }; 4121 li.className = 'li-items no-results'; 4122 li.textContent = tradu_notFound[lang] || tradu_notFound['es']; 4123 resultsList.appendChild(li); 4124 return; 4125 } 4126 4127 matches.forEach(hotel => { 4128 const li = document.createElement('li'); 4129 li.className = 'li-items'; 4130 li.textContent = `${hotel.HotelName} (${hotel.HotelCity[lang]?.name || hotel.HotelCity['es']?.name || hotel.HotelCity[Object.keys(hotel.HotelCity)[0]]?.name || ''})`; 4131 4132 li.addEventListener('click', () => { 4133 // Actualizamos ambos inputs al seleccionar un resultado 4134 inputs.forEach(i => { 4135 i.value = `${hotel.HotelName} (${hotel.HotelCity[lang]?.name || hotel.HotelCity['es']?.name || hotel.HotelCity[Object.keys(hotel.HotelCity)[0]]?.name || ''})`; 4136 i.dataset.hotelData = JSON.stringify(hotel); // Guardamos el objeto completo 4137 }); 4138 resultsList.innerHTML = ''; 4139 }); 4140 4141 resultsList.appendChild(li); 4142 }); 4143 } 4144 4145 input.addEventListener('input', handleInput); 4146 4147 // Configuración de accesibilidad 4148 input.addEventListener('keydown', (e) => { 4149 const items = resultsList.querySelectorAll('.li-items'); 4150 let current = Array.from(items).findIndex(item => item === document.activeElement); 4151 4152 if (e.key === 'ArrowDown') { 4153 e.preventDefault(); 4154 current = (current + 1) % items.length; 4155 items[current]?.focus(); 4156 } else if (e.key === 'ArrowUp') { 4157 e.preventDefault(); 4158 current = (current - 1 + items.length) % items.length; 4159 items[current]?.focus(); 4160 } else if (e.key === 'Enter' && document.activeElement.classList.contains('li-items')) { 4161 e.preventDefault(); 4162 document.activeElement.click(); 4163 } 4164 }); 4165 }); 4166 4167 const buttons = document.querySelectorAll('.tpl-buttonSearchME-eh_buscador'); 4168 4169 buttons.forEach(button => { 4170 button.addEventListener('click', (e) => { 4171 e.preventDefault(); 4172 const modalMobile = document.querySelector('.tpl-buscadorME-eh.mobile'); 4173 if (modalMobile && modalMobile.classList.contains('openModal')) { 4174 modalMobile.classList.remove('openModal'); 4175 dom.html.classList.remove('sta-noScroll'); 4176 } 4177 4178 const input = document.getElementById('hotel_destino'); 4179 if (!input) return; 4180 4181 const hotelData = input.dataset.hotelData; 4182 4183 if (hotelData) { 4184 const selectedHotel = JSON.parse(hotelData); 4185 search.renderResults([selectedHotel], '.sta-resultsModuleME-eh_max'); 4186 } else { 4187 const query = utils.normalize(input.value); 4188 const lang = utils.language(); 4189 const filtered = data.filter(hotel => 4190 utils.normalize(hotel.HotelName).includes(query) || 4191 utils.normalize(hotel.HotelCity[lang]?.name || hotel.HotelCity['es']?.name || hotel.HotelCity[Object.keys(hotel.HotelCity)[0]]?.name || '').includes(query) 4192 4193 ); 4194 4195 if (filtered.length === 0) { 4196 utils.showNotification('No se encontraron resultados', 'warning'); 4197 } 4198 4199 search.renderResults(filtered, '.sta-resultsModuleME-eh_max'); 4200 } 4201 }); 4202 }); 4203 }, 4204 4205 // Mostrar resultados 4206 renderResults: (hoteles, containerSelector) => { 4207 const container = document.querySelector(containerSelector); 4208 if (!container) return; 4209 4210 // limpiar resultados previos 4211 if (globalScrollHandler) { 4212 window.removeEventListener('scroll', globalScrollHandler); 4213 globalScrollHandler = null; 4214 } 4215 4216 container.innerHTML = ''; 4217 4218 if (!hoteles || hoteles.length === 0) { 4219 const lang = utils.language(); 4220 const tradu_noResults = { 4221 "es": "No se encontraron hoteles con esos criterios de búsqueda", 4222 "en": "No hotels found with those search criteria", 4223 "it": "Nessun hotel trovato con quei criteri di ricerca", 4224 "fr": "Aucun hôtel trouvé avec ces critères de recherche", 4225 "de": "Keine Hotels mit diesen Suchkriterien gefunden", 4226 "pt": "Nenhum hotel encontrado com esses critérios de pesquisa", 4227 "ru": "ÐÑели Ñ Ñакими кÑиÑеÑиÑми поиÑка не найденÑ", 4228 "nl": "Geen hotels gevonden met die zoekcriteria" 4229 }; 4230 4231 container.innerHTML = ` 4232 <div class="no-results"> 4233 <p>${tradu_noResults[lang] || tradu_noResults["es"]}</p> 4234 </div> 4235 `; 4236 return; 4237 } 4238 4239 // reiniciar variables globales 4240 globalCurrentPage = 0; 4241 globalIsLoading = false;
4242 globalAllItemsLoaded = false; 4243 globalHoteles = hoteles; 4244 globalContainer = container; 4245 4246 const itemsPerPage = 9; 4247 const totalPages = Math.ceil(hoteles.length / itemsPerPage); 4248 const lang = utils.language(); 4249 4250 const tradu_seeHotel = { 4251 "es": "Ver Hotel", 4252 "en": "View Hotel", 4253 "it": "Visualizza hotel", 4254 "fr": "Voir l'hôtel", 4255 "de": "Hotel anzeigen", 4256 "pt": "Ver hotel", 4257 "ru": "ÐоÑмоÑÑеÑÑ Ð¾ÑелÑ", 4258 "nl": "Bekijk hotel" 4259 }; 4260 4261 const tradu_select = { 4262 "es": "SELECCIONAR", 4263 "en": "SELECT", 4264 "it": "SELEZIONARE", 4265 "fr": "SÃLECTIONNER", 4266 "de": "AUSWÃHLEN", 4267 "pt": "SELECIONAR", 4268 "ru": "ÐЫÐÐ ÐТЬ", 4269 "nl": "SELECTEREN" 4270 }; 4271 4272 const tradu_salones = { 4273 "es": "Salones", 4274 "en": "Halls", 4275 "it": "Sale", 4276 "fr": "Salles", 4277 "de": "Säle", 4278 "pt": "Salões", 4279 "ru": "ÐалÑ", 4280 "nl": "Zalen" 4281 }; 4282
4283 const loadMoreItems = () => { 4284 if (globalIsLoading || globalAllItemsLoaded) return; 4285 4286 globalIsLoading = true; 4287 4288 const start = globalCurrentPage * itemsPerPage; 4289 const end = start + itemsPerPage; 4290 const pageItems = globalHoteles.slice(start, end); 4291 4292 if (pageItems.length === 0) { 4293 globalAllItemsLoaded = true; 4294 globalIsLoading = false; 4295 return; 4296 } 4297 4298 const moduleDeleted = document.querySelector('.tpl-boxesME-eh'); 4299 4300 pageItems.forEach(hotel => { 4301 const div = document.createElement('div'); 4302 div.className = 'sta-resultsModuleME-eh'; 4303 div.setAttribute('data-hotel', JSON.stringify(hotel)); 4304 div.innerHTML = ` 4305 <div class="sta-resultsModuleME-eh_photo"> 4306 <img src="https://${utils.getFirstValidImage(hotel)}" 4307 alt="${hotel.HotelName}"> 4308 <div class="sta-resultsModuleME-eh_total"> 4309 ${Object.keys(hotel.Salones).filter(key => !isNaN(key)).length} ${tradu_salones[lang] || tradu_salones["es"]} 4310 </div> 4311 </div> 4312 <div class="sta-resultsModuleME-eh_text">${hotel.HotelName}</div> 4313 <div class="sta-resultsModuleME-eh_text_dir">${hotel.HotelAddress}, ${hotel.HotelCity[lang]?.name || hotel.HotelCity['es']?.name || hotel.HotelCity[Object.keys(hotel.HotelCity)[0]]?.name || ''}</div> 4314 <div class="sta-resultsModuleME-eh_contButton"> 4315 <div class="sta-resultsModuleME-eh_link"> 4316 <a href="${utils.slugify(hotel.HotelName)}" target="_blank" rel="noopener noreferrer">${tradu_seeHotel[lang] || tradu_seeHotel["es"]}</a> 4317 </div> 4318 <button class="sta-resultsModuleME-eh_selection">${tradu_select[lang] || tradu_select["es"]}</button> 4319 </div> 4320 `; 4321 globalContainer.appendChild(div); 4322 }); 4323 4324 if (moduleDeleted) { 4325 moduleDeleted.remove(); 4326 } 4327 4328 globalCurrentPage++; 4329 globalIsLoading = false; 4330 4331 if (globalCurrentPage >= totalPages) { 4332 globalAllItemsLoaded = true; 4333 } 4334 }; 4335 4336 const handleScroll = () => { 4337 if (globalIsLoading || globalAllItemsLoaded) return; 4338 4339 const scrollTop = window.pageYOffset || document.documentElement.scrollTop; 4340 const windowHeight = window.innerHeight; 4341 const documentHeight = document.documentElement.scrollHeight; 4342 4343 if (scrollTop + windowHeight >= documentHeight - 200) { 4344 loadMoreItems(); 4345 } 4346 }; 4347 4348 const moduleDeleted = document.querySelector('.tpl-boxesME-eh'); 4349 if (moduleDeleted) { 4350 moduleDeleted.remove(); 4351 } 4352 4353 globalScrollHandler = handleScroll; 4354 window.addEventListener('scroll', globalScrollHandler); 4355 4356 loadMoreItems(); 4357 4358 // eventHandlers.openForm(); 4359 } 4360 }; 4361 4362 // ========== INICIALIZACIÃN ========== 4363 const init = async () => { 4364 // Configurar eventos del DOM 4365 for (let i = 0; i < buscador.length; i++) { 4366 eventHandlers.setupBuscadorEvents(buscador[i]); 4367 } 4368 eventHandlers.setupSelects(); 4369 // Cargar datos y configurar búsqueda 4370 try { 4371 await api.getHotelsWithMeetingRooms(); 4372 search.setupAutocomplete(); 4373 utils.showNotification('Datos cargados correctamente', 'success'); 4374 } catch (error) { 4375 console.error('Error inicializando:', error); 4376 utils.showNotification('Error al cargar los datos iniciales', 'error'); 4377 } 4378 }; 4379 4380 // Iniciar la aplicación 4381 init(); 4382 4383})(document.querySelectorAll('.tpl-buscadorME-eh')); 4384/** 4385 * validacion y envio formulario 4386 */ 4387((o, h) => { 4388 if (!o || !h) return false; 4389 4390 const buttonClose = o.querySelector('.sta-contactModal-eh_sta-close'); 4391 const calendarVan = o.querySelector('.sta-form-contacto-input.date'); 4392 const phonePrefix = o.querySelector('.sta-form-contacto-tel .search-box'); 4393 4394 window.mailReserva = null; 4395 window.hotelName = null; 4396 let isLoaded = false; // Para inicializar solo una vez 4397 4398 // === Carga del archivo de banderas === 4399 async function cargarArchivo() { 4400 try { 4401 const arrayCountries = await import('/CLIENTES/www.eurostarshotels.com/js/otros/banderas.js?_=202502191129'); 4402 return Array.isArray(arrayCountries.FLAGS_COUNTRIES) ? arrayCountries.FLAGS_COUNTRIES : []; 4403 } catch (error) { 4404 console.error("Error al cargar el archivo de banderas:", error); 4405 return []; 4406 } 4407 } 4408 document.addEventListener('click', function (e) { 4409 if (phonePrefix && !phonePrefix.contains(e.target)) { 4410 if (!phonePrefix.value || phonePrefix.value.trim() === '') { 4411 initPhonePrefix(); 4412 } 4413 } 4414 }) 4415 // === Inicializa el prefijo telefónico con geolocalización === 4416 async function initPhonePrefix() { 4417 try { 4418 const ipRes = await fetch('https://media.booking-channel.com//api/cms/check_ip_user'); 4419 const ipData = await ipRes.json(); 4420 const countryCode = ipData.CountryCode; 4421 const countryPrefix = { 4422 'AD': '+376', 'AE': '+971', 'AF': '+93', 'AG': '+1', 'AI': '+1', 'AL': '+355', 4423 'AM': '+374', 'AO': '+244', 'AR': '+54', 'AS': '+1', 'AT': '+43', 'AU': '+61', 4424 'AW': '+297', 'AZ': '+994', 'BA': '+387', 'BB': '+1', 'BD': '+880', 'BE': '+32', 4425 'BF': '+226', 'BG': '+359', 'BH': '+973', 'BI': '+257', 'BJ': '+229', 'BM': '+1', 4426 'BN': '+673', 'BO': '+591', 'BR': '+55', 'BS': '+1', 'BT': '+975', 'BW': '+267', 4427 'BY': '+375', 'BZ': '+501', 'CA': '+1', 'CC': '+61', 'CD': '+243', 'CF': '+236', 4428 'CG': '+242', 'CH': '+41', 'CI': '+225', 'CK': '+682', 'CL': '+56', 'CM': '+237', 4429 'CN': '+86', 'CO': '+57', 'CR': '+506', 'CU': '+53', 'CV': '+238', 'CW': '+599', 4430 'CX': '+61', 'CY': '+357', 'CZ': '+420', 'DE': '+49', 'DJ': '+253', 'DK': '+45', 4431 'DM': '+1', 'DO': '+1', 'DZ': '+213', 'EC': '+593', 'EE': '+372', 'EG': '+20',
4432 'ER': '+291', 'ES': '+34', 'ET': '+251', 'FI': '+358', 'FJ': '+679', 'FK': '+500', 4433 'FM': '+691', 'FO': '+298', 'FR': '+33', 'GA': '+241', 'GB': '+44', 'GD': '+1', 4434 'GE': '+995', 'GF': '+594', 'GG': '+44', 'GH': '+233', 'GI': '+350', 'GL': '+299', 4435 'GM': '+220', 'GN': '+224', 'GP': '+590', 'GQ': '+240', 'GR': '+30', 'GT': '+502', 4436 'GU': '+1', 'GW': '+245', 'GY': '+592', 'HK': '+852', 'HN': '+504', 'HR': '+385', 4437 'HT': '+509', 'HU': '+36', 'ID': '+62', 'IE': '+353', 'IL': '+972', 'IM': '+44', 4438 'IN': '+91', 'IO': '+246', 'IQ': '+964', 'IR': '+98', 'IS': '+354', 'IT': '+39', 4439 'JE': '+44', 'JM': '+1', 'JO': '+962', 'JP': '+81', 'KE': '+254', 'KG': '+996', 4440 'KH': '+855', 'KI': '+686', 'KM': '+269', 'KN': '+1', 'KP': '+850', 'KR': '+82', 4441 'KW': '+965', 'KY': '+1', 'KZ': '+7', 'LA': '+856', 'LB': '+961', 'LC': '+1', 4442 'LI': '+423', 'LK': '+94', 'LR': '+231', 'LS': '+266', 'LT': '+370', 'LU': '+352', 4443 'LV': '+371', 'LY': '+218', 'MA': '+212', 'MC': '+377', 'MD': '+373', 'ME': '+382', 4444 'MF': '+590', 'MG': '+261', 'MH': '+692', 'MK': '+389', 'ML': '+223', 'MM': '+95', 4445 'MN': '+976', 'MO': '+853', 'MP': '+1', 'MQ': '+596', 'MR': '+222', 'MS': '+1', 4446 'MT': '+356', 'MU': '+230', 'MV': '+960', 'MW': '+265', 'MX': '+52', 'MY': '+60', 4447 'MZ': '+258', 'NA': '+264', 'NC': '+687', 'NE': '+227', 'NF': '+672', 'NG': '+234', 4448 'NI': '+505', 'NL': '+31', 'NO': '+47', 'NP': '+977', 'NR': '+674', 'NU': '+683', 4449 'NZ': '+64', 'OM': '+968', 'PA': '+507', 'PE': '+51', 'PF': '+689', 'PG': '+675', 4450 'PH': '+63', 'PK': '+92', 'PL': '+48', 'PM': '+508', 'PR': '+1', 'PS': '+970', 4451 'PT': '+351', 'PW': '+680', 'PY': '+595', 'QA': '+974', 'RE': '+262', 'RO': '+40', 4452 'RS': '+381', 'RU': '+7', 'RW': '+250', 'SA': '+966', 'SB': '+677', 'SC': '+248', 4453 'SD': '+249', 'SE': '+46', 'SG': '+65', 'SH': '+290', 'SI': '+386', 'SJ': '+47', 4454 'SK': '+421', 'SL': '+232', 'SM': '+378', 'SN': '+221', 'SO': '+252', 'SR': '+597', 4455 'SS': '+211', 'ST': '+239', 'SV': '+503', 'SX': '+1', 'SY': '+963', 'SZ': '+268', 4456 'TC': '+1', 'TD': '+235', 'TF': '+262', 'TG': '+228', 'TH': '+66', 'TJ': '+992', 4457 'TK': '+690', 'TL': '+670', 'TM': '+993', 'TN': '+216', 'TO': '+676', 'TR': '+90', 4458 'TT': '+1', 'TV': '+688', 'TW': '+886', 'TZ': '+255', 'UA': '+380', 'UG': '+256', 4459 'US': '+1', 'UY': '+598', 'UZ': '+998', 'VA': '+379', 'VC': '+1', 'VE': '+58', 4460 'VG': '+1', 'VI': '+1', 'VN': '+84', 'VU': '+678', 'WF': '+681', 'WS': '+685', 4461 'XK': '+383', 'YE': '+967', 'YT': '+262', 'ZA': '+27', 'ZM': '+260', 'ZW': '+263' 4462 }[countryCode] || '+34'; 4463 4464 const flags = await cargarArchivo(); 4465 const match = flags.find(obj => { 4466 const key = Object.keys(obj)[0]; 4467 return key.includes(`(+`) && key.includes(countryPrefix); 4468 }); 4469 4470 if (match) { 4471 const [label, image] = [Object.keys(match)[0], Object.values(match)[0]]; 4472 const prefixMatch = label.match(/\(\+[\d]+\)/); 4473 if (prefixMatch) { 4474 const prefix = prefixMatch[0].replace(/[()]/g, ''); 4475 phonePrefix.value = prefix; 4476 4477 const flagImage = document.createElement('div'); 4478 flagImage.className = 'sta-flag'; 4479 flagImage.style.backgroundImage = `url(${image})`; 4480 phonePrefix.parentNode.insertBefore(flagImage, phonePrefix); 4481 4482 phonePrefix.classList.add('sta-focus', 'sta-relleno'); 4483 } 4484 } 4485 } catch (err) { 4486 console.error('Error al inicializar el prefijo telefónico:', err); 4487 } 4488 } 4489 4490 // === Carga el calendario === 4491 const loadCalendar = function (elem) { 4492 let filesLoaded = 2; 4493 4494 const showDatePicker = function (elem) { 4495 const lang = document.documentElement.lang; 4496 let firstClick = null; 4497 4498 const calendar = new VanillaCalendar(elem, { 4499 input: true, 4500 settings: { 4501 lang: lang, 4502 selection: { day: 'multiple-ranged' }, 4503 visibility: { 4504 weekend: false, 4505 today: true, 4506 theme: 'light', 4507 positionToInput: 'auto', 4508 }, 4509 }, 4510 date: { min: 'today' },
4511 CSSClasses: { calendar: 'lib-formLateral-calendar_salones' }, 4512 actions: { 4513 clickDay(e, self) { 4514 const clickedDate = e.target.dataset.calendarDay; 4515 4516 const formatShortDate = (dateStr) => { 4517 const [year, month, day] = dateStr.split('-'); 4518 const date = new Date(year, month - 1, day); 4519 const isUS = location.hostname.endsWith('.us'); 4520 const locale = isUS ? 'en-US' : 'es-ES'; 4521 const fmt = new Intl.DateTimeFormat(locale, { weekday: 'short', day: 'numeric', month: 'short' }); 4522 const parts = fmt.formatToParts(date); 4523 const get = (type) => parts.find(p => p.type === type)?.value.replace('.', '').slice(0, 3) || ''; 4524 const dayName = get('weekday'); 4525 const dayNumber = get('day'); 4526 const monthName = get('month'); 4527 return isUS 4528 ? `${dayName}, ${monthName} ${dayNumber}` // Tue Jun, 9 4529 : `${dayName}, ${dayNumber} ${monthName}`; // mar, 9 jun 4530 }; 4531 4532 if (!firstClick) { 4533 firstClick = clickedDate; 4534 calendar.selectedDates = [firstClick]; 4535 self.HTMLInputElement.value = formatShortDate(firstClick); 4536 } else { 4537 const secondClick = clickedDate; 4538 let [start, end] = [firstClick, secondClick]; 4539 const parseLocal = (str) => { const [y,m,d] = str.split('-').map(Number); return new Date(y, m-1, d); }; 4540 if (parseLocal(start) > parseLocal(end)) [start, end] = [end, start]; 4541 4542 const formattedStart = formatShortDate(start); 4543 const formattedEnd = formatShortDate(end); 4544 self.HTMLInputElement.value = start === end ? formattedStart : `${formattedStart} - ${formattedEnd}`; 4545 4546 calendar.selectedDates = [start, end]; 4547 self.hide(); 4548 firstClick = null; 4549 } 4550 } 4551 } 4552 }); 4553 4554 calendar.init(); 4555 4556 const modal = o.querySelector('.sta-contactModal-eh_modal'); 4557 modal?.addEventListener('scroll', () => calendar.hide()); 4558 4559 const resizeObserver = new ResizeObserver(() => calendar.hide()); 4560 resizeObserver.observe(o); 4561 }; 4562 4563 h.cargarFicheroCSS("/js/libraries/vanillaCalendar/css/vanilla-calendar.min.css", () => { 4564 filesLoaded--; 4565 if (!filesLoaded) showDatePicker(elem); 4566 }); 4567 h.cargarFicheroJS("/js/libraries/vanillaCalendar/js/vanilla-calendar.min.js", () => { 4568 filesLoaded--; 4569 if (!filesLoaded) showDatePicker(elem); 4570 }); 4571 }; 4572 4573 // === Carga los selects personalizados === 4574 function loadSelects() { 4575 const selects = o.querySelectorAll('.select'); 4576 selects.forEach(select => { 4577 const input = select.querySelector('.sta-form-contacto-input'); 4578 const options = select.querySelectorAll('#results ul li'); 4579 4580 input.addEventListener('click', () => select.classList.toggle("open")); 4581 4582 options.forEach(li => { 4583 li.addEventListener('click', () => { 4584 input.value = li.textContent; 4585 select.classList.remove("open"); 4586 }); 4587 }); 4588 4589 document.addEventListener('click', (event) => { 4590 if (!select.contains(event.target) && !input.contains(event.target)) { 4591 select.classList.remove("open"); 4592 } 4593 }); 4594 4595 input.addEventListener('blur', () => { 4596 setTimeout(() => select.classList.remove("open"), 200); 4597 }); 4598 }); 4599 } 4600 4601 function setupRadioListeners(form) { 4602 const radioGroups = {}; 4603 form.querySelectorAll('input[type="radio"]').forEach(radio => { 4604 (radioGroups[radio.name] = radioGroups[radio.name] || []).push(radio); 4605 }); 4606 4607 for (const name in radioGroups) { 4608 const group = radioGroups[name]; 4609 const container = group[0].parentElement.previousElementSibling; 4610 4611 group.forEach(radio => { 4612 radio.addEventListener('change', function () { 4613 if (container.classList.contains('sta-ko')) { 4614 container.classList.remove('sta-ko'); 4615 const errorSpan = container.parentElement.querySelector('.sta-error'); 4616 if (errorSpan) { 4617 errorSpan.remove(); 4618 } 4619 } 4620 }); 4621 }); 4622 } 4623 } 4624 4625 function cargarFormulario(o, arrayCountries) { 4626 if (!o) return false;
4627 4628 const inputDateContainer = document.querySelector('.sta-form-contacto-two.fecha'); 4629 const roomsRb = document.querySelector('.sta-form-contacto-one.rb.rooms'); 4630 const numberRooms = document.querySelector('.sta-form-contacto-inputs.rooms'); 4631 4632 // Responsive display 4633 function updateDisplay() { 4634 const isDesktop = window.matchMedia('(min-width: 768px)').matches; 4635 inputDateContainer.style.display = isDesktop ? 'flex' : 'block'; 4636 } 4637 window.addEventListener('resize', updateDisplay); 4638 updateDisplay(); 4639 4640 // Mostrar número de habitaciones 4641 roomsRb?.querySelectorAll('input').forEach(rb => { 4642 rb.addEventListener('change', () => { 4643 numberRooms.style.display = rb.value === 'yes' ? 'block' : 'none'; 4644 }); 4645 }); 4646 4647 // Autocompletado de paÃses 4648 const searchText = document.getElementById("search-text"); 4649 const searchResults = document.getElementById("search-results"); 4650 let bandera = false; 4651 4652 function updateList(listArray, searchText, searchResults, flagImage = false) { 4653 const searchTerm = searchText.value.trim(); 4654 let ul = searchResults && searchResults.querySelector('ul'); 4655 if (!ul) { 4656 // render list only when input (select) is opened/focused 4657 if (!searchText.matches(':focus')) return; 4658 ul = document.createElement('ul'); searchResults.appendChild(ul); 4659 } 4660 ul.innerHTML = ""; 4661 4662 const isNumericSearch = /^\+?\d/.test(searchTerm); 4663 4664 const matchedItems = []; 4665 4666 listArray.forEach(item => { 4667 const itemKey = Object.keys(item)[0]; 4668 let matches = false; 4669 4670 if (isNumericSearch) { 4671 4672 const phoneCodeRegex = /\(\+([0-9\-]+)\)/; 4673 const match = itemKey.match(phoneCodeRegex); 4674 if (match) { 4675 const phoneCode = match[0].slice(1, -1); 4676 const normalizedPhoneCode = phoneCode.replace(/^\+/, ''); 4677 const normalizedSearchTerm = searchTerm.replace(/^\+/, ''); 4678 matches = normalizedPhoneCode.startsWith(normalizedSearchTerm); 4679 }else{ 4680 const normalizedItemKey = itemKey.replace(/^\+/, ''); 4681 const normalizedSearchTerm = searchTerm.replace(/^\+/, ''); 4682 matches = normalizedItemKey.startsWith(normalizedSearchTerm); 4683 } 4684 } else { 4685 const searchTermLower = searchTerm.toLowerCase(); 4686 const itemKeyWithoutAccents = itemKey 4687 .normalize("NFD") 4688 .replace(/[\u0300-\u036f]/g, "") 4689 .toLowerCase(); 4690 matches = itemKeyWithoutAccents.startsWith(searchTermLower); 4691 } 4692 4693 if (matches) { 4694 matchedItems.push(item); 4695 }; 4696 }); 4697 4698 if (isNumericSearch){ 4699 matchedItems.sort((a, b) => { 4700 const getPhoneCode = (key) => { 4701 const match = key.match(/\(\+([0-9\-]+)\)/); 4702 return match ? parseInt(match[1].replace(/\-/g, ''), 10) : 0; 4703 }; 4704 4705 const codeA = getPhoneCode(Object.keys(a)[0]); 4706 const codeB = getPhoneCode(Object.keys(b)[0]); 4707 return codeA - codeB; 4708 }); 4709 }else{ 4710 matchedItems.sort((a, b) => { 4711 const aKey = Object.keys(a)[0].toLowerCase(); 4712 const bKey = Object.keys(b)[0].toLowerCase(); 4713 return aKey.localeCompare(bKey); 4714 }); 4715 } 4716 matchedItems.forEach(item => { 4717 const option = document.createElement('option'); 4718 const itemKey = Object.keys(item)[0]; 4719 option.value = itemKey; 4720 option.dataset.image = Object.values(item)[0]; 4721 const li = document.createElement('li'); 4722 const span = document.createElement('span'); 4723 span.textContent = option.value; 4724 li.style.backgroundImage = flagImage ? `url(${option.dataset.image})` : ''; 4725 li.addEventListener("click", function () { 4726 document.querySelector('#search-text').classList.add('sta-fill') 4727 if (searchText.value !== option.value) { 4728 var div = document.createElement('div'); 4729 div.classList.add('sta-flag'); 4730 div.style.backgroundImage = "url(" + option.dataset.image
4730+ ")"; 4731 searchText.parentElement.prepend(div); 4732 4733 let regex = /\(\+([0-9\-]+)\)/, 4734 match = option.value.match(regex); 4735 searchText.value = match ? "+" + match[1] : option.value; 4736 bandera = true; 4737 } 4738 const _ul = searchResults && searchResults.querySelector('ul'); if (_ul) _ul.innerHTML = ""; 4739 }); 4740 4741 li.appendChild(span); 4742 ul.appendChild(li); 4743 4744 }); 4745 } 4746 4747 function handleInput(searchText, searchResults, listArray, flagImage) { 4748 function bucle(searchText, searchResults, listArray, flagImage) { 4749 const agregarClaseFocus = (e) => e.target.classList.add("sta-focus"); 4750 4751 document.querySelectorAll("input, textarea").forEach(input => { 4752 input.addEventListener("focus", agregarClaseFocus); 4753 }); 4754 4755 searchText.addEventListener("click", () => { 4756 const flag = searchText.parentElement.querySelector(".sta-flag"); 4757 if (flag) flag.remove(); 4758 searchText.value = ""; 4759 updateList(listArray, searchText, searchResults, flagImage); 4760 searchText.classList.add("sta-fill"); 4761 }); 4762 4763 searchText.addEventListener("input", () => { 4764 updateList(listArray, searchText, searchResults, flagImage); 4765 searchText.classList.add("sta-fill"); 4766 }); 4767 4768 document.addEventListener("click", (e) => { 4769 if (!searchResults.contains(e.target) && e.target !== searchText) { 4770 const ul = searchResults.querySelector("ul"); if (ul) ul.innerHTML = ""; 4771 } 4772 }); 4773 4774 } 4775 bucle(searchText, searchResults, arrayCountries, true); 4776 } 4777 4778 if (searchText && searchResults) { 4779 handleInput(searchText, searchResults, arrayCountries, true); 4780 } 4781 4782 // Focus en inputs 4783 document.querySelectorAll('input, textarea').forEach(input => { 4784 input.addEventListener('focus', () => input.classList.add('sta-focus')); 4785 }); 4786 4787 // Validación y envÃo 4788 const form = o.querySelector('.tpl-form-contacto.ME'); 4789 if (!form) return; 4790 4791 // Configurar los listeners de radio buttons UNA SOLA VEZ 4792 setupRadioListeners(form); 4793 4794 form.addEventListener('submit', function (e) { 4795 e.preventDefault(); 4796 4797 let hasError = false; 4798 4799 // Limpiar TODOS los errores previos 4800 this.querySelectorAll('.sta-ko').forEach(el => { 4801 el.classList.remove('sta-ko'); 4802 }); 4803 this.querySelectorAll('.sta-error').forEach(el => { 4804 el.remove(); 4805 }); 4806 4807 // === VALIDACIÃN DE INPUTS Y TEXTAREAS === 4808 const lang = document.documentElement.lang; 4809 const errorMessage = { 4810 "es": "Campo obligatorio", 4811 "en": "Required field", 4812 "it": "Campo obbligatorio", 4813 "fr": "Champ obligatoire", 4814 "de": "Pflichtfeld", 4815 "pt": "Campo obrigatório", 4816 "ru": "ÐбÑзаÑелÑное поле", 4817 "nl": "Verplicht veld" 4818 }; 4819 const errorEmail = { 4820 "es": "Email no válido", 4821 "en": "Invalid Email", 4822 "it": "Email non valida", 4823 "fr": "Email non valide", 4824 "de": "Ungültige E-Mail", 4825 "pt": "E-mail inválido", 4826 "ru": "ÐедейÑÑвиÑелÑнÑй email", 4827 "nl": "Ongeldig e-mailadres" 4828 }; 4829 this.querySelectorAll('input:not([type="radio"]):not([type="hidden"]), textarea').forEach(input => { 4830 4831 if (input.type === 'email' && input.value.trim() !== '') { 4832 const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; 4833 if (!emailRegex.test(input.value.trim())) { 4834 showError(input, errorEmail[lang] || errorEmail['es']); 4835 hasError = true; 4836 } 4837 } 4838 4839 if (!input.classList.contains('sta-noOblig') && input.value.trim() === '') { 4840 showError(input, errorMessage[lang] || errorMessage['es']); 4841 hasError = true; 4842 } 4843 }); 4844 4845 // === VALIDACIÃN DE RADIO BUTTONS === 4846 const radioGroups = {}; 4847 this.querySelectorAll('input[type="radio"]').forEach(radio => { 4848 if (!radioGroups[radio.name]) { 4849 radioGroups[radio.name] = []; 4850 } 4851 radioGroups[radio.name].push(radio); 4852 }); 4853
4854 Object.keys(radioGroups).forEach(groupName => { 4855 const group = radioGroups[groupName]; 4856 const isChecked = group.some(radio => radio.checked); 4857 4858 const isOptional = group.some(radio => radio.classList.contains('sta-noOblig')); 4859 4860 if (!isChecked && !isOptional) { 4861 const container = group[0].parentElement.previousElementSibling; 4862 if (container) { 4863 showError(container, errorMessage[lang] || errorMessage['es'], true); 4864 hasError = true; 4865 } 4866 } 4867 }); 4868 // === VALIDACIÃN DE CHECKBOXES === 4869 this.querySelectorAll('input[type="checkbox"]').forEach(checkbox => { 4870 const isRequired = checkbox.hasAttribute('required') || !checkbox.classList.contains('sta-noOblig'); 4871 4872 if (isRequired && !checkbox.checked) { 4873 showError(checkbox, errorMessage[lang] || errorMessage['es']); 4874 hasError = true; 4875 } 4876 }); 4877 // === VALIDACIÃN DE SELECTS PERSONALIZADOS === 4878 this.querySelectorAll('.sta-form-contacto-inputs.select .sta-form-contacto-input').forEach(select => { 4879 if (!select.classList.contains('sta-noOblig') && select.value.trim() === '') { 4880 showError(select, errorMessage[lang] || errorMessage['es']); 4881 hasError = true; 4882 } 4883 }); 4884 // SI HAY ERRORES, DETENER COMPLETAMENTE EL ENVÃO 4885 if (hasError) { 4886 // Buscamos primero el input de nombre 4887 const inputNombre = this.querySelector('input[name="name"]'); 4888 const firstError = this.querySelector('.sta-ko'); 4889 4890 if (firstError) { 4891 // Desenfocamos lo que esté activo para evitar conflictos 4892 if (document.activeElement) document.activeElement.blur(); 4893 4894 // Hacemos scroll hacia el primer error para que el usuario vea el problema 4895 firstError.scrollIntoView({ behavior: 'smooth', block: 'center' }); 4896 // Pero ponemos el foco directamente en el campo Nombre (si existe) 4897 if (inputNombre) { 4898 setTimeout(() => { 4899 inputNombre.focus(); 4900 }, 400); 4901 } 4902 } 4903 4904 return false; // DETENER EJECUCIÃN 4905 } 4906 4907 // === ENVÃO DEL FORMULARIO (solo si NO hay errores) === 4908 const obj = { 4909 id: "Salones - " + window.hotelName, 4910 title: ["Fecha", "name", "lastname", "country", "phone", "email", "tipo de contacto", "tipo de evento", "asistentes", "fecha", "disposicion sala", "Habitaciones", "Numero habitaciones", "Restauracion", "Material audiovisual", "Comentarios", "ID"], 4911 new: [ 4912 Date.now(), 4913 form['name'].value.trim(), 4914 form['lastname'].value.trim(), 4915 form['country'].value.trim(), 4916 form['phone'].value.trim(), 4917 form['email'].value.trim(), 4918 form['contact'].value.trim(), 4919 form['event'].value.trim(), 4920 form['number_asist'].value.trim(), 4921 form['calendar'].value.trim(), 4922 form['work_day'].value.trim(), 4923 form['disposition'].value.trim(), 4924 form['rooms'].value.trim(), 4925 form['number_rooms'].value.trim(), 4926 form['restauration'].value.trim(), 4927 form['audiovisual'].value.trim(), 4928 form['mensaje'].value.trim().replace(/["']/g, ''), 4929 ], 4930 nl: { 4931 nlH: window.mailReserva, 4932 rutaH: "/images/eventos/form/nl-interna.html", 4933 subject: "Formulario de contacto", 4934 from: "[email protected]", 4935 tags: { 4936 campana: "Salones - " + window.hotelName, 4937 name: form['name'].value.trim(), 4938 lastname: form['lastname'].value.trim(), 4939 country: form['country'].value.trim(), 4940 phone: form['phone'].value.trim(), 4941 email: form['email'].value.trim(), 4942 contact: form['contact'].value.trim(), 4943 evento: form['event'].value.trim(), 4944 days: form['calendar'].value.trim(), 4945 workDay: form['work_day'].value.trim(), 4946 asistants: form['number_asist'].value.trim(), 4947 disposition: form['disposition'].value.trim(), 4948 rooms: form['rooms'].value.trim(), 4949 numberRooms: form['number_rooms'].value.trim(), 4950 restauration: form['restauration'].value.trim(), 4951 audiovisual: form['audiovisual'].value.trim(), 4952 mensaje: form['mensaje'].value.trim().replace(/["']/g, ''), 4953 url: window.parent.location.href 4954 } 4955 } 4956 }; 4957 4958 console.log('Enviando datos:', obj); 4959 4960 jQuery.ajax({ 4961 type: "POST", 4962 url: 'https://nl.booking-channel.com/CLIENTES/nl/php/inscripcion2.0.php', 4963 dataType: 'json', 4964 async: true, 4965 data: JSON.stringify(obj), 4966 success: () => {
4967 console.log('Formulario enviado correctamente'); 4968 o.querySelector('.sta-form-contacto_enviado').classList.add('sta-block'); 4969 form.reset(); 4970 o.querySelectorAll('.sta-flag').forEach(el => el.remove()); 4971 form.querySelectorAll('input, textarea').forEach(input => input.classList.remove('sta-fill')); 4972 setTimeout(() => { 4973 o.querySelector('.sta-form-contacto_enviado').classList.remove('sta-block'); 4974 }, 5000); 4975 }, 4976 error: (e) => { 4977 console.error('Error al enviar formulario:', e); 4978 } 4979 }); 4980 }); 4981 4982 // Función showError mejorada 4983 function showError(input, msg, isContainer = false) { 4984 // Evitar errores duplicados 4985 if (input.classList.contains('sta-ko')) { 4986 return; 4987 } 4988 4989 input.classList.add('sta-ko'); 4990 const div = document.createElement('span'); 4991 div.className = 'sta-error'; 4992 div.textContent = msg; 4993 input.parentElement.appendChild(div); 4994 4995 if (!isContainer) { 4996 // Para inputs normales, limpiar error en focus 4997 const clearError = function () { 4998 input.classList.remove('sta-ko'); 4999 const errorSpan = input.parentElement.querySelector('.sta-error'); 5000 if (errorSpan) { 5001 errorSpan.remove(); 5002 } 5003 input.removeEventListener('focus', clearError); 5004 input.removeEventListener('input', clearError); 5005 }; 5006 5007 input.addEventListener('focus', clearError); 5008 input.addEventListener('input', clearError); 5009 } 5010 } 5011 } 5012 5013 // === EVENTO PRINCIPAL: CLICK EN BOTÃN DE HOTEL === 5014 document.addEventListener('click', (event) => { 5015 const button = event.target.closest('.sta-resultsModuleME-eh_selection'); 5016 if (!button) return; 5017 5018 const hotelElement = button.closest('.sta-resultsModuleME-eh'); 5019 if (!hotelElement) return; 5020 5021 try { 5022 const hotelData = JSON.parse(hotelElement.getAttribute('data-hotel')); 5023 const lang = document.documentElement.lang || 'en'; 5024 const hotelName = hotelData.HotelName || ''; 5025 window.hotelName = hotelData.HotelName || ''; 5026 const hotelAddress = hotelData.HotelAddress || ''; 5027 const hotelCity = hotelData.HotelCity[lang]?.name || hotelData.HotelCity['es']?.name || hotelData.HotelCity[Object.keys(hotelData.HotelCity)[0]]?.name || ''; 5028 function getFirstValidImage(hotelData) { 5029 // Buscar el primer salon con foto valida 5030 const primerSalonValido = hotelData?.Salones?.find(salon => { 5031 const imagen = salon?.image; 5032 return imagen && !imagen.endsWith('/.jpeg') && imagen.includes('.jpeg'); 5033 }); 5034 return primerSalonValido?.image || null; 5035 }; 5036 const photoSalon = getFirstValidImage(hotelData); 5037 window.mailReserva = hotelData.HotelMail || '[email protected]'; 5038 5039 const header = document.querySelector('.sta-form-contacto-container'); 5040 const toInsert = header?.querySelector('.sta-contactModal-eh_title'); 5041 if (!toInsert) return; 5042 5043 const existingHeader = header.querySelector('.sta-form-contacto-header'); 5044 if (existingHeader) existingHeader.remove(); 5045 5046 const headerForm = document.createElement('div'); 5047 headerForm.className = 'sta-form-contacto-header'; 5048 headerForm.innerHTML = ` 5049 <div class="sta-form-contacto-header_photo"> 5050 <img src="https://${photoSalon}" alt="${hotelName}" onerror="this.style.display='none'"> 5051 </div> 5052 <div class="sta-form-contacto-header_text"> 5053 <div class="sta-resultsModuleME-eh_text">${hotelName}</div> 5054 <div class="sta-resultsModuleME-eh_text_dir">${hotelAddress}, ${hotelCity}</div> 5055 </div> 5056 `; 5057 toInsert.after(headerForm); 5058 } catch (e) { 5059 console.error('Error al cargar header:', e); 5060 } 5061 5062 o.classList.add('open'); 5063 document.body.classList.add('sta-noScroll'); 5064 5065 if (!isLoaded) { 5066 isLoaded = true; 5067 //initPhonePrefix(); 5068 cargarArchivo().then(arrayCountries => { 5069 if (Array.isArray(arrayCountries)) { 5070 cargarFormulario(o, arrayCountries); 5071 } 5072 }); 5073 loadCalendar(calendarVan); 5074 loadSelects(); 5075 } 5076 }); 5077 5078 // === Cerrar modal === 5079 buttonClose?.addEventListener('click', () => { 5080 o.classList.remove('open'); 5081 document.body.classList.remove('sta-noScroll'); 5082 }); 5083 5084 const mp = o.querySelector('.tpl-modalPolitica-eh'); 5085 const btnOpen = document.querySelector('.button-polit'); 5086 const btnClose = mp?.querySelector('.sta-modalPolitica-eh_cerrar'); 5087 btnOpen?.addEventListener('click', () => { 5088 mp?.classList.add('open'); 5089 document.body.classList.add('sta-noScroll'); 5090 }); 5091 btnClose?.addEventListener('click', (e) => { 5092 mp?.classList.remove('open'); 5093 e.preventDefault(); 5094 e.stopPropagation(); 5095 // document.body.classList.remove('sta-noScroll'); 5096 }); 5097 5098 document.addEventListener('click', (e) => { 5099 5100 if(e.target.closest('.button-polit') || e.target.closest('.lib-formLateral-calendar_salones') || e.target.closest('[class*="vanilla-calendar"]') 5101 || e.target.matches('li,li *') || e.target.closest('.sta-resultsModuleME-eh_selection')) { 5102 return; 5103 } 5104 5105 const modalContact = o.classList.contains('open') ? o : null; 5106 const modalPoliticas = o.querySelector('.tpl-modalPolitica-eh.open'); 5107 5108 const openModals = [modalContact, modalPoliticas].filter(m => m !== null); 5109 5110 if(openModals.length === 0) return; 5111 5112 let modalSuperior = openModals[0]; 5113 let zIndexMax = parseInt(getComputedStyle(modalSuperior).zIndex) || 0; 5114
5115 openModals.forEach(modal => { 5116 const zIndex = parseInt(getComputedStyle(modal).zIndex) || 0; 5117 if(zIndex > zIndexMax) { 5118 zIndexMax = zIndex; 5119 modalSuperior = modal; 5120 } 5121 }); 5122 5123 const contenidoModal = modalSuperior === modalPoliticas 5124 ? modalSuperior.querySelector('.sta-modalPolitica-eh_content, .sta-modalPolitica-eh_cerrar') 5125 : modalSuperior.querySelector('.sta-contactModal-eh_modal'); 5126 5127 if(contenidoModal && !contenidoModal.contains(e.target)) { 5128 modalSuperior.classList.remove('open'); 5129 5130 const modalsRestantes = [ 5131 document.querySelector('.tpl-contactModal-eh.open'), 5132 document.querySelector('.tpl-modalPolitica-eh.open') 5133 ].filter(m => m !== null); 5134 5135 if(modalsRestantes.length === 0) { 5136 document.body.classList.remove('sta-noScroll'); 5137 } 5138 } 5139 }); 5140 5141})(document.querySelector('.tpl-contactModal-eh'), window.hotusa && hotusa()); 5142 5143 5144 5145 5146 5147 5148(function () { 5149 window.dataLayer = window.dataLayer || []; 5150 5151 function getCookie(name) { 5152 return document.cookie 5153 .split('; ') 5154 .find(row => row.startsWith(name + '=')) 5155 ?.split('=')[1] || null; 5156 } 5157 5158 5159 function getDevice() { 5160 return /Mobi|Android/i.test(navigator.userAgent) ? 'mobile' : 'desktop'; 5161 } 5162 5163 const currentStep = window.datalayerStep?.step || 'x0'; 5164 const previousStep = sessionStorage.getItem('datalayer_prestep') || 'e0'; 5165 sessionStorage.setItem('datalayer_OldPrestep', previousStep); 5166 sessionStorage.setItem('datalayer_prestep', currentStep); 5167 5168 let customer = {}; 5169 try { 5170 customer = JSON.parse(localStorage.getItem('currency_country')) || {}; 5171 } catch (e) {} 5172 5173 const now = new Date(); 5174 const timestamp = Math.floor(now.getTime() / 1000); 5175 const dateFormatted = 5176 now.toLocaleTimeString('es-ES', { hour12: false }) + 5177 ' ' + 5178 now.toLocaleDateString('es-ES', { 5179 day: '2-digit', 5180 month: '2-digit', 5181 year: 'numeric' 5182 }); 5183 5184 const ua = navigator.userAgent; 5185 const browserName = ua.includes('Chrome') ? 'Google Chrome' : 'Other'; 5186 5187 const gaClient = getCookie('_ga'); 5188 5189 5190 window.dataLayer.push({ 5191 event: window.datalayerStep?.name || 'Sin nombre', 5192 timestamp: String(timestamp), 5193 date: dateFormatted, 5194 ga_idclient: gaClient, 5195 site: { 5196 page: location.href, 5197 lang: document.documentElement.lang?.toUpperCase() || 'ES', 5198 step: currentStep, 5199 prestep: previousStep 5200 }, 5201 customer: { 5202 CountryCode: customer.CountryCode || null, 5203 ClientIP: customer.ClientIP || null 5204 }, 5205 browser: { 5206 name: browserName, 5207 version: navigator.appVersion, 5208 os: navigator.platform, 5209 lang: navigator.language, 5210 device: getDevice(), 5211 viewport: { 5212 width: window.innerWidth, 5213 height: window.innerHeight 5214 } 5215 } 5216 }); 5217})(); 5218/** logica para boton guido -- INICIO */ 5219const createVisibilityObserver = (target, onIntersect, options = {}) => { 5220 if (!target) return null; 5221 5222 const observer = new IntersectionObserver(([entry]) => { 5223 onIntersect(entry?.isIntersecting ?? false); 5224 }, { threshold: 0, ...options }); 5225 5226 observer.observe(target); 5227 return observer; 5228}; 5229 5230const getHeaderMargin = () => { 5231 const headerSelector = 'div[class^="tpl-"][class*="header"]'; 5232 const candidates = document.querySelectorAll(headerSelector); 5233 const activeHeader = Array.from(candidates).find(el => { 5234 const isVisible = el.offsetHeight > 0; 5235 const isTopLevel = !el.parentElement.closest(headerSelector); 5236 return isVisible && isTopLevel; 5237 }); 5238 5239 return activeHeader ? `-${activeHeader.offsetHeight}px 0px 0px 0px` : '0px'; 5240}; 5241 5242const guidoManager = () => { 5243 const desktopEl = document.querySelector('.fn-guidoBubble'); 5244 const mobileEl = document.querySelector('.fn-guidoMobile'); 5245 const mainGuido = document.querySelector('.fn-guidoBtn'); 5246 5247 if (!desktopEl && !mobileEl) return; 5248 5249 const engineElement = document.getElementById('default_sygy_element_engine'); 5250 const reserveBtn = document.querySelector('.sta-reservaModal'); 5251 const altReserveBtn = document.querySelector('.tpl-showEngine-eh'); 5252 const searchBtnEvents = document.querySelector('.tpl-buttonSearchME-eh'); 5253 const BREAKPOINT = 1024; 5254 const HIDE_CLASS = 'tpl-guido-elementHide';
5255 const mediaQuery = window.matchMedia(`(min-width: ${BREAKPOINT}px)`); 5256 5257 let intObserver = null; 5258 let mutObserver = null; 5259 5260 const cleanUp = () => { 5261 intObserver?.disconnect(); 5262 mutObserver?.disconnect(); 5263 mobileEl?.style.removeProperty('--reserveBtnHeight'); 5264 }; 5265 5266 const setupReserveBtnObserver = () => { 5267 if (!mobileEl) return; 5268 5269 const checkClasses = () => { 5270 const isVisible = reserveBtn?.classList.contains('showBtn') || altReserveBtn?.classList.contains('sta-show-reserve_btn') || altReserveBtn?.classList.contains('sta-showButton'); 5271 mobileEl.style.setProperty('--reserveBtnHeight', isVisible ? '60px' : '0px'); 5272 5273 var footer = document.querySelector('.tpl-footer2-eh'); 5274 if (!!footer) { 5275 footer.style.setProperty('margin-bottom', isVisible ? '124px' : '60px'); 5276 } 5277 5278 5279 }; 5280 checkClasses(); 5281 5282 mutObserver = new MutationObserver(checkClasses); 5283 5284 const config = { attributes: true, attributeFilter: ['class'] }; 5285 5286 if (reserveBtn) mutObserver.observe(reserveBtn, config); 5287 if (altReserveBtn) mutObserver.observe(altReserveBtn, config); 5288 }; 5289 5290 const applyBehavior = (isDesk) => { 5291 cleanUp(); 5292 5293 if (isDesk && desktopEl) { 5294 mobileEl?.classList.add(HIDE_CLASS); 5295 5296 if (!mainGuido) { 5297 desktopEl.classList.remove(HIDE_CLASS); 5298 } else { 5299 intObserver = createVisibilityObserver(mainGuido, (isVisible) => { 5300 desktopEl.classList.toggle(HIDE_CLASS, isVisible); 5301 }, { rootMargin: getHeaderMargin() }); 5302 } 5303 } 5304 else if (!isDesk && mobileEl) { 5305 desktopEl?.classList.add(HIDE_CLASS); 5306 const hideReserveBtn = engineElement 5307 ? !reserveBtn?.classList.contains('showBtn') || !altReserveBtn?.classList.contains('sta-show-reserve_btn') : !searchBtnEvents; 5308 5309 if (hideReserveBtn) mobileEl.style.setProperty('--reserveBtnHeight', '0px'); 5310 5311 if (!searchBtnEvents) { 5312 setupReserveBtnObserver(); 5313 } 5314 5315 if (!mainGuido) { 5316 mobileEl.classList.remove(HIDE_CLASS); 5317 } else { 5318 intObserver = createVisibilityObserver(mainGuido, (isVisible) => { 5319 mobileEl.classList.toggle(HIDE_CLASS, isVisible); 5320 }, { rootMargin: getHeaderMargin() }); 5321 } 5322 } 5323 }; 5324 5325 applyBehavior(mediaQuery.matches); 5326 mediaQuery.addEventListener('change', e => applyBehavior(e.matches)); 5327}; 5328 5329guidoManager(); 5330/** logica para boton guido -- FIN */ 5331/** TPL-BREADCRUMBS-EH - SEO BREADCRUMBS*/ 5332(function(o, seo){ 5333 5334 var allBreadcrumbs = document.querySelectorAll('.tpl-breadCrumbs-eh'); 5335 if (allBreadcrumbs.length > 0) { 5336 for (var j = 0; j < allBreadcrumbs.length - 1; j++) { 5337 allBreadcrumbs[j].remove(); 5338 } 5339 // Reasignamos "o" para que se muestre el último 5340 o = allBreadcrumbs[allBreadcrumbs.length - 1]; 5341 } 5342 5343 if( !o ) return false; 5344 5345 // Verificamos si NO tiene la clase 'v2' 5346 if( !o.classList.contains('v2') ){ 5347 o.style.display='none'; // Oculta el viejo 5348 5349 // Reasignamos "o" al que sà tiene .v2 5350 o = document.querySelector('.tpl-breadCrumbs-eh.v2'); 5351 if( !o ) return false; 5352 } 5353 5354 var migas = o.querySelectorAll('#breadCrumbsContainer .breadCrumbsElement'), 5355 datos = { 5356 "@context" : "http://schema.org/", 5357 "@type" : "BreadcrumbList", 5358 itemListElement : [] 5359 }, 5360 control = {"#":true}, 5361 isHome = window.header4_fichaHome, 5362 script = document.createElement('script'), 5363 urlAct = location.origin + location.pathname, 5364 urlSeo = seo && seo.hotel && seo.hotel.url ? seo.hotel.url : false; 5365 5366 // Array con los textos a ocultar 5367 var ocultarArray = ["Instalaciones Y Servicios", "Facilities And Services", "Strutture E Servizi", "Installations Et Services", "Ausstattung Und Leistungen", "Instalações E Serviços", "УдобÑÑва РУÑлÑги", "Faciliteiten En Service"]; 5368 5369 if( urlSeo === urlAct ) o.classList.add('sta-init'); 5370 5371 for (var i = 0; i < migas.length; i++) { 5372 (function( p, arr, last ){ 5373 var m = p.querySelector('a'), 5374 url = m.getAttribute('href'), 5375 texto = m.textContent.trim(), // Obtiene el texto del enlace 5376 _tmp = { 5377 "@type" : "ListItem", 5378 position : arr.length+1, 5379 item : { 5380 name: m.text, 5381 "@id" : url 5382 } 5383 }; 5384 5385 // Verificar si el texto del enlace está en el array de textos a ocultar 5386 if (ocultarArray.includes(texto)) { 5387 p.remove(); // Ocultar el elemento si coincide 5388 return; // Salir de la función actual para que no procese más este elemento 5389 } 5390 5391 if( last ){ 5392 _tmp.item["@id"] = location.origin + location.pathname; 5393 5394 m.setAttribute('aria-current', 'page'); 5395 m.setAttribute('tabindex', '-1'); 5396 m.style.pointerEvents = 'none'; 5397 m.style.cursor = 'default'; 5398 m.setAttribute('href', '...'); 5399 url = ''; 5400 } else { 5401 _tmp.item["@id"] = url; 5402 }; 5403 5404 // Cambiamos la condición para que solo le aplique la clase al primer elemento (i === 0) 5405 if( i === 0 ) p.classList.add('sta-home'); 5406 5407 if( url == '#' ) m.addEventListener('click' ,function(e){ e.preventDefault(); }) 5408 5409 if( !control[ _tmp.item['@id'] ] ){ 5410 control[ _tmp.item['@id'] ] = true; 5411 if( url != '#' ) arr.push(_tmp); 5412 }; 5413 })( migas[i], datos.itemListElement, i == migas.length-1 ); 5414 }; 5415 5416 5417 if( isHome ){ 5418 var _tmp = JSON.parse( JSON.stringify( datos.itemListElement[datos.itemListElement.length - 1] ) ); 5419 _tmp.position++; 5420 _tmp.item["@id"] = _tmp.item["@id"] + '?hotel'; 5421 5422 datos.itemListElement.push( _tmp ); 5423 }; 5424 5425 if( parseInt(seo.hotel.stars) ){ 5426 var n = parseInt( seo.hotel.stars ), 5427 strn = ' '; 5428 5429 for (var i = 0; i < n; i++) strn += "\u2B50"; 5430 5431 datos.itemListElement[datos.itemListElement.length - 2].item.name += strn; 5432 } else { 5433 datos.itemListElement[datos.itemListElement.length - 2].item.name += ' - '+ seo.hotel.stars; 5434 }; 5435 5436 if( datos.itemListElement.length ){ 5437 script.type = "application/ld+json"; 5438 script.title = "BreadcrumbList"; 5439 script.innerHTML = JSON.stringify(datos); 5440 var h = document.querySelector('head'); 5441 h.appendChild(script); 5442 }; 5443})(document.querySelector('.tpl-breadCrumbs-eh'), window.dataSeo ); 5444 5445//#region | Lógica para ocultar breadcrumbs en ST si el usuario está logueado 5446(function ocultarBreadcrumbsST() { 5447 const KEY_LOGIN = 'login_user';
5448 const VALOR_NO_LOGIN = 'NoLogin'; 5449 5450 const main = document.querySelector('main'); 5451 if (main?.dataset.id !== '105526576') { 5452 return; 5453 } 5454 5455 const breadcrumbs = document.querySelector('.tpl-breadCrumbs-eh'); 5456 if (!breadcrumbs) return; 5457 5458 function checkLogin() { 5459 let loginUsuario = null; 5460 try { 5461 const storedData = sessionStorage.getItem(KEY_LOGIN); 5462 if (storedData) { 5463 loginUsuario = JSON.parse(storedData); 5464 } 5465 } catch (e) { 5466 console.warn('Error parseando login_user de sessionStorage', e); 5467 } 5468 5469 breadcrumbs.style.display = 5470 (loginUsuario?.name && loginUsuario.name !== VALOR_NO_LOGIN) 5471 ? 'none' 5472 : ''; 5473 } 5474 5475 checkLogin(); 5476 5477 const setItem = sessionStorage.setItem; 5478 sessionStorage.setItem = function (key, value) { 5479 setItem.call(this, key, value); 5480 if (key === KEY_LOGIN) checkLogin(); 5481 }; 5482 5483 const removeItem = sessionStorage.removeItem; 5484 sessionStorage.removeItem = function (key) { 5485 removeItem.call(this, key); 5486 if (key === KEY_LOGIN) checkLogin(); 5487 }; 5488 5489 const clear = sessionStorage.clear; 5490 sessionStorage.clear = function () { 5491 clear.call(this); 5492 checkLogin(); 5493 }; 5494 5495 window.addEventListener('storage', function (e) { 5496 if (e.key === KEY_LOGIN || e.key === null) { 5497 checkLogin(); 5498 } 5499 }); 5500})(); 5501//#endregion | Lógica para ocultar breadcrumbs en ST si el usuario está logueado*/ 5502 5503//#region | Logica para traducir Surname a LastName y Name a First Name 5504(function translateSurnameandLastName() { 5505 if (window.location.hostname !== 'www.eurostarshotels.us') return; 5506 5507 // Traduce las etiquetas asociadas a un input de Name a First Name 5508 const replaceInputLabels = (input) => { 5509 const siblings = input.parentNode ? input.parentNode.children : []; 5510 for (let j = 0; j < siblings.length; j++) { 5511 const sibling = siblings[j]; 5512 if (sibling === input) continue; 5513 const text = sibling.textContent ? sibling.textContent.trim() : ''; 5514 if (text === 'Name*') { 5515 sibling.textContent = 'First Name*'; 5516 } else if (text === 'Name') { 5517 sibling.textContent = 'First Name'; 5518 } else if (text === 'Company Contact Name*') { 5519 sibling.innerHTML = '<strong>Company Contact First Name*</strong>'; 5520 } else if (text === 'Company Contact Name') { 5521 sibling.innerHTML = '<strong>Company Contact First Name</strong>'; 5522 } 5523 } 5524 }; 5525 5526 // Regla única de traducción "Surname" -> "Last Name", usada tanto en texto como en atributos 5527 const translateSurnameText = (text) => text.replace(/\bSurname\b/gi, 'Last Name'); 5528 5529 const replaceText = (node) => { 5530 if (node.nodeType === Node.TEXT_NODE) { 5531 const translatedText = translateSurnameText(node.textContent); 5532 if (translatedText !== node.textContent) { 5533 node.textContent = translatedText; 5534 } 5535 } else if (node.nodeType === Node.ELEMENT_NODE) { 5536 ['placeholder', 'aria-label', 'title', 'alt'].forEach(attr => { 5537 if (node.hasAttribute(attr)) { 5538 const attrVal = node.getAttribute(attr); 5539 if (attrVal) { 5540 const translatedAttrVal = translateSurnameText(attrVal); 5541 // Solo actualiza el atributo si hubo algún cambio real 5542 if (translatedAttrVal !== attrVal) { 5543 node.setAttribute(attr, translatedAttrVal); 5544 } 5545 } 5546 } 5547 }); 5548 // Traducir Name a First Name en las etiquetas de los inputs 5549 if (node.tagName === 'INPUT') { 5550 replaceInputLabels(node); 5551 } 5552 // Recorrer hijos 5553 node.childNodes.forEach(replaceText); 5554 } 5555 }; 5556 5557 // Ejecución inicial 5558 replaceText(document.body); 5559 5560 // Observador para detectar cuando la web pinte el formulario más tarde 5561 const observer = new MutationObserver((mutations) => { 5562 mutations.forEach((mutation) => {
5563 mutation.addedNodes.forEach((node) => { 5564 replaceText(node); 5565 }); 5566 // Si muta el texto de un nodo que ya existÃa 5567 if (mutation.type === 'characterData' || mutation.type === 'attributes') { 5568 replaceText(mutation.target); 5569 } 5570 }); 5571 }); 5572 5573 observer.observe(document.body, { 5574 childList: true, 5575 subtree: true, 5576 attributes: true, 5577 characterData: true 5578 }); 5579})(); 5580//#endregion | Lógica para traducir Name a First Name */ 5581
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.