From 563db0423ad8882a380c3039355d7040a73dc5c7 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Thu, 23 Aug 2018 09:32:42 -0400 Subject: [PATCH] fixing off canvas toggle clicking functionality --- js/app.js | 52 +++++++++++++++++++++++++++++++----------- js/custom/pageSetup.js | 52 +++++++++++++++++++++++++++++++----------- 2 files changed, 78 insertions(+), 26 deletions(-) diff --git a/js/app.js b/js/app.js index 9662e06..4bca222 100644 --- a/js/app.js +++ b/js/app.js @@ -14,12 +14,46 @@ $(document).ready(function () { $('ul.children').each(function () { $(this).before(''); }); - $('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, diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index 839b41f..df06d6d 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -5,12 +5,46 @@ $(document).ready(function () { $('ul.children').each(function () { $(this).before(''); }); - $('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, -- 2.17.1