jQuery(function(a){a.fn.intervalLoop=function(b,c,d,e){var f=0,g=setInterval(function(){f>=e||a.fn.checkIfElementExists(b)?clearInterval(g):(c(),f++)},d)},a.fn.checkIfElementExists=function(b){return a(b).length},a.fn.slideFadeToggle=function(a,b){return this.animate({opacity:"toggle",height:"toggle"},a,b)};var b={init:function(){var a=this;a._buildSubMenu(),setTimeout(function(){a._moveLogin()},500)},_buildSubMenu:function(){a(".wsite-menu-default").find("li.wsite-menu-item-wrap").each(function(){var b=a(this);b.children(".wsite-menu-wrap").length>0&&(b.addClass("has-submenu"),a('').insertAfter(b.children("a.wsite-menu-item")))}),a(".wsite-menu").find("li.wsite-menu-subitem-wrap").each(function(){var b=a(this);b.children(".wsite-menu-wrap").length>0&&(b.addClass("has-submenu"),a('').insertAfter(b.children("a.wsite-menu-subitem")))}),a("li.wsite-menu-subitem-wrap.wsite-nav-current").parents(".wsite-menu-wrap").addClass("open"),a("li.has-submenu > span.icon-caret").on("click",function(){var b=a(this);b.toggleClass("active"),b.siblings(".wsite-menu-wrap").hasClass("open")?b.siblings(".wsite-menu-wrap").removeClass("open"):b.siblings(".wsite-menu-wrap").addClass("open")})},_detachLogin:function(){var b=a("#member-login").detach();a(".mobile-nav .wsite-menu-default > li:last-child").after(b)},_moveLogin:function(){var b=this;a(window).width()<=992&&a.fn.intervalLoop(".mobile-nav #member-login",b._detachLogin,800,5)}};a(document).ready(function(){b.init()})});
jQuery(function($) {
// Fixed nav
$.fn.checkElementPositioning = function($el, $offsetHeightEl, scrollClass) {
if (!this.length) {
return;
}
if(((this.offset().top - $(window).scrollTop()) <= $offsetHeightEl.outerHeight()) && !$el.hasClass(scrollClass)) {
$el.addClass(scrollClass);
} else if(((this.offset().top - $(window).scrollTop()) >= $offsetHeightEl.outerHeight()) && $el.hasClass(scrollClass)) {
$el.removeClass(scrollClass);
}
}
// Fade banner
$.fn.fadeBanner = function($el, scrollClass, offset) {
if (!this.length) {
return;
}
if((this.offset().top < ($(window).scrollTop() + offset)) && !$el.hasClass(scrollClass)) {
$el.addClass(scrollClass);
} else if((this.offset().top >= ($(window).scrollTop() + offset)) && $el.hasClass(scrollClass)) {
$el.removeClass(scrollClass);
}
}
// Mobile sidebars
$.fn.expandableSidebar = function(expandedClass) {
var $me = this;
$me.on('click', function() {
if(!$me.hasClass(expandedClass)) {
$me.addClass(expandedClass);
} else {
$me.removeClass(expandedClass);
}
});
}
// Interval loop
$.fn.intervalLoop = function(condition, action, duration, limit) {
var counter = 0;
var looper = setInterval(function(){
if (counter >= limit || $.fn.checkIfElementExists(condition)) {
clearInterval(looper);
} else {
action();
counter++;
}
}, duration);
}
// Check if element exists
$.fn.checkIfElementExists = function(selector) {
return $(selector).length;
}
var duskController = {
init: function(opts) {
var base = this;
// Check content positioning
$('.main-wrap').checkElementPositioning($('body.page-has-banner'), $('.dusk-header'), 'affix');
// Add classes to elements
base._addClasses();
setTimeout(function(){
base._checkCartItems();
base._attachEvents();
}, 1000);
},
_addClasses: function() {
var base = this;
// Add class to nav items with subnav
$('.wsite-menu-default').find('li.wsite-menu-item-wrap').each(function(){
var $me = $(this);
if($me.children('.wsite-menu-wrap').length > 0) {
$me.addClass('has-submenu');
$('').insertAfter($me.children('a.wsite-menu-item'));
}
});
// Add class to subnav items with subnav
$('.wsite-menu').find('li.wsite-menu-subitem-wrap').each(function(){
var $me = $(this);
if($me.children('.wsite-menu-wrap').length > 0) {
$me.addClass('has-submenu');
$('').insertAfter($me.children('a.wsite-menu-subitem'));
}
});
// Keep subnav open if submenu item is active
$('li.wsite-menu-subitem-wrap.wsite-nav-current').parents('.wsite-menu-wrap').addClass('open');
// Add placeholder text to inputs
$('.wsite-form-sublabel').each(function(){
var sublabel = $(this).text();
$(this).prev('.wsite-form-input').attr('placeholder', sublabel);
});
// Add fullwidth class to gallery thumbs if less than 6
$('.imageGallery').each(function(){
if ($(this).children('div').length <= 6) {
$(this).children('div').addClass('fullwidth-mobile');
}
});
},
_checkCartItems: function() {
var base = this;
if($('#wsite-mini-cart').find('li.wsite-product-item').length > 0) {
$('body').addClass('cart-full');
} else {
$('body').removeClass('cart-full');
}
},
_moveLogin: function() {
var loginDetach = $('#member-login').detach();
$('.mobile-nav .wsite-menu-default > li:last-child').after(loginDetach);
},
_attachEvents: function() {
var base = this;
// Nav toggle
$('label.hamburger').on('click', function() {
if(!$('body').hasClass('nav-open')) {
$('body').addClass('nav-open');
} else {
$('body').removeClass('nav-open');
}
});
// Move cart + login
if ($(window).width() <= 992) {
$.fn.intervalLoop('.mobile-nav #member-login', base._moveLogin, 800, 5);
}
// Window scroll
if($('body').hasClass('page-has-banner')) {
var offset;
var headerHeight = $('.dusk-header').outerHeight();
$(window).on('scroll', function(){
// Set offset
if($(window).width() <= 767) {
offset = headerHeight;
} else {
offset = 0;
}
// Affix nav
$('.main-wrap').checkElementPositioning($('body.page-has-banner'), $('.dusk-header'), 'affix');
// Fade out banner header
$('.banner h2').fadeBanner($('body.page-has-banner'), 'fade-on-scroll', offset);
});
}
// Subnav toggle
$('li.has-submenu span.icon-caret').on('click', function() {
var $me = $(this);
if($me.siblings('.wsite-menu-wrap').hasClass('open')) {
$me.siblings('.wsite-menu-wrap').removeClass('open');
} else {
$me.siblings('.wsite-menu-wrap').addClass('open');
}
});
// Store category dropdown
$('.wsite-com-sidebar').expandableSidebar('sidebar-expanded');
// Search filters dropdown
$('#wsite-search-sidebar').expandableSidebar('sidebar-expanded');
// Init fancybox swipe on mobile
if ('ontouchstart' in window) {
$('body').on('click', 'a.w-fancybox', function() {
base._initSwipeGallery();
});
}
},
_initSwipeGallery: function() {
var base = this;
setTimeout(function(){
var touchGallery = document.getElementsByClassName('fancybox-wrap')[0];
var mc = new Hammer(touchGallery);
mc.on("panleft panright", function(ev) {
if (ev.type == "panleft") {
$("a.fancybox-next").trigger("click");
} else if (ev.type == "panright") {
$("a.fancybox-prev").trigger("click");
}
base._initSwipeGallery();
});
}, 500);
}
}
$(document).ready(function(){
duskController.init();
});
});
//Custom
jQuery(function($) {
// Define Theme specific functions
var Theme = {
// Swiping mobile galleries wwith Hammer.js
swipeGallery: function() {
setTimeout(function() {
var touchGallery = document.getElementsByClassName("fancybox-wrap")[0];
var mc = new Hammer(touchGallery);
mc.on("panleft panright", function(ev) {
if (ev.type == "panleft") {
$("a.fancybox-next").trigger("click");
} else if (ev.type == "panright") {
$("a.fancybox-prev").trigger("click");
}
Theme.swipeGallery();
});
}, 500);
},
swipeInit: function() {
if ('ontouchstart' in window) {
$("body").on("click", "a.w-fancybox", function() {
Theme.swipeGallery();
});
}
// Add fullwidth class to gallery thumbs if less than 6
$('.imageGallery').each(function(){
if ($(this).children('div').length <= 6) {
$(this).children('div').addClass('fullwidth-mobile');
}
});
},
toggleClick: function(click, target, classname){
$(click).click(function(){
$(target).toggleClass(classname);
});
},
// Interval function to execute post-post-load events
interval: function(condition, action, duration, limit) {
var counter = 0;
var looper = setInterval(function(){
if (counter >= limit || Theme.checkElement(condition)) {
clearInterval(looper);
} else {
action();
counter++;
}
}, duration);
},
checkElement: function(selector) {
return $(selector).length;
},
moveLogin: function() {
var login = $("#member-login");
login.detach().appendTo("#navmobile .wsite-menu-default");
},
setPosition: function(){
$("#wrapper").height() < $(window).height() ? $("#wrapper").css({"position": "absolute"}) : $("#wrapper").css({"position": "relative"});
},
cartDisplay: function() {
if (Number($('#wsite-mini-cart .wsite-subtotal-wrapper .wsite-price').text()) > 0 ) {
$('#wsite-mini-cart').addClass('full');
$('#footer').addClass('footer-full');
}
else {
$('#wsite-mini-cart').removeClass('full');
$('#footer').removeClass('footer-full');
}
}
}
$(document).ready(function() {
console.log('prueba');
setTimeout(function() {
$(
'#banner > div > div > div > div.wsite-section-content > div > div > div > div > div > div > table > tbody > tr > td:nth-child(2) > div > div > a > img'
).click(function() {
gtag('event', 'clic', {
event_category: 'saliente',
event_label:
'https://www.hemisferios.org/calendarioviajes.asp?origenreserva=catamaranesribeirasacra',
transport_type: 'beacon'
});
console.log('ev saliente');
});
});
$("body").addClass("postload");
Theme.swipeInit();
Theme.toggleClick(".wsite-com-sidebar", ".wsite-com-sidebar", "sidebar-expanded");
Theme.toggleClick(".hamburger", "body", "menu-open");
Theme.interval("#wsite-mini-cart.full", Theme.cartDisplay, 800, 10);
$('.wsite-product-button, #wsite-com-product-add-to-cart, .wsite-product-item .wsite-remove-button').on('click', function(){
setTimeout(function() { Theme.cartDisplay(); }, 800);
});
if ($(window).width() <= 1024) {
Theme.moveLogin();
Theme.setPosition();
// Add fullwidth class to gallery thumbs if less than 6
$('.imageGallery').each(function(){
if ($(this).children('div').length <= 6) {
$(this).children('div').addClass('fullwidth-mobile');
}
});
}
});
});