Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91754191
behavior-phui-file-upload.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Nov 14, 03:18
Size
1 KB
Mime Type
text/x-Algol68
Expires
Sat, Nov 16, 03:18 (2 d)
Engine
blob
Format
Raw Data
Handle
22318997
Attached To
rPH Phabricator
behavior-phui-file-upload.js
View Options
/**
* @provides javelin-behavior-phui-file-upload
* @requires javelin-behavior
* javelin-stratcom
* javelin-dom
* phuix-dropdown-menu
*/
JX
.
behavior
(
'phui-file-upload'
,
function
(
config
)
{
function
startUpload
(
workflow
,
input
)
{
var
files
=
input
.
files
;
if
(
!
files
||
!
files
.
length
)
{
return
;
}
var
state
=
{
workflow
:
workflow
,
input
:
input
,
waiting
:
0
,
phids
:
[]
};
var
callback
=
JX
.
bind
(
null
,
didUpload
,
state
);
var
dummy
=
input
;
var
uploader
=
new
JX
.
PhabricatorDragAndDropFileUpload
(
dummy
)
.
setURI
(
config
.
uploadURI
)
.
setChunkThreshold
(
config
.
chunkThreshold
);
uploader
.
listen
(
'didUpload'
,
callback
);
uploader
.
start
();
workflow
.
pause
();
for
(
var
ii
=
0
;
ii
<
files
.
length
;
ii
++
)
{
state
.
waiting
++
;
uploader
.
sendRequest
(
files
[
ii
]);
}
}
function
didUpload
(
state
,
file
)
{
state
.
phids
.
push
(
file
.
getPHID
());
state
.
waiting
--
;
if
(
state
.
waiting
)
{
return
;
}
state
.
workflow
.
addData
(
config
.
inputName
,
state
.
phids
.
join
(
', '
))
.
resume
();
}
JX
.
Workflow
.
listen
(
'start'
,
function
(
workflow
)
{
var
form
=
workflow
.
getSourceForm
();
if
(
!
form
)
{
return
;
}
var
input
;
try
{
input
=
JX
.
$
(
config
.
fileInputID
);
}
catch
(
ex
)
{
return
;
}
var
local_form
=
JX
.
DOM
.
findAbove
(
input
,
'form'
);
if
(
!
local_form
)
{
return
;
}
if
(
local_form
!==
form
)
{
return
;
}
startUpload
(
workflow
,
input
);
});
});
Event Timeline
Log In to Comment