adding js logic for the off canvas reservation widget to restrict the arrival and...
authorAnthony Talarico <talarico@gaslightmedia.com>
Wed, 27 Jul 2016 13:25:29 +0000 (09:25 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Wed, 27 Jul 2016 13:25:29 +0000 (09:25 -0400)
js/app.js
js/custom/pageSetup.js

index 0419507..944a050 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -80,5 +80,50 @@ $(document).ready(function () {
     $("#departCal").click(function () {
         $(departure_date).datepicker("show");
     });
+    
+    var extraDay, end, arrival, currentDate, currentDate2,
+        requiredDate, requiredDate1, minDays, departure,
+        stay, d, dd,  m, y;
+   $(document).on('change', '#arriveOff', function () {
+        currentDate = $("#arriveOff").val();
+        currentDate = new Date(currentDate);
+       
+       // this section is used to circumvent issues with selecting the last day of the month without a proper rollover to the following month.
+        currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(),   currentDate.getUTCDate());
+        currentDate.setDate(currentDate.getDate());
+       
+        dd = currentDate.getDate() + 1;
+        if (dd <= 9) {
+            dd = '0' + dd;
+        }
+        d = currentDate.getDate();
+        if (d <= 9) {
+            d = '0' + d;
+        }
+        m = currentDate.getMonth() + 1;
+        if (m <= 9) {
+            m = '0' + m;
+        }
+        y = currentDate.getFullYear();
+        
+        // this variable is for passing to booking site
+        requiredDate = y + '-' + m + '-' + d;
+        minDays = y + '-' + m + '-' + dd;
+        $("#departOff").attr("min", minDays);
+        if (requiredDate <= $("#arriveOff").attr("min")) {
+            minDays = $("#arriveOff").attr("min");
+            $("#arriveOff").val(minDays);
+        }
+    });
+    // restrict departure date ///////////////////////////////
+    $(document).on('change', '#departOff', function () {
+        currentDate2 = $("#departOff").val();
+        currentDate2 = new Date(currentDate2);
+        currentDate2 = new Date(currentDate2.getUTCFullYear(), currentDate2.getUTCMonth(),currentDate2.getUTCDate());
+        currentDate2.setDate(currentDate2.getDate());
+        if($("#departOff").val() <= requiredDate){
+            $("#departOff").val(minDays);
+        }
+    });
 
 });
index 8adf876..69d7fcd 100644 (file)
@@ -71,5 +71,50 @@ $(document).ready(function () {
     $("#departCal").click(function () {
         $(departure_date).datepicker("show");
     });
+    
+    var extraDay, end, arrival, currentDate, currentDate2,
+        requiredDate, requiredDate1, minDays, departure,
+        stay, d, dd,  m, y;
+   $(document).on('change', '#arriveOff', function () {
+        currentDate = $("#arriveOff").val();
+        currentDate = new Date(currentDate);
+       
+       // this section is used to circumvent issues with selecting the last day of the month without a proper rollover to the following month.
+        currentDate = new Date(currentDate.getUTCFullYear(), currentDate.getUTCMonth(),   currentDate.getUTCDate());
+        currentDate.setDate(currentDate.getDate());
+       
+        dd = currentDate.getDate() + 1;
+        if (dd <= 9) {
+            dd = '0' + dd;
+        }
+        d = currentDate.getDate();
+        if (d <= 9) {
+            d = '0' + d;
+        }
+        m = currentDate.getMonth() + 1;
+        if (m <= 9) {
+            m = '0' + m;
+        }
+        y = currentDate.getFullYear();
+        
+        // this variable is for passing to booking site
+        requiredDate = y + '-' + m + '-' + d;
+        minDays = y + '-' + m + '-' + dd;
+        $("#departOff").attr("min", minDays);
+        if (requiredDate <= $("#arriveOff").attr("min")) {
+            minDays = $("#arriveOff").attr("min");
+            $("#arriveOff").val(minDays);
+        }
+    });
+    // restrict departure date ///////////////////////////////
+    $(document).on('change', '#departOff', function () {
+        currentDate2 = $("#departOff").val();
+        currentDate2 = new Date(currentDate2);
+        currentDate2 = new Date(currentDate2.getUTCFullYear(), currentDate2.getUTCMonth(),currentDate2.getUTCDate());
+        currentDate2.setDate(currentDate2.getDate());
+        if($("#departOff").val() <= requiredDate){
+            $("#departOff").val(minDays);
+        }
+    });
 
 });