Index: modules/overlay/overlay.install
===================================================================
RCS file: modules/overlay/overlay.install
diff -N modules/overlay/overlay.install
--- modules/overlay/overlay.install	18 Jan 2010 17:12:04 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,20 +0,0 @@
-<?php
-// $Id: overlay.install,v 1.3 2010/01/18 17:12:04 dries Exp $
-
-/**
- * @file
- * Install, update and uninstall functions for the overlay module.
- */
-
-/**
- * Implements hook_enable().
- *
- * If the module is being enabled through the admin UI, and not from an
- * install profile, reopen the modules page in an overlay.
- */
-function overlay_enable() {
-  if (strpos(current_path(), 'admin/modules') === 0) {
-    // Flag for a redirect to <front>#overlay=admin/modules on hook_init().
-    $_SESSION['overlay_enable_redirect'] = 1;
-  }
-}
Index: modules/overlay/overlay-child.js
===================================================================
RCS file: modules/overlay/overlay-child.js
diff -N modules/overlay/overlay-child.js
--- modules/overlay/overlay-child.js	8 Jul 2010 12:20:23 -0000	1.10
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,180 +0,0 @@
-// $Id: overlay-child.js,v 1.10 2010/07/08 12:20:23 dries Exp $
-
-(function ($) {
-
-/**
- * Attach the child dialog behavior to new content.
- */
-Drupal.behaviors.overlayChild = {
-  attach: function (context, settings) {
-    // Make sure this behavior is not processed more than once.
-    if (this.processed) {
-      return;
-    }
-    this.processed = true;
-
-    // If we cannot reach the parent window, break out of the overlay.
-    if (!parent.Drupal || !parent.Drupal.overlay) {
-      window.location = window.location.href.replace(/([?&]?)render=overlay&?/g, '$1').replace(/\?$/, '');
-    }
-
-    var settings = settings.overlayChild || {};
-
-    // If the entire parent window should be refreshed when the overlay is
-    // closed, pass that information to the parent window.
-    if (settings.refreshPage) {
-      parent.Drupal.overlay.refreshPage = true;
-    }
-
-    // If a form has been submitted successfully, then the server side script
-    // may have decided to tell the parent window to close the popup dialog.
-    if (settings.closeOverlay) {
-      parent.Drupal.overlay.bindChild(window, true);
-      // Use setTimeout to close the child window from a separate thread,
-      // because the current one is busy processing Drupal behaviors.
-      setTimeout(function () {
-        if (typeof settings.redirect == 'string') {
-          parent.Drupal.overlay.redirect(settings.redirect);
-        }
-        else {
-          parent.Drupal.overlay.close();
-        }
-      }, 1);
-      return;
-    }
-
-    // If one of the regions displaying outside the overlay needs to be
-    // reloaded immediately, let the parent window know.
-    if (settings.refreshRegions) {
-      parent.Drupal.overlay.refreshRegions(settings.refreshRegions);
-    }
-
-    // Ok, now we can tell the parent window we're ready.
-    parent.Drupal.overlay.bindChild(window);
-
-    // IE8 crashes on certain pages if this isn't called; reason unknown.
-    window.scrollTo(window.scrollX, window.scrollY);
-
-    // Attach child related behaviors to the iframe document.
-    Drupal.overlayChild.attachBehaviors(context, settings);
-  }
-};
-
-/**
- * Overlay object for child windows.
- */
-Drupal.overlayChild = Drupal.overlayChild || {
-  behaviors: {}
-};
-
-Drupal.overlayChild.prototype = {};
-
-/**
- * Attach child related behaviors to the iframe document.
- */
-Drupal.overlayChild.attachBehaviors = function (context, settings) {
-  $.each(this.behaviors, function () {
-    this(context, settings);
-  });
-};
-
-/**
- * Capture and handle clicks.
- *
- * 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.addClickHandler = function (context, settings) {
-  $(document).bind('click.drupal-overlay mouseup.drupal-overlay', $.proxy(parent.Drupal.overlay, 'eventhandlerOverrideLink'));
-};
-
-/**
- * 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');
-    // Keep internal forms in the overlay.
-    if (action == undefined || (action.indexOf('http') != 0 && action.indexOf('https') != 0)) {
-      action += (action.indexOf('?') > -1 ? '&' : '?') + 'render=overlay';
-      $(this).attr('action', action);
-    }
-    // Submit external forms into a new window.
-    else {
-      $(this).attr('target', '_new');
-    }
-  });
-};
-
-/**
- * Replace the overlay title with a message while loading another page.
- */
-Drupal.overlayChild.behaviors.loading = function (context, settings) {
-  var $title;
-  var text = Drupal.t('Loading');
-  var dots = '';
-
-  $(document).bind('drupalOverlayBeforeLoad.drupal-overlay.drupal-overlay-child-loading', function () {
-    $title = $('#overlay-title').text(text);
-    var id = setInterval(function () {
-      dots = (dots.length > 10) ? '' : dots + '.';
-      $title.text(text + dots);
-    }, 500);
-  });
-};
-
-/**
- * Switch active tab immediately.
- */
-Drupal.overlayChild.behaviors.tabs = function (context, settings) {
-  var $tabsLinks = $('#overlay-tabs > li > a');
-
-  $('#overlay-tabs > li > a').bind('click.drupal-overlay', function () {
-    var active_tab = Drupal.t('(active tab)');
-    $tabsLinks.parent().siblings().removeClass('active').find('element-invisible:contains(' + active_tab + ')').appendTo(this);
-    $(this).parent().addClass('active');
-  });
-};
-
-/**
- * If the shortcut add/delete button exists, move it to the overlay titlebar.
- */
-Drupal.overlayChild.behaviors.shortcutAddLink = function (context, settings) {
-  // Remove any existing shortcut button markup from the titlebar.
-  $('#overlay-titlebar').find('.add-or-remove-shortcuts').remove();
-  // If the shortcut add/delete button exists, move it to the titlebar.
-  var $addToShortcuts = $('.add-or-remove-shortcuts');
-  if ($addToShortcuts.length) {
-    $addToShortcuts.insertAfter('#overlay-title');
-  }
-
-  $(document).bind('drupalOverlayBeforeLoad.drupal-overlay.drupal-overlay-child-loading', function () {
-    $('#overlay-titlebar').find('.add-or-remove-shortcuts').remove();
-  });
-};
-
-/**
- * Use displacement from parent window.
- */
-Drupal.overlayChild.behaviors.alterTableHeaderOffset = function (context, settings) {
-  if (Drupal.settings.tableHeaderOffset) {
-    Drupal.overlayChild.prevTableHeaderOffset = Drupal.settings.tableHeaderOffset;
-  }
-  Drupal.settings.tableHeaderOffset = 'Drupal.overlayChild.tableHeaderOffset';
-};
-
-/**
- * Callback for Drupal.settings.tableHeaderOffset.
- */
-Drupal.overlayChild.tableHeaderOffset = function () {
-  var topOffset = Drupal.overlayChild.prevTableHeaderOffset ? eval(Drupal.overlayChild.prevTableHeaderOffset + '()') : 0;
-
-  return topOffset + parseInt($(document.body).css('marginTop'));
-};
-
-})(jQuery);
Index: modules/overlay/overlay-parent.css
===================================================================
RCS file: modules/overlay/overlay-parent.css
diff -N modules/overlay/overlay-parent.css
--- modules/overlay/overlay-parent.css	8 Jun 2010 05:16:29 -0000	1.15
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,48 +0,0 @@
-/* $Id: overlay-parent.css,v 1.15 2010/06/08 05:16:29 webchick Exp $ */
-
-html.overlay-open,
-html.overlay-open body {
-  height: 100%;
-  overflow: hidden;
-}
-
-#overlay-container,
-.overlay-modal-background,
-.overlay-element {
-  height: 100%;
-  left: 0;
-  position: fixed;
-  top: 0;
-  width: 100%;
-  z-index: 500;
-}
-
-.overlay-modal-background {
-  /* Using a transparent png renders faster than using opacity */
-  background: transparent url(images/background.png) repeat;
-}
-
-.overlay-element {
-  background: transparent;
-  left: -200%;
-  z-index: 501;
-}
-.overlay-element.overlay-active {
-  left: 0;
-}
-
-html.overlay-open .displace-top,
-html.overlay-open .displace-bottom {
-  z-index: 600;
-}
-
-/**
- * IE6 shows elements with position:fixed as position:static so replace
- * it with position:absolute;
- */
-* html #overlay-container,
-* html .overlay-modal-background,
-* html .overlay-element
-{
-  position: absolute;
-}
Index: modules/overlay/overlay.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay.module,v
retrieving revision 1.30
diff -u -r1.30 overlay.module
--- modules/overlay/overlay.module	11 Aug 2010 02:08:09 -0000	1.30
+++ modules/overlay/overlay.module	17 Aug 2010 22:45:42 -0000
@@ -14,26 +14,12 @@
     case 'admin/help#overlay':
       $output = '';
       $output .= '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t('The Overlay module makes the administration pages on your site display in a JavaScript overlay of the page you were viewing when you clicked the administrative link, instead of replacing the page in your browser window. Use the close link on the overlay to return to the page you were viewing when you clicked the link. For more information, see the online handbook entry for <a href="@overlay">Overlay module</a>.', array('@overlay' => 'http://drupal.org/handbook/modules/overlay')) . '</p>';
