Commit 9588a5b3 authored by webchick's avatar webchick

#655416 by casey, yoroy, BTMash, Bojhan, Gábor Hojtsy, sun, ksenzee, oseldman,...

#655416 by casey, yoroy, BTMash, Bojhan, Gábor Hojtsy, sun, ksenzee, oseldman, jrguitar21, et al: 'Demonstrate block preview' should not open in the overlay, and should reflect the regions in the front-end theme.
parent f8dea099
......@@ -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;
}
......@@ -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,
);
}
}
}
......@@ -980,6 +989,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().
*
......
......@@ -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 });
};
/**
......
......@@ -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');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment