diff options
author | Andrew Dolgov <[email protected]> | 2018-07-02 15:32:55 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-07-02 15:32:55 +0300 |
commit | 6a244552a58beafe64ab12142d5b98bec0c97c1b (patch) | |
tree | 1f216bda0270b97a9ad088728b9b9ec08331ec13 | |
parent | 62346ca9259cd2571b9dd4746341107d6409b35d (diff) |
add toolbar button to jump back if following relative URL
-rw-r--r-- | css/read.css | 4 | ||||
-rw-r--r-- | js/read.js | 8 | ||||
-rw-r--r-- | 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; @@ -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(); +} @@ -191,6 +191,11 @@ </span> <span class="toolbar"> + <span class="prev_location_btn" + onclick="open_previous_location(this)" style="display : none"> + <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> + </span> + <span onclick="request_fullscreen()"> <span class="glyphicon glyphicon-fullscreen" aria-hidden="true"></span> </span> @@ -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" ]; |