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

github.com/kc0bfv/autophugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
authorKarl <kc0bfv@gmail.com>2021-07-10 21:22:54 +0300
committerKarl <kc0bfv@gmail.com>2021-07-10 21:22:54 +0300
commit12f3d6c8086353a249399921b5cbdf481e11c9aa (patch)
tree04347c3891a961ca7ca36d5810e02ac6c8dce9b2 /assets
parentfdcfbff6febbedfed37bf1597351453835e3433e (diff)
On img click change fragment id & handle change
Diffstat (limited to 'assets')
-rw-r--r--assets/js/main.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/assets/js/main.js b/assets/js/main.js
index 39ad007..79904be 100644
--- a/assets/js/main.js
+++ b/assets/js/main.js
@@ -288,7 +288,45 @@
enabled:true,
arrowMarkup: '<button title="%title%" class="nav-%dir%"></button>',
},
+ callbacks: {
+ change: function() {
+ window.location.hash = this.currItem.el.attr("id");
+ },
+ close: function() {
+ window.location.hash = "";
+ },
+ },
});
+
+ // If there's a fragment id, see if it's an image index
+ // If it is, and it's really a gallery_item then click on it
+ let click_hash = function () {
+ let fid = $(window.location.hash);
+ if( fid.length == 1 && fid[0].classList.contains("gallery-item") ) {
+ let curr_item = $.magnificPopup.instance.currItem;
+ if( curr_item &&
+ curr_item.el.attr("id") == fid[0].id )
+ {
+ // Nothing needs to happen in this case...
+ } else
+ {
+ // Otherwise we need to update the popup, so click it
+ fid.click();
+ }
+ } else {
+ // Here there was an invalid hash...
+ $.magnificPopup.close();
+ window.location.hash = "";
+ }
+ }
+
+ // Check the fragment id at load
+ if( window.location.hash != "" ) {
+ click_hash();
+ }
+
+ // Check the fragment id on hashchange
+ $(window).on("hashchange", click_hash);
});
})(jQuery);