Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F19081821
behavior-workflow.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
behavior-workflow.js
View Options
/**
* @provides javelin-behavior-workflow
* @requires javelin-behavior
* javelin-stratcom
* javelin-workflow
* javelin-dom
* javelin-router
*/
JX
.
behavior
(
'workflow'
,
function
()
{
// Queue a workflow at elevated priority. The user just clicked or submitted
// something, so service this before loading background content.
var
queue
=
function
(
workflow
)
{
var
routable
=
workflow
.
getRoutable
()
.
setPriority
(
2000
)
.
setType
(
'workflow'
);
JX
.
Router
.
getInstance
().
queue
(
routable
);
};
// If a user clicks an alternate submit button, make sure it gets marshalled
// into the workflow.
JX
.
Stratcom
.
listen
(
'click'
,
[
'workflow'
,
'tag:form'
,
'alternate-submit-button'
],
function
(
e
)
{
e
.
prevent
();
var
target
=
e
.
getNode
(
'alternate-submit-button'
);
var
form
=
e
.
getNode
(
'tag:form'
);
var
button
=
{};
button
[
target
.
name
]
=
target
.
value
||
true
;
JX
.
DOM
.
invoke
(
form
,
'didSyntheticSubmit'
,
{
extra
:
button
});
});
// Listen for both real and synthetic submit events.
JX
.
Stratcom
.
listen
(
[
'submit'
,
'didSyntheticSubmit'
],
[
'workflow'
,
'tag:form'
],
function
(
e
)
{
if
(
JX
.
Stratcom
.
pass
())
{
return
;
}
var
data
=
e
.
getData
();
var
extra
=
(
data
&&
data
.
extra
)
||
{};
// NOTE: We activate workflow if any parent node has the "workflow" sigil,
// not just the <form /> itself.
e
.
prevent
();
queue
(
JX
.
Workflow
.
newFromForm
(
e
.
getNode
(
'tag:form'
),
extra
));
});
JX
.
Stratcom
.
listen
(
'click'
,
[
'workflow'
,
'tag:a'
],
function
(
e
)
{
if
(
!
e
.
isNormalClick
())
{
return
;
}
// NOTE: As above, we want to activate workflow if a parent node has
// the sigil, not just the <a /> that the user clicked. However, there
// is an exception in this case: if the <a /> does not have workflow and
// is inside a <form /> which does, we don't workflow it (this covers
// things like "help" links in captions). Test if the node with the
// workflow sigil is a form.
var
workflow_node
=
e
.
getNode
(
'workflow'
);
if
(
JX
.
DOM
.
isType
(
workflow_node
,
'form'
))
{
// This covers the case of an <a /> without workflow inside a <form />
// with workflow.
return
;
}
if
(
JX
.
Stratcom
.
pass
())
{
return
;
}
e
.
prevent
();
queue
(
JX
.
Workflow
.
newFromLink
(
e
.
getNode
(
'tag:a'
)));
});
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 4, 8:33 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8116909
Default Alt Text
behavior-workflow.js (2 KB)
Attached To
Mode
rP Phabricator
Attached
Detach File
Event Timeline
Log In to Comment