Pārlūkot izejas kodu

Merge pull request #5004 from VidVidex/master

Fix setting background image
Lauri Ojansivu 1 gadu atpakaļ
vecāks
revīzija
d7784a8d38

+ 1 - 1
client/components/cards/attachments.jade

@@ -95,7 +95,7 @@ template(name="attachmentGallery")
               if currentUser.isBoardMember
               if currentUser.isBoardMember
                 unless currentUser.isCommentOnly
                 unless currentUser.isCommentOnly
                   unless currentUser.isWorker
                   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")
 template(name="attachmentActionsPopup")

+ 9 - 3
client/components/cards/attachments.js

@@ -10,6 +10,10 @@ const prettyMilliseconds = require('pretty-ms');
 let cardId = null;
 let cardId = null;
 let openAttachmentId = null;
 let openAttachmentId = null;
 
 
+
+// Stores link to the attachment for which attachment actions popup was opened
+attachmentActionsLink = null
+
 Template.attachmentGallery.events({
 Template.attachmentGallery.events({
   'click .open-preview'(event) {
   'click .open-preview'(event) {
 
 
@@ -25,6 +29,9 @@ Template.attachmentGallery.events({
     event.stopPropagation();
     event.stopPropagation();
   },
   },
   'click .js-open-attachment-menu': Popup.open('attachmentActions'),
   '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-rename': Popup.open('attachmentRename'),
   'click .js-confirm-delete': Popup.afterConfirm('attachmentDelete', function() {
   'click .js-confirm-delete': Popup.afterConfirm('attachmentDelete', function() {
     Attachments.remove(this._id);
     Attachments.remove(this._id);
@@ -336,9 +343,8 @@ BlazeComponent.extendComponent({
         },
         },
         'click .js-add-background-image'() {
         'click .js-add-background-image'() {
           const currentBoard = Boards.findOne(Session.get('currentBoard'));
           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();
           Popup.back();
           event.preventDefault();
           event.preventDefault();
         },
         },