diff --git a/src/pyj/read_book/goto.pyj b/src/pyj/read_book/goto.pyj index 05d18e1c7c..fa3c32a4b5 100644 --- a/src/pyj/read_book/goto.pyj +++ b/src/pyj/read_book/goto.pyj @@ -21,6 +21,8 @@ def create_goto_list(onclick): items.push(create_item(_('Next Section'), icon='caret-right', subtitle=after.title, action=onclick.bind(None, after.dest, after.frag))) if before: items.push(create_item(_('Previous Section'), icon='caret-left', subtitle=before.title, action=onclick.bind(None, before.dest, before.frag))) + items.push(create_item(_('Document Start'), action=onclick.bind(None, def(view): view.goto_doc_boundary(True);))) + items.push(create_item(_('Document End'), action=onclick.bind(None, def(view): view.goto_doc_boundary(False);))) build_list(ans, items) return ans diff --git a/src/pyj/read_book/overlay.pyj b/src/pyj/read_book/overlay.pyj index eb27ebe08e..fe4b5197a9 100644 --- a/src/pyj/read_book/overlay.pyj +++ b/src/pyj/read_book/overlay.pyj @@ -237,7 +237,10 @@ class TOCOverlay: # {{{ def handle_activate(self, dest, frag): self.overlay.hide() - self.overlay.view.goto_named_destination(dest, frag) + if jstype(dest) is 'function': + dest(self.overlay.view, frag) + else: + self.overlay.view.goto_named_destination(dest, frag) # }}} class PrefsOverlay: # {{{ diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index 290d59a607..a207e6a972 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -84,7 +84,7 @@ class View: 'error': self.on_iframe_error, 'next_spine_item': self.on_next_spine_item, 'next_section': self.on_next_section, - 'goto_doc_boundary': self.goto_doc_boundary, + 'goto_doc_boundary': def(data): self.goto_doc_boundary(data.start);, 'scroll_to_anchor': self.on_scroll_to_anchor, 'update_cfi': self.on_update_cfi, 'update_toc_position': self.on_update_toc_position, @@ -279,9 +279,9 @@ class View: self.set_margins() load_resources(self.ui.db, self.book, name, self.loaded_resources, self.show_spine_item) - def goto_doc_boundary(self, data): - name = self.book.manifest.spine[0 if data.start else self.book.manifest.spine.length - 1] - self.show_name(name, initial_position={'type':'frac', 'frac':0 if data.start else 1, 'replace_history':False}) + def goto_doc_boundary(self, start): + name = self.book.manifest.spine[0 if start else self.book.manifest.spine.length - 1] + self.show_name(name, initial_position={'type':'frac', 'frac':0 if start else 1, 'replace_history':False}) def on_scroll_to_anchor(self, data): self.show_name(data.name, initial_position={'type':'anchor', 'anchor':data.frag, 'replace_history':False})