diff --git a/core/includes/common.inc b/core/includes/common.inc index 0fb232e..b9e3ca4 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -2216,7 +2216,8 @@ function drupal_add_js($data = NULL, $options = NULL) { url('', array('script' => &$scriptPath, 'prefix' => &$pathPrefix)); $current_path = current_path(); $current_path_is_admin = FALSE; - if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE !== 'update') { + // The function path_is_admin() is not available on update.php pages. + if (!(defined('MAINTENANCE_MODE') && MAINTENANCE_MODE === 'update')) { $current_path_is_admin = path_is_admin($current_path); } $javascript['settings']['data'][] = array( diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockController.php b/core/modules/block/lib/Drupal/block/Controller/BlockController.php index 0536022..f2ebb41 100644 --- a/core/modules/block/lib/Drupal/block/Controller/BlockController.php +++ b/core/modules/block/lib/Drupal/block/Controller/BlockController.php @@ -32,7 +32,10 @@ public function demo($theme) { '#attached' => array( 'js' => array( array( - // Let JavaScript know this really is an admin page. + // The block demonstration page is not marked as an administrative + // page by path_is_admin() function in order to use the frontend + // theme. Since JavaScript relies on a proper separation of admin + // pages, it needs to know this is an actual administrative page. 'data' => array('currentPathIsAdmin' => TRUE), 'type' => 'setting', ) diff --git a/core/modules/toolbar/css/toolbar.icons.css b/core/modules/toolbar/css/toolbar.icons.css index a0cfce2..0d265d6 100644 --- a/core/modules/toolbar/css/toolbar.icons.css +++ b/core/modules/toolbar/css/toolbar.icons.css @@ -319,16 +319,16 @@ background-image: url("../../../misc/icons/787878/twistie-up.png"); background-size: auto auto; } -.toolbar .toolbar-icon-escape:before { +.toolbar .toolbar-icon-escape-admin:before { background-image: url("../../../misc/icons/bebebe/chevron-disc-left.svg"); } -.no-svg .toolbar .toolbar-icon-escape:before { +.no-svg .toolbar .toolbar-icon-escape-admin:before { background-image: url("../../../misc/icons/bebebe/chevron-disc-left.png"); } -[dir="rtl"] .toolbar .toolbar-icon-escape:before { +[dir="rtl"] .toolbar .toolbar-icon-escape-admin:before { background-image: url("../../../misc/icons/bebebe/chevron-disc-right.svg"); } -[dir="rtl"] .no-svg .toolbar .toolbar-icon-escape:before { +[dir="rtl"] .no-svg .toolbar .toolbar-icon-escape-admin:before { background-image: url("../../../misc/icons/bebebe/chevron-disc-right.png"); } /** diff --git a/core/modules/toolbar/js/escapeAdmin.js b/core/modules/toolbar/js/escapeAdmin.js index 4343ce1..eb580fe 100644 --- a/core/modules/toolbar/js/escapeAdmin.js +++ b/core/modules/toolbar/js/escapeAdmin.js @@ -1,36 +1,49 @@ +/** + * @file + * + * Replaces the home link in toolbar with a back to site link. + */ (function ($, Drupal, drupalSettings) { - "use strict"; +"use strict"; - var escapeAdminPage = sessionStorage.getItem('escapeAdminPage'); +var escapeAdminPath = sessionStorage.getItem('escapeAdminPath'); - if (!drupalSettings.currentPathIsAdmin) { - sessionStorage.setItem('escapeAdminPage', drupalSettings.currentPath); - } +// Saves the last non-administrative page in the browser to be able to link back +// to it when browsing administrative pages. +if (!drupalSettings.currentPathIsAdmin) { + sessionStorage.setItem('escapeAdminPath', drupalSettings.currentPath); +} - Drupal.behaviors.escapeAdmin = { - attach: function () { - var $toolbarEscape = $('[data-toolbar-escape]').once('escapeAdmin'); - if ($toolbarEscape.length) { - if (drupalSettings.currentPathIsAdmin && escapeAdminPage) { - $toolbarEscape - .removeClass('toolbar-icon-home') - .addClass('toolbar-icon-escape') - .attr({ - 'href': Drupal.url(escapeAdminPage), - 'title': Drupal.t('Return to site content') - }) - .text(Drupal.t('Back to site')); +/** + * Replaces the Home link with Back to site link. + * + * Back to site link points to the last non-administrative page the user visited + * withing the same browser tab. + */ +Drupal.behaviors.escapeAdmin = { + attach: function () { + var $toolbarEscape = $('[data-toolbar-escape-admin]').once('escapeAdmin'); + if ($toolbarEscape.length) { + if (drupalSettings.currentPathIsAdmin && escapeAdminPath) { + $toolbarEscape + .removeClass('toolbar-icon-home') + .addClass('toolbar-icon-escape-admin') + .attr({ + 'href': Drupal.url(escapeAdminPath), + 'title': Drupal.t('Return to site content') + }) + .text(Drupal.t('Back to site')); - // Escape admin when hitting Esc key. - $(window).on('keydown', function (event) { - if (event.keyCode === 27) { - window.location = Drupal.url(escapeAdminPage); - } - }); - } + // Escape admin when hitting Esc key. + $(window).on('keydown', function (event) { + if (event.keyCode === 27) { + window.location = Drupal.url(escapeAdminPath); + } + }); } } - }; + } +}; })(jQuery, Drupal, drupalSettings); diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index 56f0012..bafda79 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -416,7 +416,7 @@ function toolbar_toolbar() { 'attributes' => array( 'title' => t('Home page'), 'class' => array('toolbar-icon', 'toolbar-icon-home'), - 'data-toolbar-escape' => TRUE, + 'data-toolbar-escape-admin' => TRUE, ), ), ),