Index: modules/overlay/overlay-parent.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay-parent.js,v
retrieving revision 1.11
diff -u -r1.11 overlay-parent.js
--- modules/overlay/overlay-parent.js	25 Dec 2009 10:15:23 -0000	1.11
+++ modules/overlay/overlay-parent.js	28 Dec 2009 19:07:30 -0000
@@ -7,58 +7,23 @@
  */
 Drupal.behaviors.overlayParent = {
   attach: function (context, settings) {
-    var $window = $(window);
-
-    // Alter all admin links so that they will open in the overlay.
-    $('a', context).filter(function () {
-      return Drupal.overlay.isAdminLink(this.href);
-    })
-    .once('overlay')
-    .each(function () {
-      // Move the link destination to a URL fragment.
-      this.href = Drupal.overlay.fragmentizeLink(this);
-    });
-
-    // Simulate the native click event for all links that appear outside the
-    // overlay. jQuery UI Dialog prevents all clicks outside a modal dialog.
-    $('.overlay-displace-top a:not(.overlay-displace-no-click)', context)
-    .add('.overlay-displace-bottom a:not(.overlay-displace-no-click)', context)
-    .click(function () {
-      window.location.href = this.href;
-    });
-
-    // Resize the overlay when the toolbar drawer is toggled.
-    $('#toolbar a.toggle', context).once('overlay').click(function () {
-      setTimeout(function () {
-        // Resize the overlay, if it's open.
-        if (Drupal.overlay.isOpen) {
-          Drupal.overlay.outerResize();
-        }
-      }, 10);
-    });
-
     // Make sure the onhashchange handling below is only processed once.
     if (this.processed) {
       return;
     }
     this.processed = true;
 
+    // Bind event handlers to the parent window.
+    $(window)
     // When the hash (URL fragment) changes, open the overlay if needed.
-    $window.bind('hashchange', function (e) {
-      // If we changed the hash to reflect an internal redirect in the overlay,
-      // its location has already been changed, so don't do anything.
-      if ($.data(window.location, window.location.href) === 'redirect') {
-        $.data(window.location, window.location.href, null);
-      }
-      // Otherwise, change the contents of the overlay to reflect the new hash.
-      else {
-        Drupal.overlay.trigger();
-      }
-    });
-
+    .bind('hashchange', Drupal.overlay.hashchangeHandler)
     // Trigger the hashchange event once, after the page is loaded, so that
     // permalinks open the overlay.
-    $window.trigger('hashchange');
+    .trigger('hashchange');
+    // Instead of binding a click event handler to every link we bind one to the
+    // document and only handle events that bubble up. This allows other scripts
+    // to bind their own handlers to links and also to prevent overlay's handling.
+    $(document).click(Drupal.overlay.clickHandler);
   }
 };
 
@@ -311,6 +276,9 @@
   // No need to resize when loading.
   clearTimeout(self.resizeTimeoutID);
 
+  // Reset the scroll to the top of the window so that the overlay is visible again.
+  window.scrollTo(0, 0);
+
   // Change the overlay title.
   self.$container.dialog('option', 'title', Drupal.t('Loading...'));
 
@@ -322,16 +290,16 @@
   self.$iframe
     .css('visibility', 'hidden')
     .load(function () {
-      self.isLoading = false;
+    self.isLoading = false;
 
-      // Only continue when overlay is still open and not closing.
-      if (self.isOpen && !self.isClosing) {
+    // Only continue when overlay is still open and not closing.
+    if (self.isOpen && !self.isClosing) {
         self.$iframe.css('visibility', '');
-        self.$dialog.addClass('overlay-loaded');
-      }
-      else {
-        self.destroy();
-      }
+      self.$dialog.addClass('overlay-loaded');
+    }
+    else {
+      self.destroy();
+    }
   });
 
   // Get the document object of the iframe window.
@@ -413,11 +381,7 @@
   // Make sure the parent window URL matches the child window URL.
   self.syncChildLocation(iframeWindow.document.location);
 
