From a71472a4277740380a4f287d4f0088240159a5a1 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Sat, 9 Nov 2019 22:21:34 +0000 Subject: [PATCH] Port contextmenus to Vue --- client/components/App.vue | 7 + client/components/ChannelWrapper.vue | 6 + client/components/Chat.vue | 13 +- client/components/ChatUserList.vue | 8 + client/components/ContextMenu.vue | 141 ++++++++ client/components/Message.vue | 19 +- client/components/MessageList.vue | 1 + client/components/ParsedMessage.vue | 3 +- client/components/Username.vue | 7 + client/components/UsernameFiltered.vue | 7 + client/css/style.css | 1 - client/index.html.tpl | 1 - client/js/contextMenu.js | 172 ---------- client/js/contextMenuFactory.js | 438 ------------------------- client/js/helpers/contextMenu.js | 278 ++++++++++++++++ client/js/helpers/parse.js | 27 +- client/js/utils.js | 21 -- client/js/vue.js | 1 - 18 files changed, 507 insertions(+), 644 deletions(-) create mode 100644 client/components/ContextMenu.vue delete mode 100644 client/js/contextMenu.js delete mode 100644 client/js/contextMenuFactory.js create mode 100644 client/js/helpers/contextMenu.js delete mode 100644 client/js/utils.js diff --git a/client/components/App.vue b/client/components/App.vue index 3f341038..a83c0f4d 100644 --- a/client/components/App.vue +++ b/client/components/App.vue @@ -6,6 +6,7 @@ + @@ -16,12 +17,14 @@ const storage = require("../js/localStorage"); import Sidebar from "./Sidebar.vue"; import ImageViewer from "./ImageViewer.vue"; +import ContextMenu from "./ContextMenu.vue"; export default { name: "App", components: { Sidebar, ImageViewer, + ContextMenu, }, computed: { viewportClasses() { @@ -84,6 +87,10 @@ export default { this.$store.commit("userlistOpen", isUserlistOpen === "true"); }, + openContextMenu(event, items) { + // TODO: maybe move this method to the store or some other more accessible place + this.$refs.contextMenu.open(event, items); + }, }, }; diff --git a/client/components/ChannelWrapper.vue b/client/components/ChannelWrapper.vue index b1edf7ba..b5c4b0a0 100644 --- a/client/components/ChannelWrapper.vue +++ b/client/components/ChannelWrapper.vue @@ -24,6 +24,7 @@ :style="closed ? {transition: 'none', opacity: 0.4} : null" role="tab" @click="click" + @contextmenu.prevent="openContextMenu" > @@ -31,6 +32,7 @@ diff --git a/client/components/Chat.vue b/client/components/Chat.vue index 7920bf08..d210eaed 100644 --- a/client/components/Chat.vue +++ b/client/components/Chat.vue @@ -38,7 +38,11 @@ :network="network" :text="channel.topic" /> -