2011-01-25 20:57:47 +01:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-differential-populate
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
* @requires javelin-behavior
|
2011-07-16 16:09:19 +02:00
|
|
|
* javelin-workflow
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
* javelin-util
|
|
|
|
* javelin-dom
|
2012-03-13 04:04:12 +01:00
|
|
|
* javelin-stratcom
|
2013-01-14 23:20:35 +01:00
|
|
|
* javelin-behavior-device
|
2012-03-13 04:04:12 +01:00
|
|
|
* phabricator-tooltip
|
2011-01-25 20:57:47 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
JX.behavior('differential-populate', function(config) {
|
|
|
|
|
|
|
|
function onresponse(target, response) {
|
2012-03-13 01:06:55 +01:00
|
|
|
JX.DOM.replace(JX.$(target), JX.$H(response.changeset));
|
|
|
|
if (response.coverage) {
|
|
|
|
for (var k in response.coverage) {
|
|
|
|
try {
|
|
|
|
JX.DOM.replace(JX.$(k), JX.$H(response.coverage[k]));
|
|
|
|
} catch (ignored) {
|
|
|
|
// Not terribly important.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-25 20:57:47 +01:00
|
|
|
}
|
|
|
|
|
2013-01-14 23:20:35 +01:00
|
|
|
// NOTE: If you load the page at one device resolution and then resize to
|
|
|
|
// a different one we don't re-render the diffs, because it's a complicated
|
|
|
|
// mess and you could lose inline comments, cursor positions, etc.
|
|
|
|
var renderer = (JX.Device.getDevice() == 'desktop') ? '2up' : '1up';
|
|
|
|
|
2013-01-18 00:04:44 +01:00
|
|
|
// TODO: Once 1up works better, figure out when to show it.
|
|
|
|
renderer = '2up';
|
|
|
|
|
2011-01-25 20:57:47 +01:00
|
|
|
for (var k in config.registry) {
|
2011-07-16 16:09:19 +02:00
|
|
|
var data = {
|
|
|
|
ref : config.registry[k],
|
2013-01-14 23:20:35 +01:00
|
|
|
whitespace: config.whitespace,
|
|
|
|
renderer: renderer
|
2011-07-16 16:09:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
new JX.Workflow(config.uri, data)
|
|
|
|
.setHandler(JX.bind(null, onresponse, k))
|
|
|
|
.start();
|
2011-01-25 20:57:47 +01:00
|
|
|
}
|
|
|
|
|
2012-03-13 04:04:12 +01:00
|
|
|
var highlighted = null;
|
|
|
|
var highlight_class = null;
|
|
|
|
|
2012-05-01 21:09:50 +02:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
'differential-load',
|
|
|
|
function(e) {
|
|
|
|
var meta = e.getNodeData('differential-load');
|
2012-08-07 08:01:23 +02:00
|
|
|
var diff;
|
|
|
|
try {
|
|
|
|
diff = JX.$(meta.id);
|
|
|
|
} catch (e) {
|
|
|
|
// Already loaded.
|
|
|
|
}
|
|
|
|
if (diff) {
|
|
|
|
JX.DOM.setContent(
|
|
|
|
diff,
|
|
|
|
JX.$H('<div class="differential-loading">Loading...</div>'));
|
|
|
|
var data = {
|
|
|
|
ref : meta.ref,
|
|
|
|
whitespace : config.whitespace
|
|
|
|
};
|
|
|
|
new JX.Workflow(config.uri, data)
|
|
|
|
.setHandler(JX.bind(null, onresponse, meta.id))
|
|
|
|
.start();
|
|
|
|
}
|
2012-05-01 21:09:50 +02:00
|
|
|
if (meta.kill) {
|
|
|
|
e.kill();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-03-13 04:04:12 +01:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
['mouseover', 'mouseout'],
|
|
|
|
['differential-changeset', 'tag:td'],
|
|
|
|
function(e) {
|
|
|
|
var t = e.getTarget();
|
|
|
|
|
|
|
|
// NOTE: Using className is not best practice, but the diff UI is perf
|
|
|
|
// sensitive.
|
2012-05-05 02:41:06 +02:00
|
|
|
if (!t.className.match(/cov|copy/)) {
|
2012-03-13 04:04:12 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (e.getType() == 'mouseout') {
|
|
|
|
JX.Tooltip.hide();
|
|
|
|
if (highlighted) {
|
|
|
|
JX.DOM.alterClass(highlighted, highlight_class, false);
|
|
|
|
highlighted = null;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
highlight_class = null;
|
|
|
|
var msg;
|
2012-12-21 03:23:35 +01:00
|
|
|
var align = 'W';
|
2012-05-05 02:41:06 +02:00
|
|
|
var sibling = 'previousSibling';
|
2012-08-07 02:17:38 +02:00
|
|
|
var width = 120;
|
2012-03-13 04:04:12 +01:00
|
|
|
if (t.className.match(/cov-C/)) {
|
|
|
|
msg = 'Covered';
|
|
|
|
highlight_class = 'source-cov-C';
|
|
|
|
} else if (t.className.match(/cov-U/)) {
|
|
|
|
msg = 'Not Covered';
|
|
|
|
highlight_class = 'source-cov-U';
|
|
|
|
} else if (t.className.match(/cov-N/)) {
|
|
|
|
msg = 'Not Executable';
|
|
|
|
highlight_class = 'source-cov-N';
|
2012-05-05 02:41:06 +02:00
|
|
|
} else {
|
|
|
|
var match = /new-copy|new-move/.exec(t.className);
|
|
|
|
if (match) {
|
|
|
|
sibling = 'nextSibling';
|
2012-08-07 02:17:38 +02:00
|
|
|
width = 500;
|
2012-05-05 02:41:06 +02:00
|
|
|
msg = JX.Stratcom.getData(t).msg;
|
|
|
|
highlight_class = match[0];
|
|
|
|
}
|
2012-03-13 04:04:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (msg) {
|
2012-08-07 02:17:38 +02:00
|
|
|
JX.Tooltip.show(t, width, align, msg);
|
2012-03-13 04:04:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (highlight_class) {
|
2012-05-05 02:41:06 +02:00
|
|
|
highlighted = t[sibling];
|
2012-03-13 04:04:12 +01:00
|
|
|
JX.DOM.alterClass(highlighted, highlight_class, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-25 20:57:47 +01:00
|
|
|
});
|