From 0da4319f76ecbb08599b73d313aae22e5be3c66a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 24 Aug 2019 19:00:15 +0100 Subject: [PATCH] Dropdown on click --- epicyon-profile.css | 2 +- webinterface.py | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/epicyon-profile.css b/epicyon-profile.css index cd0c28de..b239a6e6 100644 --- a/epicyon-profile.css +++ b/epicyon-profile.css @@ -644,7 +644,7 @@ input[type=submit]:hover { .dropdown-content a:hover {background-color: #111;} /* Show the dropdown menu on hover */ -.dropdown:hover .dropdown-content {display: block;} +.show {display: block;} /* Change the background color of the dropdown button when the dropdown content is shown */ .dropdown:hover .dropbtn {background-color: var(--main-fg-color);} diff --git a/webinterface.py b/webinterface.py index 55e826a9..6942c5d3 100644 --- a/webinterface.py +++ b/webinterface.py @@ -654,8 +654,8 @@ def htmlNewPost(baseDir: str,path: str,inReplyTo: str,mentions: []) -> str: ' ' \ '
' \ ' \n' +def clickToDropDownScript() -> str: + """Function run onclick to create a dropdown + """ + script= \ + '/* When the user clicks on the button,' \ + 'toggle between hiding and showing the dropdown content */' \ + 'function dropdown() {' \ + ' document.getElementById("myDropdown").classList.toggle("show");' \ + '}' \ + '' \ + '// Close the dropdown menu if the user clicks outside of it' \ + 'window.onclick = function(event) {' \ + " if (!event.target.matches('.dropdown')) {" \ + ' var dropdowns = document.getElementsByClassName("dropdown-content");' \ + ' var i;' \ + ' for (i = 0; i < dropdowns.length; i++) {' \ + ' var openDropdown = dropdowns[i];' \ + " if (openDropdown.classList.contains('show')) {" \ + " openDropdown.classList.remove('show');" \ + ' }' \ + ' }' \ + ' }' \ + '}' + return script + def contentWarningScript() -> str: """Returns a script used for content warnings """ @@ -1216,7 +1244,7 @@ def individualPostAsHtml(baseDir: str, \ avatarDropdown= \ ' ' \ - ' Avatar' + ' Avatar' if showAvatarDropdown and fullDomain+'/users/'+nickname not in postJsonObject['actor']: # if not following then show "Follow" in the dropdown @@ -1241,7 +1269,7 @@ def individualPostAsHtml(baseDir: str, \ avatarDropdown= \ '