+      $output .= '<p>' . t('The Overlay module makes the administration pages on your site display in a overlay on top of the page you were viewing when you clicked the administrative link. Use the close link on the overlay to return to the page you were viewing when you clicked the link. For more information, see the online handbook entry for <a href="@overlay">Overlay module</a>.', array('@overlay' => 'http://drupal.org/handbook/modules/overlay')) . '</p>';
       return $output;
   }
 }
 
 /**
- * Implements hook_menu().
- */
-function overlay_menu() {
-  $items['overlay-ajax/%'] = array(
-    'title' => '',
-    'page callback' => 'overlay_ajax_render_region',
-    'page arguments' => array(1),
-    'access arguments' => array('access overlay'),
-    'type' => MENU_CALLBACK,
-  );
-  return $items;
-}
-
-/**
  * Implements hook_permission().
  */
 function overlay_permission() {
@@ -101,35 +87,16 @@
 function overlay_init() {
   global $user;
 
-  $mode = overlay_get_mode();
-
   // Only act if the user has access to the overlay and a mode was not already
   // set. Other modules can also enable the overlay directly for other uses.
   $use_overlay = !isset($user->data['overlay']) || $user->data['overlay'];
-  if (empty($mode) && user_access('access overlay') && $use_overlay) {
+  if ($use_overlay && overlay_get_mode() === NULL && user_access('access overlay')) {
     $current_path = current_path();
-    // After overlay is enabled on the modules page, redirect to
-    // <front>#overlay=admin/modules to actually enable the overlay.
-    if (isset($_SESSION['overlay_enable_redirect']) && $_SESSION['overlay_enable_redirect']) {
-      unset($_SESSION['overlay_enable_redirect']);
-      drupal_goto('<front>', array('fragment' => 'overlay=' . $current_path));
-    }
-
-    if (isset($_GET['render']) && $_GET['render'] == 'overlay') {
-      // If this page shouldn't be rendered here, redirect to the parent.
-      if (!path_is_admin($current_path)) {
-        overlay_close_dialog($current_path);
-      }
 
-      // Indicate that we are viewing an overlay child page.
+    if (path_is_admin($current_path)) {
       overlay_set_mode('child');
-
-      // Unset the render parameter to avoid it being included in URLs on the page.
-      unset($_GET['render']);
     }
-    // Do not enable the overlay if we already are on an admin page.
-    elseif (!path_is_admin($current_path)) {
-      // Otherwise add overlay parent code and our behavior.
+    elseif (isset($_GET['overlay-context'])) {
       overlay_set_mode('parent');
     }
   }
@@ -137,107 +104,11 @@
 
 /**
  * Implements hook_exit().
- *
- * When viewing an overlay child page, check if we need to trigger a refresh of
- * the supplemental regions of the overlay on the next page request.
  */
 function overlay_exit() {
-  // Check that we are in an overlay child page. Note that this should never
-  // return TRUE on a cached page view, since the child mode is not set until
-  // overlay_init() is called.
-  if (overlay_get_mode() == 'child') {
-    // Load any markup that was stored earlier in the page request, via calls
-    // to overlay_store_rendered_content(). If none was stored, this is not a
-    // page request where we expect any changes to the overlay supplemental
-    // regions to have occurred, so we do not need to proceed any further.
-    $original_markup = overlay_get_rendered_content();
-    if (!empty($original_markup)) {
-      // Compare the original markup to the current markup that we get from
-      // rendering each overlay supplemental region now. If they don't match,
-      // something must have changed, so we request a refresh of that region
-      // within the parent window on the next page request.
-      foreach (overlay_supplemental_regions() as $region) {
-        if (!isset($original_markup[$region]) || $original_markup[$region] != overlay_render_region($region)) {
-          overlay_request_refresh($region);
-        }
-      }
-    }
-  }
-}
-
-/**
- * Implements hook_library().
- */
-function overlay_library() {
-  $module_path = drupal_get_path('module', 'overlay');
-
-  // Overlay parent.
-  $libraries['parent'] = array(
-    'title' => 'Overlay: Parent',
-    'website' => 'http://drupal.org/handbook/modules/overlay',
-    'version' => '1.0',
-    'js' => array(
-      $module_path . '/overlay-parent.js' => array(),
-    ),
-    'css' => array(
-      $module_path . '/overlay-parent.css' => array(),
-    ),
-    'dependencies' => array(
-      array('system', 'ui'),
-      array('system', 'jquery-bbq'),
-    ),
-  );
-  // Overlay child.
-  $libraries['child'] = array(
-    'title' => 'Overlay: Child',
-    'website' => 'http://drupal.org/handbook/modules/overlay',
-    'version' => '1.0',
-    'js' => array(
-      $module_path . '/overlay-child.js' => array(),
-    ),
-    'css' => array(
-      $module_path . '/overlay-child.css' => array(),
-    ),
-  );
-
-  return $libraries;
-}
-
-/**
- * Implements hook_drupal_goto_alter().
- *
- * If the current page request is inside the overlay, add ?render=overlay to
- * the new path, so that it appears correctly inside the overlay.
- *
- * @see overlay_get_mode()
- */
-function overlay_drupal_goto_alter(&$path, &$options, &$http_response_code) {
-  if (overlay_get_mode() == 'child') {
-    if (isset($options['query'])) {
-      $options['query'] += array('render' => 'overlay');
-    }
-    else {
-      $options['query'] = array('render' => 'overlay');
-    }
-  }
-}
-
-/**
- * Implements hook_batch_alter().
- *
- * If the current page request is inside the overlay, add ?render=overlay to
- * the success callback URL, so that it appears correctly within the overlay.
- *
- * @see overlay_get_mode()
- */
-function overlay_batch_alter(&$batch) {
-  if (overlay_get_mode() == 'child') {
-    if (isset($batch['url_options']['query'])) {
-      $batch['url_options']['query']['render'] = 'overlay';
-    }
-    else {
-      $batch['url_options']['query'] = array('render' => 'overlay');
-    }
+  // Update context during hook_exit() to retrieve te correct page title.
+  if (overlay_get_mode() === NULL) {
+    overlay_set_context();
   }
 }
 
@@ -286,6 +157,8 @@
  */
 function overlay_system_info_alter(&$info, $file, $type) {
   if ($type == 'theme') {
+    $info['overlay_regions'][] = 'page_top';
+    $info['overlay_regions'][] = 'page_bottom';
     $info['overlay_regions'][] = 'content';
     $info['overlay_regions'][] = 'help';
   }
@@ -294,14 +167,13 @@
 /**
  * Implements hook_preprocess_html().
  *
- * If the current page request is inside the overlay, add appropriate classes
- * to the <body> element, and simplify the page title.
+ * If the current page request is inside the overlay, overlay class, so themes
+ * can react to being displayed in the overlay.
  *
  * @see overlay_get_mode()
  */
 function overlay_preprocess_html(&$variables) {
   if (overlay_get_mode() == 'child') {
-    // Add overlay class, so themes can react to being displayed in the overlay.
     $variables['classes_array'][] = 'overlay';
   }
 }
@@ -309,10 +181,7 @@
 /**
  * Implements hook_preprocess_maintenance_page().
  *
- * If the current page request is inside the overlay, add appropriate classes
- * to the <body> element, and simplify the page title.
- *
- * @see overlay_preprocess_maintenance_page()
+ * @see overlay_preprocess_html()
  */
 function overlay_preprocess_maintenance_page(&$variables) {
   overlay_preprocess_html($variables);
@@ -324,8 +193,18 @@
  * @see overlay.tpl.php
  */
 function template_preprocess_overlay(&$variables) {
-  $variables['tabs']              = menu_primary_local_tasks();
-  $variables['title']             = drupal_get_title();
+  $context = overlay_get_context();
+
+  $context_url_options = $context['options'];
+  $context_url_options['query']['overlay-context'] = NULL;
+
+  $variables['overlay_context_url'] = url($context['path'], $context_url_options);
+
+  $variables['overlay_close'] = l('<span class="element-invisible">' . $context['title'] . '</span>', $context['path'],  array('html' => TRUE, 'attributes' => array('id' => 'overlay-close', 'class' => 'overlay-close')) + $context['options']);
+
+
+  $variables['tabs'] = menu_primary_local_tasks();
+  $variables['title'] = drupal_get_title();
 
   $variables['content_attributes_array']['class'][] = 'clearfix';
 }
@@ -360,59 +239,6 @@
 }
 
 /**
- * Callback to request that the overlay display an empty page.
- *
- * This is used to prevent a page request which closes the overlay (for
- * example, a form submission) from being fully re-rendered before the overlay
- * is closed. Instead, we store a variable which will cause the page to be
- * rendered by a delivery callback function that does not actually print
- * visible HTML (but rather only the bare minimum scripts and styles necessary
- * to trigger the overlay to close), thereby allowing the dialog to be closed
- * faster and with less interruption, and also allowing the display of messages
- * to be deferred to the parent window (rather than displaying them in the
- * child window, which will close before the user has had a chance to read
- * them).
- *
- * @param $value
- *   By default, an empty page will not be displayed. Set to TRUE to request
- *   an empty page display, or FALSE to disable the empty page display (if it
- *   was previously enabled on this page request).
- *
- * @return
- *   TRUE if the current behavior is to display an empty page, or FALSE if not.
- *
- * @see overlay_page_delivery_callback_alter()
- */
-function overlay_display_empty_page($value = NULL) {
-  $display_empty_page = &drupal_static(__FUNCTION__, FALSE);
-  if (isset($value)) {
-    $display_empty_page = $value;
-  }
-  return $display_empty_page;
-}
-
-/**
- * Implements hook_page_delivery_callback_alter().
- */
-function overlay_page_delivery_callback_alter(&$callback) {
-  if (overlay_display_empty_page()) {
-    $callback = 'overlay_deliver_empty_page';
-  }
-}
-
-/**
- * Delivery callback to display an empty page.
- *
- * This function is used to print out a bare minimum empty page which still has
- * the scripts and styles necessary in order to trigger the overlay to close.
- */
-function overlay_deliver_empty_page() {
-  $empty_page = '<html><head><title></title>' . drupal_get_css() . drupal_get_js() . '</head><body class="overlay"></body></html>';
-  print $empty_page;
-  drupal_exit();
-}
-
-/**
  * Get the current overlay mode.
  *
  * @see overlay_set_mode()
@@ -450,7 +276,6 @@
  * @return
  *   The current mode, if any has been set, or NULL if no mode has been set.
  *
- * @ingroup overlay_api
  * @see overlay_init()
  */
 function overlay_set_mode($mode = NULL) {
@@ -466,15 +291,11 @@
 
   switch ($overlay_mode) {
     case 'parent':
-      drupal_add_library('overlay', 'parent');
-
       // Allow modules to act upon overlay events.
       module_invoke_all('overlay_parent_initialize');
       break;
 
     case 'child':
-      drupal_add_library('overlay', 'child');
-
       // Allow modules to act upon overlay events.
       module_invoke_all('overlay_child_initialize');
       break;
@@ -486,38 +307,32 @@
  * Implements hook_overlay_parent_initialize().
  */
 function overlay_overlay_parent_initialize() {
-  // Let the client side know which paths are administrative.
-  $paths = path_get_admin_paths();
-  foreach ($paths as &$type) {
-    $type = str_replace('<front>', variable_get('site_frontpage', 'node'), $type);
-  }
-  drupal_add_js(array('overlay' => array('paths' => $paths)), 'setting');
-  // Pass along the AJAX callback for rerendering sections of the parent window.
-  drupal_add_js(array('overlay' => array('ajaxCallback' => 'overlay-ajax')), 'setting');
+  $context = overlay_get_context();
+  $etag = md5($context['path']);
+
+  $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] : FALSE;
+  if (!overlay_refresh_context() && $if_none_match !== FALSE && $if_none_match == $etag) {
+    drupal_add_http_header('Status', '304 Not Modified');
+    drupal_exit();
+  }
+
+  unset($_SESSION['overlay-refresh-context']);
+  drupal_add_http_header('ETag', $etag);
+  drupal_add_http_header('Cache-Control', 'private, must-revalidate, post-check=0, pre-check=10');
 }
 
 /**
  * Implements hook_overlay_child_initialize().
  */
 function overlay_overlay_child_initialize() {
-  // Check if the parent window needs to refresh any page regions on this page
-  // request.
-  overlay_trigger_refresh();
   // If this is a POST request, or a GET request with a token parameter, we
-  // have an indication that something in the supplemental regions of the
-  // overlay might change during the current page request. We therefore store
-  // the initial rendered content of those regions here, so that we can compare
-  // it to the same content rendered in overlay_exit(), at the end of the page
-  // request. This allows us to check if anything actually did change, and, if
-  // so, trigger an immediate AJAX refresh of the parent window.
+  // have an indication that during the current page request something in
+  // the context document might change.
   if (!empty($_POST) || isset($_GET['token'])) {
-    foreach (overlay_supplemental_regions() as $region) {
-      overlay_store_rendered_content($region, overlay_render_region($region));
-    }
-    // In addition, notify the parent window that when the overlay closes,
-    // the entire parent window should be refreshed.
-    overlay_request_page_refresh();
+    overlay_refresh_context(TRUE);
   }
+  drupal_add_css(drupal_get_path('module', 'overlay') . '/overlay.css');
+
   // Indicate that when the main page rendering occurs later in the page
   // request, only the regions that appear within the overlay should be
   // rendered.
@@ -525,36 +340,6 @@
 }
 
 /**
- * Callback to request that the overlay close as soon as the page is displayed.
- *
- * @param $redirect
- *   (optional) The path that should open in the parent window after the
- *   overlay closes. If not set, no redirect will be performed on the parent
- *   window.
- * @param $redirect_options
- *   (optional) An associative array of options to use when generating the
- *   redirect URL.
- */
-function overlay_close_dialog($redirect = NULL, $redirect_options = array()) {
-  $settings = array(
-    'overlayChild' => array(
-      'closeOverlay' => TRUE,
-    ),
-  );
-
-  // Tell the child window to perform the redirection when requested to.
-  if (isset($redirect)) {
-    $settings['overlayChild']['redirect'] = url($redirect, $redirect_options);
-  }
-
-  drupal_add_js($settings, array('type' => 'setting'));
-
-  // Since we are closing the overlay as soon as the page is displayed, we do
-  // not want to show any of the page's actual content.
-  overlay_display_empty_page(TRUE);
-}
-
-/**
  * Returns a list of page regions that appear in the overlay.
  *
  * Overlay regions correspond to the entire contents of the overlay child
@@ -564,36 +349,12 @@
  * @return
  *   An array of region names that correspond to those which appear in the
  *   overlay, within the theme that is being used to display the current page.
- *
- * @see overlay_supplemental_regions()
  */
 function overlay_regions() {
   return _overlay_region_list('overlay_regions');
 }
 
 /**
- * Returns a list of supplemental page regions for the overlay.
- *
- * Supplemental overlay regions are those which are technically part of the
- * parent window, but appear to the user as being related to the overlay
- * (usually because they are displayed next to, rather than underneath, the
- * main overlay regions) and therefore need to be dynamically refreshed if any
- * administrative actions taken within the overlay change their contents.
- *
- * An example of a typical overlay supplemental region would be the 'page_top'
- * region, in the case where a toolbar is being displayed there.
- *
- * @return
- *   An array of region names that correspond to supplemental overlay regions,
- *   within the theme that is being used to display the current page.
- *
- * @see overlay_regions()
- */
-function overlay_supplemental_regions() {
-  return _overlay_region_list('overlay_supplemental_regions');
-}
-
-/**
  * Helper function for returning a list of page regions related to the overlay.
  *
  * @param $type
@@ -661,163 +422,57 @@
 }
 
 /**
- * Renders an individual page region.
- *
- * This function is primarily intended to be used for checking the content of
- * supplemental overlay regions (e.g., a region containing a toolbar). Passing
- * in a region that is intended to display the main page content is not
- * supported; the region will be rendered by this function, but the main page
- * content will not appear in it. In addition, although this function returns
- * the rendered HTML for the provided region, it does not place it on the final
- * page, nor add any of its associated JavaScript or CSS to the page.
- *
- * @param $region
- *   The name of the page region that should be rendered.
+ * Returns the currently active overlay context.
  *
  * @return
- *   The rendered HTML of the provided region.
+ *   An array containing information of the currently active overlay context.
  */
-function overlay_render_region($region) {
-  // Indicate the region that we will be rendering, so that other regions will
-  // be hidden by overlay_page_alter() and overlay_block_list_alter().
-  overlay_set_regions_to_render(array($region));
-  // Do what is necessary to force drupal_render_page() to only display HTML
-  // from the requested region. Specifically, declare that the main page
-  // content does not need to automatically be added to the page, and pass in
-  // a page array that has all theme functions removed (so that overall HTML
-  // for the page will not be added either).
-  $system_main_content_added = &drupal_static('system_main_content_added');
-  $system_main_content_added = TRUE;
-  $page = array(
-    '#type' => 'page',
-    '#theme' => NULL,
-    '#theme_wrappers' => array(),
+function overlay_get_context() {
+  $defaults = array(
+    'title' => variable_get('site_name', 'Drupal'),
+    'path' => variable_get('site_frontpage', 'node'),
+    'options' => array()
   );
-  // Render the region, but do not cache any JavaScript or CSS associated with
-  // it. This region might not be included the next time drupal_render_page()
-  // is called, and we do not want its JavaScript or CSS to erroneously appear
-  // on the final rendered page.
-  $original_js = drupal_add_js();
-  $original_css = drupal_add_css();
-  $js = &drupal_static('drupal_add_js');
-  $css = &drupal_static('drupal_add_css');
-  $markup = drupal_render_page($page);
-  $js = $original_js;
-  $css = $original_css;
-  // Indicate that the main page content has not, in fact, been displayed, so
-  // that future calls to drupal_render_page() will be able to render it
-  // correctly.
-  $system_main_content_added = FALSE;
-  // Restore the original behavior of rendering all regions for the next time
-  // drupal_render_page() is called.
-  overlay_set_regions_to_render(array());
-  return $markup;
-}
 
-/**
- * Returns any rendered content that was stored earlier in the page request.
- *
- * @return
- *   An array of all rendered HTML that was stored earlier in the page request,
- *   keyed by the identifier with which it was stored. If no content was
- *   stored, an empty array is returned.
- *
- * @see overlay_store_rendered_content()
- */
-function overlay_get_rendered_content() {
-  return overlay_store_rendered_content();
+  return isset($_SESSION['overlay-context']) ? $_SESSION['overlay-context'] + $defaults : $defaults;
 }
 
 /**
- * Stores strings representing rendered HTML content.
- *
- * This function is used to keep a static cache of rendered content that can be
- * referred to later in the page request.
- *
- * @param $id
- *   (Optional) An identifier for the content which is being stored, which will
- *   be used as an array key in the returned array. If omitted, no change will
- *   be made to the current stored data.
- * @param $content
- *   (Optional) A string representing the rendered data to store. This only has
- *   an effect if $id is also provided.
  *
- * @return
- *   An array representing all data that is currently being stored, or an empty
- *   array if there is none.
- *
- * @see overlay_get_rendered_content()
+ * @param unknown_type $title
+ * @param unknown_type $path
+ * @param unknown_type $options
+ * @return unknown_type
  */
-function overlay_store_rendered_content($id = NULL, $content = NULL) {
-  $rendered_content = &drupal_static(__FUNCTION__, array());
-  if (isset($id)) {
-    $rendered_content[$id] = $content;
+function overlay_set_context($title = NULL, $path = NULL, $options = array()) {
+  if (isset($title, $path)) {
+    $_SESSION['overlay-context'] = array(
+      'title' => $title,
+      'path' => $path,
+      'options' => $options
+    );
   }
-  return $rendered_content;
-}
-
-/**
- * Request that the parent window refresh a particular page region.
- *
- * @param $region
- *   The name of the page region to refresh. The parent window will trigger a
- *   refresh of this region on the next page load.
- *
- * @see overlay_trigger_refresh()
- * @see Drupal.overlay.refreshRegions()
- */
-function overlay_request_refresh($region) {
-  $class = drupal_region_class($region);
-  $_SESSION['overlay_regions_to_refresh'][] = array($class => $region);
-}
-
-/**
- * Request that the entire parent window be reloaded when the overlay closes.
- *
- * @see overlay_trigger_refresh()
- */
-function overlay_request_page_refresh() {
-  $_SESSION['overlay_refresh_parent'] = TRUE;
-}
-
-/**
- * Check if the parent window needs to be refreshed on this page load.
- *
- * If the previous page load requested that any page regions be refreshed, or
- * if it requested that the entire page be refreshed when the overlay closes,
- * pass that request via JavaScript to the child window, so it can in turn pass
- * the request to the parent window.
- *
- * @see overlay_request_refresh()
- * @see overlay_request_page_refresh()
- * @see Drupal.overlay.refreshRegions()
- */
-function overlay_trigger_refresh() {
-  if (!empty($_SESSION['overlay_regions_to_refresh'])) {
-    $settings = array(
-      'overlayChild' => array(
-        'refreshRegions' => $_SESSION['overlay_regions_to_refresh'],
+  elseif (!drupal_is_front_page()) {
+    $_SESSION['overlay-context'] = array(
+      'title' => drupal_get_title(),
+      'path' => $_GET['q'],
+      'options' => array(
+        'query' => drupal_get_query_parameters(),
       ),
     );
-    drupal_add_js($settings, array('type' => 'setting'));
-    unset($_SESSION['overlay_regions_to_refresh']);
   }
-  if (!empty($_SESSION['overlay_refresh_parent'])) {
-    drupal_add_js(array('overlayChild' => array('refreshPage' => TRUE)), array('type' => 'setting'));
-    unset($_SESSION['overlay_refresh_parent']);
+  else {
+    unset($_SESSION['overlay-context']);
   }
 }
 
 /**
- * Prints the markup obtained by rendering a single region of the page.
- *
- * This function is intended to be called via AJAX.
- *
- * @param $region
- *   The name of the page region to render.
- *
- * @see Drupal.overlay.refreshRegions()
+ * Request that the overlay context document be refreshed instead of retrieved
+ * from browser cache.
  */
-function overlay_ajax_render_region($region) {
-  print overlay_render_region($region);
+function overlay_refresh_context($value = NULL) {
+  if (isset($value)) {
+    $_SESSION['overlay-refresh-context'] = (bool) $value;
+  }
+  return isset($_SESSION['overlay-refresh-context']) ? $_SESSION['overlay-refresh-context'] : FALSE;
 }
Index: modules/overlay/overlay-parent.js
===================================================================
RCS file: modules/overlay/overlay-parent.js
diff -N modules/overlay/overlay-parent.js
--- modules/overlay/overlay-parent.js	31 Jul 2010 12:54:59 -0000	1.53
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,830 +0,0 @@
-// $Id: overlay-parent.js,v 1.53 2010/07/31 12:54:59 webchick Exp $
-
-(function ($) {
-
-/**
- * Open the overlay, or load content into it, when an admin link is clicked.
- */
-Drupal.behaviors.overlayParent = {
-  attach: function (context, settings) {
-    if (this.processed) {
-      return;
-    }
-    this.processed = true;
-
-    $(window)
-      // When the hash (URL fragment) changes, open the overlay if needed.
-      .bind('hashchange.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOperateByURLFragment'))
-      // Trigger the hashchange handler once, after the page is loaded, so that
-      // permalinks open the overlay.
-      .triggerHandler('hashchange.drupal-overlay');
-
-    $(document)
-      // 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.
-      .bind('click.drupal-overlay mouseup.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOverrideLink'));
-  }
-};
-
-/**
- * Overlay object for parent windows.
- *
- * Events
- * Overlay triggers a number of events that can be used by other scripts.
- * - drupalOverlayOpen: This event is triggered when the overlay is opened.
- * - drupalOverlayBeforeClose: This event is triggered when the overlay attempts
- *   to close. If an event handler returns false, the close will be prevented.
- * - drupalOverlayClose: This event is triggered when the overlay is closed.
- * - drupalOverlayBeforeLoad: This event is triggered right before a new URL
- *   is loaded into the overlay.
- * - drupalOverlayReady: This event is triggered when the DOM of the overlay
- *   child document is fully loaded.
- * - drupalOverlayLoad: This event is triggered when the overlay is finished
- *   loading.
- * - drupalOverlayResize: This event is triggered when the overlay is being
- *   resized to match the parent window.
- */
-Drupal.overlay = Drupal.overlay || {
-  isOpen: false,
-  isOpening: false,
-  isClosing: false,
-  isLoading: false
-};
-
-Drupal.overlay.prototype = {};
-
-/**
- * Open the overlay.
- *
- * @param url
- *   The URL of the page to open in the overlay.
- *
- * @return
- *   TRUE if the overlay was opened, FALSE otherwise.
- */
-Drupal.overlay.open = function (url) {
-  // Just one overlay is allowed.
-  if (this.isOpen || this.isOpening) {
-    return this.load(url);
-  }
-  this.isOpening = true;
-  // Store the original document title.
-  this.originalTitle = document.title;
-
-  // Create the dialog and related DOM elements.
-  this.create();
-
-  this.isOpening = false;
-  this.isOpen = true;
-  $(document.documentElement).addClass('overlay-open');
-
-  // Allow other scripts to respond to this event.
-  $(document).trigger('drupalOverlayOpen');
-
-  return this.load(url);
-};
-
-/**
- * Create the underlying markup and behaviors for the overlay.
- */
-Drupal.overlay.create = function () {
-  this.$container = $(Drupal.theme('overlayContainer'))
-    .appendTo(document.body);
-
-  // Overlay uses transparent iframes that cover the full parent window.
-  // When the overlay is open the scrollbar of the parent window is hidden.
-  // Because some browsers show a white iframe background for a short moment
-  // while loading a page into an iframe, overlay uses two iframes. By loading
-  // the page in a hidden (inactive) iframe the user doesn't see the white
-  // background. When the page is loaded the active and inactive iframes
-  // are switched.
-  this.activeFrame = this.$iframeA = $(Drupal.theme('overlayElement'))
-    .appendTo(this.$container);
-
-  this.inactiveFrame = this.$iframeB = $(Drupal.theme('overlayElement'))
-    .appendTo(this.$container);
-
-  this.$iframeA.bind('load.drupal-overlay', { self: this.$iframeA[0], sibling: this.$iframeB }, $.proxy(this, 'loadChild'));
-  this.$iframeB.bind('load.drupal-overlay', { self: this.$iframeB[0], sibling: this.$iframeA }, $.proxy(this, 'loadChild'));
-
-  // Add a second class "drupal-overlay-open" to indicate these event handlers
-  // should only be bound when the overlay is open.
-  var eventClass = '.drupal-overlay.drupal-overlay-open';
-  $(window)
-    .bind('resize' + eventClass, $.proxy(this, 'eventhandlerOuterResize'));
-  $(document)
-    .bind('drupalOverlayLoad' + eventClass, $.proxy(this, 'eventhandlerOuterResize'))
-    .bind('drupalOverlayReady' + eventClass +
-          ' drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerSyncURLFragment'))
-    .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRefreshPage'))
-    .bind('drupalOverlayBeforeClose' + eventClass +
-          ' drupalOverlayBeforeLoad' + eventClass +
-          ' drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerDispatchEvent'))
-    .bind('keydown' + eventClass, $.proxy(this, 'eventhandlerRestrictKeyboardNavigation'));
-
-  if ($('.overlay-displace-top, .overlay-displace-bottom').length) {
-    $(document)
-      .bind('drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerAlterDisplacedElements'))
-      .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRestoreDisplacedElements'));
-  }
-};
-
-/**
- * Load the given URL into the overlay iframe.
- *
- * Use this method to change the URL being loaded in the overlay if it is
- * already open.
- *
- * @return
- *   TRUE if URL is loaded into the overlay, FALSE otherwise.
- */
-Drupal.overlay.load = function (url) {
-  if (!this.isOpen) {
-    return false;
-  }
-
-  // Allow other scripts to respond to this event.
-  $(document).trigger('drupalOverlayBeforeLoad');
-
-  $(document.documentElement).addClass('overlay-loading');
-
-  // The contentDocument property is not supported in IE until IE8.
-  var iframeDocument = this.inactiveFrame[0].contentDocument || this.inactiveFrame[0].contentWindow.document;
-
-  // location.replace doesn't create a history entry. location.href does.
-  // In this case, we want location.replace, as we're creating the history
-  // entry using URL fragments.
-  iframeDocument.location.replace(url);
-
-  // Immediately move the focus to the iframe.
-  this.inactiveFrame.focus();
-  return true;
-};
-
-/**
- * Close the overlay and remove markup related to it from the document.
- *
- * @return
- *   TRUE if the overlay was closed, FALSE otherwise.
- */
-Drupal.overlay.close = function () {
-  // Prevent double execution when close is requested more than once.
-  if (!this.isOpen || this.isClosing) {
-    return false;
-  }
-
-  // Allow other scripts to respond to this event.
-  var event = $.Event('drupalOverlayBeforeClose');
-  $(document).trigger(event);
-  // If a handler returned false, the close will be prevented.
-  if (event.isDefaultPrevented()) {
-    return false;
-  }
-
-  this.isClosing = true;
-  this.isOpen = false;
-  $(document.documentElement).removeClass('overlay-open');
-  // Restore the original document title.
-  document.title = this.originalTitle;
-
-  // Allow other scripts to respond to this event.
-  $(document).trigger('drupalOverlayClose');
-
-  // When the iframe is still loading don't destroy it immediately but after
-  // the content is loaded (see Drupal.overlay.loadChild).
-  if (!this.isLoading) {
-    this.destroy();
-    this.isClosing = false;
-  }
-  return true;
-};
-
-/**
- * Destroy the overlay.
- */
-Drupal.overlay.destroy = function () {
-  $([document, window]).unbind('.drupal-overlay-open');
-  this.$iframeA.unbind('.drupal-overlay');
-  this.$iframeB.unbind('.drupal-overlay');
-  this.$container.remove();
-
-  this.$container = null;
-  this.$iframeA = null;
-  this.$iframeB = null;
-
-  this.iframeWindow = null;
-};
-
-/**
- * Redirect the overlay parent window to the given URL.
- *
- * @param url
- *   Can be an absolute URL or a relative link to the domain root.
- */
-Drupal.overlay.redirect = function (url) {
-  // Create a native Link object, so we can use its object methods.
-  var link = $(url.link(url)).get(0);
-
-  // If the link is already open, force the hashchange event to simulate reload.
-  if (window.location.href == link.href) {
-    $(window).triggerHandler('hashchange.drupal-overlay');
-  }
-
-  window.location.href = link.href;
-  return true;
-};
-
-/**
- * Bind the child window.
- *
- * Note that this function is fired earlier than Drupal.overlay.loadChild.
- */
-Drupal.overlay.bindChild = function (iframeWindow, isClosing) {
-  this.iframeWindow = iframeWindow;
-
-  // We are done if the child window is closing.
-  if (isClosing || this.isClosing || !this.isOpen) {
-    return;
-  }
-
-  // Allow other scripts to respond to this event.
-  $(document).trigger('drupalOverlayReady');
-};
-
-/**
- * Event handler: load event handler for the overlay iframe.
- *
- * @param event
- *   Event being triggered, with the following restrictions:
- *   - event.type: load
- *   - event.currentTarget: iframe
- */
-Drupal.overlay.loadChild = function (event) {
-  var iframe = event.data.self;
-  var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
-  var iframeWindow = iframeDocument.defaultView || iframeDocument.parentWindow;
-  if (iframeWindow.location == 'about:blank') {
-    return;
-  }
-
-  this.isLoading = false;
-  $(document.documentElement).removeClass('overlay-loading');
-  event.data.sibling.removeClass('overlay-active');
-
-  // Only continue when overlay is still open and not closing.
-  if (this.isOpen && !this.isClosing) {
-    // And child document is an actual overlayChild.
-    if (iframeWindow.Drupal && iframeWindow.Drupal.overlayChild) {
-      // Replace the document title with title of iframe.
-      document.title = iframeWindow.document.title;
-
-      this.activeFrame = $(iframe)
-        .addClass('overlay-active')
-        // Add a title attribute to the iframe for accessibility.
-        .attr('title', Drupal.t('@title dialog', { '@title': iframeWindow.jQuery('#overlay-title').text() }));
-      this.inactiveFrame = event.data.sibling;
-
-      // Load an empty document into the inactive iframe.
-      (this.inactiveFrame[0].contentDocument || this.inactiveFrame[0].contentWindow.document).location.replace('about:blank');
-
-      // Allow other scripts to respond to this event.
-      $(document).trigger('drupalOverlayLoad');
-    }
-    else {
-      window.location = iframeWindow.location.href.replace(/([?&]?)render=overlay&?/g, '$1').replace(/\?$/, '');
-    }
-  }
-  else {
-    this.destroy();
-  }
-};
-
-/**
- * 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 path = this.getPath(url);
-
-  // Turn the list of administrative paths into a regular expression.
-  if (!this.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, '.*');
-    this.adminPathRegExp = new RegExp(adminPaths);
-    this.nonAdminPathRegExp = new RegExp(nonAdminPaths);
-  }
-
-  return this.adminPathRegExp.exec(path) && !this.nonAdminPathRegExp.exec(path);
-};
-
-/**
- * Event handler: resizes overlay according to the size of the parent window.
- *
- * @param event
- *   Event being triggered, with the following restrictions:
- *   - event.type: any
- *   - event.currentTarget: any
- */
-Drupal.overlay.eventhandlerOuterResize = function (event) {
-  // Proceed only if the overlay still exists.
-  if (!(this.isOpen || this.isOpening) || this.isClosing || !this.iframeWindow) {
-    return;
-  }
-
-  // IE6 uses position:absolute instead of position:fixed.
-  if (typeof document.body.style.maxHeight != 'string') {
-    this.activeFrame.height($(window).height());
-  }
-
-  // Allow other scripts to respond to this event.
-  $(document).trigger('drupalOverlayResize');
-};
-
-/**
- * Event handler: resizes displaced elements so they won't overlap the scrollbar
- * of overlay's iframe.
- *
- * @param event
- *   Event being triggered, with the following restrictions:
- *   - event.type: any
- *   - event.currentTarget: any
- */
-Drupal.overlay.eventhandlerAlterDisplacedElements = function (event) {
-  // Proceed only if the overlay still exists.
-  if (!(this.isOpen || this.isOpening) || this.isClosing || !this.iframeWindow) {
-    return;
-  }
-
-  $(this.iframeWindow.document.body).css({
-    marginTop: Drupal.overlay.getDisplacement('top'),
-    marginBottom: Drupal.overlay.getDisplacement('bottom')
-  })
-  // IE7 isn't reflowing the document immediately.
-  // @todo This might be fixed in a cleaner way.
-  .addClass('overlay-trigger-reflow').removeClass('overlay-trigger-reflow');
-
-  var documentHeight = this.iframeWindow.document.body.clientHeight;
-  var documentWidth = this.iframeWindow.document.body.clientWidth;
-  // IE6 doesn't support maxWidth, use width instead.
-  var maxWidthName = (typeof document.body.style.maxWidth == 'string') ? 'maxWidth' : 'width';
-
-  // Consider any element that should be visible above the overlay (such as
-  // a toolbar).
-  $('.overlay-displace-top, .overlay-displace-bottom').each(function () {
-    var data = $(this).data();
-    var maxWidth = documentWidth;
-    // In IE, Shadow filter makes element to overlap the scrollbar with 1px.
-    if (this.filters && this.filters.length && this.filters.item('DXImageTransform.Microsoft.Shadow')) {
-      maxWidth -= 1;
-    }
-
-    // Prevent displaced elements overlapping window's scrollbar.
-    var currentMaxWidth = parseInt($(this).css(maxWidthName));
-    if ((data.drupalOverlay && data.drupalOverlay.maxWidth) || isNaN(currentMaxWidth) || currentMaxWidth > maxWidth || currentMaxWidth <= 0) {
-      $(this).css(maxWidthName, maxWidth);
-      (data.drupalOverlay = data.drupalOverlay || {}).maxWidth = true;
-    }
-
-    // Use a more rigorous approach if the displaced element still overlaps
-    // window's scrollbar; clip the element on the right.
-    var offset = $(this).offset();
-    var offsetRight = offset.left + $(this).outerWidth();
-    if ((data.drupalOverlay && data.drupalOverlay.clip) || offsetRight > maxWidth) {
-      $(this).css('clip', 'rect(auto, ' + (maxWidth - offset.left) + 'px, ' + (documentHeight - offset.top) + 'px, auto)');
-      (data.drupalOverlay = data.drupalOverlay || {}).clip = true;
-    }
-  });
-};
-
-/**
- * Event handler: restores size of displaced elements as they were before
- * overlay was opened.
- *
- * @param event
- *   Event being triggered, with the following restrictions:
- *   - event.type: any
- *   - event.currentTarget: any
- */
-Drupal.overlay.eventhandlerRestoreDisplacedElements = function (event) {
-  var $displacedElements = $('.overlay-displace-top, .overlay-displace-bottom');
-  try {
-    $displacedElements.css({ maxWidth: null, clip: null });
-  }
-  // IE bug that doesn't allow unsetting style.clip (http://dev.jquery.com/ticket/6512).
-  catch (err) {
-    $displacedElements.attr('style', function (index, attr) {
-      return attr.replace(/clip\s*:\s*rect\([^)]+\);?/i, '');
-    });
-  }
-};
-
-/**
- * Event handler: overrides href of administrative links to be opened in
- * the overlay.
- *
- * This click event handler should be bound to any document (for example the
- * overlay iframe) of which you want links to open in the overlay.
- *
- * @param event
- *   Event being triggered, with the following restrictions:
- *   - event.type: click, mouseup
- *   - event.currentTarget: document
- *
- * @see Drupal.overlayChild.behaviors.addClickHandler
- */
-Drupal.overlay.eventhandlerOverrideLink = function (event) {
-  // In some browsers the click event isn't fired for right-clicks. Use the
-  // mouseup event for right-clicks and the click event for everything else.
-  if ((event.type == 'click' && event.button == 2) || (event.type == 'mouseup' && event.button != 2)) {
-    return;
-  }
-
-  var $target = $(event.target);
-
-  // Only continue if clicked target (or one of its parents) is a link.
-  if (!$target.is('a')) {
-    $target = $target.closest('a');
-    if (!$target.length) {
-      return;
-    }
-  }
-
-  // Never open links in the overlay that contain the overlay-exclude class.
-  if ($target.hasClass('overlay-exclude')) {
-    return;
-  }
-
-  // Close the overlay when the link contains the overlay-close class.
-  if ($target.hasClass('overlay-close')) {
-    // Clearing the overlay URL fragment will close the overlay.
-    $.bbq.removeState('overlay');
-    return;
-  }
-
-  var target = $target[0];
-  var href = target.href;
-  // Only handle links that have an href attribute and use the http(s) protocol.
-  if (href != undefined && href != '' && target.protocol.match(/^https?\:/)) {
-    var anchor = href.replace(target.ownerDocument.location.href, '');
-    // Skip anchor links.
-    if (anchor.length == 0 || anchor.charAt(0) == '#') {
-      return;
-    }
-    // Open admin links in the overlay.
-    else if (this.isAdminLink(href)) {
-      // If the link contains the overlay-restore class and the overlay-context
-      // state is set, also update the parent window's location.
-      var parentLocation = ($target.hasClass('overlay-restore') && typeof $.bbq.getState('overlay-context') == 'string')
-        ? Drupal.settings.basePath + $.bbq.getState('overlay-context')
-        : null;
-      href = this.fragmentizeLink($target.get(0), parentLocation);
-      // Only override default behavior when left-clicking and user is not
-      // pressing the ALT, CTRL, META (Command key on the Macintosh keyboard)
-      // or SHIFT key.
-      if (event.button == 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
-        // Redirect to a fragmentized href. This will trigger a hashchange event.
-        this.redirect(href);
-        // Prevent default action and further propagation of the event.
-        return false;
-      }
-      // Otherwise alter clicked link's href. This is being picked up by
-      // the default action handler.
-      else {
-        $target
-          // Restore link's href attribute on blur or next click.
-          .one('blur mousedown', { target: target, href: target.href }, function (event) { $(event.data.target).attr('href', event.data.href); })
-          .attr('href', href);
-      }
-    }
-    // Non-admin links should close the overlay and open in the main window,
-    // which is the default action for a link. We only need to handle them
-    // if the overlay is open and the clicked link is inside the overlay iframe.
-    else if (this.isOpen && target.ownerDocument === this.iframeWindow.document) {
-      // Open external links in a new window.
-      if (target.hostname != window.location.hostname) {
-        // Add a target attribute to the clicked link. This is being picked up by
-        // the default action handler.
-        if (!$target.attr('target')) {
-          $target.attr('target', '_new');
-        }
-      }
-      else {
-        // Add the overlay-context state to the link, so "overlay-restore" links
-        // can restore the context.
-        $target.attr('href', $.param.fragment(href, { 'overlay-context': this.getPath(window.location) + window.location.search }));
-
-        // When the link has a destination query parameter and that destination
-        // is an admin link we need to fragmentize it. This will make it reopen
-        // in the overlay.
-        var params = $.deparam.querystring(href);
-        if (params.destination && this.isAdminLink(params.destination)) {
-          var fragmentizedDestination = $.param.fragment(this.getPath(window.location), { overlay: params.destination });
-          $target.attr('href', $.param.querystring(href, { destination: fragmentizedDestination }));
-        }
-
-        // Make the link open in the immediate parent of the frame.
-        $target.attr('target', '_parent');
-      }
-    }
-  }
-};
-
-/**
- * Event handler: opens or closes the overlay based on the current URL fragment.
- *
- * @param event
- *   Event being triggered, with the following restrictions:
- *   - event.type: hashchange
- *   - event.currentTarget: document
- */
-Drupal.overlay.eventhandlerOperateByURLFragment = function (event) {
-  // 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 frame code to the page if needed.
-    var url = $.param.querystring(Drupal.settings.basePath + state, { render: 'overlay' });
-
-    this.open(url);
-    this.resetActiveClass(this.getPath(Drupal.settings.basePath + state));
-  }
-  // If there is no overlay URL in the fragment and the overlay is (still)
-  // open, close the overlay.
-  else if (this.isOpen && !this.isClosing) {
-    this.close();
-    this.resetActiveClass(this.getPath(window.location));
-  }
-};
-
-/**
- * Event handler: makes sure the internal overlay URL is reflected in the parent
- * URL fragment.
- *
- * Normally the parent URL fragment determines the overlay location. However, if
- * the overlay redirects internally, the parent doesn't get informed, and the
- * parent URL fragment will be out of date. This is a sanity check to make
- * sure we're in the right place.
- *
- * The parent URL fragment is also not updated automatically when overlay's
- * open, close or load functions are used directly (instead of through
- * eventhandlerOperateByURLFragment).
- *
- * @param event
- *   Event being triggered, with the following restrictions:
- *   - event.type: drupalOverlayReady, drupalOverlayClose
- *   - event.currentTarget: document
- */
-Drupal.overlay.eventhandlerSyncURLFragment = function (event) {
-  if (this.isOpen) {
-    var expected = $.bbq.getState('overlay');
-    // This is just a sanity check, so we're comparing paths, not query strings.
-    if (this.getPath(Drupal.settings.basePath + expected) != this.getPath(this.iframeWindow.document.location)) {
-      // There may have been a redirect inside the child overlay window that the
-      // parent wasn't aware of. Update the parent URL fragment appropriately.
-      var newLocation = Drupal.overlay.fragmentizeLink(this.iframeWindow.document.location);
-      // Set a 'redirect' flag on the new location so the hashchange event handler
-      // knows not to change the overlay's content.
-      $.data(window.location, newLocation, 'redirect');
-      // Use location.replace() so we don't create an extra history entry.
-      window.location.replace(newLocation);
-    }
-  }
-  else {
-    $.bbq.removeState('overlay');
-  }
-};
-
-/**
- * Event handler: if the child window suggested that the parent refresh on
- * close, force a page refresh.
- *
- * @param event
- *   Event being triggered, with the following restrictions:
- *   - event.type: drupalOverlayClose
- *   - event.currentTarget: document
- */
-Drupal.overlay.eventhandlerRefreshPage = function (event) {
-  if (Drupal.overlay.refreshPage) {
-    window.location.reload(true);
-  }
-};
-
-/**
- * Event handler: makes sure that when the overlay is open no elements (except
- * for elements inside any displaced elements) of the parent document are
- * reachable through keyboard (TAB) navigation.
- *
- * @param event
- *   Event being triggered, with the following restrictions:
- *   - event.type: keydown
- *   - event.currentTarget: document
- */
-Drupal.overlay.eventhandlerRestrictKeyboardNavigation = function (event) {
-  if (!this.$tabbables) {
-    this.$tabbables = $(':tabbable');
-  }
-
-  if (event.keyCode && event.keyCode == $.ui.keyCode.TAB) {
-    // Whenever the focus is not inside the overlay (or a displaced element)
-    // move the focus along until it is.
-    var direction = event.shiftKey ? -1 : 1;
-    var current = this.$tabbables.index(event.target);
-    var $allowedParent = '#overlay-container, .overlay-displace-top, .overlay-displace-bottom';
-    if (current != -1 && this.$tabbables[current + direction] && !this.$tabbables.eq(current + direction).closest($allowedParent).length) {
-      while (this.$tabbables[current + direction] && !this.$tabbables.eq(current + direction).closest($allowedParent).length) {
-        current = current + direction;
-      }
-      // Move focus.
-      this.$tabbables.eq(current).focus();
-    }
-  }
-};
-
-/**
- * Event handler: dispatches events to the overlay document.
- *
- * @param event
- *   Event being triggered, with the following restrictions:
- *   - event.type: any
- *   - event.currentTarget: any
- */
-Drupal.overlay.eventhandlerDispatchEvent = function (event) {
-  if (this.iframeWindow && this.iframeWindow.document) {
-    this.iframeWindow.jQuery(this.iframeWindow.document).trigger(event);
-  }
-};
-
-/**
- * Make a regular admin link into a URL that will trigger the overlay to open.
- *
- * @param link
- *   A Javascript Link object (i.e. an <a> element).
- * @param parentLocation
- *   (optional) URL to override the parent window's location with.
- *
- * @return
- *   A URL that will trigger the overlay (in the form
- *   /node/1#overlay=admin/config).
- */
-Drupal.overlay.fragmentizeLink = function (link, parentLocation) {
-  // 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. Set ignorePathFromQueryString to
-  // true to prevent transforming this link into a clean URL while clean URLs
-  // may be disabled.
-  var path = this.getPath(link, true);
-  // Preserve existing query and fragment parameters in the URL, except for
-  // "render=overlay" which is re-added in Drupal.overlay.eventhandlerOperateByURLFragment.
-  var destination = path + link.search.replace(/&?render=overlay/, '').replace(/\?$/, '') + link.hash;
-
-  // Assemble and return the overlay-ready link.
-  return $.param.fragment(parentLocation || window.location.href, { overlay: destination });
-};
-
-/**
- * Refresh any regions of the page that are displayed outside the overlay.
- *
- * @param data
- *   An array of objects with information on the page regions to be refreshed.
- *   For each object, the key is a CSS class identifying the region to be
- *   refreshed, and the value represents the section of the Drupal $page array
- *   corresponding to this region.
- */
-Drupal.overlay.refreshRegions = function (data) {
-  $.each(data, function () {
-    var region_info = this;
-    $.each(region_info, function (regionClass) {
-      var regionName = region_info[regionClass];
-      var regionSelector = '.' + regionClass;
-      // Allow special behaviors to detach.
-      Drupal.detachBehaviors($(regionSelector));
-      $.get(Drupal.settings.basePath + Drupal.settings.overlay.ajaxCallback + '/' + regionName, function (newElement) {
-        $(regionSelector).replaceWith($(newElement));
-        Drupal.attachBehaviors($(regionSelector), Drupal.settings);
-      });
-    });
-  });
-};
-
-/**
- * Reset the active class on links in displaced elements according to
- * given path.
- *
- * @param activePath
- *   Path to match links against.
- */
-Drupal.overlay.resetActiveClass = function(activePath) {
-  var self = this;
-  var windowDomain = window.location.protocol + window.location.hostname;
-
-  $('.overlay-displace-top, .overlay-displace-bottom')
-  .find('a[href]')
-  // Remove active class from all links in displaced elements.
-  .removeClass('active')
-  // Add active class to links that match activePath.
-  .each(function () {
-    var linkDomain = this.protocol + this.hostname;
-    var linkPath = self.getPath(this);
-
-    // A link matches if it is part of the active trail of activePath, except
-    // for frontpage links.
-    if (linkDomain == windowDomain && (activePath + '/').indexOf(linkPath + '/') === 0 && (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.
- * @param ignorePathFromQueryString
- *   Boolean whether to ignore path from query string if path appears empty.
- *
- * @return
- *   The Drupal path.
- */
-Drupal.overlay.getPath = function (link, ignorePathFromQueryString) {
-  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 + '(?:index.php)?'), '');
-  if (path == '' && !ignorePathFromQueryString) {
-    // 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;
-};
-
-/**
- * Get the total displacement of given region.
- *
- * @param region
- *   Region name. Either "top" or "bottom".
- *
- * @return
- *   The total displacement of given region in pixels.
- */
-Drupal.overlay.getDisplacement = function (region) {
-  var displacement = 0;
-  var lastDisplaced = $('.overlay-displace-' + region + ':last');
-  if (lastDisplaced.length) {
-    displacement = lastDisplaced.offset().top + lastDisplaced.outerHeight();
-
-    // Remove height added by IE Shadow filter.
-    if (lastDisplaced[0].filters && lastDisplaced[0].filters.length && lastDisplaced[0].filters.item('DXImageTransform.Microsoft.Shadow')) {
-      displacement -= lastDisplaced[0].filters.item('DXImageTransform.Microsoft.Shadow').strength;
-      displacement = Math.max(0, displacement);
-    }
-  }
-  return displacement;
-};
-
-/**
- * Theme function to create the overlay iframe element.
- */
-Drupal.theme.prototype.overlayContainer = function () {
-  return '<div id="overlay-container" role="dialog"><div class="overlay-modal-background"></div></div>';
-};
-
-/**
- * Theme function to create an overlay iframe element.
- */
-Drupal.theme.prototype.overlayElement = function (url) {
-  return '<iframe class="overlay-element" frameborder="0" scrolling="auto" allowtransparency="true" role="document"></iframe>';
-};
-
-})(jQuery);
Index: modules/overlay/overlay-child.css
===================================================================
RCS file: modules/overlay/overlay-child.css
diff -N modules/overlay/overlay-child.css
--- modules/overlay/overlay-child.css	28 Jul 2010 01:26:00 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,140 +0,0 @@
-/* $Id: overlay-child.css,v 1.6 2010/07/28 01:26:00 dries Exp $ */
-
-html.js {
-  background: transparent !important;
-  overflow-y: scroll;
-}
-html.js body {
-  background: transparent !important;
-  padding: 20px 0;
-}
-
-#overlay {
-  display: table;
-  margin: 0 auto;
-  min-height: 100px;
-  min-width: 700px;
-  position: relative;
-  padding: .2em;
-  padding-right: 26px;
-  width: 88%;
-}
-#overlay-titlebar {
-  padding: 0 20px;
-  position: relative;
-  white-space: nowrap;
-  z-index: 100;
-}
-#overlay-content {
-  background: #fff;
-  clear: both;
-  color: #000;
-  padding: .5em 1em;
-  position: relative;
-}
-
-#overlay-title-wrapper {
-  overflow: hidden;
-}
-#overlay-title {
-  color: #fff;
-  float: left;
-  font-size: 20px;
-  margin: 0;
-  padding: 0.3em 0;
-}
-#overlay-title:active,
-#overlay-title:focus {
-  outline: 0;
-}
-
-#overlay-close-wrapper {
-  position: absolute;
-  right: 0;
-}
-#overlay-close,
-#overlay-close:hover {
-  background: transparent url(images/close.png) no-repeat;
-  -moz-border-radius-topleft: 0;
-  -webkit-border-top-left-radius: 0;
-  border-top-left-radius: 0;
-  display: block;
-  height: 26px;
-  margin: 0;
-  padding: 0;
-  /* Replace with position:fixed to get a scrolling close button. */
-  position: absolute;
-  width: 26px;
-}
-#overlay-title:active,
-#overlay-close:hover,
-#overlay-close:focus {
-  padding: 0;
-}
-
-/**
- * Tabs on the overlay.
- */
-#overlay-tabs {
-  line-height: 27px;
-  margin: -28px 0 0 0;
-  position: absolute;
-  right: 20px;
-  text-transform: uppercase;
-}
-#overlay-tabs li {
-  display: inline;
-  list-style: none;
-  margin: 0 0 0 -3px;
-  padding: 0;
-}
-#overlay-tabs li a,
-#overlay-tabs li a:active,
-#overlay-tabs li a:visited,
-#overlay-tabs li a:hover {
-  background-color: #a6a7a2;
-  -moz-border-radius: 8px 8px 0 0;
-  -webkit-border-top-left-radius: 8px;
-  -webkit-border-top-right-radius: 8px;
-  border-radius: 8px 8px 0 0;
-  color: #000;
-  display: inline-block;
-  font-size: 11px;
-  font-weight: bold;
-  margin: 0 0 2px 0;
-  outline: 0;
-  padding: 0 14px;
-  text-decoration: none;
-}
-#overlay-tabs li.active a,
-#overlay-tabs li.active a.active,
-#overlay-tabs li.active a:active,
-#overlay-tabs li.active a:visited {
-  background-color: #fff;
-  margin: 0;
-  padding-bottom: 2px;
-}
-#overlay-tabs li a:focus,
-#overlay-tabs li a:hover {
-  color: #fff;
-}
-#overlay-tabs li.active a:focus,
-#overlay-tabs li.active a:hover {
-  color: #000;
-}
-
-/**
- * Add to shortcuts link
- */
-#overlay-titlebar .add-or-remove-shortcuts {
-  padding-top: 0.9em;
-}
-
-/**
- * IE6 shows elements with position:fixed as position:static so replace
- * it with position:absolute;
- */
-* html #overlay-close,
-* html #overlay-close:hover {
-  position: absolute;
-}
Index: modules/overlay/overlay.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay.tpl.php,v
retrieving revision 1.3
diff -u -r1.3 overlay.tpl.php
--- modules/overlay/overlay.tpl.php	11 Jul 2010 22:03:45 -0000	1.3
+++ modules/overlay/overlay.tpl.php	17 Aug 2010 22:45:42 -0000
@@ -21,13 +21,16 @@
  */
 ?>
 
