Added new functions to go to next/previous chapter that also work with 2-page layout
This commit is contained in:
parent
c1ecf23c2c
commit
9bdcaa2b46
1 changed files with 62 additions and 0 deletions
|
|
@ -101,6 +101,7 @@ end
|
|||
function ReaderToc:_getChapterPagesLeft(pageno,pages)
|
||||
local i
|
||||
local j = 0
|
||||
|
||||
if not self.toc then
|
||||
-- build toc when needed.
|
||||
self:fillToc()
|
||||
|
|
@ -134,6 +135,7 @@ end
|
|||
function ReaderToc:_getChapterPagesDone(pageno)
|
||||
local i
|
||||
local j = 0
|
||||
|
||||
if not self.toc then
|
||||
-- build toc when needed.
|
||||
self:fillToc()
|
||||
|
|
@ -160,6 +162,66 @@ function ReaderToc:_getChapterPagesDone(pageno)
|
|||
end
|
||||
end
|
||||
|
||||
function ReaderToc:_getPreviousChapter(pageno)
|
||||
local i
|
||||
local j = 0
|
||||
|
||||
if not self.toc then
|
||||
-- build toc when needed.
|
||||
self:fillToc()
|
||||
end
|
||||
|
||||
-- no table of content
|
||||
if #self.toc == 0 then
|
||||
return ""
|
||||
end
|
||||
|
||||
if #self.toc > 0 then
|
||||
for i = 1, #self.toc do
|
||||
v = self.toc[i]
|
||||
if v.page >= pageno then
|
||||
break
|
||||
end
|
||||
j = v.page
|
||||
end
|
||||
end
|
||||
if j >= pageno then
|
||||
return ""
|
||||
else
|
||||
return j
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderToc:_getNextChapter(pageno)
|
||||
local i
|
||||
local j = 0
|
||||
|
||||
if not self.toc then
|
||||
-- build toc when needed.
|
||||
self:fillToc()
|
||||
end
|
||||
|
||||
-- no table of content
|
||||
if #self.toc == 0 then
|
||||
return ""
|
||||
end
|
||||
|
||||
if #self.toc > 0 then
|
||||
for i = 1, #self.toc do
|
||||
v = self.toc[i]
|
||||
if v.page >= pageno then
|
||||
j = v.page
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if j < pageno then
|
||||
return ""
|
||||
else
|
||||
return j
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function ReaderToc:onShowToc()
|
||||
if not self.toc then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue