From 8b8f6bdf4673c403cc13a5d3e9fe4b8e614a5d08 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 23 Sep 2018 14:29:05 -0700 Subject: [PATCH] Add photo_clipboard.ingest_toolbox_items. So that the page does not need to construct toolbox items through javascript on pageload, they can just write regular html and we'll move it over. --- .../static/css/clipboard_tray.css | 4 ++++ .../static/js/photoclipboard.js | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/frontends/etiquette_flask/static/css/clipboard_tray.css b/frontends/etiquette_flask/static/css/clipboard_tray.css index 1e39ca0..b2a9bd2 100644 --- a/frontends/etiquette_flask/static/css/clipboard_tray.css +++ b/frontends/etiquette_flask/static/css/clipboard_tray.css @@ -35,3 +35,7 @@ justify-content: space-between; align-items: center; } +.my_clipboard_tray_toolbox +{ + display: none; +} diff --git a/frontends/etiquette_flask/static/js/photoclipboard.js b/frontends/etiquette_flask/static/js/photoclipboard.js index 7d268bb..017cf63 100644 --- a/frontends/etiquette_flask/static/js/photoclipboard.js +++ b/frontends/etiquette_flask/static/js/photoclipboard.js @@ -218,6 +218,26 @@ function clipboard_tray_collapse_toggle() } } +photo_clipboard.ingest_toolbox_items = +function ingest_toolbox_items() +{ + /* + The page may provide divs with the class "my_clipboard_tray_toolbox", and + we will migrate all the elements into the real clipboard tray toolbox. + */ + var toolbox = document.getElementById("clipboard_tray_toolbox"); + var moreboxes = document.getElementsByClassName("my_clipboard_tray_toolbox"); + for (var i = 0; i < moreboxes.length; i += 1) + { + var box = moreboxes[i]; + while (box.firstElementChild) + { + toolbox.appendChild(box.removeChild(box.firstElementChild)); + } + box.parentElement.removeChild(box); + } +} + photo_clipboard.on_tray_delete_button = function on_tray_delete_button(event) { @@ -321,6 +341,7 @@ function on_pageload() hotkeys.register_hotkey("d", 1, 0, 0, photo_clipboard.unselect_all_photos, "Deselect all photos."); hotkeys.register_hotkey("c", 0, 0, 0, photo_clipboard.clipboard_tray_collapse_toggle, "Toggle clipboard tray."); hotkeys.register_hotkey("c", 0, 1, 0, photo_clipboard.open_full_clipboard_tab, "Open full clipboard page."); + photo_clipboard.ingest_toolbox_items(); photo_clipboard.load_clipboard(); photo_clipboard.update_pagestate(); }