TOC, bookmarks: remember current page so we can go back to it

pull/3650/head
poire-z 6 years ago committed by Frans de Jonge
parent d0f9b53eb3
commit e615345ffa

@ -241,6 +241,7 @@ function ReaderBookmark:onShowBookmark()
-- buid up menu widget method as closure
local bookmark = self
function bm_menu:onMenuChoice(item)
bookmark.ui.link:addCurrentLocationToStack()
bookmark:gotoBookmark(item.page)
end

@ -199,6 +199,15 @@ function ReaderLink:onTap(_, ges)
end
end
--- Remember current location so we can go back to it
function ReaderLink:addCurrentLocationToStack()
if self.ui.document.info.has_pages then
table.insert(self.location_stack, self.ui.paging:getBookLocation())
else
table.insert(self.location_stack, self.ui.rolling:getBookLocation())
end
end
--- Goes to link.
function ReaderLink:onGotoLink(link)
logger.dbg("onGotoLink:", link)
@ -206,7 +215,7 @@ function ReaderLink:onGotoLink(link)
-- internal pdf links have a "page" attribute, while external ones have an "uri" attribute
if link.page then -- Internal link
logger.dbg("Internal link:", link)
table.insert(self.location_stack, self.ui.paging:getBookLocation())
self:addCurrentLocationToStack()
self.ui:handleEvent(Event:new("GotoPage", link.page + 1))
return true
end
@ -220,7 +229,7 @@ function ReaderLink:onGotoLink(link)
-- which accepts both of the above legitimate xpointer as input.
if self.ui.document:isXPointerInDocument(link) then
logger.dbg("Internal link:", link)
table.insert(self.location_stack, self.ui.rolling:getBookLocation())
self:addCurrentLocationToStack()
self.ui:handleEvent(Event:new("GotoXPointer", link))
return true
end

@ -345,6 +345,7 @@ function ReaderToc:onShowToc()
item.state.callback()
else
toc_menu:close_callback()
self.ui.link:addCurrentLocationToStack()
self.ui:handleEvent(Event:new("GotoPage", item.page))
end
end

Loading…
Cancel
Save