From 2e98b9307826b78ccc331ec2154f3152094751c2 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Wed, 17 Oct 2018 20:37:40 -0700 Subject: [PATCH] Lightbox delete should close lightbox Signed-off-by: James Ketrenos --- frontend/elements/photo-lightbox.html | 10 ++++++ frontend/src/ketr-photos/ketr-photos.html | 38 ++++++++++++----------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/frontend/elements/photo-lightbox.html b/frontend/elements/photo-lightbox.html index 7e02bb3..1fa2123 100644 --- a/frontend/elements/photo-lightbox.html +++ b/frontend/elements/photo-lightbox.html @@ -179,6 +179,10 @@ Polymer({ }, onKeyDown: function(e) { + if (!this.active) { + return; + } + if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey) { return; } @@ -202,6 +206,7 @@ Polymer({ console.log(e.keyCode); break; } + if (this.hasFocus) { e.preventDefault(); e.stopPropagation(); @@ -237,7 +242,12 @@ Polymer({ }, close: function() { + if (this.closed) { + return; + } + this.style.opacity = 0; + this.async(function() { this.setActive(false); this.style.display = 'none'; diff --git a/frontend/src/ketr-photos/ketr-photos.html b/frontend/src/ketr-photos/ketr-photos.html index aa0cd02..58e10aa 100755 --- a/frontend/src/ketr-photos/ketr-photos.html +++ b/frontend/src/ketr-photos/ketr-photos.html @@ -1344,26 +1344,28 @@ } window.fetch("api/v1/photos/" + thumbnail.item.id + query, this._removeImageAfterFetch.bind(this, thumbnail, function() { - /* In duplicates mode, if an image is deleted it has the same - * effect as renaming it since it removes it from the view */ - if (this.mode != "duplicates") { - return; - } - /* If there is now only one item with this thumbnail's name, - * remove it from the view */ - var orphan = null; - for (var i = 0; i < this.thumbnails.length; i++) { - if (this.thumbnails[i].item.filename == thumbnail.item.filename) { - if (orphan) { - return; - } - orphan = this.thumbnails[i]; + /* If there is a lightbox, close the lightbox */ + this.$.lightbox.close(); + /* In duplicates mode, if an image is deleted it has the same + * effect as renaming it since it removes it from the view */ + if (this.mode != "duplicates") { + return; + } + /* If there is now only one item with this thumbnail's name, + * remove it from the view */ + var orphan = null; + for (var i = 0; i < this.thumbnails.length; i++) { + if (this.thumbnails[i].item.filename == thumbnail.item.filename) { + if (orphan) { + return; } + orphan = this.thumbnails[i]; } - if (orphan) { - this._removeImageAfterFetch(orphan, null); - } - }.bind(this)), {}, "DELETE"); + } + if (orphan) { + this._removeImageAfterFetch(orphan, null); + } + }.bind(this)), {}, "DELETE"); }, renameAction: function(thumbnail) {