summaryrefslogtreecommitdiffstats
path: root/client/lib
diff options
context:
space:
mode:
Diffstat (limited to 'client/lib')
-rw-r--r--client/lib/filter.js4
-rw-r--r--client/lib/popup.js2
-rw-r--r--client/lib/utils.js77
3 files changed, 81 insertions, 2 deletions
diff --git a/client/lib/filter.js b/client/lib/filter.js
index f19dc617..1ca3a280 100644
--- a/client/lib/filter.js
+++ b/client/lib/filter.js
@@ -451,10 +451,12 @@ Filter = {
// before changing the schema.
labelIds: new SetFilter(),
members: new SetFilter(),
+ archive: new SetFilter(),
+ hideEmpty: new SetFilter(),
customFields: new SetFilter('_id'),
advanced: new AdvancedFilter(),
- _fields: ['labelIds', 'members', 'customFields'],
+ _fields: ['labelIds', 'members', 'archive', 'hideEmpty', 'customFields'],
// We don't filter cards that have been added after the last filter change. To
// implement this we keep the id of these cards in this `_exceptions` fields
diff --git a/client/lib/popup.js b/client/lib/popup.js
index 6c294d32..8095fbd2 100644
--- a/client/lib/popup.js
+++ b/client/lib/popup.js
@@ -67,7 +67,7 @@ window.Popup = new (class {
title: self._getTitle(popupName),
depth: self._stack.length,
offset: self._getOffset(openerElement),
- dataContext: (this.currentData && this.currentData()) || this,
+ dataContext: (this && this.currentData && this.currentData()) || this,
});
// If there are no popup currently opened we use the Blaze API to render
diff --git a/client/lib/utils.js b/client/lib/utils.js
index 5681273e..81835929 100644
--- a/client/lib/utils.js
+++ b/client/lib/utils.js
@@ -24,6 +24,83 @@ Utils = {
);
},
+ MAX_IMAGE_PIXEL: Meteor.settings.public.MAX_IMAGE_PIXEL,
+ COMPRESS_RATIO: Meteor.settings.public.IMAGE_COMPRESS_RATIO,
+ processUploadedAttachment(card, fileObj, callback) {
+ const next = attachment => {
+ if (typeof callback === 'function') {
+ callback(attachment);
+ }
+ };
+ if (!card) {
+ return next();
+ }
+ const file = new FS.File(fileObj);
+ if (card.isLinkedCard()) {
+ file.boardId = Cards.findOne(card.linkedId).boardId;
+ file.cardId = card.linkedId;
+ } else {
+ file.boardId = card.boardId;
+ file.swimlaneId = card.swimlaneId;
+ file.listId = card.listId;
+ file.cardId = card._id;
+ }
+ file.userId = Meteor.userId();
+ if (file.original) {
+ file.original.name = fileObj.name;
+ }
+ return next(Attachments.insert(file));
+ },
+ shrinkImage(options) {
+ // shrink image to certain size
+ const dataurl = options.dataurl,
+ callback = options.callback,
+ toBlob = options.toBlob;
+ let canvas = document.createElement('canvas'),
+ image = document.createElement('img');
+ const maxSize = options.maxSize || 1024;
+ const ratio = options.ratio || 1.0;
+ const next = function(result) {
+ image = null;
+ canvas = null;
+ if (typeof callback === 'function') {
+ callback(result);
+ }
+ };
+ image.onload = function() {
+ let width = this.width,
+ height = this.height;
+ let changed = false;
+ if (width > height) {
+ if (width > maxSize) {
+ height *= maxSize / width;
+ width = maxSize;
+ changed = true;
+ }
+ } else if (height > maxSize) {
+ width *= maxSize / height;
+ height = maxSize;
+ changed = true;
+ }
+ canvas.width = width;
+ canvas.height = height;
+ canvas.getContext('2d').drawImage(this, 0, 0, width, height);
+ if (changed === true) {
+ const type = 'image/jpeg';
+ if (toBlob) {
+ canvas.toBlob(next, type, ratio);
+ } else {
+ next(canvas.toDataURL(type, ratio));
+ }
+ } else {
+ next(changed);
+ }
+ };
+ image.onerror = function() {
+ next(false);
+ };
+ image.src = dataurl;
+ },
capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
},