mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 10:42:41 +01:00
6a17de65df
Summary: It makes perfect sense to add more reviewers while requesting review. Test Plan: Request review. Verify that Add Reviewers field shows and works. Add some reviewer. Verify that comment preview works. Submit. Verify that reviewers are saved and displayed. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1473
61 lines
1.4 KiB
JavaScript
61 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(id, props) {
|
|
var root = JX.$(id);
|
|
|
|
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(k, props),
|
|
actions : props.actions
|
|
};
|
|
}
|
|
|
|
JX.DOM.listen(
|
|
JX.$(config.select),
|
|
'change',
|
|
null,
|
|
function(e) {
|
|
var v = JX.$(config.select).value;
|
|
for (var k in dynamic) {
|
|
if (dynamic[k].actions[v]) {
|
|
JX.DOM.show(dynamic[k].row);
|
|
dynamic[k].tokenizer.refresh();
|
|
} else {
|
|
JX.DOM.hide(dynamic[k].row);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|