Skip to content

Commit

Permalink
details + keyboard nav
Browse files Browse the repository at this point in the history
  • Loading branch information
Clararigaud committed Sep 21, 2024
1 parent f308d93 commit f7370a7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
21 changes: 21 additions & 0 deletions assets/js/theme/components/lightbox/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ window.osuny.lightbox = window.osuny.lightbox || {};
window.osuny.lightbox.LightboxContainer = function (element) {
this.element = element;
this.bodyElement = document.querySelector('body');
this.mainElement = document.querySelector('main');
this.headerElement = document.querySelector('header');
this.footerElement = document.querySelector('footer');
this.opened = false;
this.content = this.element.getElementsByClassName(window.osuny.lightbox.classes.content).item(0);
};

window.osuny.lightbox.LightboxContainer.prototype = {
open () {
this._disablePageElement();
this.bodyElement.style.overflow = 'hidden';
this.element.style.display = 'block';
this.opened = true;
},
close () {
this._removeImageContent();
this._enablePageElement();
this.bodyElement.style.overflow = 'visible';
this.element.style.display = 'none';
this.opened = false;
Expand All @@ -34,5 +39,21 @@ window.osuny.lightbox.LightboxContainer.prototype = {
},
_removeImageContent () {
this.content.innerHTML = '';
},
_disablePageElement () {
this.mainElement.inert = true;
this.mainElement.setAttribute('aria-hidden', 'true');
this.headerElement.inert = true;
this.headerElement.setAttribute('aria-hidden', 'true');
this.footerElement.inert = true;
this.footerElement.setAttribute('aria-hidden', 'true');
},
_enablePageElement() {
this.mainElement.inert = false;
this.mainElement.setAttribute('aria-hidden', 'false');
this.headerElement.inert = false;
this.headerElement.setAttribute('aria-hidden', 'false');
this.footerElement.inert = false;
this.footerElement.setAttribute('aria-hidden', 'false');
}
};
2 changes: 1 addition & 1 deletion assets/js/theme/components/lightbox/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ window.osuny.lightbox.manager = {
popupDetailsElement = controlRackElement.getElementsByClassName(window.osuny.lightbox.classes.detailWindow).item(0);
this.container = new window.osuny.lightbox.LightboxContainer(containerElement);
this.controlRack = new window.osuny.lightbox.ControlRack(controlRackElement);
this.popupDetails = new window.osuny.lightbox.DetailWindow(popupDetailsElement);
this.popupDetails = new window.osuny.lightbox.Popup(popupDetailsElement);
},
_initializeListeners () {
var i = 0;
Expand Down
4 changes: 2 additions & 2 deletions assets/js/theme/components/lightbox/popupDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
window.osuny = window.osuny || {};
window.osuny.lightbox = window.osuny.lightbox || {};

window.osuny.lightbox.DetailWindow = function (element) {
window.osuny.lightbox.Popup = function (element) {
this.element = element;
this.content = this.element.getElementsByClassName(window.osuny.lightbox.classes.detailWindowContent).item(0);
this.title = null;
Expand All @@ -15,7 +15,7 @@ window.osuny.lightbox.DetailWindow = function (element) {
this.close();
};

window.osuny.lightbox.DetailWindow.prototype = {
window.osuny.lightbox.Popup.prototype = {
_show (content) {
this._resetTitle();
if (content === 'description') {
Expand Down
6 changes: 3 additions & 3 deletions assets/sass/_theme/components/lightbox.sass
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ a.glightbox
display: flex
justify-content: space-between
width: 100%
a
color: $color-text
text-decoration: underline
a
color: $color-text
text-decoration: underline
&-content
@include body-text
@include media-breakpoint-down(sm)
Expand Down

0 comments on commit f7370a7

Please sign in to comment.