summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/block/block.css19
-rw-r--r--modules/block/block.module21
-rw-r--r--modules/overlay/overlay-parent.js17
-rw-r--r--modules/overlay/overlay.module1
4 files changed, 54 insertions, 4 deletions
diff --git a/modules/block/block.css b/modules/block/block.css
index 56ba1c560..1f543d92a 100644
--- a/modules/block/block.css
+++ b/modules/block/block.css
@@ -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;
+}
diff --git a/modules/block/block.module b/modules/block/block.module
index 1dc32f6af..bfca75590 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -294,6 +294,15 @@ function block_page_build(&$page) {
'#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 @@ function block_form_system_performance_settings_alter(&$form, &$form_state) {
}
/**
+ * 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.
diff --git a/modules/overlay/overlay-parent.js b/modules/overlay/overlay-parent.js
index bb3067857..a3e9d017d 100644
--- a/modules/overlay/overlay-parent.js
+++ b/modules/overlay/overlay-parent.js
@@ -481,7 +481,12 @@ Drupal.overlay.eventhandlerOverrideLink = function (event) {
}
// 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 @@ Drupal.overlay.eventhandlerOverrideLink = function (event) {
}
}
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 @@ Drupal.overlay.eventhandlerDispatchEvent = function (event) {
*
* @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 @@ Drupal.overlay.fragmentizeLink = function (link) {
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 });
};
/**
diff --git a/modules/overlay/overlay.module b/modules/overlay/overlay.module
index 5537ddf0e..edf584adf 100644
--- a/modules/overlay/overlay.module
+++ b/modules/overlay/overlay.module
@@ -542,7 +542,6 @@ function overlay_set_mode($mode = NULL) {
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');