1 2 3var getClosest = function (sel, ele) { 4 var closest = null; 5 6 // Absolute 7 if ($(sel).length === 1) { 8 return $(sel); 9 } 10 11 // Relative 12 if ($(sel, ele).length === 1) { 13 return $(sel, ele); 14 } 15 16 ele.parents().each(function () { 17 if (closest) { 18 return; 19 } 20 21 if ($(sel, $(this)).length >= 1) { 22 closest = $(sel, $(this)); 23 } 24 }); 25 26 return closest ? closest : $(); 27}; 28 29// burger 30var burger = (function () { 31 var burgers = []; 32 var load = function () { 33 var burger = document.querySelectorAll('[data-type="menu"]'); 34 35 for (var i = 0, len = burger.length; i < len; i++) { 36 burger[i].onclick = function () { 37 var header = document.getElementsByTagName('header')[0]; 38 39 40 if (header.classList) { 41 header.classList.toggle("open"); 42 } else { 43 // For IE9 44 var classes = this.className.split(" "); 45 var i = classes.indexOf("open"); 46 47 if (i >= 0) 48 this.splice(i, 1); 49 else 50 classes.push("open"); 51 this.className = classes.join(" "); 52 } 53 }; 54 burgers.push(burger[i]); 55 } 56 }; 57 var reload = function () { 58 var w = window.innerWidth; 59 if (w > 992) { 60 document.getElementsByTagName('header')[0].classList.remove('open'); 61 var burger = document.querySelectorAll('[data-type="menu"]'); 62 for (var i = 0, len = burger.length; i < len; i++) { 63 burger[i].classList.remove('open'); 64 65 } 66 } 67 }; 68 69 return { 70 init: function () { 71 load(); 72 }, 73 resize: function () { 74 if (document.querySelectorAll('[data-type="menu"]').length > 0) { 75 reload(); 76 } 77 } 78 } 79 80}()); 81 82// toggle 83var toggle = (function () { 84 var toggles = []; 85 var load = function () { 86 var toggle = document.querySelectorAll('[data-type="toggle"]'); 87 for (var i = 0, len = toggle.length; i < len; i++) { 88 toggle[i].onclick = function () { 89 if (this.parentNode.classList) { 90 this.parentNode.classList.toggle("open"); 91 } 92 else { 93 // For IE9 94 var classes = this.parentNode.className.split(" "); 95 var i = classes.indexOf("open"); 96 97 if (i >= 0) 98 classes.splice(i, 1); 99 else 100 classes.push("open"); 101 this.parentNode.className = classes.join(" "); 102 } 103 }; 104 toggles.push(toggle[i]); 105 106 } 107 }; 108 return { 109 init: function () { 110 load(); 111 } 112 } 113 114}()); 115 116// socialShare 117var socialShare = (function () { 118 var objs = []; 119 120 var getByEle = function (ele) { 121 var theObj = null; 122 123 objs.forEach(function (obj) { 124 if (obj.ele[0] === ele[0]) { 125 theObj = obj; 126 } 127 }); 128 129 return theObj; 130 }; 131 132 var executeTrack = function (service, urlToShare) { 133 var serviceStr; 134 135 // Ignore if not defined 136 if (typeof socialAction === 'undefined') { 137 return; 138 } 139 140 if (service === 'twitter') {// Twitter 141 serviceStr = 'twitter'; 142 } 143 else if (service === 'google') {// Google 144 serviceStr = 'google plus'; 145 } 146 else if (service === 'whatsapp') {// Whatsapp 147 serviceStr = 'whatsapp'; 148 } 149 else if (service === 'linkedin') {// Linkedin 150 serviceStr = 'linkedin'; 151 } 152 else if (service === 'pinterest') {// Pinterest 153 serviceStr = 'pinterest'; 154 } 155 else if (service === 'facebook') {// Facebook 156 serviceStr = 'facebook'; 157 } 158 else if (service === 'tiktok') {// TikTok 159 serviceStr = 'tiktok'; 160 } 161 else if (service === 'messenger-desktop' || service === 'messenger-mobile') {// Facebook Messenger 162 serviceStr = 'messenger'; 163 } 164 165 socialAction(serviceStr, 'compartir', urlToShare); 166 }; 167 168 var executeShareBrowser = function (service, urlToShare, text, postText, isApp) { 169 var url; 170 var width = null; 171 var height; 172 var type = 'window'; 173 174 if (service === 'twitter') {// Twitter 175 var items = []; 176 177 url = 'https://twitter.com/intent/tweet?text='; 178 179 if (text) { 180 items.push(text); 181 } 182 183 items.push(urlToShare); 184 185 if (postText) { 186 items.push(postText); 187 } 188 189 url += items.join(' '); 190 191 width = 650; 192 height = 360; 193 } 194 else if (service === 'google') {// Google 195 url = 'https://plus.google.com/share?hl=' + document.documentElement.lang + '&url=' + urlToShare; 196 width = 500; 197 height = 500; 198 } 199 else if (service === 'whatsapp') {// Whatsapp 200 url = 'whatsapp://send?text='; 201 202 if (text) { 203 url += text; 204 } 205 206 url += ' ' + encodeURI(urlToShare); 207 208 type = 'redirect'; 209 210 } 211 else if (service === 'linkedin') {// Linkedin 212 url = 'https://www.linkedin.com/shareArticle?mini=true&url=' + encodeURI(urlToShare); 213 width = 520; 214 height = 570; 215 } 216 else if (service === 'pinterest') {// Pinterest 217 url = 'https://pinterest.com/pin/create/button/?url=' + encodeURI(urlToShare); 218 url += '&description=' + text; 219 220 width = 734; 221 height = 535; 222 } 223 else if (service === 'tiktok') {// TikTok 224 url = 'https://www.tiktok.com/?url=' + encodeURI(urlToShare); 225 url += '&description=' + text; 226 227 width = 734; 228 height = 535; 229 } 230 else if (service === 'messenger-desktop') {// Facebook Messenger Desktop 231 url = 'http://www.facebook.com/dialog/send?app_id=' + zProperties.fbAppId + '&link=' + urlToShare + '&redirect_uri='
231+ urlToShare; 232 } 233 else if (service === 'messenger-mobile') {// Facebook Messenger Mobile 234 url = 'fb-messenger://share?link=' + encodeURI(urlToShare); 235 236 type = 'redirect'; 237 } 238 else if (service === 'facebook') {// Facebook 239 url = 'http://www.facebook.com/sharer/sharer.php?u=' + urlToShare; 240 width = 900; 241 height = 500; 242 } 243 244 if (type === 'redirect') { 245 document.location.href = url; 246 } 247 else { 248 if (isApp) {// App 249 window.open(url, '_system');// Catched by PhoneGap 250 } 251 else {// Browser 252 if (width) { 253 window.open(url, service, 'toolbar=0,status=0,width=' + width + ',height=' + height); 254 } 255 else { 256 window.open(url, service); 257 } 258 } 259 } 260 }; 261 262 var executeShareApp = function (service, urlToShare, text, postText) { 263 var doWeb = false; 264 265 async.series([ 266 function (callback) { 267 if (service === 'twitter') {// Twitter 268 window.plugins.socialsharing.shareViaTwitter(text, null, urlToShare, null, function () {// Error 269 doWeb = true; 270 271 callback(); 272 }); 273 } 274 else if (service === 'google') {// Google 275 callback(); 276 } 277 else if (service === 'whatsapp') {// Whatsapp 278 window.plugins.socialsharing.shareViaWhatsApp(text, null, urlToShare, null, function () {// Error 279 doWeb = true; 280 281 callback(); 282 }); 283 } 284 else if (service === 'linkedin') {// Linkedin 285 callback(); 286 } 287 else if (service === 'pinterest') {// Pinterest 288 callback(); 289 } 290 else if (service === 'messenger-desktop') {// Facebook Messenger Desktop 291 service = 'messenger-mobile';// Desktop url is not available in mobile/tablet 292 doWeb = true; 293 294 callback(); 295 } 296 else if (service === 'messenger-mobile') {// Facebook Messenger Mobile 297 doWeb = true; 298 299 callback(); 300 } 301 else if (service === 'facebook') {// Facebook 302 window.plugins.socialsharing.shareViaFacebook(text, null, urlToShare, null, function () {// Error 303 doWeb = true; 304 305 callback(); 306 }); 307 } 308 } 309 ], function () { 310 // Share with web method 311 if (doWeb) { 312 executeShareBrowser(service, urlToShare, text, postText, true); 313 } 314 }); 315 }; 316 317 var execute = function (buttonEle, urlToShare, text, postText, mobileOn) { 318 var service; 319 320 if (buttonEle.getAttribute('data-share-button') === 'twitter') {// Twitter 321 service = 'twitter'; 322 } 323 else if (buttonEle.getAttribute('data-share-button') === 'google') {// Google 324 service = 'google'; 325 } 326 else if (buttonEle.getAttribute('data-share-button') === 'whatsapp') {// Whatsapp 327 service = 'whatsapp'; 328 } 329 else if (buttonEle.getAttribute('data-share-button') === 'linkedin') {// Linkedin 330 service = 'linkedin'; 331 } 332 else if (buttonEle.getAttribute('data-share-button') === 'pinterest') {// Pinterest 333 service = 'pinterest'; 334 } 335 else if (buttonEle.getAttribute('data-share-button') === 'tiktok') {// TikTok 336 service = 'tiktok'; 337 } 338 else if (buttonEle.getAttribute('data-share-button') === 'messenger') {// Facebook Messenger 339 if (mobileOn && Modernizr.mq('(max-width: ' + mobileOn + 'px)')) { 340 service = 'messenger-mobile'; 341 } 342 else { 343 service = 'messenger-desktop'; 344 } 345 } 346 else {// Facebook 347 service = 'facebook'; 348 } 349 350 if (window.plugins && window.plugins.socialsharing) {// App 351 executeShareApp(service, urlToShare, text, postText); 352 } 353 else {// Browser 354 executeShareBrowser(service, urlToShare, text, postText, false); 355 } 356 357 executeTrack(service, urlToShare); 358 }; 359 360 var start = function () { 361 var component = document.querySelectorAll('[data-share-url]'); 362 component.forEach(function (element, index) { 363 364 var url = element.getAttribute('data-share-url'); 365 var text = element.getAttribute('data-share-text') ? element.getAttribute('data-share-text') : null; 366 var postText = element.getAttribute('data-share-posttext') ? element.getAttribute('data-share-posttext') : null; 367 var mobileOn = null; 368 /*console.log("aqui"); 369 console.log("url: "+ url); 370 console.log("text: "+ text);*/ 371 // Mobile-on 372 if (element.getAttribute('data-share-mobileon-xs') !== undefined) { 373 mobileOn = 767; 374 } 375 if (element.getAttribute('data-share-mobileon-sm') !== undefined) { 376 mobileOn = 991; 377 } 378 if (element.getAttribute('data-share-mobileon-md') !== undefined) { 379 mobileOn = 1199; 380 } 381 382 // Ignore already added
383 if (getByEle(element)) { 384 return; 385 } 386 387 objs.push({ 388 ele: element 389 }); 390 391 if (element.getAttribute('data-share-button')) {// It's a button 392 console.log('It\'s a button'); 393 /*element.click(function(e) { 394 e.preventDefault(); 395 execute(element, url, text, postText, mobileOn); 396 });*/ 397 398 this.addEventListener('click', function () { 399 execute(element, url, text, postText, mobileOn); 400 }, false); 401 402 } 403 else {// It's a container 404 /*console.log('It\'s a container');*/ 405 var aux = element.querySelectorAll('[data-share-button]'); 406 aux.forEach(function (element, index) { 407 //console.log(index); 408 element.addEventListener('click', function () { 409 execute(element, url, text, postText, mobileOn); 410 }, false); 411 }); 412 413 /*element.querySelectorAll('[data-share-button]', element).click(function(e) { 414 //$('[data-share-button]', $(this)).click(function(e) { 415 e.preventDefault(); 416 417 execute(element, url, text, postText, mobileOn); 418 });*/ 419 } 420 }); 421 }; 422 423 return { 424 init: function () { 425 start(); 426 }, 427 reload: function () { 428 start(); 429 }, 430 execute: function (ele, url, text, postText) { 431 var mobileOn = null; 432 433 // Mobile-on 434 if (ele.getAttribute('data-share-mobileon-xs') !== undefined) { 435 mobileOn = 767; 436 } 437 if (ele.getAttribute('data-share-mobileon-sm') !== undefined) { 438 mobileOn = 991; 439 } 440 if (ele.getAttribute('data-share-mobileon-md') !== undefined) { 441 mobileOn = 1199; 442 } 443 444 execute(ele, url, text, postText, mobileOn); 445 } 446 }; 447}()); 448 449// carousel 450var carousel = (function () { 451 var carousels = []; 452 var load = function (startIndex) { 453 var carousel = document.querySelectorAll('[data-type="carousel"]'); 454 for (var i = 0, len = carousel.length; i < len; i++) { 455 var numItemsXs = carousel[i].getAttribute('data-carousel-items-xs') ? carousel[i].getAttribute('data-carousel-items-xs') : 1; 456 var numItems = carousel[i].getAttribute('data-carousel-items') ? carousel[i].getAttribute('data-carousel-items') : 1; 457 //var center = carousel[i].getAttribute('data-carousel-center') ? carousel[i].getAttribute('data-carousel-center'): 0; 458 var fixedWidthXs; 459 if (numItemsXs == 1) { 460 fixedWidthXs = 235; 461 } 462 else { 463 fixedWidthXs = false; 464 } 465 var fixedWidth; 466 if (numItems == 1) { 467 fixedWidth = 200; 468 } 469 else { 470 fixedWidth = false; 471 } 472 473 var className = "o-carousel-" + i; 474 console.log(className + "/ numItems: " + numItems); 475 476 carousel[i].classList.add(className); 477 var ele = tns({ 478 container: '.' + className + ' .o-carousel__wrap', 479 items: numItemsXs, 480 //fixedWidth: fixedWidthXs, 481 //slideBy: 'page', 482 autoplay: false, 483 gutter: 15, 484 mouseDrag: true, 485 nav: true, 486 navPosition: 'bottom', 487 controlsText: 488 [ 489 '<svg aria-hidden="true" focusable="false" data-prefix="fal" data-icon="angle-left" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 192 512">\n' + 490 '<path fill="#05DCDC" d="M25.1 247.5l117.8-116c4.7-4.7 12.3-4.7 17 0l7.1 7.1c4.7 4.7 4.7 12.3 0 17L64.7 256l102.2 100.4c4.7 4.7 4.7 12.3 0 17l-7.1 7.1c-4.7 4.7-12.3 4.7-17 0L25 264.5c-4.6-4.7-4.6-12.3.1-17z" class=""></path>\n' + 491 '</svg>', 492 '<svg aria-hidden="true" focusable="false" data-prefix="fal" data-icon="angle-left" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 192 512">\n' + 493 '<path fill="#05DCDC" d="M25.1 247.5l117.8-116c4.7-4.7 12.3-4.7 17 0l7.1 7.1c4.7 4.7 4.7 12.3 0 17L64.7 256l102.2 100.4c4.7 4.7 4.7 12.3 0 17l-7.1 7.1c-4.7 4.7-12.3 4.7-17 0L25 264.5c-4.6-4.7-4.6-12.3.1-17z" class=""></path>\n' + 494 '</svg>', 495 ], 496 speed: 300, 497 edgePadding: 35,
498 //controlsContainer:'.carousel' 499 responsive: { 500 768: 501 { 502 edgePadding: 90, 503 gutter: 20, 504 items: numItems 505 //fixedWidth: fixedWidth 506 } 507 }, 508 startIndex: startIndex ? startIndex : 0 509 }); 510 511 carousel[i] = ele; 512 513 carousels.push(carousel[i]); 514 515 } 516 }; 517 var reload = function () { 518 //var carousel = document.querySelectorAll('[data-type="carousel"]'); 519 for (var i = 0, len = carousels.length; i < len; i++) { 520 for (var i = 0, len = this.carousel.length; i < len; i++) { 521 this.carousel[i].destroy(); 522 this.carousel[i] = this.carousel[i].rebuild(); 523 } 524 } 525 }; 526 return { 527 init: function (startIndex) { 528 load(startIndex); 529 }, 530 resize: function () { 531 reload(); 532 } 533 } 534})(); 535 536 537// slider 538var slides = []; 539var slider = (function () { 540 var load = function () { 541 var slide = document.querySelectorAll('[data-type="slider"]'); 542 for (var i = 0, len = slide.length; i < len; i++) { 543 var className = "o-slider-" + i; 544 slide[i].classList.add(className); 545 slides[i] = tns({ 546 container: '.' + className + ' .o-slider__wrap', 547 autoplay: false, 548 items: 1, 549 speed: 300, 550 swipeAngle: 30, 551 gutter: 5, 552 mouseDrag: true, 553 loop: false, 554 nav: false, 555 controls: false 556 }); 557 slides.push(slides[i]); 558 } 559 }; 560 return { 561 init: function () { 562 console.log('slider iniciado'); 563 load(); 564 } 565 } 566})(); 567 568// scrollVisible 569var headVisible = (function () { 570 571 572 return { 573 init: function () { 574 const header = document.querySelector('header'); 575 576 window.addEventListener("scroll", function () { 577 const ele = document.getElementById('video'); 578 //console.log("eel" + ele.scrollHeight); 579 if (ele) { 580 if (window.scrollY < ele.scrollHeight) { 581 header.classList.add("fixed"); 582 } else { 583 header.classList.remove("fixed"); 584 } 585 } 586 }); 587 588 } 589 }; 590}()); 591 592// expo 593var expo = (function () { 594 var exposition = []; 595 var load = function () { 596 var expo = document.querySelectorAll('[data-type="expo"]');
597 for (var i = 0, len = expo.length; i < len; i++) { 598 599 600 var className = "o-expo-" + i; 601 //console.log(className+ "/ numItems: "+numItems); 602 var ele = expo[i]; 603 ele.classList.add(className); 604 $(ele).slick({ 605 focusOnSelect: true, 606 infinite: false, 607 arrows: false, 608 dots: true, 609 autoplay: false, 610 speed: 1100, 611 slidesToShow: 3, 612 slidesToScroll: 3, 613 centerMode: true, 614 mobileFirst: true, 615 //initialSlide: 1, 616 variableWidth: true 617 }); 618 619 exposition.push(expo[i]); 620 621 } 622 }; 623 624 return { 625 init: function () { 626 load(); 627 } 628 629 } 630})(); 631 632//expoTimeline 633var expoTimeline = (function () { 634 var expoLines = []; 635 var load = function (startIndex) { 636 var expoLine = document.querySelectorAll('[data-type="expoLine"]');
637 for (var i = 0, len = expoLine.length; i < len; i++) { 638 var className = "o-expoLine-" + i; 639 console.log(className + "/ numItems: " + i); 640 var ele = expoLine[i]; 641 var hasChanged; 642 643 ele.classList.add(className); 644 $(ele).slick({ 645 focusOnSelect: true, 646 infinite: true, 647 arrows: true, 648 dots: true, 649 autoplay: false, 650 speed: 1100, 651 slidesToShow: 3, 652 slidesToScroll: 3, 653 centerMode: true, 654 mobileFirst: true, 655 initialSlide: startIndex ? startIndex : 0,//Math.floor(Math.random() * 20), // slider random 656 variableWidth: true 657 }); 658 659 $(ele).on('beforeChange', function (event, slick, currentSlide, nextSlide) { 660 var tl = gsap.timeline(); 661 var eList = ele.querySelector('.slick-list'); 662 // Determine if slide has changed 663 if (currentSlide === nextSlide) { 664 hasChanged = false; 665 666 } 667 else { 668 hasChanged = true; 669 } 670 671 // Skip if slide has not changed 672 if (!hasChanged) { 673 return; 674 } 675 676 ele.querySelector('.slick-prev').style.opacity = 0; 677 ele.querySelector('.slick-next').style.opacity = 0; 678 ele.querySelectorAll('.c-card-stand__txt').forEach(function (e) { 679 e.style.opacity = 0; 680 }); 681 682 tl.to(eList, { 683 transform: 'scale(0.8)', 684 duration: 0.4, 685 ease: 'power1.out' 686 }); 687 688 tl.to(eList, { 689 transform: 'scale(1)', 690 duration: 0.7, 691 ease: 'power1.in' 692 }); 693 }); 694 695 $(ele).on('afterChange', function () { 696 // Skip if slide has not changed 697 if (!hasChanged) { 698 return; 699 } 700 701 ele.querySelector('.slick-prev').style.opacity = 1; 702 ele.querySelector('.slick-next').style.opacity = 1; 703 ele.querySelector('.slick-slide.slick-current .c-card-stand__txt').style.opacity = 1; 704 }); 705 706 expoLines.push(expoLine[i]); 707 } 708 }; 709 710 return { 711 init: function (startIndex) { 712 load(startIndex); 713 } 714 }; 715})(); 716 717 718//timeline 719var timeline = (function () { 720 var timelines = []; 721 var load = function () { 722 var timeline = document.querySelectorAll('[data-type="timeline"]'); 723 for (var i = 0, len = timeline.length; i < len; i++) { 724 725 726 var className = "o-timeline-" + i; 727 //console.log(className+ "/ numItems: "+numItems); 728 var ele = timeline[i]; 729 ele.classList.add(className); 730 $(ele).slick({ 731 focusOnSelect: true, 732 infinite: false, 733 arrows: false, 734 dots: false, 735 autoplay: false, 736 speed: 1100, 737 slidesToShow: 3, 738 slidesToScroll: 3, 739 centerMode: true, 740 mobileFirst: true, 741 //initialSlide: 1, 742 variableWidth: true 743 }); 744 745 timelines.push(timeline[i]); 746 747 } 748 }; 749 750 return { 751 init: function () { 752 load(); 753 } 754 } 755})(); 756 757// tab 758var tab = (function () { 759 var tabs = []; 760 var load = function () { 761 $('[data-type="tab"]').each(function () { 762 763 var tab = { 764 ele: $(this), 765 disableOn: null, 766 buttonBackItem: $(this).data('tab-button-back') ? $(this).data('tab-button-back') : null, 767 buttonBackItemClass: $(this).data('tab-button-back-class') ? $(this).data('tab-button-back-class') : null, 768 activeItem: $(this).data('tab-item-active') ? $(this).data('tab-item-active') : null, 769 className: $(this).data('tab-active-class') 770 771 }; 772 773 if ($(this).data('tab-disableon-xs') !== undefined) { 774 tab.disableOn = 767; 775 } 776 if ($(this).data('tab-disableon-sm') !== undefined) { 777 tab.disableOn = 991; 778 } 779 if ($(this).data('tab-disableon-md') !== undefined) { 780 tab.disableOn = 1199; 781 } 782 // Ignore if container is disabled 783 /*if (tab.disableOn && Modernizr.mq('(max-width: ' + tab.disableOn + 'px)')) { 784 // Oculto el botón volver si está inactivo 785 $(tab.buttonBackItemClass).hide(); 786 return; 787 }*/ 788 789 // Initial 790 tab.ele.each(function () { 791 var container = $(this); 792 var className = tab.className; 793 var activeItem = tab.activeItem; 794 var buttonBackItem = tab.buttonBackItem; 795 var buttonBackItemClass = tab.buttonBackItemClass; 796 var oculta = true; 797 798 // Initial active class 799 $('[data-tab-content=' + activeItem + ']').addClass(className); 800 801 // Handle active class 802 $('[data-tab-item]', container).click(function (e) { 803 e.preventDefault(); 804 805 // autoclose 806 var autoclose = $(this).attr("data-tab-autoclose") && $(this).hasClass(className); 807 808 // Remove class in all items 809 $('[data-tab-item]', container).removeClass(className); 810 $('[data-tab-content]', container).removeClass(className); 811 812 // Add active class 813 var activo = $(this).attr('data-tab-item'); 814 $('[data-tab-content=' + activo + ']', container).addClass(className); 815 $('[data-tab-item=' + activo + ']', container).addClass(className); 816 817 var carousel = ($('[data-tab-content=' + activo + '] [data-actas="carousel"]', container));
818 819 var $el = carousel; 820 var $elClean = $el.clone(); 821 822 823 $elClean.find('.slick-list').children().unwrap(); 824 $elClean.find('.slick-track').children().unwrap(); 825 $elClean.find('.slick-slide').children().unwrap(); 826 $elClean.find('.slides').removeClass('slick-slider'); 827 $elClean.find('.slides').removeClass('slick-initialized'); 828 $elClean.find('.slides > div:not(.item)').children().unwrap(); 829 $elClean.find('.nav a') 830 .removeClass('slick-arrow') 831 .removeClass('slick-disabled'); 832 //.find('.clone, .flex-direction-nav, .navigation, .flex-control-nav') 833 //.remove() 834 //.end() 835 $elClean.find('*').removeAttr('aria-disabled'); 836 $elClean.find('*').removeAttr('style').removeClass(function (index, css) { 837 // If element is SVG css has an Object inside (?) 838 if (typeof css === 'string') { 839 return (css.match(/\bflex\S+/g) || []).join(' '); 840 } 841 }); 842 843 $elClean.insertBefore($el); 844 $el.remove(); 845 846 carousel.init(); 847 848 // buttonBack 849 if (activo == activeItem && oculta) { 850 $(buttonBackItemClass).hide(); 851 oculta = false; 852 } 853 else { 854 $(buttonBackItemClass).show(); 855 oculta = true; 856 } 857 858 // autoclose 859 if (autoclose) { 860 $('[data-tab-item]', container).removeClass(className); 861 $('[data-tab-content]', container).removeClass(className); 862 863 } 864 865 }); 866 867 if (activeItem) { 868 $(buttonBackItemClass).hide(); 869 oculta = false; 870 } 871 else { 872 $(buttonBackItemClass).show(); 873 oculta = true; 874 } 875 876 $(buttonBackItemClass, container).click(function (e) { 877 e.preventDefault(); 878 879 // Remove class in all items 880 $('[data-tab-item]', container).removeClass(className); 881 $('[data-tab-content]', container).removeClass(className); 882 883 // Add class in activeItem 884 $('[data-tab-content=' + activeItem + ']').addClass(className); 885 886 // hide buttonback 887 $(buttonBackItemClass).hide(); 888 oculta = false; 889 890 }); 891 892 893 }); 894 895 tabs.push(tab); 896 897 898 }); 899 }; 900 return { 901 init: function () { 902 903 load(); 904 }, 905 reload: function () { 906 907 load(); 908 // Remove class in all items 909 $('[data-tab-item]').removeClass('open'); 910 $('[data-tab-content]').removeClass('open'); 911 912 } 913 } 914}()); 915 916// Share-sticky 917var shareSticky = (function () { 918 var items; 919 920 var load = function () { 921 items = []; 922 923 document.querySelectorAll('.c-detail__head').forEach(function (eHead) { 924 var eShare = eHead.querySelector('.c-detail__share'); 925 926 if (!eShare) { 927 return; 928 } 929 930 items.push({ 931 eHead: eHead, 932 eShare: eShare 933 }); 934 }); 935 }; 936 937 return { 938 init: function () { 939 load(); 940 941 setInterval(function () { 942 items.forEach(function (item) { 943 var eHead = item.eHead; 944 var eShare = item.eShare; 945 946 if (!eHead || !eShare) { 947 return; 948 } 949 950 if (eHead.getBoundingClientRect().top < 0) { 951 eShare.classList.add('sticky'); 952 } 953 else { 954 eShare.classList.remove('sticky'); 955 } 956 }); 957 }, 10); 958 }, 959 reload: function () { 960 load(); 961 } 962 }; 963})(); 964 965// scrollVisible 966var scrollVisible = (function () { 967 /** 968 * If element is visible. 969 * @param {Object} ele Jquery object. 970 * @param {Object} down If only can be hidden after the element. 971 */ 972 var isVisible = function (ele, down) { 973 var scrollPos = $(window).scrollTop(); 974 var windowHeight = $(window).height(); 975 var eleTop = ele.offset().top; 976 var eleHeight = ele.height(); 977 var eleBottom = eleTop + eleHeight; 978 979 return ((eleBottom - eleHeight > scrollPos) && (down || eleTop < (scrollPos + windowHeight))); 980 }; 981 982 var handle = function () { 983 $('[data-type="scroll-visible"]').each(function () { 984 var ele = $($(this).data('scroll-visible-ele')); 985 var className = $(this).data('scroll-visible-class'); 986 987 if (!ele.length) { 988 return; 989 } 990 991 if (isVisible(ele, $(this).data('scroll-visible-down') !== undefined)) { 992 if ($(this).hasClass(className)) { 993 $(this).slideUp(); 994 } 995 else { 996 $(this).addClass(className); 997 998 $(this).hide(); 999 } 1000 1001 } 1002 else { 1003 $(this).slideDown(); 1004 1005 } 1006 1007 }); 1008 }; 1009 1010 return { 1011 init: function () { 1012 $(window).on('scroll', function () { 1013 handle(); 1014 }); 1015 1016 // Initial 1017 handle(); 1018 } 1019 }; 1020}()); 1021 1022// navigation 1023var navigation = (function () { 1024 1025 /** 1026 * 1027 * @param {(number|HTMLElement)} destination - Destination to scroll to (DOM element or number) 1028 * @param {number} duration - Duration of scrolling animation 1029 * @param {string} easing - Timing function name (Allowed values: 'linear', 'easeInQuad', 'easeOutQuad', 'easeInOutQuad', 'easeInCubic', 'easeOutCubic', 'easeInOutCubic', 'easeInQuart', 'easeOutQuart', 'easeInOutQuart', 'easeInQuint', 'easeOutQuint', 'easeInOutQuint') 1030 * @param {function} callback - Optional callback invoked after animation 1031 */ 1032 var scrollIt = function (destination, duration, easing, callback) { 1033 1034 var element = destination; 1035 destination = document.querySelector(element); 1036 duration = typeof duration !== 'undefined' ? duration : 3000; 1037 easing = typeof easing !== 'undefined' ? easing : 'linear'; 1038 1039 // Predefine list of available timing functions 1040 var easings = { 1041 // no easing, no acceleration 1042 linear: function (t) { return t }, 1043 // accelerating from zero velocity 1044 easeInQuad: function (t) { return t * t }, 1045 // decelerating to zero velocity 1046 easeOutQuad: function (t) { return t * (2 - t) }, 1047 // acceleration until halfway, then deceleration 1048 easeInOutQuad: function (t) { return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t }, 1049 // accelerating from zero velocity 1050 easeInCubic: function (t) { return t * t * t }, 1051 // decelerating to zero velocity 1052 easeOutCubic: function (t) { return (--t) * t * t + 1 }, 1053 // acceleration until halfway, then deceleration 1054 easeInOutCubic: function (t) { return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1 }, 1055 // accelerating from zero velocity 1056 easeInQuart: function (t) { return t * t * t * t }, 1057 // decelerating to zero velocity 1058 easeOutQuart: function (t) { return 1 - (--t) * t * t * t }, 1059 // acceleration until halfway, then deceleration 1060 easeInOutQuart: function (t) { return t < .5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t }, 1061 // accelerating from zero velocity 1062 easeInQuint: function (t) { return t * t * t * t * t }, 1063 // decelerating to zero velocity 1064 easeOutQuint: function (t) { return 1 + (--t) * t * t * t * t }, 1065 // acceleration until halfway, then deceleration 1066 easeInOutQuint: function (t) { return t < .5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t } 1067 }; 1068 1069 1070 if (destination === null) { 1071 window.location.assign("/home.html");// http://welifestival.es 1072 } 1073 // Store initial position of a window and time 1074 // If performance is not available in your browser 1075 // It will fallback to new Date().getTime() - thanks IE < 10 1076 var start = window.pageYOffset; 1077 //const startTime = 'now' in window.performance ? performance.now() : new Date().getTime(); 1078 var startTime = typeof (window.performance['now']) == 'function' ? performance.now() : new Date().getTime(); 1079 1080 // Take height of window and document to sesolve max scrollable value 1081 // Prevent requestAnimationFrame() from scrolling below maximum scollable value 1082 // Resolve destination type (node or number) 1083 var documentHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight); 1084 var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight; 1085 var destinationOffset = typeof destination === 'number' ? destination : destination.offsetTop; 1086 var destinationOffsetToScroll = Math.round(documentHeight - destinationOffset < windowHeight ? documentHeight - windowHeight : destinationOffset); 1087 1088 // If requestAnimationFrame is not supported 1089 // Move window to destination position and trigger callback function 1090 if ('requestAnimationFrame' in window === false) { 1091 window.scroll(0, destinationOffsetToScroll); 1092 if (callback) { 1093 callback(); 1094 } 1095 return; 1096 } 1097 1098 // function resolves position of a window and moves to exact amount of pixels 1099 // Resolved by calculating delta and timing function choosen by user 1100 function scroll() { 1101 //const now = 'now' in window.performance ? performance.now() : new Date().getTime(); 1102 const now = typeof (window.performance['now']) == 'function' ? performance.now() : new Date().getTime(); 1103 const time = Math.min(1, ((now - startTime) / duration)); 1104 const timeFunction = easings[easing](time); 1105 window.scroll(0, Math.ceil((timeFunction * (destinationOffsetToScroll - start)) + start)); 1106 // Stop requesting animation when window reached its destination 1107 // And run a callback function
1108 if (window.pageYOffset === destinationOffsetToScroll) { 1109 if (callback) { 1110 callback(); 1111 //callbackFunc(); 1112 1113 } 1114 return; 1115 } 1116 1117 requestAnimationFrame(scroll); 1118 } 1119 1120 1121 scroll(); 1122 }; 1123 1124 var callbackFunc = function () { 1125 //console.log('Just finished scrolling to '+window.pageYOffset+'px'); 1126 1127 return false; 1128 }; 1129 1130 var load = function () { 1131 var component = document.querySelectorAll('[data-type="nav"]'); 1132 console.log("location:" + window.location); 1133 component.forEach(function (link) { 1134 // listen for a click 1135 link.addEventListener('click', function () { 1136 1137 var scrollTo = '.' + this.getAttribute('data-nav-scroll-to'); 1138 console.log("scrollTo:" + scrollTo); 1139 document.getElementsByClassName('c-header')[0].classList.remove('open'); 1140 scrollIt(scrollTo, 3000, 'easeOutQuart', callbackFunc); 1141 // toggle current on and off when we click a link 1142 component.forEach(function (link) { 1143 if (link.classList.contains('current')) { 1144 link.classList.remove('current'); 1145 } 1146 }); 1147 link.classList.add('current'); // get the element where to scroll 1148 }); 1149 }); 1150 1151 }; 1152 1153 // function to Scroll on Init depends on URL 1154 var goTo = function () { 1155 var initialURL = window.location.pathname; 1156 var component = document.querySelectorAll('[data-type="nav"]'); 1157 component.forEach(function (link) { 1158 var scrollTo = link.getAttribute('data-nav-scroll-to'); 1159 if (scrollTo == initialURL.replace('/', 'o-section-')) { 1160 scrollTo = '.' + scrollTo; 1161 scrollIt(scrollTo, 3000, 'easeOutQuart', callbackFunc); 1162 } 1163 }); 1164 1165 }; 1166 1167 return { 1168 init: function () { 1169 load(); 1170 goTo(); 1171 } 1172 } 1173 1174})(); 1175 1176// modal 1177var modal = (function () { 1178 1179 var modals = []; 1180 1181 var load = function () { 1182 var modal = document.querySelectorAll('[data-type="modal"]'); 1183 1184 for (var i = 0, len = modal.length; i < len; i++) { 1185 var element = modal[i].getAttribute('data-modal-content'); 1186 var btnClose = document.getElementsByClassName(element)[0].getElementsByClassName('modal-content__close')[0]; 1187 var modalContent = document.getElementsByClassName(element)[0];// ? modal[i].getAttribute('data-modal-content'): 0; 1188 var body = document.getElementsByTagName("body")[0]; 1189 1190 1191 modal[i].addEventListener('click', function () { 1192 var element = this.getAttribute('data-modal-content'); 1193 document.getElementsByClassName(element)[0].classList.add('current'); 1194 body.classList.add('open-modal'); 1195 1196 }, false); 1197 1198 btnClose.addEventListener('click', function () { 1199 var element = this.parentElement.parentNode;// getAttribute('data-modal-content'); 1200 element.classList.remove('current'); 1201 body.classList.remove('open-modal'); 1202 //console.log('btn: '+ btnClose); 1203 1204 }, false); 1205 1206 window.addEventListener('click', function (event) { 1207 //console.log(event.target); 1208 if (event.target == modalContent) { 1209 modalContent.classList.remove('current'); 1210 body.classList.remove('open-modal'); 1211 } 1212 }, false); 1213 1214 modals.push(modal[i]); 1215 1216 } 1217 1218 1219 1220 }; 1221 1222 return { 1223 init: function () { 1224 load(); 1225 1226 1227 } 1228 } 1229 1230 1231})(); 1232 1233 1234/* =WINDOW.ONLOAD 1235 ----------------------------------------------------------------------------- */ 1236var callback = function () { 1237 burger.init(); 1238 socialShare.init(); 1239 //carousel.init(); 1240 //expo.init();
1241 //toggle.init(); 1242 //timeline.init(); 1243 expoTimeline.init(); 1244 slider.init(); 1245 //tab.init(); 1246 navigation.init(); 1247 modal.init(); 1248 /*if(typeof expoLib != 'undefined'){ 1249 expoLib.init(); 1250 }*/ 1251 headVisible.init(); 1252 //scrollVisible.init(); 1253 //shareSticky.init(); 1254 1255}; 1256 1257if (document.readyState === "complete" || (document.readyState !== "loading" && !document.documentElement.doScroll)) { 1258 callback(); 1259} 1260else { 1261 document.addEventListener("DOMContentLoaded", callback); 1262 window.addEventListener("resize", function () { 1263 burger.resize(); 1264 //carousel.resize(); 1265 }); 1266} 1267 1268 1269 1270 1271 1272 1273
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.