Jump to content

dwinnbrown

Circle Member
  • Posts

    14
  • Joined

  • Last visited

Posts posted by dwinnbrown

  1. I have put together a solution for those using the form block...

    Full walkthrough here: https://www.winn-brown.co.uk/blog/how-to-add-a-datepicker-to-squarespace-form-block-2023

    Note: this doesn't yet support the add to cart popup forms but I will be updating it soon with support for that. 

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
    <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
    <script>
      $(window).on("load", function() {
    	  
    	  function rmydays(date) {
    		  //disable weekends (Sat and Sun // 0 = Sunday, 1= Monday etc.)
    		  return date.getDay() === 0 || date.getDay() === 6;
    	  }
    	  var flatpickrOptions = {
    		  "disable": [
    			  // Disable weekends and specific dates using the rmydays function
    			  rmydays,
    			  "2023-12-24",
    			  "2023-12-25"
    		  ],
    		  minDate: "today", //don't allow users to select dates in the past
    		  "locale": {
    			  "firstDayOfWeek": 1 // Start the week on Monday
    		  }
    	  };
    	  
    	  $(".sqs-block-form").each(function() {	  
    		  if ( $(".lightbox-handle-wrapper").length ) {
    			  $(".lightbox-handle").click(function() {
    				  var checkExist = setInterval(function() {
    					  if ( $(".form-item label:contains('Date')").length ) {
    						  clearInterval(checkExist);
    						  $(".form-item label:contains('Date')").next().flatpickr(flatpickrOptions);
    					  }
    				  }, 100);
    			  });
    		  } else {
    			  $(".form-item label:contains('Date')").next().flatpickr(flatpickrOptions);
    		  }
    	  });
      });
    </script>
    <style>
    	.flatpickr-calendar.open {
    		z-index: 999999999 !important;
    	}
    </style>

    Hope it helps!

     

  2. Hey @Molololol

    Try pasting this into the code injection area:

    Let me know how that goes!

    <script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
    <link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.css"/>
    <script type="text/javascript" src="//cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js"></script>
    <script>
      $(window).on("load", function() {
        $(".sqs-announcement-bar-text-inner").slick({
          autoplay: true,
          arrows: false,
          autoplaySpeed: 3000
        });
      });
    </script>
    <style>
      .sqs-announcement-bar-text-inner:not(.slick-initialized) p {
        font-size: 0;
      }
    </style>
×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.