1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 16:00:59 +01:00
phorge-phorge/webroot/rsrc/js/application/differential/behavior-add-reviewers-and-ccs.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

60 lines
1.4 KiB
JavaScript

/**
* @provides javelin-behavior-differential-add-reviewers-and-ccs
* @requires javelin-behavior
* javelin-dom
* javelin-tokenizer
* javelin-typeahead
* javelin-typeahead-preloaded-source
*/
JX.behavior('differential-add-reviewers-and-ccs', function(config) {
function buildTokenizer(props) {
var root = JX.$(props.tokenizer);
var datasource;
if (props.ondemand) {
datasource = new JX.TypeaheadOnDemandSource(props.src);
} else {
datasource = new JX.TypeaheadPreloadedSource(props.src);
}
var typeahead = new JX.Typeahead(root);
typeahead.setDatasource(datasource);
var tokenizer = new JX.Tokenizer(root);
tokenizer.setTypeahead(typeahead);
JX.Stratcom.addData(root, {'tokenizer' : tokenizer});
tokenizer.start();
return tokenizer;
}
var dynamic = {};
for (var k in config.dynamic) {
props = config.dynamic[k];
dynamic[k] = {
row : JX.$(props.row),
tokenizer : buildTokenizer(props)
};
}
JX.DOM.listen(
JX.$(config.select),
'change',
null,
function(e) {
var v = JX.$(config.select).value;
for (var k in dynamic) {
if (v == k) {
JX.DOM.show(dynamic[k].row);
dynamic[k].tokenizer.refresh();
} else {
JX.DOM.hide(dynamic[k].row);
}
}
});
});