mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 23:32:40 +01:00
40 lines
1 KiB
JavaScript
40 lines
1 KiB
JavaScript
|
/**
|
||
|
* @provides javelin-behavior-conpherence-drag-and-drop-photo
|
||
|
* @requires javelin-behavior
|
||
|
* javelin-dom
|
||
|
* javelin-workflow
|
||
|
* phabricator-drag-and-drop-file-upload
|
||
|
*/
|
||
|
|
||
|
JX.behavior('conpherence-drag-and-drop-photo', function(config) {
|
||
|
|
||
|
var target = JX.$(config.target);
|
||
|
var form_pane = JX.$(config.form_pane);
|
||
|
|
||
|
function onupload(f) {
|
||
|
var data = {
|
||
|
'file_id' : f.getID(),
|
||
|
'action' : 'metadata'
|
||
|
};
|
||
|
|
||
|
var form = JX.DOM.find(form_pane, 'form');
|
||
|
var workflow = JX.Workflow.newFromForm(form, data);
|
||
|
workflow.start();
|
||
|
}
|
||
|
|
||
|
if (JX.PhabricatorDragAndDropFileUpload.isSupported()) {
|
||
|
var drop = new JX.PhabricatorDragAndDropFileUpload(target)
|
||
|
.setURI(config.upload_uri);
|
||
|
drop.listen('didBeginDrag', function(e) {
|
||
|
JX.DOM.alterClass(target, config.activated_class, true);
|
||
|
});
|
||
|
drop.listen('didEndDrag', function(e) {
|
||
|
JX.DOM.alterClass(target, config.activated_class, false);
|
||
|
});
|
||
|
drop.listen('didUpload', onupload);
|
||
|
drop.start();
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|