Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.422
diff -u -r1.422 block.module
--- modules/block/block.module	12 Jun 2010 08:42:46 -0000	1.422
+++ modules/block/block.module	12 Jun 2010 14:33:49 -0000
@@ -264,6 +264,14 @@
           '#weight' => 15,
         );
       }
+      $page['page_top']['backlink'] = array(
+        '#type' => 'link',
+        '#title' => t('Back to block configuration'),
+        '#href' => 'admin/structure/block/list' . (variable_get('theme_default', 'garland') == $theme ? '' : '/' . $theme),
+        // Add the "overlay-restore" class to indicate this link should be
+        // restore context in which the block administration was opened.
+        '#options' => array('attributes' => array('class' => array('block-demo-backlink', 'overlay-restore')))
+      );
     }
   }
 }
@@ -937,6 +945,17 @@
 }
 
 /**
+ * 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	12 Jun 2010 14:33:49 -0000
@@ -16,3 +16,24 @@
   margin-bottom: 4px;
   padding: 3px;
 }
+
+a.block-demo-backlink,
+a.block-demo-backlink:link,
+a.block-demo-backlink:visited {
+  height: 16px;
+  padding: 5px 10px;
+  margin: 0 10px 0 75%;
+  float: right;
+  background: #666;
+  color: #fff;
+  line-height: 16px;
+  position: absolute;
+  z-index: 999;
+  -moz-border-radius-bottomright: 10px;
+  -moz-border-radius-bottomleft: 10px;
+  -webkit-border-bottom-right-radius: 10px;
+  -webkit-border-bottom-left-radius: 10px;
+}
+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.21
diff -u -r1.21 overlay.module
--- modules/overlay/overlay.module	11 Jun 2010 12:30:30 -0000	1.21
+++ modules/overlay/overlay.module	12 Jun 2010 14:33:49 -0000
@@ -167,6 +167,7 @@
     'dependencies' => array(
       array('system', 'ui'),
       array('system', 'jquery-bbq'),
+      array('system', 'cookie'),
     ),
   );
   // Overlay child.
@@ -517,7 +518,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.47
diff -u -r1.47 overlay-parent.js
--- modules/overlay/overlay-parent.js	11 Jun 2010 14:07:32 -0000	1.47
+++ modules/overlay/overlay-parent.js	12 Jun 2010 14:33:49 -0000
@@ -473,7 +473,9 @@
     }
     // Open admin links in the overlay.
     else if (this.isAdminLink(href)) {
-      href = this.fragmentizeLink($target.get(0));
+      // Fragmentize the link. Override the parent window's location if the
+      // link contains the overlay-restore class.
+      href = this.fragmentizeLink($target.get(0), $target.hasClass('overlay-restore') ? $.cookie('Drupal.overlay.lastParentLocation') : null);
       // 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.
@@ -504,6 +506,8 @@
     // 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 (this.isOpen && target.ownerDocument === this.iframeWindow.document) {
+      $.cookie('Drupal.overlay.lastParentLocation', window.location, { path: Drupal.settings.basePath });
+
       // 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.
@@ -641,12 +645,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) {
@@ -662,7 +668,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 });
 };
 
 /**
