Let sidebar stay in view
Change-Id: I2abaae25be040a4a898667d21554df6865720961
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 6b4ad67..1a2992b 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -122,7 +122,8 @@
// lazyLoad
matchClass.create(this).open();
};
- e.halt();
+ // This would prevent the sidebar to go back
+ // e.halt();
});
inactiveLi[i].addEventListener('keydown', function (e) {
var code = _codeFromEvent(e);
@@ -141,9 +142,19 @@
});
};
- document.getElementsByTagName('aside')[0].addEventListener('focus', function() {
- this.classList.add('active')
- });
+ // Add focus listener to aside
+ var aside = document.getElementsByTagName('aside')[0];
+
+ if (aside && aside.classList.contains('active') == false) {
+ aside.addEventListener('focus', function() {
+ this.classList.add('active');
+ });
+
+ var main = document.getElementsByTagName('main')[0];
+ main.addEventListener('click', function() {
+ aside.classList.remove('active');
+ });
+ };
// Replace QL select menus with KorAP menus
diff --git a/dev/scss/sidebar/sidebar.scss b/dev/scss/sidebar/sidebar.scss
index 4584437..384f598 100644
--- a/dev/scss/sidebar/sidebar.scss
+++ b/dev/scss/sidebar/sidebar.scss
@@ -176,7 +176,7 @@
}
}
-aside:focus {
+aside {
transition: all .3s ease-in-out;
}