From a883ad4b5a25f0128fd2eab521637b75ea11bfad Mon Sep 17 00:00:00 2001 From: "Dmitriy A. Golev" Date: Sat, 27 Aug 2016 13:07:13 +0300 Subject: [PATCH] v1.0.6 - Move codebase to ES5 - Fix #6 --- .versions | 2 +- lib/client/fileUpload.js | 22 +++++++++++++--------- package.js | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.versions b/.versions index 4d4965a..fb23d68 100644 --- a/.versions +++ b/.versions @@ -41,7 +41,7 @@ mongo-id@1.0.5 npm-mongo@1.5.45 observe-sequence@1.0.12 ordered-dict@1.0.8 -ostrio:autoform-files@1.0.5 +ostrio:autoform-files@1.0.6 ostrio:cookies@2.0.5 ostrio:files@1.7.1 promise@0.8.3 diff --git a/lib/client/fileUpload.js b/lib/client/fileUpload.js index c2ecfd5..0e8a26c 100644 --- a/lib/client/fileUpload.js +++ b/lib/client/fileUpload.js @@ -1,4 +1,5 @@ Template.afFileUpload.onCreated(function () { + var self = this; if (!this.data) { this.data = { atts: {} @@ -10,7 +11,10 @@ Template.afFileUpload.onCreated(function () { throw new Meteor.Error(404, '[meteor-autoform-files] No such collection "' + this.data.atts.collection + '"'); } - this.collectionName = () => this.data.atts.collection; + this.collectionName = function () { + return self.data.atts.collection; + }; + this.currentUpload = new ReactiveVar(false); this.inputName = this.data.name; this.fileId = new ReactiveVar(this.data.value || false); @@ -18,13 +22,13 @@ Template.afFileUpload.onCreated(function () { }); Template.afFileUpload.helpers({ - currentUpload() { + currentUpload: function () { return Template.instance().currentUpload.get(); }, - fileId() { + fileId: function () { return Template.instance().fileId.get(); }, - uploadedFile() { + uploadedFile: function () { return global[Template.instance().collectionName()].findOne({ _id: Template.instance().fileId.get() }); @@ -32,12 +36,12 @@ Template.afFileUpload.helpers({ }); Template.afFileUpload.events({ - 'click [data-reset-file]'(e, template) { + 'click [data-reset-file]': function (e, template) { e.preventDefault(); template.fileId.set(false); return false; }, - 'click [data-remove-file]'(e, template) { + 'click [data-remove-file]': function (e, template) { e.preventDefault(); template.fileId.set(false); try { @@ -45,9 +49,9 @@ Template.afFileUpload.events({ } catch (error) {} return false; }, - 'change [data-files-collection-upload]'(e, template) { + 'change [data-files-collection-upload]': function (e, template) { if (e.currentTarget.files && e.currentTarget.files[0]) { - const upload = global[template.collectionName()].insert({ + var upload = global[template.collectionName()].insert({ file: e.currentTarget.files[0], streams: 'dynamic', chunkSize: 'dynamic' @@ -66,7 +70,7 @@ Template.afFileUpload.events({ return; }); - upload.on('end', (error, fileObj) => { + upload.on('end', function (error, fileObj) { if (!error) { if (template) { template.fileId.set(fileObj._id); diff --git a/package.js b/package.js index c856c4f..0fe7a9a 100644 --- a/package.js +++ b/package.js @@ -2,7 +2,7 @@ Package.describe({ name: "ostrio:autoform-files", summary: "File upload for AutoForm using ostrio:files", description: "File upload for AutoForm using ostrio:files", - version: "1.0.5", + version: "1.0.6", git: "https://github.com/VeliovGroup/meteor-autoform-file.git" });