-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #306 from City-of-Helsinki/UHF-10892
UHF-10892 Gin sidebar
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
patches/gin-3460390-sidebar-nextsibling-innerhtml-rc11.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
diff --git a/dist/js/sidebar.js b/dist/js/sidebar.js | ||
index 979bdcb..6c32188 100644 | ||
--- a/dist/js/sidebar.js | ||
+++ b/dist/js/sidebar.js | ||
@@ -30,9 +30,10 @@ | ||
const chooseStorage = window.innerWidth < 1024 ? "Drupal.gin.sidebarExpanded.mobile" : storageDesktop, hideLabel = Drupal.t("Hide sidebar panel"), sidebarTrigger = document.querySelector(".meta-sidebar__trigger"); | ||
var _Drupal$ginCoreNaviga; | ||
if (sidebarTrigger.querySelector("span").innerHTML = hideLabel, sidebarTrigger.setAttribute("title", hideLabel), | ||
- sidebarTrigger.nextSibling.innerHTML = hideLabel, sidebarTrigger.setAttribute("aria-expanded", "true"), | ||
- sidebarTrigger.classList.add("is-active"), document.body.setAttribute("data-meta-sidebar", "open"), | ||
- localStorage.setItem(chooseStorage, "true"), window.innerWidth < 1280) if (null === (_Drupal$ginCoreNaviga = Drupal.ginCoreNavigation) || void 0 === _Drupal$ginCoreNaviga || _Drupal$ginCoreNaviga.collapseToolbar(), | ||
+ sidebarTrigger.nextSibling && (sidebarTrigger.nextSibling.innerHTML = hideLabel), | ||
+ sidebarTrigger.setAttribute("aria-expanded", "true"), sidebarTrigger.classList.add("is-active"), | ||
+ document.body.setAttribute("data-meta-sidebar", "open"), localStorage.setItem(chooseStorage, "true"), | ||
+ window.innerWidth < 1280) if (null === (_Drupal$ginCoreNaviga = Drupal.ginCoreNavigation) || void 0 === _Drupal$ginCoreNaviga || _Drupal$ginCoreNaviga.collapseToolbar(), | ||
"vertical" === toolbarVariant) Drupal.ginToolbar.collapseToolbar(); else if ("new" === toolbarVariant) { | ||
var _Drupal$behaviors$gin; | ||
null === (_Drupal$behaviors$gin = Drupal.behaviors.ginNavigation) || void 0 === _Drupal$behaviors$gin || _Drupal$behaviors$gin.collapseSidebar(); | ||
@@ -41,9 +42,9 @@ | ||
collapseSidebar: () => { | ||
const chooseStorage = window.innerWidth < 1024 ? "Drupal.gin.sidebarExpanded.mobile" : storageDesktop, showLabel = Drupal.t("Show sidebar panel"), sidebarTrigger = document.querySelector(".meta-sidebar__trigger"); | ||
sidebarTrigger.querySelector("span").innerHTML = showLabel, sidebarTrigger.setAttribute("title", showLabel), | ||
- sidebarTrigger.nextSibling.innerHTML = showLabel, sidebarTrigger.setAttribute("aria-expanded", "false"), | ||
- sidebarTrigger.classList.remove("is-active"), document.body.setAttribute("data-meta-sidebar", "closed"), | ||
- localStorage.setItem(chooseStorage, "false"); | ||
+ sidebarTrigger.nextSibling && (sidebarTrigger.nextSibling.innerHTML = showLabel), | ||
+ sidebarTrigger.setAttribute("aria-expanded", "false"), sidebarTrigger.classList.remove("is-active"), | ||
+ document.body.setAttribute("data-meta-sidebar", "closed"), localStorage.setItem(chooseStorage, "false"); | ||
}, | ||
handleResize: function() { | ||
let windowSize = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : window; | ||
diff --git a/js/sidebar.js b/js/sidebar.js | ||
index b8b97c5..a6155c6 100644 | ||
--- a/js/sidebar.js | ||
+++ b/js/sidebar.js | ||
@@ -83,7 +83,9 @@ | ||
|
||
sidebarTrigger.querySelector('span').innerHTML = hideLabel; | ||
sidebarTrigger.setAttribute('title', hideLabel); | ||
- sidebarTrigger.nextSibling.innerHTML = hideLabel; | ||
+ if (sidebarTrigger.nextSibling) { | ||
+ sidebarTrigger.nextSibling.innerHTML = hideLabel; | ||
+ } | ||
sidebarTrigger.setAttribute('aria-expanded', 'true'); | ||
sidebarTrigger.classList.add('is-active'); | ||
|
||
@@ -111,7 +113,9 @@ | ||
|
||
sidebarTrigger.querySelector('span').innerHTML = showLabel; | ||
sidebarTrigger.setAttribute('title', showLabel); | ||
- sidebarTrigger.nextSibling.innerHTML = showLabel; | ||
+ if (sidebarTrigger.nextSibling) { | ||
+ sidebarTrigger.nextSibling.innerHTML = showLabel; | ||
+ } | ||
sidebarTrigger.setAttribute('aria-expanded', 'false'); | ||
sidebarTrigger.classList.remove('is-active'); | ||
|