From 3655d8e8df61297ce184581de2ad23bb1bc4a293 Mon Sep 17 00:00:00 2001 From: Guillaume Vincent Date: Thu, 10 Nov 2016 15:49:37 +0100 Subject: [PATCH] remove confirm box and add a long press button help to fix confirm box that doesn't work on Firefox web extension https://github.com/lesspass/lesspass/issues/29 --- src/components/DeleteButton.vue | 77 ++++++++++++++++++++++++++++++++++++----- src/views/Passwords.vue | 51 +++++++++++---------------- 2 files changed, 89 insertions(+), 39 deletions(-) diff --git a/src/components/DeleteButton.vue b/src/components/DeleteButton.vue index ea6b82d..16dc806 100644 --- a/src/components/DeleteButton.vue +++ b/src/components/DeleteButton.vue @@ -2,11 +2,40 @@ .fa-white { color: #ffffff; } + + #delete-button { + position: relative; + } + + .btn-progress:before { + content: ""; + position: absolute; + background: #D9534F; + bottom: 0; + left: 0; + top: 80%; + z-index: 1; + animation: 2s progress; + } + + @keyframes progress { + 0% { + right: 100%; + } + 100% { + right: 0; + } + } @@ -14,7 +43,10 @@ export default { data() { return { - pending: false + progress: false, + pressTimer: null, + longPress: false, + confirmHelp: '' } }, props: { @@ -23,12 +55,41 @@ object: {type: Object, required: true} }, methods: { - confirm() { - this.pending = true; - var response = confirm(this.text); - if (response == true) { - this.action(this.object); + start(event){ + if (event.type === "click" && event.button !== 0) { + return; + } + this.longPress = false; + this.progress = true; + this.pressTimer = setTimeout(() => { + this.longPress = true; + this.deleteConfirmed(); + }, 2000); + return false; + }, + click(){ + if (this.longPress) { + return; + } + if (this.pressTimer !== null) { + clearTimeout(this.pressTimer); + this.pressTimer = null; } + this.progress = false; + this.confirmHelp = 'Long Press To Confirm'; + }, + cancel(){ + if (this.pressTimer !== null) { + clearTimeout(this.pressTimer); + this.pressTimer = null; + this.confirmHelp = ''; + } + this.progress = false; + }, + deleteConfirmed(){ + setTimeout(() => { + this.action(this.object); + }, 1000); } } } diff --git a/src/views/Passwords.vue b/src/views/Passwords.vue index 602f7a9..49b8cf0 100644 --- a/src/views/Passwords.vue +++ b/src/views/Passwords.vue @@ -1,15 +1,8 @@ -