Improve context menus
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
f26f102650
commit
8f3929875f
|
@ -199,7 +199,7 @@ function redrawMessages() {
|
|||
messageContentSpan.innerText = message['content']
|
||||
messageContentDiv.appendChild(messageContentSpan)
|
||||
|
||||
registerMessageContextMenu(message, messageContentSpan)
|
||||
registerMessageContextMenu(message, messageContentDiv, messageContentSpan)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ function redrawMessages() {
|
|||
authorSpan.innerText = message['author']
|
||||
authorDiv.appendChild(authorSpan)
|
||||
|
||||
registerSendPrivateMessageContextMenu(message, authorSpan)
|
||||
registerSendPrivateMessageContextMenu(message, authorDiv, authorSpan)
|
||||
|
||||
let dateSpan = document.createElement('span')
|
||||
dateSpan.classList.add('text-muted', 'float-end')
|
||||
|
@ -232,7 +232,7 @@ function redrawMessages() {
|
|||
messageContentSpan.innerText = message['content']
|
||||
messageContentDiv.appendChild(messageContentSpan)
|
||||
|
||||
registerMessageContextMenu(message, messageContentSpan)
|
||||
registerMessageContextMenu(message, messageContentDiv, messageContentSpan)
|
||||
|
||||
lastMessage = message
|
||||
lastContentDiv = contentDiv
|
||||
|
@ -253,11 +253,11 @@ function removeAllPopovers() {
|
|||
}
|
||||
}
|
||||
|
||||
function registerSendPrivateMessageContextMenu(message, element) {
|
||||
element.addEventListener('contextmenu', (menu_event) => {
|
||||
function registerSendPrivateMessageContextMenu(message, div, span) {
|
||||
div.addEventListener('contextmenu', (menu_event) => {
|
||||
menu_event.preventDefault()
|
||||
removeAllPopovers()
|
||||
const popover = bootstrap.Popover.getOrCreateInstance(element, {
|
||||
const popover = bootstrap.Popover.getOrCreateInstance(span, {
|
||||
'title': message['author'],
|
||||
'content': `<a id="send-private-message-link-${message['id']}" class="nav-link" href="#" tabindex="0">Envoyer un message privé</a>`,
|
||||
'html': true,
|
||||
|
@ -275,8 +275,8 @@ function registerSendPrivateMessageContextMenu(message, element) {
|
|||
})
|
||||
}
|
||||
|
||||
function registerMessageContextMenu(message, element) {
|
||||
element.addEventListener('contextmenu', (menu_event) => {
|
||||
function registerMessageContextMenu(message, div, span) {
|
||||
div.addEventListener('contextmenu', (menu_event) => {
|
||||
menu_event.preventDefault()
|
||||
removeAllPopovers()
|
||||
let content = `<a id="send-private-message-link-msg-${message['id']}" class="nav-link" href="#" tabindex="0">Envoyer un message privé</a>`
|
||||
|
@ -288,7 +288,7 @@ function registerMessageContextMenu(message, element) {
|
|||
content += `<a id="delete-message-${message['id']}" class="nav-link" href="#" tabindex="0">Supprimer</a>`
|
||||
}
|
||||
|
||||
const popover = bootstrap.Popover.getOrCreateInstance(element, {
|
||||
const popover = bootstrap.Popover.getOrCreateInstance(span, {
|
||||
'content': content,
|
||||
'html': true,
|
||||
'placement': 'bottom',
|
||||
|
@ -321,7 +321,7 @@ function registerMessageContextMenu(message, element) {
|
|||
document.getElementById('delete-message-' + message['id']).addEventListener('click', event => {
|
||||
event.preventDefault()
|
||||
popover.dispose()
|
||||
if (confirm("Supprimer le message ?")) {
|
||||
if (confirm(`Supprimer le message ?\n${message['content']}`)) {
|
||||
socket.send(JSON.stringify({
|
||||
'type': 'delete_message',
|
||||
'message_id': message['id'],
|
||||
|
|
Loading…
Reference in New Issue