3 * Replaces the home link in toolbar with a back to site link.
6 (function($, Drupal, drupalSettings) {
7 const pathInfo = drupalSettings.path;
8 const escapeAdminPath = sessionStorage.getItem('escapeAdminPath');
9 const windowLocation = window.location;
11 // Saves the last non-administrative page in the browser to be able to link
12 // back to it when browsing administrative pages. If there is a destination
13 // parameter there is not need to save the current path because the page is
14 // loaded within an existing "workflow".
16 !pathInfo.currentPathIsAdmin &&
17 !/destination=/.test(windowLocation.search)
19 sessionStorage.setItem('escapeAdminPath', windowLocation);
23 * Replaces the "Home" link with "Back to site" link.
25 * Back to site link points to the last non-administrative page the user
26 * visited within the same browser tab.
28 * @type {Drupal~behavior}
30 * @prop {Drupal~behaviorAttach} attach
31 * Attaches the replacement functionality to the toolbar-escape-admin element.
33 Drupal.behaviors.escapeAdmin = {
35 const $toolbarEscape = $('[data-toolbar-escape-admin]').once(
38 if ($toolbarEscape.length && pathInfo.currentPathIsAdmin) {
39 if (escapeAdminPath !== null) {
40 $toolbarEscape.attr('href', escapeAdminPath);
42 $toolbarEscape.text(Drupal.t('Home'));
47 })(jQuery, Drupal, drupalSettings);