diff --git a/src/pyj/read_book/goto.pyj b/src/pyj/read_book/goto.pyj index 39be3a10a6..60856f2ad2 100644 --- a/src/pyj/read_book/goto.pyj +++ b/src/pyj/read_book/goto.pyj @@ -2,7 +2,7 @@ # License: GPL v3 Copyright: 2016, Kovid Goyal from __python__ import hash_literals, bound_methods -from dom import set_css, svgicon +from dom import set_css from elementmaker import E from gettext import gettext as _ @@ -26,11 +26,6 @@ def create_goto_list(onclick): def create_goto_panel(book, container, onclick, onclose): - container.appendChild(E.div( - style='display: flex; justify-content: space-between; padding: 1ex 1em; border-bottom: solid 1px currentColor', - E.h2(_('Go to...')), - E.div(svgicon('close'), style='cursor:pointer', onclick=def(event):event.preventDefault(), event.stopPropagation(), onclose(event);, class_='simple-link'), - )) panel = create_goto_list(onclick) set_css(container, display='flex', flex_direction='column') set_css(panel, flex_grow='10') diff --git a/src/pyj/read_book/overlay.pyj b/src/pyj/read_book/overlay.pyj index c44ba91921..eb27ebe08e 100644 --- a/src/pyj/read_book/overlay.pyj +++ b/src/pyj/read_book/overlay.pyj @@ -218,16 +218,22 @@ class MainOverlay: class TOCOverlay: # {{{ - def __init__(self, overlay, create_func): + def __init__(self, overlay, create_func, title): self.overlay = overlay self.create_func = create_func or create_toc_panel + self.title = title or _('Table of Contents') def on_container_click(self, evt): pass # Dont allow panel to be closed by a click def show(self, container): container.style.backgroundColor = get_color('window-background') - self.create_func(self.overlay.view.book, container, self.handle_activate, self.overlay.hide_current_panel) + container.appendChild(E.div( + style='padding: 1ex 1em; border-bottom: solid 1px currentColor', + E.h2(self.title, style='float:left'), + E.div(svgicon('close'), style='cursor:pointer; float:right', onclick=def(event):event.preventDefault(), event.stopPropagation(), self.overlay.hide_current_panel(event);, class_='simple-link'), + )) + self.create_func(self.overlay.view.book, container, self.handle_activate) def handle_activate(self, dest, frag): self.overlay.hide() @@ -337,7 +343,7 @@ class Overlay: self.show_current_panel() def show_goto(self): - self.panels.push(TOCOverlay(self, create_goto_panel)) + self.panels.push(TOCOverlay(self, create_goto_panel, _('Go to…'))) self.show_current_panel() def show_prefs(self): diff --git a/src/pyj/read_book/toc.pyj b/src/pyj/read_book/toc.pyj index 0123840571..a6a384feaf 100644 --- a/src/pyj/read_book/toc.pyj +++ b/src/pyj/read_book/toc.pyj @@ -119,12 +119,7 @@ def do_search(text): 'The text "{}" was not found in the Table of Contents').format(text)) scroll_tree_item_into_view(a) -def create_toc_panel(book, container, onclick, onclose): - container.appendChild(E.div( - style='display: flex; justify-content: space-between; padding: 1ex 1em; border-bottom: solid 1px currentColor', - E.h2(_('Table of Contents')), - E.div(svgicon('close'), style='cursor:pointer', onclick=def(event):event.preventDefault(), event.stopPropagation(), onclose(event);, class_='simple-link'), - )) +def create_toc_panel(book, container, onclick): def handle_click(event, li): if event.button is 0: onclick(li.dataset.tocDest, li.dataset.tocFrag)