-  // Reset the scroll to the top of the window so that the overlay is visible again.
-  window.scrollTo(0, 0);
-
   var iframeTitle = self.$iframeDocument.attr('title');
-
   // Update the dialog title with the child window title.
   self.$container.dialog('option', 'title', iframeTitle);
   self.$dialogTitlebar.find('.ui-dialog-title').focus();
@@ -429,15 +393,12 @@
   // If the shortcut add/delete button exists, move it to the dialog title.
   var $addToShortcuts = self.$iframeWindow('.add-or-remove-shortcuts');
   if ($addToShortcuts.length) {
-    // Make the link overlay-friendly.
-    var $link = $('a', $addToShortcuts);
-    $link.attr('href', Drupal.overlay.fragmentizeLink($link.get(0)));
     // Move the button markup to the title section. We need to copy markup
     // instead of moving the DOM element, because Webkit and IE browsers will
     // not move DOM elements between two DOM documents.
-    var shortcutsMarkup = '<div class="' + $($addToShortcuts).attr('class') + '">' + $($addToShortcuts).html() + '</div>';
-    self.$dialogTitlebar.find('.ui-dialog-title').after(shortcutsMarkup);
-    self.$iframeWindow('.add-or-remove-shortcuts').remove();
+    $addToShortcuts = $(self.$iframeWindow('<div>').append($addToShortcuts).remove().html());
+
+    self.$dialogTitlebar.find('.ui-dialog-title').after($addToShortcuts);
   }
 
   // Remove any existing tabs in the title section.
@@ -448,7 +409,7 @@
     // Move the tabs markup to the title section. We need to copy markup
     // instead of moving the DOM element, because Webkit and IE browsers will
     // not move DOM elements between two DOM documents.
-    $tabs = $(self.$iframeWindow('<div>').append($tabs.clone()).remove().html());
+    $tabs = $(self.$iframeWindow('<div>').append($tabs).remove().html());
 
     self.$dialogTitlebar.append($tabs);
     if ($tabs.is('.primary')) {
@@ -545,7 +506,7 @@
     clearTimeout(self.resizeTimeoutID);
     self.resizeTimeoutID = setTimeout(delayedResize, 150);
   }
-  
+
   // Scroll to anchor in overlay. This needs to be done after delayedResize().
   if (iframeWindow.document.location.hash) {
     window.scrollTo(0, self.$iframeWindow(iframeWindow.document.location.hash).position().top);
@@ -573,46 +534,6 @@
 };
 
 /**
- * Check if the given link is in the administrative section of the site.
- *
- * @param url
- *   The url to be tested.
- * @return boolean
- *   TRUE if the URL represents an administrative link, FALSE otherwise.
- */
-Drupal.overlay.isAdminLink = function (url) {
-  var self = this;
-  // Create a native Link object, so we can use its object methods.
-  var link = $(url.link(url)).get(0);
-  var path = link.pathname;
-  // Ensure a leading slash on the path, omitted in some browsers.
-  if (path.substr(0, 1) != '/') {
-    path = '/' + path;
-  }
-  path = path.replace(new RegExp(Drupal.settings.basePath), '');
-  if (path == '') {
-    // If the path appears empty, it might mean the path is represented in the
-    // query string (clean URLs are not used).
-    var match = new RegExp("(\\?|&)q=(.+)(&|$)").exec(link.search);
-    if (match && match.length == 4) {
-      path = match[2];
-    }
-  }
-
-  // Turn the list of administrative paths into a regular expression.
-  if (!self.adminPathRegExp) {
-    var adminPaths = '^(' + Drupal.settings.overlay.paths.admin.replace(/\s+/g, ')$|^(') + ')$';
-    var nonAdminPaths = '^(' + Drupal.settings.overlay.paths.non_admin.replace(/\s+/g, ')$|^(') + ')$';
-    adminPaths = adminPaths.replace(/\*/g, '.*');
-    nonAdminPaths = nonAdminPaths.replace(/\*/g, '.*');
-    self.adminPathRegExp = new RegExp(adminPaths);
-    self.nonAdminPathRegExp = new RegExp(nonAdminPaths);
-  }
-
-  return self.adminPathRegExp.exec(path) && !self.nonAdminPathRegExp.exec(path);
-};
-
-/**
  * Resize overlay according to the size of its content.
  *
  * @todo: Watch for experience in the way we compute the size of the iframed
@@ -688,39 +609,126 @@
 };
 
 /**
- * Add overlay rendering GET parameter to the given href.
+ * Click event handler.
+ *
+ * Instead of binding a click event handler to every link we bound one to the
+ * document and handle events that bubble up. This allows other scripts to bind
+ * their own handlers to links and also to prevent overlay's handling.
+ *
+ * This handler makes links in displaced regions work correctly, even when the
+ * overlay is open.
+ *
+ * This handler also is being used by the overlay iframe.
+ *
+ * @see Drupal.overlayChild.behaviors.addClickHandler (overlay-child.js)
  */
