Mercurial > hg > isophonics-drupal-site
comparison core/modules/toolbar/js/escapeAdmin.es6.js @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 4c8ae668cc8c |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 /** | 1 /** |
2 * @file | 2 * @file |
3 * Replaces the home link in toolbar with a back to site link. | 3 * Replaces the home link in toolbar with a back to site link. |
4 */ | 4 */ |
5 | 5 |
6 (function ($, Drupal, drupalSettings) { | 6 (function($, Drupal, drupalSettings) { |
7 const pathInfo = drupalSettings.path; | 7 const pathInfo = drupalSettings.path; |
8 const escapeAdminPath = sessionStorage.getItem('escapeAdminPath'); | 8 const escapeAdminPath = sessionStorage.getItem('escapeAdminPath'); |
9 const windowLocation = window.location; | 9 const windowLocation = window.location; |
10 | 10 |
11 // Saves the last non-administrative page in the browser to be able to link | 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 | 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 | 13 // parameter there is not need to save the current path because the page is |
14 // loaded within an existing "workflow". | 14 // loaded within an existing "workflow". |
15 if (!pathInfo.currentPathIsAdmin && !/destination=/.test(windowLocation.search)) { | 15 if ( |
16 !pathInfo.currentPathIsAdmin && | |
17 !/destination=/.test(windowLocation.search) | |
18 ) { | |
16 sessionStorage.setItem('escapeAdminPath', windowLocation); | 19 sessionStorage.setItem('escapeAdminPath', windowLocation); |
17 } | 20 } |
18 | 21 |
19 /** | 22 /** |
20 * Replaces the "Home" link with "Back to site" link. | 23 * Replaces the "Home" link with "Back to site" link. |
27 * @prop {Drupal~behaviorAttach} attach | 30 * @prop {Drupal~behaviorAttach} attach |
28 * Attaches the replacement functionality to the toolbar-escape-admin element. | 31 * Attaches the replacement functionality to the toolbar-escape-admin element. |
29 */ | 32 */ |
30 Drupal.behaviors.escapeAdmin = { | 33 Drupal.behaviors.escapeAdmin = { |
31 attach() { | 34 attach() { |
32 const $toolbarEscape = $('[data-toolbar-escape-admin]').once('escapeAdmin'); | 35 const $toolbarEscape = $('[data-toolbar-escape-admin]').once( |
36 'escapeAdmin', | |
37 ); | |
33 if ($toolbarEscape.length && pathInfo.currentPathIsAdmin) { | 38 if ($toolbarEscape.length && pathInfo.currentPathIsAdmin) { |
34 if (escapeAdminPath !== null) { | 39 if (escapeAdminPath !== null) { |
35 $toolbarEscape.attr('href', escapeAdminPath); | 40 $toolbarEscape.attr('href', escapeAdminPath); |
36 } | 41 } else { |
37 else { | |
38 $toolbarEscape.text(Drupal.t('Home')); | 42 $toolbarEscape.text(Drupal.t('Home')); |
39 } | 43 } |
40 } | 44 } |
41 }, | 45 }, |
42 }; | 46 }; |
43 }(jQuery, Drupal, drupalSettings)); | 47 })(jQuery, Drupal, drupalSettings); |