From 6a244552a58beafe64ab12142d5b98bec0c97c1b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 2 Jul 2018 15:32:55 +0300 Subject: add toolbar button to jump back if following relative URL --- css/read.css | 4 ++-- js/read.js | 8 ++++++++ read.html | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/css/read.css b/css/read.css index d1cb1be..7495ad3 100644 --- a/css/read.css +++ b/css/read.css @@ -93,13 +93,13 @@ @media (max-width: 767px) { .toolbar { - width : 96px; + width : 105px; } } @media (max-width: 576px) { .toolbar { - width : 96px; + width : 105px; } #reader { left : 24px; diff --git a/js/read.js b/js/read.js index 6d81cb5..779a112 100644 --- a/js/read.js +++ b/js/read.js @@ -314,4 +314,12 @@ function dict_lookup(word, callback) { }); } +function open_previous_location(elem) { + var cfi = $(elem).attr("data-location-cfi"); + if (cfi) { + window.book.rendition.display(cfi); + } + + $(elem).fadeOut(); +} diff --git a/read.html b/read.html index c1983dd..ae1a008 100644 --- a/read.html +++ b/read.html @@ -191,6 +191,11 @@ + + @@ -432,6 +437,21 @@ rendition.hooks.content.register(function(contents) { + contents.on("linkClicked", function(href) { + console.log('linkClicked', href); + + if (href.indexOf("://") == -1) { + $(".prev_location_btn") + .attr("data-location-cfi", book.rendition.currentLocation().start.cfi) + .show(); + + window.setTimeout(function() { + show_ui(true); + }, 50); + } + + }); + var base_url = window.location.href.match(/^.*\//)[0]; var res_names = [ "lib/bootstrap/v3/js/jquery.js", "lib/jquery.mobile.custom.js", "js/reader.js", "js/dict.js" ]; -- cgit v1.2.3