+<iframe id="overlay-context" frameborder="0" scrolling="no" src="<?php print $overlay_context_url; ?>" tabindex="-1"></iframe>
+<div id="overlay-modal-background"></div>
+
 <div id="overlay" <?php print $attributes; ?>>
   <div id="overlay-titlebar" class="clearfix">
     <div id="overlay-title-wrapper" class="clearfix">
       <h1 id="overlay-title"<?php print $title_attributes; ?>><?php print $title; ?></h1>
     </div>
     <div id="overlay-close-wrapper">
-      <a id="overlay-close" href="#" class="overlay-close"><span class="element-invisible"><?php print t('Close overlay'); ?></span></a>
+      <?php print $overlay_close; ?>
     </div>
     <?php if ($tabs): ?><ul id="overlay-tabs"><?php print render($tabs); ?></ul><?php endif; ?>
   </div>
Index: modules/overlay/overlay.css
===================================================================
RCS file: modules/overlay/overlay.css
diff -N modules/overlay/overlay.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/overlay/overlay.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,153 @@
+/* $Id: overlay-child.css,v 1.6 2010/07/28 01:26:00 dries Exp $ */
+
+html.js {
+  background: transparent !important;
+  overflow-y: scroll;
+}
+html.js body {
+  background: transparent !important;
+}
+
+#overlay-context,
+#overlay-modal-background {
+  height: 100%;
+  left: 0;
+  position: fixed;
+  top: 0;
+  width: 100%;
+}
+
+#overlay-modal-background {
+  /* Using a transparent png renders faster than using opacity */
+  background: transparent url(images/background.png) repeat;
+}
+
+#overlay {
+  display: table;
+  margin: 20px auto;
+  min-height: 100px;
+  min-width: 700px;
+  position: relative;
+  padding: .2em;
+  padding-right: 26px;
+  width: 88%;
+}
+#overlay-titlebar {
+  padding: 0 20px;
+  position: relative;
+  white-space: nowrap;
+  z-index: 100;
+}
+#overlay-content {
+  background: #fff;
+  clear: both;
+  color: #000;
+  padding: .5em 1em;
+  position: relative;
+}
+
+#overlay-title-wrapper {
+  overflow: hidden;
+}
+#overlay-title {
+  color: #fff;
+  float: left;
+  font-size: 20px;
+  margin: 0;
+  padding: 0.3em 0;
+}
+#overlay-title:active,
+#overlay-title:focus {
+  outline: 0;
+}
+
+#overlay-close-wrapper {
+  position: absolute;
+  right: 0;
+}
+#overlay-close,
+#overlay-close:hover {
+  background: transparent url(images/close.png) no-repeat;
+  -moz-border-radius-topleft: 0;
+  -webkit-border-top-left-radius: 0;
+  border-top-left-radius: 0;
+  display: block;
+  height: 26px;
+  margin: 0;
+  padding: 0;
+  /* Replace with position:fixed to get a scrolling close button. */
+  position: absolute;
+  width: 26px;
+}
+#overlay-title:active,
+#overlay-close:hover,
+#overlay-close:focus {
+  padding: 0;
+}
+
+/**
+ * Tabs on the overlay.
+ */
+#overlay-tabs {
+  line-height: 27px;
+  margin: -28px 0 0 0;
+  position: absolute;
+  right: 20px;
+  text-transform: uppercase;
+}
+#overlay-tabs li {
+  display: inline;
+  list-style: none;
+  margin: 0 0 0 -3px;
+  padding: 0;
+}
+#overlay-tabs li a,
+#overlay-tabs li a:active,
+#overlay-tabs li a:visited,
+#overlay-tabs li a:hover {
+  background-color: #a6a7a2;
+  -moz-border-radius: 8px 8px 0 0;
+  -webkit-border-top-left-radius: 8px;
+  -webkit-border-top-right-radius: 8px;
+  border-radius: 8px 8px 0 0;
+  color: #000;
+  display: inline-block;
+  font-size: 11px;
+  font-weight: bold;
+  margin: 0 0 2px 0;
+  outline: 0;
+  padding: 0 14px;
+  text-decoration: none;
+}
+#overlay-tabs li.active a,
+#overlay-tabs li.active a.active,
+#overlay-tabs li.active a:active,
+#overlay-tabs li.active a:visited {
+  background-color: #fff;
+  margin: 0;
+  padding-bottom: 2px;
+}
+#overlay-tabs li a:focus,
+#overlay-tabs li a:hover {
+  color: #fff;
+}
+#overlay-tabs li.active a:focus,
+#overlay-tabs li.active a:hover {
+  color: #000;
+}
+
+/**
+ * Add to shortcuts link
+ */
+#overlay-titlebar .add-or-remove-shortcuts {
+  padding-top: 0.9em;
+}
+
+/**
+ * IE6 shows elements with position:fixed as position:static so replace
+ * it with position:absolute;
+ */
+* html #overlay-close,
+* html #overlay-close:hover {
+  position: absolute;
+}
