$(document).ready(function() { var originalContent_subscribe; var window_subscribe = $('#popup-subscribe').dialog({ autoOpen: false, modal: true, position: { my: "top", at: "top", of: window }, width: 620, height: 'auto', resizable: false, title: "Request for availability subscription", buttons: {}, open : function(event, ui) { originalContent_subscribe = $("#popup-subscribe").html(); }, close: function (event, ui) { $('#popup-subscribe').html(originalContent_subscribe); } }).load('subscribe.php'); $('.ajax-popup-subscribe').click(function(event) { event.preventDefault(); window_subscribe.dialog('open'); }); $('#check-camino2') .checkboxradio() .on('change', function(event){ checked = ($(this).is(':checked')); $('#calendar').find('.trek-box-camino2').each(function(){ $(this).toggle(checked); }); monthSoldOut(); displayStamp(); }); $('#check-camino4') .checkboxradio() .on('change', function(event){ checked = ($(this).is(':checked')); $('#calendar').find('.trek-box-camino4').each(function(){ $(this).toggle(checked); }); monthSoldOut(); displayStamp(); }); $('#check-salcantay') .checkboxradio() .on('change', function(event){ checked = ($(this).is(':checked')); $('#calendar').find('.trek-box-salcantay').each(function(){ $(this).toggle(checked); }); monthSoldOut(); displayStamp(); }); $('#check-jungle') .checkboxradio() .on('change', function(event){ checked = ($(this).is(':checked')); $('#calendar').find('.trek-box-jungle').each(function(){ $(this).toggle(checked); }); monthSoldOut(); displayStamp(); }); var $wrap = $('#select-month').parent(); var frame = $('#select-month').sly({ horizontal: true, // Switch to horizontal mode. itemNav: 'basic', // Item navigation type. Can be: 'basic', 'centered', 'forceCentered'. smart: true, // Repositions the activated item to help with further navigation. activateOn: 'click', // Activate an item on this event. Can be: 'click', 'mouseenter', ... activateMiddle: true, // Always activate the item in the middle of the FRAME. forceCentered only. mouseDragging: true, // Enable navigation by dragging the SLIDEE with mouse cursor. touchDragging: true, // Enable navigation by dragging the SLIDEE with touch events. releaseSwing: true, // Ease out on dragging swing release. swingSpeed: 0.2, // Swing synchronization speed, where: 1 = instant, 0 = infinite. elasticBounds: true, // Stretch SLIDEE position limits when dragging past FRAME boundaries. startAt: 9,// Starting offset in pixels or items. scrollBy: 1, // Pixels or items to move per one mouse scroll. 0 to disable scrolling. pagesBar: $wrap.find('.pages'), // Selector or DOM element for pages bar container. speed: 300, // Animations speed in milliseconds. 0 to disable animations. easing: 'easeOutExpo', // Easing for duration based (tweening) animations. dragHandle: true, // Whether the scrollbar handle should be draggable. dynamicHandle: true, // Scrollbar handle represents the ratio between hidden and visible content. clickBar: true, // Enable navigation by clicking on scrollbar. keyboardNavBy: 'items', // Enable keyboard navigation by 'items' or 'pages'. prev: $wrap.find('.prev'), // Selector or DOM element for "previous item" button. next: $wrap.find('.next'), // Selector or DOM element for "next item" button. prevPage: $wrap.find('.prevPage'), // Selector or DOM element for "previous page" button. nextPage: $wrap.find('.nextPage'), // Selector or DOM element for "next page" button. },{ active: function(event, item) { //$('#waiting-spin').fadeIn(200); var sdate = $(".select-date").eq(item).attr('data-month'); $.ajax({ url: 'display_calendar-ajax.php?date='+sdate, async: true, dataType: 'text', success: function(data) { //$('#waiting-spin').fadeOut(20); $('#calendar').html(data); checked = ($('#check-camino2').is(':checked')); $('#calendar').find('.trek-box-camino2').each(function(){ $(this).toggle(checked); }); checked = ($('#check-camino4').is(':checked')); $('#calendar').find('.trek-box-camino4').each(function(){ $(this).toggle(checked); }); checked = ($('#check-salcantay').is(':checked')); $('#calendar').find('.trek-box-salcantay').each(function(){ $(this).toggle(checked); }); checked = ($('#check-jungle').is(':checked')); $('#calendar').find('.trek-box-jungle').each(function(){ $(this).toggle(checked); }); displayStamp(); } }); } }); $('.ajax-popup').magnificPopup({ type: 'ajax', tClose: "Close (Esc)", tLoading: "Loading..." }); monthSoldOut(); }); function monthSoldOut() { $('.select-date').removeClass('soldout'); if($('#check-camino2').is(':checked') || !$('#check-camino4').is(':checked') || $('#check-salcantay').is(':checked') || $('#check-jungle').is(':checked')) { $('.select-date').removeClass('soldout'); return; } $('.select-date').each(function() { var month = $(this); var mdate = $(this).data('month'); $.ajax({ url: 'get_spaces_c4.php?date='+mdate, async: true, dataType: 'text', success: function(spaces) { if(spaces==0) month.addClass('soldout'); } }); }); } function displayStamp() { check2 = $('#check-camino2').is(':checked'); check4 = $('#check-camino4').is(':checked'); checkS = $('#check-salcantay').is(':checked'); checkJ = $('#check-jungle').is(':checked'); spaces2 = $('#spaces2').val(); spaces4 = $('#spaces4').val(); if(check2 && spaces2==0 && !check4 && !checkS && !checkJ) $('.stamp-nospace').show(); else if(check4 && spaces4==0 && !check2 && !checkS && !checkJ) $('.stamp-nospace').show(); else $('.stamp-nospace').hide(); if(check2 && spaces2==-1 && !check4 && !checkS && !checkJ) $('.stamp-closed').show(); else if(check4 && spaces4==-1 && !check2 && !checkS && !checkJ) $('.stamp-closed').show(); else $('.stamp-closed').hide(); } $.fn.toggleIf = function(showOrHide) { return this.each(function() { if (showOrHide) return $(this).show(); else return $(this).hide(); }); };