From 70a795dced5860176ebf87f07495ac6614c3fa23 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Fri, 20 Sep 2019 21:10:48 +0300 Subject: [PATCH] Start porting image viewer to Vue --- client/components/App.vue | 3 ++ client/components/ImageViewer.vue | 60 +++++++++++++++++++++++++++++++ client/components/LinkPreview.vue | 15 +++++++- client/components/Message.vue | 3 -- client/index.html.tpl | 1 - client/views/image_viewer.tpl | 21 ----------- 6 files changed, 77 insertions(+), 26 deletions(-) create mode 100644 client/components/ImageViewer.vue delete mode 100644 client/views/image_viewer.tpl diff --git a/client/components/App.vue b/client/components/App.vue index 9c769ed6..8af3f566 100644 --- a/client/components/App.vue +++ b/client/components/App.vue @@ -10,6 +10,7 @@ /> + @@ -19,6 +20,7 @@ const throttle = require("lodash/throttle"); import Sidebar from "./Sidebar.vue"; import NetworkList from "./NetworkList.vue"; import Chat from "./Chat.vue"; +import ImageViewer from "./ImageViewer.vue"; import SignIn from "./Windows/SignIn.vue"; import Settings from "./Windows/Settings.vue"; import NetworkEdit from "./Windows/NetworkEdit.vue"; @@ -31,6 +33,7 @@ export default { components: { Sidebar, NetworkList, + ImageViewer, Chat, SignIn, Settings, diff --git a/client/components/ImageViewer.vue b/client/components/ImageViewer.vue new file mode 100644 index 00000000..bce41f79 --- /dev/null +++ b/client/components/ImageViewer.vue @@ -0,0 +1,60 @@ + + + diff --git a/client/components/LinkPreview.vue b/client/components/LinkPreview.vue index 298ec998..08a4e3e6 100644 --- a/client/components/LinkPreview.vue +++ b/client/components/LinkPreview.vue @@ -11,6 +11,7 @@ class="toggle-thumbnail" target="_blank" rel="noopener" + @click="onThumbnailClick" > @@ -173,6 +180,12 @@ export default { this.link.thumb = ""; this.onPreviewReady(); }, + onThumbnailClick(e) { + e.preventDefault(); + + const imageViewer = this.$root.$refs.app.$refs.imageViewer; + imageViewer.link = this.link; + }, onMoreClick() { this.isContentShown = !this.isContentShown; this.keepScrollPosition(); diff --git a/client/components/Message.vue b/client/components/Message.vue index 5f5c68ec..a0ff9c81 100644 --- a/client/components/Message.vue +++ b/client/components/Message.vue @@ -100,9 +100,6 @@ export default { return "message-" + this.message.type; }, }, - mounted() { - require("../js/renderPreview"); - }, methods: { isAction() { return typeof MessageTypes["message-" + this.message.type] !== "undefined"; diff --git a/client/index.html.tpl b/client/index.html.tpl index eb584d7b..bbd144fa 100644 --- a/client/index.html.tpl +++ b/client/index.html.tpl @@ -65,7 +65,6 @@
-
diff --git a/client/views/image_viewer.tpl b/client/views/image_viewer.tpl deleted file mode 100644 index 71306050..00000000 --- a/client/views/image_viewer.tpl +++ /dev/null @@ -1,21 +0,0 @@ - - -{{#if hasPreviousImage}} - -{{/if}} - -{{#if hasNextImage}} - -{{/if}} - - - - - - - {{#equal type "image"}} - Open image - {{else}} - Visit page - {{/equal}} -