From d6a8209b314b8dae9a7eba6d630a99138c41c477 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Thu, 5 Nov 2020 21:52:34 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B4=20ExternalLibs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ExternalLibs/ExternalLibs.vue | 65 +++++++++++++++++-- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/client/components/ExternalLibs/ExternalLibs.vue b/client/components/ExternalLibs/ExternalLibs.vue index 04650073..bb8c9f3d 100644 --- a/client/components/ExternalLibs/ExternalLibs.vue +++ b/client/components/ExternalLibs/ExternalLibs.vue @@ -5,14 +5,22 @@
@@ -68,8 +76,10 @@
-
- +
+
+ +
@@ -217,12 +227,15 @@ class ExternalLibs extends Vue { closeAfterSubmit = false; openInFrameOnEnter = false; openInFrameOnAdd = false; + frameScale = 1; created() { this.oldStartLink = ''; this.justOpened = true; this.$root.addKeyHook(this.keyHook); + this.$root.$on('resize', this.frameResize); + document.addEventListener('fullscreenchange', () => { this.fullScreenActive = (document.fullscreenElement !== null); }); @@ -360,6 +373,11 @@ class ExternalLibs extends Vue { this.openInFrameOnEnter = libs.openInFrameOnEnter || false; this.openInFrameOnAdd = libs.openInFrameOnAdd || false; + this.frameScale = 1; + const index = lu.getSafeRootIndexByUrl(this.libs.groups, this.selectedLink); + if (index >= 0) + this.frameScale = this.libs.groups[index].frameScale || 1; + this.updateStartLink(); } @@ -494,12 +512,45 @@ class ExternalLibs extends Vue { this.$nextTick(() => { this.frameVisible = true; this.$nextTick(() => { - if (this.$refs.frame) + if (this.$refs.frame) { this.$refs.frame.contentWindow.focus(); + this.frameResize(); + } }); }); } + frameResize() { + if (this.$refs.frame) { + const w = this.$refs.frameBox.offsetWidth; + const h = this.$refs.frameBox.offsetHeight; + const normalSize = `width: ${w}px; height: ${h}px;`; + this.$refs.frameWrap.style = normalSize; + if (this.frameScale != 1) { + const s = this.frameScale; + this.$refs.frame.style = `width: ${w/s}px; height: ${h/s}px; transform: scale(${s}); transform-origin: 0 0;`; + } else { + this.$refs.frame.style = normalSize; + } + } + } + + changeScale(delta) { + if ((this.frameScale > 0.1 && delta <= 0) || (this.frameScale < 5 && delta >= 0)) { + this.frameScale = _.round(this.frameScale + delta, 1); + + const index = lu.getSafeRootIndexByUrl(this.libs.groups, this.selectedLink); + if (index >= 0) { + let libs = _.cloneDeep(this.libs); + libs.groups[index].frameScale = this.frameScale; + this.commitLibs(libs); + } + + this.frameResize(); + this.$root.notify.success(`Масштаб изменен: ${(this.frameScale*100).toFixed(0)}%`, '', {position: 'bottom-right'}); + } + } + getCommentByLink(list, link) { const item = lu.getListItemByLink(list, link); return (item ? item.c : '');