Toggle submenu in mobile

Hi All,

I have my site created in WordPress and here is the url for it http://littlewhitechurch.com/

In the mobile devices the menu shows all the items at one time, I am looking to show only the parent items first and when they click on the parent item the toggle the sub menu. Here is my mobile menu code. Where would I be adding the toggle code whenever there is a sub menu class. Here is my menu code for the site.

Thanks

		/**
		 * Inits the drop-down menu functionality.
		 */
		dropDown: function() {
			var padding = 1,
				//default menu top offset
				defaultOffset = parseInt($('#navigation-container').css('marginTop'), 10),
				top = 39,
				onMenuMouseover = function() {
					var $el = $(this),
						$ul = $el.find('ul:first'),
						left = $el.width(),
						parentUlNum = $ul.parents('ul').length,
						elWidth = $el.width(),
						ulWidth = $ul.width(),
						winWidth = $(window).width(),
						elOffset = $el.offset().left;


					$el.addClass('hovered');
					if(parentUlNum > 1 && (elWidth + ulWidth + elOffset > winWidth)) {
						//if the drop down ul goes beyound the screen, move it on the left side
						$ul.css({
							left: -elWidth
						});
					} else if(parentUlNum === 1) {
						if(ulWidth + elOffset > winWidth) {
							$ul.css({
								left: (winWidth - 3 - (ulWidth + elOffset))
							});
						} else {
							$ul.css({
								left: 0
							});
						}
					}

					if(parentUlNum === 1) {
						$ul.data('padding', padding);
					}


					$ul.stop().css({
						height: 'auto',
						paddingTop: 0,
						top: ($ul.data('padding') + $ul.data('top'))
					}).slideToggle(200, function() {
						$ul.css({
							overflow: 'visible',
							visibility: 'visible',
							paddingTop: $ul.data('padding'),
							top: $ul.data('top')
						});
					});
				},
				onMenuMouseout = function() {
					var $el = $(this),
						$ul = $el.find('ul:first');
					$el.removeClass('hovered');

					$ul.stop().css({
						paddingTop: 0,
						top: ($ul.data('padding') + $ul.data('top'))
					}).slideToggle(200, function() {
						$ul.css({
							overflow: 'hidden',
							display: 'none'
						});
					});
				};

			$('#menu ul ul').data('padding', padding).data('top', top);
			$('#menu ul ul ul').data('padding', 0).data('top', 0);

			$('#menu ul li').has('ul').each(function() {
				var $el = $(this);
				$el.hoverIntent(onMenuMouseover, onMenuMouseout).append('<span class="drop-arrow">&raquo;</span>');

			});

			//SET THE SMALL RESOLUTION MENU
			this.smallMenu();

		},


		/**
		 * Inits the drop-down menu for small screen devices.
		 */
		smallMenu: function() {
			var menuClass = 'mob-nav-menu',
				precedingElSel = '.header-separator',
				menuSel = '#menu',
				$menu = null,
				$menuBtn = $('.mob-nav-btn'),
				opened = false,
				inAnimation = false;

			$menuBtn.on('click', function() {
				if(!inAnimation) {
					if(!opened) {
						if(!$menu) {
							$menu = $('<div />', {
								'class': menuClass,
								html: $(menuSel).html()
							});
						}
						inAnimation = true;
						$menu.insertAfter(precedingElSel).animate({
							height: 'show'
						}, function() {
							opened = true;
							inAnimation = false;
						});
					} else {
						inAnimation = true;
						$menu.animate({
							height: 'hide'
						}, function() {
							$(this).detach();
							opened = false;
							inAnimation = false;
						});
					}
				}
			});

			$(window).on('resize', function(){
				if(!$menuBtn.is(':visible') && ($menu && opened)){
					$menu.hide().detach();
					opened = false;
				}
			});
		},

Open in new window

LVL 2
niceoneishereAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom BeckCommented:
Just dealing with the "smallMenu" part of the code you posted:
/**
		 * Inits the drop-down menu for small screen devices.
		 */
		smallMenu: function() {
			var menuClass = 'mob-nav-menu',
				precedingElSel = '.header-separator',
				menuSel = '#menu',
				$menu = null,
				$menuBtn = $('.mob-nav-btn'),
				opened = false,
				inAnimation = false;
				$menuSub = null;

			$menuBtn.on('click', function() {
				if(!inAnimation) {
					if(!opened) {
						if(!$menu) {
							$menu = $('<div />', {
								'class': menuClass,
								html: $(menuSel).html()
							});
							$menuSub = $menu.find('ul li ul');
							$menuSub.css('display', 'none');
							$menuSub.prev('a').append("<span style='font-weight:bold;color:#000'>&nbsp;&nbsp&#x25BC;</span>");	
							
							$menuSub.prev('a').click(function(e) {
							    e.preventDefault();
								$(this).next('ul').toggle();
							});						
						}
						inAnimation = true;
						$menu.insertAfter(precedingElSel).animate({
							height: 'show'
						}, function() {
							opened = true;
							inAnimation = false;
						});
					} else {
						inAnimation = true;
						$menu.animate({
							height: 'hide'
						}, function() {
							$(this).detach();
							opened = false;
							inAnimation = false;
						});
					}
				}
			});

Open in new window

I hard coded a down arrow in the javascript for brevity. You may want something more elegant.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Alicia St RoseOwner & Principle Developer/DesignerCommented:
You may want to take a look at this Plugin and save yourself the trouble. I usually use plugins as a last resort, but this one is amazing!

https://wordpress.org/plugins/responsive-menu/
niceoneishereAuthor Commented:
Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.