3 * Replaces the home link in toolbar with a back to site link.
6 (function ($, Drupal, drupalSettings) {
10 var pathInfo = drupalSettings.path;
11 var escapeAdminPath = sessionStorage.getItem('escapeAdminPath');
12 var windowLocation = window.location;
14 // Saves the last non-administrative page in the browser to be able to link
15 // back to it when browsing administrative pages. If there is a destination
16 // parameter there is not need to save the current path because the page is
17 // loaded within an existing "workflow".
18 if (!pathInfo.currentPathIsAdmin && !/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 var $toolbarEscape = $('[data-toolbar-escape-admin]').once('escapeAdmin');
36 if ($toolbarEscape.length && pathInfo.currentPathIsAdmin) {
37 if (escapeAdminPath !== null) {
38 $toolbarEscape.attr('href', escapeAdminPath);
41 $toolbarEscape.text(Drupal.t('Home'));
43 $toolbarEscape.closest('.toolbar-tab').removeClass('hidden');
48 })(jQuery, Drupal, drupalSettings);