diff --git a/client/components/cards/attachments.jade b/client/components/cards/attachments.jade index 01a2a0bb7..36b4d6563 100644 --- a/client/components/cards/attachments.jade +++ b/client/components/cards/attachments.jade @@ -95,7 +95,7 @@ template(name="attachmentGallery") if currentUser.isBoardMember unless currentUser.isCommentOnly unless currentUser.isWorker - a.fa.fa-navicon.icon.js-open-attachment-menu(title="{{_ 'attachmentActionsPopup-title'}}") + a.fa.fa-navicon.icon.js-open-attachment-menu(data-attachment-link="{{link}}" title="{{_ 'attachmentActionsPopup-title'}}") template(name="attachmentActionsPopup") diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js index f4918e0f7..2823351ea 100644 --- a/client/components/cards/attachments.js +++ b/client/components/cards/attachments.js @@ -10,6 +10,10 @@ const prettyMilliseconds = require('pretty-ms'); let cardId = null; let openAttachmentId = null; + +// Stores link to the attachment for which attachment actions popup was opened +attachmentActionsLink = null + Template.attachmentGallery.events({ 'click .open-preview'(event) { @@ -25,6 +29,9 @@ Template.attachmentGallery.events({ event.stopPropagation(); }, 'click .js-open-attachment-menu': Popup.open('attachmentActions'), + 'mouseover .js-open-attachment-menu'(event) { // For some reason I cannot combine handlers for "click .js-open-attachment-menu" and "mouseover .js-open-attachment-menu" events so this is a quick workaround. + attachmentActionsLink = event.currentTarget.getAttribute("data-attachment-link"); + }, 'click .js-rename': Popup.open('attachmentRename'), 'click .js-confirm-delete': Popup.afterConfirm('attachmentDelete', function() { Attachments.remove(this._id); @@ -336,9 +343,8 @@ BlazeComponent.extendComponent({ }, 'click .js-add-background-image'() { const currentBoard = Boards.findOne(Session.get('currentBoard')); - const url=$(".attachment-thumbnail-img").attr("src"); - currentBoard.setBackgroundImageURL(url); - Utils.setBackgroundImage(url); + currentBoard.setBackgroundImageURL(attachmentActionsLink); + Utils.setBackgroundImage(attachmentActionsLink); Popup.back(); event.preventDefault(); },