mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 13:30:55 +01:00
c16c920f94
Summary: - Prioritize higher-priority behaviors on the server. - Remove setTimeout() hacks. Test Plan: Loaded Differential, didn't get CSRF races for comment previews. Reviewers: aran, jg, cpojer Reviewed By: jg CC: btrahan, jungejason, aran, epriestley, jg Differential Revision: 1183
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-differential-feedback-preview
|
|
* @requires javelin-behavior
|
|
* javelin-stratcom
|
|
* javelin-dom
|
|
* javelin-request
|
|
* javelin-util
|
|
* phabricator-shaped-request
|
|
*/
|
|
|
|
JX.behavior('differential-feedback-preview', function(config) {
|
|
|
|
var action = JX.$(config.action);
|
|
var content = JX.$(config.content);
|
|
|
|
var callback = function(r) {
|
|
JX.DOM.setContent(JX.$(config.preview), JX.$H(r));
|
|
};
|
|
|
|
var getdata = function() {
|
|
return {
|
|
content : content.value,
|
|
action : action.value
|
|
};
|
|
};
|
|
|
|
var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata);
|
|
var trigger = JX.bind(request, request.trigger);
|
|
|
|
JX.DOM.listen(content, 'keydown', null, trigger);
|
|
JX.DOM.listen(action, 'change', null, trigger);
|
|
|
|
request.start();
|
|
|
|
|
|
function refreshInlinePreview() {
|
|
new JX.Request(config.inlineuri, function(r) {
|
|
JX.DOM.setContent(JX.$(config.inline), JX.$H(r));
|
|
})
|
|
.setTimeout(5000)
|
|
.send();
|
|
}
|
|
|
|
JX.Stratcom.listen(
|
|
'differential-inline-comment-update',
|
|
null,
|
|
refreshInlinePreview);
|
|
|
|
refreshInlinePreview();
|
|
});
|