HEX
Server: Apache
System: Linux v38079.2is.nl 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: democfellows (10015)
PHP: 8.1.34
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/creativefellows.nl/slotzeist.creativefellows.nl/public/js/app.js
Foundation.Abide.defaults.validators['max_persons'] = function($el, required, parent){ 	
	var number	= $el.val().replace(/[^0-9-]/g,'');
	if( number < 1 || number > $el.attr("maxpersons") || isNaN( $el.val() ) ) return false;
	else return true;		
};
Foundation.Abide.defaults.patterns['phone'] = /^[0-9-]*$/;


$(document).foundation().ready(function(){
	
	$("div.lazy").Lazy({
		effect: "fadeIn",
		effectTime : 500,
		enableThrottle: true,
        throttle: 250,
		afterLoad: function(){
		}
	});
	
	$("[tour-date-select]").tourSelector();
	
	
	$(".calendar").selectDate();
	
});

$.fn.selectDate = function(element, options){
	
	return this.each(function(){

		var plugin		= $(this);
		var element		= plugin.data("open");
		var reveal;
		
		plugin.options = {
			
		}
		
		plugin.init = function()
		{	
			plugin.createReveal()
			plugin.on("click",plugin.openReveal);
			
		}
		
		plugin.createReveal = function()
		{
			reveal = new Foundation.Reveal($("#"+element), plugin.options);
		}
		
		plugin.openReveal = function()
		{
			//reveal.foundation('open');
			
			$( "#datepicker" ).datepicker({
				minDate: 0,
				dateFormat: 'yy-mm-dd',
				onSelect: function(dateText, inst) { 
					
					var url = window.location.href;
					var value = url.substring(url.lastIndexOf('/') + 1);

					window.location = '/dashboard/'+dateText;//url.replace(value, dateText);
				}
			});
			
		}
				
		// init the plugin
	    plugin.init();
		
		
	});
}
		

$.fn.tourSelector = function(element, options){
	
	return this.each(function(){

		var plugin		= $(this);
		
		var $wrapper 	= plugin.find(".tour-select");
		var $buttons	= plugin.find(".tour-navigation button");
		var $persons	= $("#personen");		
		
		var $input 		= $("#"+ plugin.data("input-visible"));
		var $hidden		= $("#"+ plugin.data("input-hidden"));
	
		
		plugin.settings = {
			activeClass : "select-slot__active",
			postUrl: plugin.data("post-url"),
			weekOffset : 0,
		}
		
		plugin.init = function()
		{	
			plugin.clicks();

			$buttons.on("click",plugin.setWeekOffset);
			$persons.on("change",plugin.getBookings);
			
			$persons.on("keyup",function(){
				var num =  $(this).val().replace(/[^0-9-]/g,'');				
				$(this).val(num);
			});
			
		}
		
		plugin.clicks = function()
		{
			$slots 	= plugin.find(".select-slot").filter( ":not(.select-slot__inactive)" );
			$slots.on("click",plugin.select);
		}
		
		
		// select clicked element
		plugin.select = function()
		{
			// remove current selected
			plugin.resetSelected();
			
			// make active
			$(this).addClass( plugin.settings.activeClass );

			// set value visible
			$hidden.val( $(this).data("timestamp") );	
			
			// set value hidden
			$input.val( $(this).data("human") );					
		}	

		// set offset date
		plugin.setWeekOffset = function()
		{

			// update counter
			if($(this).data("direction")) plugin.settings.weekOffset++;
			else plugin.settings.weekOffset--;
			
			// disable previous 
			if(plugin.settings.weekOffset > 0) $buttons.first().prop('disabled', false);
			else $buttons.first().prop('disabled', true);
			
			// get bookings
			plugin.getBookings();
			
		}
		
		
		// get bookings
		plugin.getBookings = function()
		{	
			//plugin.settings.startDate = "2021-02-24"
		    $.ajax({
		        type: "POST",
		        url: plugin.settings.postUrl,
				data: {
					"persons" : $persons.val(),
					"offset" : plugin.settings.weekOffset
				},
				dataType: "json",
		        success: function(data){
					
					plugin.setSelectorData(data);
								
		        }
		    });	
		}
		
		
		// update availability
		plugin.setSelectorData = function(data)
		{
			$wrapper.html(data.html);
			
			plugin.clicks();
		}
		
		
		// remove selected class on elements
		plugin.resetSelected = function()
		{
			$slots.removeClass( plugin.settings.activeClass )
		}
			
				
		// init the plugin
	    plugin.init();
		
		
	});
}

$.fn.visible = function(partial) {
    
      var $t            = $(this),
          $w            = $(window),
          viewTop       = $w.scrollTop()-100,
          viewBottom    = viewTop + $w.height(),
          _top          = $t.offset().top,
          _bottom       = _top + $t.height(),
          compareTop    = partial === true ? _bottom : _top,
          compareBottom = partial === true ? _top : _bottom;
    
    return ((compareBottom <= viewBottom) && (compareTop >= viewTop));

};