diff --git a/src/pyj/book_list/router.pyj b/src/pyj/book_list/router.pyj index 57ca899305..4db58fcb18 100644 --- a/src/pyj/book_list/router.pyj +++ b/src/pyj/book_list/router.pyj @@ -98,7 +98,9 @@ def show_note_url(book_id, field, item_id, item_value, library_id=None, close_ac def show_note(book_id, field, item_id, item_value, replace=False, library_id=None, close_action='back', panel='show_note'): lid = library_id or current_library_id() - q = {'book_id':book_id, 'field': field, 'item':item_value, 'item_id': item_id, 'panel': panel, 'close_action': close_action} + q = {'book_id':book_id, 'field': field, 'item':item_value, 'item_id': item_id, 'panel': panel} + if panel is 'show_note': + q.close_action = close_action if lid: q.library_id = lid push_state(q, replace=replace) diff --git a/src/pyj/book_list/show_note.pyj b/src/pyj/book_list/show_note.pyj index f427e5626c..8475bcd139 100644 --- a/src/pyj/book_list/show_note.pyj +++ b/src/pyj/book_list/show_note.pyj @@ -3,23 +3,56 @@ from __python__ import bound_methods, hash_literals from elementmaker import E + from ajax import ajax +from book_list.comments_editor import ( + create_comments_editor, focus_comments_editor, get_comments_html, set_comments_html +) from book_list.details_list import sandbox_css -from book_list.router import back, home -from book_list.top_bar import create_top_bar +from book_list.router import back, home, show_note +from book_list.top_bar import add_button, create_top_bar from book_list.ui import set_panel_handler from gettext import gettext as _ -from utils import parse_url_params, sandboxed_html +from utils import parse_url_params, safe_set_inner_html, sandboxed_html + + +def message_from_iframe(ev): + c = document.getElementById(current_container_id) + if c and c.lastChild: + iframe = c.querySelector('iframe') + if iframe and ev.source is iframe.contentWindow: + if ev.data.key: + ev.data.from_iframe = True + close_action = get_close_action()[0] + onkeydown(current_container_id, close_action, ev.data) def make_iframe(html): - iframe = sandboxed_html(html, sandbox_css() + '\n\nhtml { overflow: visible; margin: 0.5rem; }') + html += ''' +