1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00
phorge-phorge/webroot/rsrc/js/application/differential/behavior-comment-preview.js
vrana 460efc4489 Include added reviewers and ccs in preview
Summary: Preview of Add Reviewers looks silly without actually showing them

Test Plan:
Go to any diff
Leap into action: Add Reviewers
Add some reviewers
Write some comment
Preview including Added reviewers should be displayed
Change action to Comment
Added reviewers should disappear
Repeat with Add CCs

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley, vrana

Differential Revision: https://secure.phabricator.com/D1276
2012-01-04 17:08:13 -08:00

62 lines
1.6 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 previewTokenizers = {};
for (var field in config.previewTokenizers) {
var tokenizer = JX.$(config.previewTokenizers[field]);
previewTokenizers[field] = JX.Stratcom.getData(tokenizer).tokenizer;
}
var callback = function(r) {
JX.DOM.setContent(JX.$(config.preview), JX.$H(r));
};
var getdata = function() {
var data = {
content : content.value,
action : action.value
};
for (var field in previewTokenizers) {
data[field] = JX.keys(previewTokenizers[field].getTokens()).join(',');
}
return data;
};
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);
for (var field in previewTokenizers) {
previewTokenizers[field].listen('change', 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();
});