Mercurial Hosting > chat
changeset 22:949914955bfe
add menu
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 05 Nov 2024 14:29:16 -0700 |
parents | 5a56297713a3 |
children | c54c806fcc6e |
files | .hgignore src/chat.css src/chat.js src/images/more_vert.svg src/lib/Shared.luan src/site.css |
diffstat | 6 files changed, 69 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Tue Nov 05 12:57:41 2024 -0700 +++ b/.hgignore Tue Nov 05 14:29:16 2024 -0700 @@ -4,3 +4,4 @@ local/ mine/ push-test.sh +.DS_Store
--- a/src/chat.css Tue Nov 05 12:57:41 2024 -0700 +++ b/src/chat.css Tue Nov 05 14:29:16 2024 -0700 @@ -56,6 +56,36 @@ margin-bottom: 16px; } +span[pulldown] { + position: relative; +} + +span[pulldown] > div { + display: none; + top: 0; + left: 100%; + z-index: 2; + position: absolute; + border: 1px solid #cccccc; + border-radius: 4px; + text-align: left; + background-color: #eeeeee; + padding: 5px 0; +} + +span[pulldown] > div > span { + white-space: nowrap; + display: block; + padding: 3px 16px; + xcolor: #333333; + cursor: pointer; +} + +span[pulldown] > div > span:hover { + color: #ffffff; + background-color: #428bca; +} + div[text] { white-space-collapse: preserve; }
--- a/src/chat.js Tue Nov 05 12:57:41 2024 -0700 +++ b/src/chat.js Tue Nov 05 14:29:16 2024 -0700 @@ -124,3 +124,26 @@ function urlsToLinks(text) { return text.replace( urlRegex, '$1<a href="$2">$2</a>' ); } + +let currentPulldown = null; +let newPulldown = null; + +function clickMenu(clicked,display) { + //console.log("clickMenu"); + let pulldown = clicked.parentNode.querySelector('div'); + if( pulldown !== currentPulldown ) { + pulldown.style.display = display || "block"; + newPulldown = pulldown; + window.onclick = function() { + //console.log("window.onclick"); + if( currentPulldown ) { + currentPulldown.style.display = "none"; + if( !newPulldown ) + window.onclick = null; + } + currentPulldown = newPulldown; + newPulldown = null; + }; + pulldown.scrollIntoViewIfNeeded(false); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/images/more_vert.svg Tue Nov 05 14:29:16 2024 -0700 @@ -0,0 +1,1 @@ +<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 -960 960 960" width="16px" fill="#5f6368"><path d="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"/></svg> \ No newline at end of file
--- a/src/lib/Shared.luan Tue Nov 05 12:57:41 2024 -0700 +++ b/src/lib/Shared.luan Tue Nov 05 14:29:16 2024 -0700 @@ -92,13 +92,25 @@ end function Shared.post_html(post) - local author = get_user_by_id(post.author_id) + local author_id = post.author_id + local user = current_user() or error() + local mine = user.id == author_id + local author = get_user_by_id(author_id) local id = post.id %> <div post="<%=id%>"> <div who> <span author><%=author.email%></span> <span when fix><%=post.date%></span> +<% if mine then %> + <span pulldown> + <img onclick="clickMenu(this)" src="/images/more_vert.svg"> + <div> + <span>Edit</span> + <span>Delete</span> + </div> + <span> +<% end %> </div> <div text fix><%= html_encode(post.content) %></div> </div>