Created
June 3, 2016 23:55
-
-
Save nem035/c6ba42e601eb5598ec12bb838a689899 to your computer and use it in GitHub Desktop.
Ember Drop Zone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { | |
get, | |
set, | |
Component | |
} = Ember; | |
export default Component.extend({ | |
// passed in | |
classes : '', | |
// local | |
classNames : [ 'drop-zone' ], | |
classNameBindings : [ 'classes', 'dragClass' ], | |
dragClass : 'drop-zone-leave', | |
dropAction : '', | |
dragLeave(e) { | |
e.preventDefault(); | |
set(this, 'dragClass', 'drop-zone-leave'); | |
}, | |
dragOver(e) { | |
e.preventDefault(); | |
set(this, 'dragClass', 'drop-zone-over'); | |
}, | |
drop(e) { | |
e.preventDefault(); | |
get(this, 'dropAction')(e); | |
set(this, 'dragClass', 'drop-zone-leave'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { | |
set, | |
Controller | |
} = Ember; | |
export default Controller.extend({ | |
fileName: '', | |
actions: { | |
onDrop({ dataTransfer }) { | |
set(this, 'fileName', dataTransfer.files[0].name); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.drop-zone { | |
border: 2px solid #e3e3e3; | |
padding: 10px; | |
text-align: center; | |
} | |
.drop-zone.drop-zone-over { | |
border-style: dashed; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.8.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.5.1", | |
"ember-data": "2.5.2", | |
"ember-template-compiler": "2.5.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment