Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/your-identity/hugo-theme-dimension.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Asnaghi <30296575+d-asnaghi@users.noreply.github.com>2020-10-23 01:57:51 +0300
committerGitHub <noreply@github.com>2020-10-23 01:57:51 +0300
commitaa2ede49a357a8fa66256ad98925f8c92602142e (patch)
tree6c6c6c837b7b76d148bb7f06c008863cec75de8b
parent0555bddd43c30c19a01e333dd8c7bc08fb80572e (diff)
parentd656d483a3925385e419b5664c7b25b8c9204510 (diff)
Merge pull request #9 from carbideband/back
static: js: main: Fix 'back' behavior for articles
-rw-r--r--static/assets/js/main.js28
1 files changed, 22 insertions, 6 deletions
diff --git a/static/assets/js/main.js b/static/assets/js/main.js
index f5fcd8c..5c00084 100644
--- a/static/assets/js/main.js
+++ b/static/assets/js/main.js
@@ -67,7 +67,12 @@
// Main.
var delay = 325,
- locked = false;
+ locked = false,
+ nohash = false;
+
+ // Set nohash.
+ if (location.hash == '' || location.hash == '#')
+ nohash = true;
// Methods.
$main._show = function(id, initial) {
@@ -208,7 +213,7 @@
// Add state?
if (typeof addState != 'undefined'
&& addState === true)
- history.pushState(null, null, '#');
+ history.replaceState(null, null, '/');
// Handle lock.
@@ -295,7 +300,12 @@
$('<div class="close">Close</div>')
.appendTo($this)
.on('click', function() {
- location.hash = '';
+ if (nohash) {
+ history.go(-1);
+ } else {
+ $main._hide(true);
+ nohash = true;
+ }
});
// Prevent clicks from inside article from bubbling.
@@ -308,9 +318,15 @@
// Events.
$body.on('click', function(event) {
- // Article visible? Hide.
- if ($body.hasClass('is-article-visible'))
- $main._hide(true);
+ // Article visible? Go back. Hide when article is accessed first.
+ if ($body.hasClass('is-article-visible')) {
+ if (nohash) {
+ history.go(-1);
+ } else {
+ $main._hide(true);
+ nohash = true;
+ }
+ }
});