Start working on Preferences UI for the viewer

This commit is contained in:
Kovid Goyal 2016-09-06 15:00:03 +05:30
parent bb3e2d6a29
commit 9ce4ce354f
3 changed files with 51 additions and 1 deletions

View File

@ -9,6 +9,7 @@ from book_list.globals import get_boss
from widgets import create_spinner, create_button
from gettext import gettext as _
from read_book.toc import create_toc_panel
from read_book.prefs import create_prefs_panel
class LoadingMessage: # {{{

View File

@ -0,0 +1,49 @@
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from __python__ import hash_literals, bound_methods
from gettext import gettext as _
from dom import svgicon, ensure_id, clear
from elementmaker import E
class Prefs:
def __init__(self, container, close_func):
self.close_func = close_func
title = E.h2(_('Configure book reader'))
self.title_id = ensure_id(title)
container.appendChild(E.div(
style='display: flex; justify-content: space-between; padding: 1ex 1em; border-bottom: solid 1px currentColor',
title,
E.div(svgicon('close'), onclick=self.onclose, style='cursor:pointer'),
))
container.appendChild(E.div())
self.container_id = ensure_id(container.lastChild)
self.stack = v'["top"]'
self.display_top(container.lastChild)
def onclose(self):
if self.stack.length > 1:
self.stack.pop()
self.display_panel(self.stack[-1])
else:
self.close_func()
@property
def container(self):
return document.getElementById(self.container_id)
def display_panel(self, which):
container = self.container
clear(container)
getattr(self, 'display_' + which)(container)
def show_panel(self, which):
self.stack.push(which)
self.display_panel(which)
def display_top(self, container):
pass
def create_prefs_panel(container, close_func):
Prefs(container, close_func)

View File

@ -32,7 +32,7 @@ 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'), onclick=def(event):event.preventDefault(), event.stopPropagation(), onclose(event);, class_='simple-link'),
E.div(svgicon('close'), style='cursor:pointer', onclick=def(event):event.preventDefault(), event.stopPropagation(), onclose(event);, class_='simple-link'),
))
def handle_click(event, li):
if event.button is 0: