fixing off canvas toggle clicking functionality
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 23 Aug 2018 13:32:42 +0000 (09:32 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 23 Aug 2018 13:32:42 +0000 (09:32 -0400)
js/app.js
js/custom/pageSetup.js

index 9662e06..4bca222 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -14,12 +14,46 @@ $(document).ready(function () {
     $('ul.children').each(function () {
         $(this).before('<a class="toggle" href="#"></a>');
     });
-    $('a.toggle').click('click', function (e) {
-        $(this).toggleClass('open');
-        $(this).siblings('ul').toggleClass('open');
+
+    $('a.toggle').on("click", function (e) {
+        // $(this).toggleClass('open');
+        // $(this).siblings('ul').toggleClass('open');
+        if( $(this).hasClass("open") ){
+            $(this).removeClass("open")
+            $(this).siblings('ul').removeClass("open");
+        }else{
+     
+            $(this).addClass("open")
+            $(this).siblings('ul').addClass("open");
+        }
+
     });
+  
+    if(window.glmData.location){
+        $('a.toggle').trigger("click");
+        $('.off-canvas-wrap').foundation('offcanvas', 'show', 'move-right');
+    }
 
-    // Custom js and jquery for staffords ///////////////////
+    $('.left-off-canvas-list').find('.menu-item-has-children > a:not(.toggle)').on("click", function(e){
+    
+        e.preventDefault();
+        // $(this).children('a.toggle').toggleClass('open');
+        // $(this).children('ul').toggleClass('open');
+        if( $(this).next().hasClass("open") ){
+            $(this).next().removeClass("open")
+            $(this).siblings('ul').removeClass("open");
+        }else{
+     
+            $(this).next().addClass("open")
+            $(this).siblings('ul').addClass("open");
+        }
+    })
+    
+    $(".menu-item:not(.menu-item-has-children) > a:not(.toggle)").on("click", function(e){
+        e.stopPropagation();
+    })
+
+      // Custom js and jquery for staffords ///////////////////
     // reservation for toggle click function ///////////////
     $("#res-tab a").on('click', function () {
         if ($("#res-tab").attr("id") === "res-tab") {
@@ -28,15 +62,7 @@ $(document).ready(function () {
             $("#res-tab-open").attr("id", "res-tab");
         }
     });
-    if(window.glmData.location){
-        $('a.toggle').trigger("click");
-        $('.off-canvas-wrap').foundation('offcanvas', 'show', 'move-right');
-    }
-    $('.left-off-canvas-list').find('.menu-item-has-children').on("click", function(e){
-        e.preventDefault();
-        $(this).children('a.toggle').toggleClass('open');
-        $(this).children('ul').toggleClass('open');
-    })
+
     var extraDay,currentDate, currentDate2, requiredDate,minDays, departure, stay, d, dd,  m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&',
         crookedRiver = 'ZhWXD46i2%2fq319vcR%2fcw69rZvA2bz%2fttOOxO9t1%2fBJ0%3d&',
         adults,
index 839b41f..df06d6d 100644 (file)
@@ -5,12 +5,46 @@ $(document).ready(function () {
     $('ul.children').each(function () {
         $(this).before('<a class="toggle" href="#"></a>');
     });
-    $('a.toggle').click('click', function (e) {
-        $(this).toggleClass('open');
-        $(this).siblings('ul').toggleClass('open');
+
+    $('a.toggle').on("click", function (e) {
+        // $(this).toggleClass('open');
+        // $(this).siblings('ul').toggleClass('open');
+        if( $(this).hasClass("open") ){
+            $(this).removeClass("open")
+            $(this).siblings('ul').removeClass("open");
+        }else{
+     
+            $(this).addClass("open")
+            $(this).siblings('ul').addClass("open");
+        }
+
     });
+  
+    if(window.glmData.location){
+        $('a.toggle').trigger("click");
+        $('.off-canvas-wrap').foundation('offcanvas', 'show', 'move-right');
+    }
 
-    // Custom js and jquery for staffords ///////////////////
+    $('.left-off-canvas-list').find('.menu-item-has-children > a:not(.toggle)').on("click", function(e){
+    
+        e.preventDefault();
+        // $(this).children('a.toggle').toggleClass('open');
+        // $(this).children('ul').toggleClass('open');
+        if( $(this).next().hasClass("open") ){
+            $(this).next().removeClass("open")
+            $(this).siblings('ul').removeClass("open");
+        }else{
+     
+            $(this).next().addClass("open")
+            $(this).siblings('ul').addClass("open");
+        }
+    })
+    
+    $(".menu-item:not(.menu-item-has-children) > a:not(.toggle)").on("click", function(e){
+        e.stopPropagation();
+    })
+
+      // Custom js and jquery for staffords ///////////////////
     // reservation for toggle click function ///////////////
     $("#res-tab a").on('click', function () {
         if ($("#res-tab").attr("id") === "res-tab") {
@@ -19,15 +53,7 @@ $(document).ready(function () {
             $("#res-tab-open").attr("id", "res-tab");
         }
     });
-    if(window.glmData.location){
-        $('a.toggle').trigger("click");
-        $('.off-canvas-wrap').foundation('offcanvas', 'show', 'move-right');
-    }
-    $('.left-off-canvas-list').find('.menu-item-has-children').on("click", function(e){
-        e.preventDefault();
-        $(this).children('a.toggle').toggleClass('open');
-        $(this).children('ul').toggleClass('open');
-    })
+
     var extraDay,currentDate, currentDate2, requiredDate,minDays, departure, stay, d, dd,  m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&',
         crookedRiver = 'ZhWXD46i2%2fq319vcR%2fcw69rZvA2bz%2fttOOxO9t1%2fBJ0%3d&',
         adults,