Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.426
diff -u -r1.426 block.module
--- modules/block/block.module	8 Jul 2010 03:41:27 -0000	1.426
+++ modules/block/block.module	28 Jul 2010 18:04:10 -0000
@@ -294,6 +294,15 @@
           '#weight' => 15,
         );
       }
+      $page['page_top']['backlink'] = array(
+        '#type' => 'link',
+        '#title' => t('Exit block region demonstration'),
+        '#href' => 'admin/structure/block/list' . (variable_get('theme_default', 'garland') == $theme ? '' : '/' . $theme),
+        // Add the "overlay-restore" class to indicate this link should restore
+        // the context in which the region demonstration page was opened.
+        '#options' => array('attributes' => array('class' => array('block-demo-backlink', 'overlay-restore'))),
+        '#weight' => -10,
+      );
     }
   }
 }
@@ -981,6 +990,18 @@
 }
 
 /**
+ * Implements hook_admin_paths().
+ */
+function block_admin_paths() {
+  $paths = array(
+    // Exclude the block demonstration page from admin (overlay) treatment.
+    // This allows us to present this page in its true form, full page.
+    'admin/structure/block/demo/*' => FALSE,
+  );
+  return $paths;
+}
+
+/**
  * Implements hook_modules_uninstalled().
  *
  * Cleanup {block} and {block_role} tables from modules' blocks.
Index: modules/block/block.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.css,v
retrieving revision 1.7
diff -u -r1.7 block.css
--- modules/block/block.css	5 Oct 2009 02:43:01 -0000	1.7
+++ modules/block/block.css	28 Jul 2010 18:04:10 -0000
@@ -16,3 +16,22 @@
   margin-bottom: 4px;
   padding: 3px;
 }
+a.block-demo-backlink,
+a.block-demo-backlink:link,
+a.block-demo-backlink:visited {
+  background-color: #B4D7F0;
+  border-radius: 0 0 10px 10px;
+  -moz-border-radius: 0 0 10px 10px;
+  -webkit-border-radius: 0 0 10px 10px;
+  color: #000;
+  font-family: "Lucida Grande", Verdana, sans-serif;
+  font-size: small;
+  line-height: 20px;
+  left: 20px; /*LTR*/
+  padding: 5px 10px;
+  position: fixed;
+  z-index: 499;
+}
+a.block-demo-backlink:hover {
+  text-decoration: underline;
+}
Index: modules/overlay/overlay.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay.module,v
retrieving revision 1.27
diff -u -r1.27 overlay.module
--- modules/overlay/overlay.module	28 Jul 2010 02:50:00 -0000	1.27
+++ modules/overlay/overlay.module	28 Jul 2010 18:04:11 -0000
@@ -542,7 +542,6 @@
   switch ($overlay_mode) {
     case 'parent':
       drupal_add_library('overlay', 'parent');
-      drupal_add_library('overlay', 'jquery-bbq');
 
       // Allow modules to act upon overlay events.
       module_invoke_all('overlay_parent_initialize');
Index: modules/overlay/overlay-parent.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay-parent.js,v
retrieving revision 1.51
diff -u -r1.51 overlay-parent.js
--- modules/overlay/overlay-parent.js	27 Jul 2010 13:47:31 -0000	1.51
+++ modules/overlay/overlay-parent.js	28 Jul 2010 18:04:10 -0000
@@ -481,7 +481,12 @@
     }
     // Open admin links in the overlay.
     else if (this.isAdminLink(href)) {
-      href = this.fragmentizeLink($target.get(0));
+      // 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.
@@ -513,6 +518,10 @@
         }
       }
       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.
@@ -666,12 +675,14 @@
  *
  * @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) {
+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) {
@@ -687,7 +698,7 @@
   var destination = path + link.search.replace(/&?render=overlay/, '').replace(/\?$/, '') + link.hash;
 
   // Assemble and return the overlay-ready link.
-  return $.param.fragment(window.location.href, { overlay: destination });
+  return $.param.fragment(parentLocation || window.location.href, { overlay: destination });
 };
 
 /**
Index: modules/block/block-rtl.css
===================================================================
RCS file: modules/block/block-rtl.css
diff -N modules/block/block-rtl.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/block/block-rtl.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,7 @@
+/* $Id $ */
+
+a.block-demo-backlink,
+a.block-demo-backlink:link,
+a.block-demo-backlink:visited {
+  right: 0;
+}
