Commit 4a689c59 authored by Dries's avatar Dries

Issue #2088121 by nod_, RobLoach, joelpittet, Gábor Hojtsy: Remove Overlay.

parent 1151c73c
Drupal 8.0, xxxx-xx-xx (development version)
----------------------
- Added Twig as the default template engine and converted all .tpl.php templates
......@@ -43,6 +42,7 @@ Drupal 8.0, xxxx-xx-xx (development version)
* Poll
* Profile
* Trigger
- Removed the Overlay module from core.
- Removed the Garland theme from core.
- Removed the Statistics module's accesslog functionality and reports from core.
- Removed backwards-compatibility with 'magic_quotes_gpc'/'magic_quotes_runtime'
......@@ -52,6 +52,7 @@ Drupal 8.0, xxxx-xx-xx (development version)
- JavaScript changes:
* Updated to jQuery 2.0.3
* Updated to jQuery UI 1.10.2
* Removed jquery.bbq
- Tremendously improved language support all around.
* Great language improvements for users:
* Improved language selection with user preference detection in the
......
......@@ -330,9 +330,6 @@ Number module
Options module
- Yves Chedemois 'yched' http://drupal.org/user/39567
Overlay module
- ?
Path module
- ?
......
This diff is collapsed.
......@@ -77,5 +77,4 @@
}
});
// @todo remove window.parent once overlay is removed from core.
})(jQuery, Drupal, drupalSettings, Drupal.debounce, window.parent.Drupal.displace);
})(jQuery, Drupal, drupalSettings, Drupal.debounce, Drupal.displace);
......@@ -17,10 +17,6 @@
*/
Drupal.behaviors.drupalDisplace = {
attach: function () {
// Do not process the window of the overlay.
if (parent.Drupal.overlay && parent.Drupal.overlay.iframeWindow === window) {
return;
}
// Mark this behavior as processed on the first pass.
if (this.displaceProcessed) {
return;
......
......@@ -7,12 +7,6 @@
"use strict";
// Do not process the window of the overlay.
if (parent.Drupal.overlay && parent.Drupal.overlay.iframeWindow === window) {
return;
}
/**
* Provides an API for managing page tabbing order modifications.
*/
......
......@@ -189,9 +189,7 @@ function block_page_build(&$page) {
'#type' => 'link',
'#title' => t('Exit block region demonstration'),
'#href' => 'admin/structure/block' . (\Drupal::config('system.theme')->get('default') == $theme ? '' : '/list/' . $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'))),
'#options' => array('attributes' => array('class' => array('block-demo-backlink'))),
'#weight' => -10,
);
}
......@@ -566,7 +564,7 @@ function block_menu_delete($menu) {
*/
function block_admin_paths() {
$paths = array(
// Exclude the block demonstration page from admin (overlay) treatment.
// Exclude the block demonstration page from admin treatment.
// This allows us to present this page in its true form, full page.
'admin/structure/block/demo/*' => FALSE,
);
......
......@@ -136,9 +136,7 @@ function contextual_library_info() {
'title' => 'Contextual Links Toolbar Tab',
'version' => \Drupal::VERSION,
'js' => array(
// Add the JavaScript, with a group and weight such that it will run
// before modules/overlay/overlay-parent.js.
$path . '/js/contextual.toolbar.js' => array('group' => JS_LIBRARY, 'weight' => -1),
$path . '/js/contextual.toolbar.js' => array('group' => JS_LIBRARY),
),
'css' => array(
$path . '/css/contextual.toolbar.css' => array(),
......
......@@ -31,16 +31,6 @@ function initContextualToolbar (context) {
new contextualToolbar.VisualView(viewOptions);
new contextualToolbar.AuralView(viewOptions);
// Update the model based on overlay events.
$(document).on({
'drupalOverlayOpen.contextualToolbar': function () {
model.set('overlayIsOpen', true);
},
'drupalOverlayClose.contextualToolbar': function () {
model.set('overlayIsOpen', false);
}
});
// Show the edit tab while there's >=1 contextual link.
if (Drupal.contextual && Drupal.contextual.collection) {
var contextualCollection = Drupal.contextual.collection;
......@@ -98,10 +88,8 @@ Drupal.contextualToolbar = {
// Indicates whether the toggle is currently in "view" or "edit" mode.
isViewing: true,
// Indicates whether the toggle should be visible or hidden. Automatically
// calculated, depends on overlayIsOpen and contextualCount.
// calculated, depends on contextualCount.
isVisible: false,
// Indicates whether the overlay is open or not.
overlayIsOpen: false,
// Tracks how many contextual links exist on the page.
contextualCount: 0,
// A TabbingContext object as returned by Drupal.TabbingManager: the set
......@@ -109,8 +97,8 @@ Drupal.contextualToolbar = {
tabbingContext: null
},
initialize: function () {
this.on('change:overlayIsOpen change:contextualCount', function (model) {
model.set('isVisible', !model.get('overlayIsOpen') && model.get('contextualCount') > 0);
this.on('change:contextualCount', function (model) {
model.set('isVisible', model.get('contextualCount') > 0);
});
}
}),
......
/**
* @file
* Basic styling for the Overlay child pages.
*/
html[dir="rtl"] {
direction: rtl;
}
.js {
background: transparent !important;
overflow-y: scroll;
}
.js body {
background: transparent !important;
margin-left: 0;
margin-right: 0;
padding: 20px 0;
}
#overlay {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
display: block;
margin: 0 auto;
max-width: 80em;
max-width: 80rem;
min-height: 100px;
position: relative;
padding: 2em 40px;
width: 100%;
}
#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; /* LTR */
font-size: 20px;
margin: 0;
padding: 0.3em 0;
}
[dir="rtl"] #overlay-title {
float: right;
left: auto;
}
#overlay-title:active,
#overlay-title:focus {
outline: 0;
}
.overlay .skip-link {
color: #fff; /* This is white to contrast with the dark background behind it. */
}
#overlay-close-wrapper {
position: absolute;
right: 0; /* LTR */
}
[dir="rtl"] #overlay-close-wrapper {
left: 0;
right: auto;
}
#overlay-close,
#overlay-close:hover {
background: #ffffff url(../images/close.png) no-repeat;
border: 0;
border-radius: 0 12px 12px 0; /* LTR */
display: block;
height: 26px;
margin: 0;
padding: 0;
/* Replace with position:fixed to get a scrolling close button. */
position: absolute;
width: 26px;
}
[dir="rtl"] #overlay-close,
[dir="rtl"] #overlay-close:hover {
border-radius: 12px 0 0 12px;
}
#overlay-close:focus, #overlay-close:active{
outline: 1px dotted;
}
/**
* Tabs on the overlay.
*/
#overlay-tabs {
line-height: 26px;
margin: -28px 0 0 0;
position: absolute;
right: 20px; /* LTR */
text-transform: uppercase;
}
[dir="rtl"] #overlay-tabs {
left: 20px;
right: auto;
}
#overlay-tabs li {
display: inline-block;
list-style: none;
margin: 0;
padding: 0;
}
#overlay-tabs li a,
#overlay-tabs li a:active,
#overlay-tabs li a:visited,
#overlay-tabs li a:hover {
background-color: #a6a7a2;
border-radius: 8px 8px 0 0;
color: #000;
display: inline-block;
font-size: 11px;
font-weight: bold;
margin: 0 1px;
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-bottom: 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.6em;
}
#overlay-titlebar .add-or-remove-shortcuts .icon {
margin-top: 4px;
}
#overlay-titlebar .add-or-remove-shortcuts .text {
padding-top: 0;
}
/**
* Disable message.
*/
#overlay-disable-message {
background-color: #fff;
margin: 0 auto 20px;
width: 80%;
border-radius: 0 0 8px 8px;
}
.overlay-disable-message-focused {
padding: 0.5em;
}
.overlay-disable-message-focused a {
display: block;
float: left;
}
.overlay-disable-message-focused #overlay-dismiss-message {
float: right;
}
/**
* @file
* Basic styling for the Overlay module.
*/
html.overlay-open,
html.overlay-open body {
height: 100%;
overflow: hidden;
}
#overlay-container,
.overlay-modal-background,
.overlay-element {
height: 100%;
left: 0;
position: absolute;
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;
}
/**
* Within the overlay parent, the message about disabling the overlay is for
* screen-reader users only. It is always kept invisible with the
* visually-hidden class, and removed from the tab order. Overlay-child.css
* contains styling for the same message appearing within the overlay, and
* intended for sighted users.
*/
#overlay-disable-message {
display: none;
}
html.overlay-open #overlay-disable-message {
display: block;
}
<?php
/**
* @file
* Contains \Drupal\overlay\Access\DismissMessageAccessCheck
*/
namespace Drupal\overlay\Access;
use Drupal\Core\Access\AccessCheckInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\HttpFoundation\Request;
/**
* Provides an access check for overlay user dismiss message routes.
*/
class DismissMessageAccessCheck implements AccessCheckInterface {
/**
* {@inheritdoc}
*/
public function applies(Route $route) {
return array_key_exists('_access_overlay_dismiss_message', $route->getRequirements());
}
/**
* {@inheritdoc}
*/
public function access(Route $route, Request $request, AccountInterface $account) {
if (!$account->hasPermission('access overlay')) {
return static::DENY;
}
// It's unlikely, but possible that "access overlay" permission is granted
// to the anonymous role. In this case, we do not display the message to
// disable the overlay, so there is nothing to dismiss.
if (!$account->id()) {
return static::DENY;
}
return static::ALLOW;
}
}
<?php
/**
* @file
* Contains \Drupal\overlay\Controller\OverlayController.
*/
namespace Drupal\overlay\Controller;
use Drupal\Core\Access\CsrfTokenGenerator;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\user\UserDataInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
/**
* Controller routines for overlay routes.
*
* @todo keeping the controllerInterface since we should be injecting
* something to take care of the overlay_render_region() call.
*/
class OverlayController extends ControllerBase implements ContainerInjectionInterface {
/**
* The userdata service.
*
* @var \Drupal\user\UserDataInterface
*/
protected $userData;
/**
* The CSRF token generator.
*
* @var \Drupal\Core\Access\CsrfTokenGenerator
*/
protected $csrfGenerator;
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $account;
/**
* Constructs a OverlayController instance.
*
* @param \Drupal\user\UserDataInterface $user_data
* The userdata service.
* @param \Drupal\Core\Access\CsrfTokenGenerator $csrf_generator
* The CSRF token generator.
* @param \Drupal\Core\Session\AccountInterface $account
* The current user.
*/
public function __construct(UserDataInterface $user_data, CsrfTokenGenerator $csrf_generator, AccountInterface $account) {
$this->userData = $user_data;
$this->csrfGenerator = $csrf_generator;
$this->account = $account;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('user.data'),
$container->get('csrf_token'),
$container->get('current_user')
);
}
/**
* Prints the markup obtained by rendering a single region of the page.
*
* @todo add a DI for managing the overlay_render_region() call.
*
* @param string
* The name of the page region to render.
*
* @return \Symfony\Component\HttpFoundation\Response
*
* @see Drupal.overlay.refreshRegions()
*/
public function regionRender($region) {
return new Response(overlay_render_region($region));
}
/**
* Dismisses the overlay accessibility message for this user.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
*
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
* Thrown when a non valid token was specified.
*
* @return \Drupal\Core\Controller\ControllerBase
* Redirects to the user's edit page.
*/
public function overlayMessage(Request $request) {
// @todo Integrate CSRF link token directly into routing system:
// http://drupal.org/node/1798296.
$token = $request->attributes->get('token');
if (!isset($token) || !$this->csrfGenerator->validate($token, 'overlay')) {
throw new AccessDeniedHttpException();
}
$this->userData->set('overlay', $this->account->id(), 'message_dismissed', 1);
drupal_set_message($this->t('The message has been dismissed. You can change your overlay settings at any time by visiting your profile page.'));
// Destination is normally given. Go to the user profile as a fallback.
return $this->redirect('user_edit', array('user' => $this->account->id()));
}
}
<?php
/**
* @file
* Contains \Drupal\overlay\EventSubscriber\OverlaySubscriber.
*/
namespace Drupal\overlay\EventSubscriber;
use Drupal\Core\ContentNegotiation;
use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Component\Utility\Url;
use Drupal\user\UserData;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* Overlay subscriber for controller requests.
*/
class OverlaySubscriber implements EventSubscriberInterface {
/**
* The content negotiation service.
*
* @var \Drupal\Core\ContentNegotiation
*/
protected $negotiation;
/**
* The user.data service.
*
* @var \Drupal\user\UserData
*/
protected $userData;
/**
* The url generator service.
*
* @var \Drupal\Core\Routing\UrlGeneratorInterface
*/
protected $urlGenerator;
/**
* Constructs an OverlaySubscriber object.
*
* @param \Drupal\Core\ContentNegotiation $negotiation
* The content negotiation service.
* @param \Drupal\user\UserData $user_data
* The user.data service.
* @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
* The url generator service.
*/
public function __construct(ContentNegotiation $negotiation, UserData $user_data, UrlGeneratorInterface $url_generator) {
$this->negotiation = $negotiation;
$this->userData = $user_data;
$this->urlGenerator = $url_generator;
}
/**
* Performs check on the beginning of a request.
*
* Determine whether the current page request is destined to appear in the
* parent window or in the overlay window, and format the page accordingly.
*
* @see overlay_set_mode()
*/
public function onRequest(GetResponseEvent $event) {
$request = $event->getRequest();
if ($this->negotiation->getContentType($request) != 'html') {
// Only act on html pages.
return;
}
$user = \Drupal::currentUser();
$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.
$user_data = $this->userData->get('overlay', $user->id(), 'enabled');
$use_overlay = !isset($user_data) || $user_data;
if (empty($mode) && $user->hasPermission('access overlay') && $use_overlay) {
$current_path = $request->attributes->get('_system_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']);
$url = $this->urlGenerator
->generateFromPath('<front>', array(
'fragment' => 'overlay=' . $current_path,
'absolute' => TRUE,
));
$response = new RedirectResponse($url);
$event->setResponse($response);
}
if ($request->query->get('render') == 'overlay') {
// If a previous page requested that we close the overlay, close it and
// redirect to the final destination.
if (isset($_SESSION['overlay_close_dialog'])) {
$response = call_user_func_array('overlay_close_dialog', $_SESSION['overlay_close_dialog']);
unset($_SESSION['overlay_close_dialog']);
$event->setResponse($response);
}
// If this page shouldn't be rendered inside the overlay, redirect to
// the parent.
elseif (!path_is_admin($current_path)) {
// Prevent open redirects by ensuring the current path is not an absolute URL.
if (Url::isExternal($current_path)) {
$current_path = '<front>';
}
$response = overlay_close_dialog($current_path, array('query' => drupal_get_query_parameters(NULL, array('render'))));
$event->setResponse($response);
}
// Indicate that we are viewing an overlay child page.
overlay_set_mode('child');
// Unset the render parameter to avoid it being included in URLs on the
// page.
$request->query->remove('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.
overlay_set_mode('parent');
}
}
}
/**
* Performs end of request tasks.
*
* 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.
*/
public function onResponse(FilterResponseEvent $event) {
// Check that we are in an overlay child page.
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);
}
}
}
$response = $event->getResponse();
if ($response instanceOf RedirectResponse) {
$path = $response->getTargetUrl();