Skip to content

Commit

Permalink
Add file binding
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissloey committed Sep 28, 2015
1 parent de4134e commit 5fce059
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ You should also update your Content Security Policy (usually in
Option Name | Description | Default Value
-----------------|-----------------------------------------------------|---------------
image | Where we should bind the base64 data. | `null`
file | Where we should bind the file object. | `null`
placeholder | The large text shown in the drop area. | `""`
helpText | The smaller text shown below the placeholder. | `"Drop your image here, or click to select"`
hideTextOnImage | Should we hide the text when an image is present? | `true`
Expand Down
5 changes: 4 additions & 1 deletion addon/components/image-drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export default Ember.Component.extend({
helpText: "Drop your image here, or click to select",
hideTextOnImage: true,

image: null,
file: null,

textStyle: Ember.computed('image', function() {
let textStyle = "";
if (this.get('hideTextOnImage') && this.get('image')) {
Expand All @@ -17,7 +20,6 @@ export default Ember.Component.extend({
return Ember.String.htmlSafe(textStyle);
}),

image: null,
style: Ember.computed('image', function() {
let backgroundStyle = "";
if (this.get('image')) {
Expand All @@ -35,6 +37,7 @@ export default Ember.Component.extend({
}),

handleFileDrop(file) {
this.set('file', file);
var reader = new FileReader();
reader.onload = (e) => {
var fileToUpload = e.target.result;
Expand Down
3 changes: 2 additions & 1 deletion tests/dummy/app/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Ember from 'ember';

export default Ember.Controller.extend({
image: null
image: null,
file: null
});
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{image-drop image=image placeholder="Company Logo"}}
{{image-drop file=file image=image placeholder="Company Logo"}}

0 comments on commit 5fce059

Please sign in to comment.