I'm having some trouble with a jQuery powered dropdown menu I have on my website. I've tried and tried and can't seem to figure out a working solution. Any help would be greatly appreciated. Thank you in advance!
You can either watch the video I made on youtube describing the issue: http://www.youtube.com/watch?v=42E_rzwdUMY
or keep reading.
The website is http://www.orangepeeltransportation.com
When you go to the website, try to view an interior page with the top left menu, like 'ABOUT', 'RESERVATIONS', 'SERVICES' or one of the others, you will then be required to 'Please Select a Location to Continue'. Once you select a location, either 'Hampton Roads, VA' or 'Savannah, GA' will load their appropriate stylesheet (and content). However, it also initiates the JQuery powered toggle function that makes the drop down location menu appear, which is not correct. The drop down location menu should only appear if someone selects the 'Change Location' button link at the top right of the website.
Here is the .js code:
/** * Styleswitch stylesheet switcher built on jQuery * Under an Attribution, Share Alike License * By Kelvin Luck ( http://www.kelvinluck.com/ ) **/
// Take content in a div with id=\"defer-xyz\" and move it to a div with id=\"xyz\" function relocateDeferredContent() { var divs=document.getElementsByTagName(\"div\"); var replacements=new Array(); for(var i2=0;i2<divs.length;i2++){ var deferredContent = divs[i2]; if (deferredContent.id.indexOf(\"defer-\") == 0) { var placeHolder = document.getElementById(deferredContent.id.slice(6)); replacements.push([deferredContent, placeHolder]); } } for(i=0;i2<replacements.length;i2++){ replacements[i2][0].parentNode.removeChild(replacements[i2][0]); replacements[i2][1].parentNode.replaceChild(replacements[i2][0], replacements[i2][1]); replacements[i2][0].style.display = \"block\"; } return true; }
animateDown = function () { $(\"#changeThemeWrap\").animate({ marginTop: \"0px\" }, 1200 ); $(\"#toggleTheme span\").text(\"LEAVE IT AS IS\"); }; $(\"#toggleTheme\").toggle(animateDown, animateUp);
});
function themeTime() { $(\"#themeChangeOverlay, #themeChangeText\").fadeOut(); $('#toggleTheme').click(); }
function switchStylestyle(styleName) { $('link[@rel*=style][@title]').each(function(i) { this.disabled = true; if (this.getAttribute('title') == styleName) this.disabled = false; }); createCookie('style', styleName, 365);
}
// cookie functions http://www.quirksmode.org/js/cookies.html function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = \"; expires=\"+date.toGMTString(); } else var expires = \"\"; document.cookie = name+\"=\"+value+expires+\"; path=/\"; } function readCookie(name) { var nameEQ = name + \"=\"; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,\"\",-1); } // /cookie functions
Here is the page.php code:
<div class=\"tagline\" id=\"selectyourlocation\"> <div id=\"selectLocation\"> <img src=\"/images/selectyourlocation.png\" width=\"1000\" height=\"42\" border=\"0\" alt=\"Please Select Your Location to Continue\" title=\"Please Select Your Location to Continue\"> </div> <!-- #selectLocation -->
animateUp = function () { $(\"#changeThemeWrap\").animate({ marginTop: \"-180px\" etc....
in the .js file but it still continues to initiate the animateDown function on the #changeThemeWrap div when a location (either Hampton Roads or Savannah) is selected from within the page.php. What I think the problem is the styleswitch function is triggering the animateDown and animateUp functions in the dropdown. Which works great when the user changes their location from the 'Change Location' dropdown because we want it to animateUp after they make their selection. However, when visitors use the other 'Please Select a Location' link in the page.php file, because it uses the same styleswitch function that is triggering the animate sequence, it's causing a problem by triggering an animateDown with the 'Change Location' (#changeThemeWrap) menu. Figuring out the best way to have the styleswitch function change the website theme (or location) with only triggering the animateUp and animateDown function if they use the 'Change Location' menu is where I'm having trouble deciding how to make it work.
Not sure if you noticed, but you're loading jQuery multiple times. This causes all kinds of problems. It's being called once in your header and again in the body.
Check out this article http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/.
Give that a try and let us know if it resolves the problem.
I'm having some trouble with a jQuery powered dropdown menu I have on my website. I've tried and tried and can't seem to figure out a working solution. Any help would be greatly appreciated. Thank you in advance!
You can either watch the video I made on youtube describing the issue: http://www.youtube.com/watch?v=42E_rzwdUMY
or keep reading.
The website is http://www.orangepeeltransportation.com
When you go to the website, try to view an interior page with the top left menu, like 'ABOUT', 'RESERVATIONS', 'SERVICES' or one of the others, you will then be required to 'Please Select a Location to Continue'. Once you select a location, either 'Hampton Roads, VA' or 'Savannah, GA' will load their appropriate stylesheet (and content). However, it also initiates the JQuery powered toggle function that makes the drop down location menu appear, which is not correct. The drop down location menu should only appear if someone selects the 'Change Location' button link at the top right of the website.
Here is the .js code:
Here is the page.php code:
Thanks but that didn't work.
I tried adding:
above:
in the .js file but it still continues to initiate the animateDown function on the #changeThemeWrap div when a location (either Hampton Roads or Savannah) is selected from within the page.php. What I think the problem is the styleswitch function is triggering the animateDown and animateUp functions in the dropdown. Which works great when the user changes their location from the 'Change Location' dropdown because we want it to animateUp after they make their selection. However, when visitors use the other 'Please Select a Location' link in the page.php file, because it uses the same styleswitch function that is triggering the animate sequence, it's causing a problem by triggering an animateDown with the 'Change Location' (#changeThemeWrap) menu. Figuring out the best way to have the styleswitch function change the website theme (or location) with only triggering the animateUp and animateDown function if they use the 'Change Location' menu is where I'm having trouble deciding how to make it work.
Thanks again for your help and input.
Not sure if you noticed, but you're loading jQuery multiple times. This causes all kinds of problems. It's being called once in your header and again in the body.
Check out this article http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/.
Give that a try and let us know if it resolves the problem.
-Jacob