Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/core/DragAndDropFileUpload.js
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | start : function() { | ||||
if (!this.getIsEnabled()) { | if (!this.getIsEnabled()) { | ||||
return; | return; | ||||
} | } | ||||
e.kill(); | e.kill(); | ||||
var files = e.getRawEvent().dataTransfer.files; | var files = e.getRawEvent().dataTransfer.files; | ||||
for (var ii = 0; ii < files.length; ii++) { | for (var ii = 0; ii < files.length; ii++) { | ||||
this._sendRequest(files[ii]); | this.sendRequest(files[ii]); | ||||
} | } | ||||
// Force depth to 0. | // Force depth to 0. | ||||
this._updateDepth(-this._depth); | this._updateDepth(-this._depth); | ||||
}); | }); | ||||
if (this._node) { | if (this._node) { | ||||
JX.DOM.listen(this._node, 'click', null, on_click); | JX.DOM.listen(this._node, 'click', null, on_click); | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | start : function() { | ||||
continue; | continue; | ||||
} | } | ||||
var spec = item.getAsFile(); | var spec = item.getAsFile(); | ||||
// pasted files don't have a name; see | // pasted files don't have a name; see | ||||
// https://code.google.com/p/chromium/issues/detail?id=361145 | // https://code.google.com/p/chromium/issues/detail?id=361145 | ||||
if (!spec.name) { | if (!spec.name) { | ||||
spec.name = 'pasted_file'; | spec.name = 'pasted_file'; | ||||
} | } | ||||
this._sendRequest(spec); | this.sendRequest(spec); | ||||
} | } | ||||
})); | })); | ||||
} | } | ||||
this.setIsEnabled(true); | this.setIsEnabled(true); | ||||
}, | }, | ||||
_sendRequest : function(spec) { | sendRequest : function(spec) { | ||||
var file = new JX.PhabricatorFileUpload() | var file = new JX.PhabricatorFileUpload() | ||||
.setRawFileObject(spec) | .setRawFileObject(spec) | ||||
.setName(spec.name) | .setName(spec.name) | ||||
.setTotalBytes(spec.size); | .setTotalBytes(spec.size); | ||||
var threshold = this.getChunkThreshold(); | var threshold = this.getChunkThreshold(); | ||||
if (threshold && (file.getTotalBytes() > threshold)) { | if (threshold && (file.getTotalBytes() > threshold)) { | ||||
// This is a large file, so we'll go through allocation so we can | // This is a large file, so we'll go through allocation so we can | ||||
▲ Show 20 Lines • Show All 222 Lines • Show Last 20 Lines |