mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Content server: Fix random book button on book details page multiplying. Fixes #1732493 [Multibpe "A random book" butons in the internet browser](https://bugs.launchpad.net/calibre/+bug/1732493)
This commit is contained in:
parent
99452442df
commit
07f5d2ecf2
@ -15,7 +15,7 @@ from book_list.library_data import (
|
|||||||
)
|
)
|
||||||
from book_list.router import back, home, open_book
|
from book_list.router import back, home, open_book
|
||||||
from book_list.theme import get_color, get_font_size
|
from book_list.theme import get_color, get_font_size
|
||||||
from book_list.top_bar import add_button, create_top_bar, set_title
|
from book_list.top_bar import add_button, create_top_bar, set_title, clear_buttons
|
||||||
from book_list.ui import query_as_href, set_panel_handler, show_panel
|
from book_list.ui import query_as_href, set_panel_handler, show_panel
|
||||||
from book_list.views import search_query_for
|
from book_list.views import search_query_for
|
||||||
from date import format_date
|
from date import format_date
|
||||||
@ -443,9 +443,10 @@ def render_book(container_id, book_id):
|
|||||||
def add_top_bar_buttons(container_id):
|
def add_top_bar_buttons(container_id):
|
||||||
container = document.getElementById(container_id)
|
container = document.getElementById(container_id)
|
||||||
if container:
|
if container:
|
||||||
|
clear_buttons(container)
|
||||||
book_id = parse_url_params().book_id
|
book_id = parse_url_params().book_id
|
||||||
if book_id is '0':
|
if book_id is '0':
|
||||||
add_button(container.parentNode, 'random', def(): fetch_metadata(container_id, 0);)
|
add_button(container, 'random', def(): fetch_metadata(container_id, 0);)
|
||||||
add_button(container, 'ellipsis-v', action=show_subsequent_panel.bind(None, 'more_actions'), tooltip=_('More actions'))
|
add_button(container, 'ellipsis-v', action=show_subsequent_panel.bind(None, 'more_actions'), tooltip=_('More actions'))
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,6 +101,13 @@ def add_button(container, icon, action=None, tooltip=''):
|
|||||||
event.preventDefault(), action()
|
event.preventDefault(), action()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def clear_buttons(container):
|
||||||
|
bars = get_bars(container)
|
||||||
|
for i, bar in enumerate(bars):
|
||||||
|
right = bar.firstChild.nextSibling
|
||||||
|
clear(right)
|
||||||
|
|
||||||
|
|
||||||
def set_button_visibility(container, icon, visible):
|
def set_button_visibility(container, icon, visible):
|
||||||
for bar in get_bars(container):
|
for bar in get_bars(container):
|
||||||
right = bar.firstChild.nextSibling
|
right = bar.firstChild.nextSibling
|
||||||
|
Loading…
x
Reference in New Issue
Block a user