2011-06-24 21:21:48 +02:00
|
|
|
/**
|
|
|
|
* @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) {
|
|
|
|
|
2012-01-24 03:34:46 +01:00
|
|
|
function buildTokenizer(id, props) {
|
|
|
|
var root = JX.$(id);
|
2011-10-08 03:25:54 +02:00
|
|
|
|
|
|
|
var datasource;
|
|
|
|
if (props.ondemand) {
|
|
|
|
datasource = new JX.TypeaheadOnDemandSource(props.src);
|
|
|
|
} else {
|
|
|
|
datasource = new JX.TypeaheadPreloadedSource(props.src);
|
|
|
|
}
|
2011-06-24 21:21:48 +02:00
|
|
|
|
|
|
|
var typeahead = new JX.Typeahead(root);
|
|
|
|
typeahead.setDatasource(datasource);
|
|
|
|
|
|
|
|
var tokenizer = new JX.Tokenizer(root);
|
|
|
|
tokenizer.setTypeahead(typeahead);
|
2011-12-23 02:59:00 +01:00
|
|
|
|
|
|
|
JX.Stratcom.addData(root, {'tokenizer' : tokenizer});
|
|
|
|
|
2011-06-24 21:21:48 +02:00
|
|
|
tokenizer.start();
|
|
|
|
|
|
|
|
return tokenizer;
|
|
|
|
}
|
|
|
|
|
|
|
|
var dynamic = {};
|
|
|
|
for (var k in config.dynamic) {
|
|
|
|
props = config.dynamic[k];
|
|
|
|
dynamic[k] = {
|
|
|
|
row : JX.$(props.row),
|
2012-01-24 03:34:46 +01:00
|
|
|
tokenizer : buildTokenizer(k, props),
|
|
|
|
actions : props.actions
|
2011-06-24 21:21:48 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
JX.DOM.listen(
|
|
|
|
JX.$(config.select),
|
|
|
|
'change',
|
|
|
|
null,
|
|
|
|
function(e) {
|
|
|
|
var v = JX.$(config.select).value;
|
|
|
|
for (var k in dynamic) {
|
2012-01-24 03:34:46 +01:00
|
|
|
if (dynamic[k].actions[v]) {
|
2011-06-24 21:21:48 +02:00
|
|
|
JX.DOM.show(dynamic[k].row);
|
|
|
|
dynamic[k].tokenizer.refresh();
|
|
|
|
} else {
|
|
|
|
JX.DOM.hide(dynamic[k].row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|