var $defaultReturnVal = '';
var setDefaultReturn = function () {
$('select#pickup-default option').prop('disabled', false);
$('select#pickup-default option[selected]').removeAttr('selected');
$('select#pickup-default option').each(function () {
if ($(this).data('note').indexOf('Motueka -') == 0 || $(this).data('note').indexOf('Nelson -') == 0) {
$(this).prop('disabled', true);
}
})
$('select#pickup-default option[value="' + $defaultReturnVal + '"]').prop('selected', true);
pickupResponseReset();
}
var setMotuekaReturn = function () {
$('select#item-unit-return-bus-from-nelson').prop('disabled', true);
$('select#pickup-default option').prop('disabled', false);
$('select#pickup-default option[selected]').removeAttr('selected');
$('select#pickup-default option').each(function () {
if ($(this).data('note').indexOf('Motueka -') < 0) {
$(this).prop('disabled', true);
}
})
$('select#pickup-default option:enabled:first').prop('selected', true);
pickupResponseReset();
}
var setNelsonReturn = function () {
$('select#item-unit-return-bus-from-motueka').prop('disabled', true);
$('select#pickup-default option').prop('disabled', false);
$('select#pickup-default option[selected]').removeAttr('selected');
$('select#pickup-default option').each(function () {
if ($(this).data('note').indexOf('Nelson -') < 0) {
$(this).prop('disabled', true);
}
})
pickupResponseReset();
}
var pickupResponseReset = function () {
$('#pickup-response-extra').remove();
$('#pickup-response').text($('select#pickup-default option:enabled:first').data('note'));
}
$(function () {
$defaultReturnVal = $('select#pickup-default option[selected]').val();
$('.header-optional-extras').text('Please select your option');
$('#frm-edit-booking .col-xs-12:first .booking-options:first label').text('Departure Point');
setDefaultReturn();
//$('#frm-edit-booking > div > div:nth-child(2) > div.col-md-5.col-md-push-7.col-sm-12.col-xs-12.col-xxs-12.col-xxs-push-0.col-xxxs-12.col-xxxs-push-0.pad-left0.pad-right0 > div:nth-child(2) > div > div > label').text('Return Water Taxi');
if (location.href.indexOf('.AQDEALSS.') > 0 || location.href.indexOf('.AQDEALSSW.') > 0 || location.href.indexOf('.AQDEALA.') > 0 || location.href.indexOf('.AQDEALAW.') > 0 || location.href.indexOf('.AQDEALB.') > 0 || location.href.indexOf('.AQDEALBW.') > 0) {
var adults = 0,
children = 0,
infants = 0,
totalPax = 0;
$(document).on('change', '#item-unit-adult, #item-unit-child, #item-unit-infant', function () {
$('#item-unit-adult option:selected').val() != undefined && (adults = parseInt($('#item-unit-adult option:selected').val()));
$('#item-unit-child option:selected').val() != undefined && (children = parseInt($('#item-unit-child option:selected').val()));
$('#item-unit-infant option:selected').val() != undefined && (infants = parseInt($('#item-unit-infant option:selected').val()));
totalPax = adults + children + infants;
setTimeout(function () {
var $this = $('#item-unit-return-bus-from-nelson');
$('#item-unit-return-bus-from-nelson option[value=' + totalPax + ']').prop('selected', true);
$(($($this).closest('.ticket-item-wrapper')).find('.ticket-total')).text('$' + (($($this).data('unit-price') * $($this).find('option:selected').val()).toFixed(2)));
BookingPageEvent.processQuantitySelect();
setMotuekaReturn();
}, 200);
setTimeout(function () {
for (i = 0; i < totalPax; i++) {
$('#item-unit-return-bus-from-nelson option[value=' + i + ']').prop('disabled', true);
}
},400)
})
}
/* case 20997 buy gift voucher button */
if (location.href.indexOf('/Booking/') > 0) {
$('.hidden-md .add-voucher').text('Buy as gift voucher');
$.fn.swapWith = function (to) {
return this.each(function () {
var copy_to = $(to).clone(true);
var copy_from = $(this).clone(true);
$(to).replaceWith(copy_from);
$(this).replaceWith(copy_to);
});
};
$('.hidden-md .add-voucher').swapWith('.hidden-md .booking-add-cart');
};
var today = new Date()
var todayDate = today.getDate()
var todayMonth = today.getMonth()
if (todayMonth > 3 && todayMonth < 9) {
if (todayMonth == 4 && todayDate < 15) {
//do nothing
} else {
if ($('body').find('.departure-body-no-avail').length > 0 && $('body').find('.departure-body-no-avail').text().indexOf('No departures available') > 0) {
$('.departure-body-no-avail').html('Available in summer only (01st October- 30th April). Click here to view other products');
}
}
}
/* case 21170 custom continue shoppping behaviour */
$('.btn-continue-shopping a').data('href', '');
$('.btn-continue-shopping a').click(function () {
top.location.replace('https://aquataxi.co.nz/shop');
})
/* working out if today is out of the season */
if (todayMonth > 3 && todayMonth < 9) {
if (todayMonth == 4 && todayDate < 15) {
//do nothing
} else {
var contentUpdated = false;
if (location.href.toLowerCase().indexOf('/departures?productcode=prodgroup-2data') > 0 || location.href.toLowerCase().indexOf('/departures?productcode=mmr') > 0 || location.href.toLowerCase().indexOf('/departures?productcode=paw') > 0) {
// Select the node that will be observed for mutations
var targetNode = document.querySelector('#departure-partial');
// Options for the observer (which mutations to observe)
var config = { attributes: true, childList: true, subtree: true };
// Callback function to execute when mutations are observed
var callback = function (mutationsList, observer) {
for(var mutation of mutationsList) {
if (mutation.type == 'childList') {
if ($('body').find('.departure-body-no-avail').length > 0 && contentUpdated == false && $('body').find('.departure-body-no-avail').text().indexOf('No departures available') > 0) {
$('.departure-body-no-avail').html('Available in summer only (01st October- 30th April). Click here to view other products');
contentUpdated = true;
setTimeout(function () {
contentUpdated = false;
}, 200)
}
}
}
};
// Create an observer instance linked to the callback function
var observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
};
}
}
})
$(document).on('change', 'select#item-unit-return-bus-from-motueka', function () {
if ($(this).val() > 0) {
setMotuekaReturn();
} else {
setDefaultReturn();
}
})
$(document).on('change', 'select#item-unit-return-bus-from-nelson', function () {
if ($(this).val() > 0) {
setNelsonReturn();
} else {
setDefaultReturn();
}
})