mirror of
https://github.com/moparisthebest/mail
synced 2024-11-23 01:12:19 -05:00
add file input and filereader logic to writer
This commit is contained in:
parent
1237fe684a
commit
bb5b63558e
@ -56,6 +56,7 @@ define(function(require) {
|
|||||||
$scope.subject = '';
|
$scope.subject = '';
|
||||||
$scope.body = '';
|
$scope.body = '';
|
||||||
$scope.ciphertextPreview = '';
|
$scope.ciphertextPreview = '';
|
||||||
|
$scope.attachments = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillFields(re) {
|
function fillFields(re) {
|
||||||
@ -239,6 +240,11 @@ define(function(require) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add attachment to email object
|
||||||
|
if ($scope.attachments.length > 0) {
|
||||||
|
email.attachments = $scope.attachments;
|
||||||
|
}
|
||||||
|
|
||||||
// persist the email locally for later smtp transmission
|
// persist the email locally for later smtp transmission
|
||||||
emailDao.store(email, function(err) {
|
emailDao.store(email, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -440,5 +446,28 @@ define(function(require) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ngModule.directive('attachment', function() {
|
||||||
|
return function(scope, elm) {
|
||||||
|
elm.bind('change', function(e) {
|
||||||
|
for (var i = 0; i < e.target.files.length; i++) {
|
||||||
|
addAttachment(e.target.files.item(i));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function addAttachment(file) {
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.onload = function(e) {
|
||||||
|
scope.attachments.push({
|
||||||
|
fileName: file.name,
|
||||||
|
contentType: file.type,
|
||||||
|
uint8Array: new Uint8Array(e.target.result)
|
||||||
|
});
|
||||||
|
scope.$apply();
|
||||||
|
};
|
||||||
|
reader.readAsArrayBuffer(file);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
return WriteCtrl;
|
return WriteCtrl;
|
||||||
});
|
});
|
@ -30,6 +30,10 @@
|
|||||||
</button>
|
</button>
|
||||||
</div><!--/.subject-box-->
|
</div><!--/.subject-box-->
|
||||||
|
|
||||||
|
<div class="attachments-box">
|
||||||
|
<input type="file" attachment multiple>
|
||||||
|
</div><!--/.attachments-box-->
|
||||||
|
|
||||||
<div class="body" focus-child>
|
<div class="body" focus-child>
|
||||||
<p ng-model="body" contentEditable="true" spellcheck="false" ng-change="updatePreview()" tabindex="3" focus-me="state.writer.open && writerTitle === 'Reply'"></p>
|
<p ng-model="body" contentEditable="true" spellcheck="false" ng-change="updatePreview()" tabindex="3" focus-me="state.writer.open && writerTitle === 'Reply'"></p>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user