Commit: a2e36f773d27b3c41165cc6117190d880658a0fa Author: Stewart Lord <[email protected]> Tue, 4 Jan 2011 05:38:14 +0000 Parents: 30309559e2cb1af6f90eb02bfec66deb6ceae62b Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=a2e36f773d27b3c41165cc6117190d880658a0fa Log: Fixed a couple of problems with the mega drop-down menu. It no longer requires two clicks to switch the current menu when the current menu has no sub-menu. Also, fixed an issue where repeatedly clicking the same link could break the dom (we now ignore clicks while animating). Changed paths: M js/common.js Diff: diff --git a/js/common.js b/js/common.js index 7d75c9b..72d5782 100644 --- a/js/common.js +++ b/js/common.js @@ -6,27 +6,35 @@ $(document).ready(function() { event.preventDefault(); var clickedMenu = $(this); - var activeMenu = $('#headmenu li.current'); var container = $('#mega-drop-down #menu-container'); + // ignore clicks if we're busy. + if (container.hasClass('busy')) return; + container.addClass('busy'); + // function to activate the clicked menu. var activate = function(){ clickedMenu.addClass('current'); clickedMenu.find("div.children").appendTo(container); - container.find("div.children").slideUp(0).slideDown("fast"); + container.find("div.children").slideUp(0).slideDown("fast", + function(){ container.removeClass('busy'); } + ); }; // if there is an active menu, deactivate it first. + var activeMenu = $('#headmenu li.current'); + var activeSubMenu = container.find("div.children"); if (activeMenu.length) { activeMenu.removeClass('current'); - var children = container.find("div.children"); - if (children) { - children.slideUp('fast', function(){ - children.appendTo(activeMenu); - if (activeMenu[0] != clickedMenu[0]) - activate(); - }); - } + } + if (activeSubMenu.length) { + activeSubMenu.slideUp('fast', function(){ + activeSubMenu.appendTo(activeMenu); + if (activeMenu[0] != clickedMenu[0]) + activate(); + else + container.removeClass('busy'); + }); } else { activate(); } -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