-Drupal.overlay.addOverlayParam = function (href) {
-  return $.param.querystring(href, {'render': 'overlay'});
-  // Do not process links with an empty href, or that only have the fragment or
-  // which are external links.
-  if (href.length > 0 && href.charAt(0) != '#' && href.indexOf('http') != 0 && href.indexOf('https') != 0) {
-    var fragmentIndex = href.indexOf('#');
-    var fragment = '';
-    if (fragmentIndex != -1) {
-      fragment = href.substr(fragmentIndex);
-      href = href.substr(0, fragmentIndex);
+Drupal.overlay.clickHandler = function (event) {
+  var self = Drupal.overlay;
+
+  var $target = $(event.target);
+
+  if (self.isOpen && $target.closest('.overlay-displace-top, .overlay-displace-bottom').length) {
+    // jQuery UI Dialog prevents all clicks outside a modal dialog. It checks
+    // if target is inside a dialog and compares its z-index against this
+    // variable. By setting it to -1, jQuery UI Dialog let the event propagate.
+    $.ui.dialog.overlay.maxZ = -1;
+    // Click events in displaced regions could potentionally change the size of
+    // that region (e.g. the toggle button of the toolbar module). Trigger the
+    // resize event to force a recalculation of overlay's size/position.
+    $(window).triggerHandler('resize');
+  }
+
+  // Only continue by left-click or right-click.
+  if (!(event.button == 0 || event.button == 2)) {
+    return;
+  }
+
+  // Only continue if clicked target (or one of its parents) is a link.
+  if (!$target.is('a') || $target.hasClass('overlay-exclude')) {
+    $target = $target.closest('a');
+    if (!$target.length) {
+      return;
+    }
+  }
+
+  var href = $target.attr('href');
+  // Only continue if link has an href attribute and user is not pressing the
+  // ALT, CTRL, META (Command key on the Macintosh keyboard) or SHIFT key.
+  if (!event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey && href != undefined) {
+    // Open admin links in the overlay.
+    if (self.isAdminLink(href)) {
+      href = self.fragmentizeLink($target.get(0));
+      if (event.button == 0) {
+        // Redirect to a fragmentized href. This will trigger a hashchange event.
+        self.redirect(href);
+        // Prevent default action and further propagation of the event.
+        return false;
+      }
+      // Right-click without pressing any key: open overlay in new window.
+      else {
+        // Alter clicked link's href. This is being picked up by the default
+        // action handler.
+        $target.attr('href', href);
+      }
+    }
+    // Open external links in a new window.
+    else if ($target.get(0).hostname != window.location.hostname) {
+      // Add a target attribute to the clicked link. This is being picked up by
+      // the default action handler.
+      $target.attr('target', '_new');
+    }
+    // Non-admin links should close the overlay and open in the main window.
+    // Only handle them if the overlay is open and the clicked link is inside
+    // the overlay iframe, else default action will do fine.
+    else if (self.isOpen) {
+      var inFrame = false;
+      // W3C: http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-UIEvent-view
+      if (event.view && event.view.frameElement != null) {
+        inFrame = true;
+      }
+      // IE: http://msdn.microsoft.com/en-us/library/ms534331%28VS.85%29.aspx
+      else if (event.target.ownerDocument.parentWindow && event.target.ownerDocument.parentWindow.frameElement != null) {
+        inFrame = true;
+      }
+
+      // Add a target attribute to the clicked link. This is being picked up by
+      // the default action handler.
+      if (inFrame) {
+        // Make the link to be opening in the immediate parent of the frame.
+        $target.attr('target', '_parent');
+      }
     }
-    href += (href.indexOf('?') > -1 ? '&' : '?') + 'render=overlay' + fragment;
   }
-  return href;
 };
 
 /**
  * Open, reload, or close the overlay, based on the current URL fragment.
  */
-Drupal.overlay.trigger = function () {
+Drupal.overlay.hashchangeHandler = function (event) {
+  var self = Drupal.overlay;
+
+  // If we changed the hash to reflect an internal redirect in the overlay,
+  // its location has already been changed, so don't do anything.
+  if ($.data(window.location, window.location.href) === 'redirect') {
+    $.data(window.location, window.location.href, null);
+    return;
+  }
+
   // Get the overlay URL from the current URL fragment.
   var state = $.bbq.getState('overlay');
   if (state) {
     // Append render variable, so the server side can choose the right
     // rendering and add child modal frame code to the page if needed.
-    var linkURL = Drupal.overlay.addOverlayParam(Drupal.settings.basePath + state);
+    var linkURL = Drupal.settings.basePath + state;
+    linkURL = $.param.querystring(linkURL, {'render': 'overlay'});
+
+    var path = self.getPath(linkURL);
+    self.resetActiveClass(path);
 
     // If the modal frame is already open, replace the loaded document with
     // this new one.
-    if (Drupal.overlay.isOpen) {
-      Drupal.overlay.load(linkURL);
+    if (self.isOpen) {
+      self.load(linkURL);
     }
     else {
       // There is not an overlay opened yet; we should open a new one.
@@ -729,23 +737,46 @@
         onOverlayClose: function () {
           // Clear the overlay URL fragment.
           $.bbq.pushState();
-          // Remove active class from all header buttons.
-          $('a.overlay-processed').each(function () {
-            $(this).removeClass('active');
-          });
+
+          self.resetActiveClass(window.location.pathname);
         }
       };
-      Drupal.overlay.open(overlayOptions);
+      self.open(overlayOptions);
     }
   }
   // If there is no overlay URL in the fragment and the overlay is (still)
   // open, close the overlay.
-  else if (Drupal.overlay.isOpen && !Drupal.overlay.isClosing) {
-    Drupal.overlay.close();
+  else if (self.isOpen && !self.isClosing) {
+    self.close();
   }
 };
 
 /**
+ * Check if the given link is in the administrative section of the site.
+ *
+ * @param url
+ *   The url to be tested.
+ * @return boolean
+ *   TRUE if the URL represents an administrative link, FALSE otherwise.
+ */
+Drupal.overlay.isAdminLink = function (url) {
+  var self = this;
+  var path = self.getPath(url);
+
+  // Turn the list of administrative paths into a regular expression.
+  if (!self.adminPathRegExp) {
+    var adminPaths = '^(' + Drupal.settings.overlay.paths.admin.replace(/\s+/g, ')$|^(') + ')$';
+    var nonAdminPaths = '^(' + Drupal.settings.overlay.paths.non_admin.replace(/\s+/g, ')$|^(') + ')$';
+    adminPaths = adminPaths.replace(/\*/g, '.*');
+    nonAdminPaths = nonAdminPaths.replace(/\*/g, '.*');
+    self.adminPathRegExp = new RegExp(adminPaths);
+    self.nonAdminPathRegExp = new RegExp(nonAdminPaths);
+  }
+
+  return self.adminPathRegExp.exec(path) && !self.nonAdminPathRegExp.exec(path);
+};
+
+/**
  * Make a regular admin link into a URL that will trigger the overlay to open.
  *
  * @param link
@@ -755,36 +786,25 @@
  *   /node/1#overlay=admin/config).
  */
 Drupal.overlay.fragmentizeLink = function (link) {
+  var self = this;
   // Don't operate on links that are already overlay-ready.
   var params = $.deparam.fragment(link.href);
   if (params.overlay) {
     return link.href;
   }
 
-  // Determine the link's original destination, and make it relative to the
-  // Drupal site.
-  var path = link.pathname;
-  // Ensure a leading slash on the path, omitted in some browsers.
-  if (path.substr(0, 1) != '/') {
-    path = '/' + path;
-  }
-  path = path.replace(new RegExp(Drupal.settings.basePath), '');
+  // Determine the link's original destination.
+  var path = self.getPath(link);
   // Preserve existing query and fragment parameters in the URL.
-  var fragment = link.hash;
-  var querystring = link.search;
-  // If the query includes ?render=overlay, leave it out.
-  if (querystring.indexOf('render=overlay') !== -1) {
-    querystring = querystring.replace(/render=overlay/, '');
-    if (querystring === '?') {
-      querystring = '';
-    }
-  }
-
-  var destination = path + querystring + fragment;
+  var destination = path + link.search + link.hash;
 
   // Assemble the overlay-ready link.
-  var base = window.location.href;
-  return $.param.fragment(base, {'overlay':destination});
+  var newLink = $.param.fragment(window.location.href, {'overlay': destination});
+  // $.param.fragment() escaped slashes in the overlay part: unescape them.
+  var regexp = new RegExp("(?:[#&]overlay=)" + escape(path).replace(/\//g, '%2F'));
+  newLink = newLink.replace(regexp, unescape);
+
+  return newLink;
 };
 
 /**
@@ -838,6 +858,63 @@
 };
 
 /**
+ * Reset the active class on links in displaced regions according to given path.
+ *
+ * @param activePath
+ *   Path to match links against.
+ */
+Drupal.overlay.resetActiveClass = function(activePath) {
+  var self = this;
+
+  $('.overlay-displace-top, .overlay-displace-bottom')
+  .find('a[href]')
+  // Remove active class from all links in displaced regions.
+  .removeClass('active')
+  // Add active class to links that match activePath.
+  .each(function () {
+    var windowDomain = window.location.protocol + window.location.hostname;
+    var linkDomain = this.protocol + this.hostname;
+    var linkPath = self.getPath(this);
+
+    if (linkDomain == windowDomain && linkPath == activePath) {
+      $(this).addClass('active');
+    }
+  });
+};
+
+/**
+ * Helper function to get the (corrected) drupal path of a link.
+ *
+ * @param link
+ *   Link object or string to get the drupal path from.
+ * @return
+ *   The drupal path.
+ */
+Drupal.overlay.getPath = function (link) {
+  if (typeof link == 'string') {
+    // Create a native Link object, so we can use its object methods.
+    link = $(link.link(link)).get(0);
+  }
+
+  var path = link.pathname;
+  // Ensure a leading slash on the path, omitted in some browsers.
+  if (path.charAt(0) != '/') {
+    path = '/' + path;
+  }
+  path = path.replace(new RegExp(Drupal.settings.basePath), '');
+  if (path == '') {
+    // If the path appears empty, it might mean the path is represented in the
+    // query string (clean URLs are not used).
+    var match = new RegExp("([?&])q=(.+)([&#]|$)").exec(link.search);
+    if (match && match.length == 4) {
+      path = match[2];
+    }
+  }
+
+  return path;
+};
+
+/**
  * Theme function to create the overlay iframe element.
  */
 Drupal.theme.prototype.overlayElement = function () {
Index: modules/overlay/overlay-child.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay-child.js,v
retrieving revision 1.3
diff -u -r1.3 overlay-child.js
--- modules/overlay/overlay-child.js	23 Dec 2009 21:33:52 -0000	1.3
+++ modules/overlay/overlay-child.js	28 Dec 2009 19:07:30 -0000
@@ -3,11 +3,6 @@
 (function ($) {
 
 /**
- * Overlay object for child windows.
- */
-Drupal.overlayChild = Drupal.overlayChild || { processed: false, behaviors: {} };
-
-/**
  * Attach the child dialog behavior to new content.
  */
 Drupal.behaviors.overlayChild = {
@@ -68,6 +63,11 @@
 };
 
 /**
+ * Overlay object for child windows.
+ */
+Drupal.overlayChild = Drupal.overlayChild || { processed: false, behaviors: {} };
+
+/**
  * Attach child related behaviors to the iframe document.
  */
 Drupal.overlayChild.attachBehaviors = function (context, settings) {
@@ -87,54 +87,21 @@
 };
 
 /**
- * Modify links and forms depending on their relation to the overlay.
- *
- * By default, forms and links are assumed to keep the flow in the overlay.
- * Thus their action and href attributes respectively get a ?render=overlay
- * suffix. Non-administrative links should however close the overlay and
- * redirect the parent page to the given link. This would include links in a
- * content listing, where administration options are mixed with links to the
- * actual content to be shown on the site out of the overlay.
- *
- * @see Drupal.overlay.isAdminLink()
+ * Instead of binding a click event handler to every link we bind one to the
+ * document and handle events that bubble up. This also allows other scripts
+ * to bind their own handlers to links and also to prevent overlay's handling.
  */
-Drupal.overlayChild.behaviors.parseLinks = function (context, settings) {
-  var closeAndRedirectOnClick = function (event) {
-    // We need to store the parent variable locally because it will
-    // disappear as soon as we close the iframe.
-    var parentWindow = parent;
-    if (parentWindow.Drupal.overlay.close(false)) {
-      parentWindow.Drupal.overlay.redirect($(this).attr('href'));
-    }
-    return false;
-  };
-  var redirectOnClick = function (event) {
-    parent.Drupal.overlay.redirect($(this).attr('href'));
-    return false;
-  };
-
-  $('a:not(.overlay-exclude)', context).once('overlay', function () {
-    var href = $(this).attr('href');
-    // Skip links that don't have an href attribute.
-    if (href == undefined) {
-      return;
-    }
-    // Non-admin links should close the overlay and open in the main window.
-    else if (!parent.Drupal.overlay.isAdminLink(href)) {
-      $(this).click(closeAndRedirectOnClick);
-    }
-    // Open external links in a new window.
-    else if (href.indexOf('http') > 0 || href.indexOf('https') > 0) {
-      $(this).attr('target', '_new');
-    }
-    // Open admin links in the overlay.
-    else {
-      $(this)
-        .attr('href', parent.Drupal.overlay.fragmentizeLink(this))
-        .click(redirectOnClick);
-    }
-  });
+Drupal.overlayChild.behaviors.addClickHandler = function (context, settings) {
+  $(document).bind('click', parent.Drupal.overlay.clickHandler);
+};
 
+/**
+ * Modify forms depending on their relation to the overlay.
+ *
+ * By default, forms are assumed to keep the flow in the overlay. Thus their
+ * action attribute get a ?render=overlay suffix.
+ */
+Drupal.overlayChild.behaviors.parseForms = function (context, settings) {
   $('form', context).once('overlay', function () {
     // Obtain the action attribute of the form.
     var action = $(this).attr('action');
Index: modules/overlay/overlay.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay.module,v
retrieving revision 1.4
diff -u -r1.4 overlay.module
--- modules/overlay/overlay.module	14 Dec 2009 16:36:56 -0000	1.4
+++ modules/overlay/overlay.module	28 Dec 2009 19:07:31 -0000
@@ -73,13 +73,16 @@
       }
       // Indicate that we are viewing an overlay child page.
       overlay_set_mode('child');
+
+      // Unset the render parameter to avoid it being included in URLs on the page.
+      unset($_GET['render']);
     }
     else {
       // Otherwise add overlay parent code and our behavior.
-      overlay_set_mode('parent');
+        overlay_set_mode('parent');
+      }
     }
   }
-}
 
 /**
  * Implements hook_exit().
@@ -282,7 +285,6 @@
  */
 function overlay_preprocess_toolbar(&$variables) {
   $variables['classes_array'][] = "overlay-displace-top";
-  $variables['toolbar']['toolbar_toggle']['#attributes']['class'][] = 'overlay-displace-no-click';
 }
 
 /**
@@ -303,7 +305,7 @@
  * @ingroup forms
  */
 function overlay_form_after_build($form, &$form_state) {
-  if (isset($_GET['render']) && $_GET['render'] == 'overlay') {
+  if (overlay_get_mode() == 'child') {
     // Form API may have already captured submit handlers from the submitted
     // button before after_build callback is invoked. This may have been done
     // by _form_builder_handle_input_element(). If so, the list of submit
Index: modules/toolbar/toolbar.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.js,v
retrieving revision 1.10
diff -u -r1.10 toolbar.js
--- modules/toolbar/toolbar.js	2 Dec 2009 07:28:22 -0000	1.10
+++ modules/toolbar/toolbar.js	28 Dec 2009 19:07:31 -0000
@@ -11,19 +11,11 @@
     $('#toolbar', context).once('toolbar', Drupal.admin.toolbar.init);
 
     // Toggling toolbar drawer.
-    $('#toolbar a.toggle', context).once('toolbar-toggle').click(function() {
+    $('#toolbar a.toggle', context).once('toolbar-toggle').click(function(e) {
       Drupal.admin.toolbar.toggle();
-      return false;
-    });
-
-    // Set the most recently clicked item as active.
-    $('#toolbar a').once().click(function() {
-      $('#toolbar a').each(function() {
-        $(this).removeClass('active');
-      });
-      if ($(this).parents('div.toolbar-shortcuts').length) {
-        $(this).addClass('active');
-      }
+      // Allow other scripts to bind their own handlers, but prevent default
+      // action.
+      e.preventDefault();
     });
   }
 };
@@ -48,7 +40,7 @@
   else {
     Drupal.admin.toolbar.expand();
   }
-}
+};
 
 /**
  * Collapse the admin toolbar.
@@ -62,15 +54,15 @@
     .html(toggle_text);
   $('body').removeClass('toolbar-drawer');
   $.cookie(
-    'Drupal.admin.toolbar.collapsed', 
-    1, 
+    'Drupal.admin.toolbar.collapsed',
+    1,
     {
       path: Drupal.settings.basePath,
       // The cookie should "never" expire.
       expires: 36500
     }
   );
-}
+};
 
 /**
  * Expand the admin toolbar.
@@ -84,15 +76,15 @@
     .html(toggle_text);
   $('body').addClass('toolbar-drawer');
   $.cookie(
-    'Drupal.admin.toolbar.collapsed', 
-    0, 
+    'Drupal.admin.toolbar.collapsed',
+    0,
     {
       path: Drupal.settings.basePath,
       // The cookie should "never" expire.
       expires: 36500
     }
   );
-}
+};
 
 /**
  * Toggle the admin toolbar.
@@ -104,10 +96,10 @@
   else {
     Drupal.admin.toolbar.collapse();
   }
-}
+};
 
 Drupal.admin.toolbar.height = function() {
   return $("#toolbar").height();
-}
+};
 
 })(jQuery);
