mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-27 16:00:59 +01:00
aa98d9e5f8
Summary: Ref T2009. It doesn't make sense to have these as separate behaviors. We require a ChangesetViewManager to track view parameter state. Test Plan: Interacted with changesets in Phriction, Differential and Diffusion. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T2009 Differential Revision: https://secure.phabricator.com/D11979
112 lines
2.8 KiB
JavaScript
112 lines
2.8 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-differential-populate
|
|
* @requires javelin-behavior
|
|
* javelin-dom
|
|
* javelin-stratcom
|
|
* phabricator-tooltip
|
|
* changeset-view-manager
|
|
*/
|
|
|
|
JX.behavior('differential-populate', function(config) {
|
|
|
|
for (var ii = 0; ii < config.changesetViewIDs.length; ii++) {
|
|
var id = config.changesetViewIDs[ii];
|
|
var view = JX.ChangesetViewManager.getForNode(JX.$(id));
|
|
if (view.shouldAutoload()) {
|
|
view.setStabilize(true).load();
|
|
}
|
|
}
|
|
|
|
JX.Stratcom.listen(
|
|
'click',
|
|
'differential-load',
|
|
function(e) {
|
|
var meta = e.getNodeData('differential-load');
|
|
var changeset = JX.$(meta.id);
|
|
var view = JX.ChangesetViewManager.getForNode(changeset);
|
|
|
|
view.load();
|
|
var routable = view.getRoutable();
|
|
if (routable) {
|
|
routable.setPriority(2000);
|
|
}
|
|
|
|
if (meta.kill) {
|
|
e.kill();
|
|
}
|
|
});
|
|
|
|
JX.Stratcom.listen(
|
|
'click',
|
|
'show-more',
|
|
function(e) {
|
|
e.kill();
|
|
|
|
var changeset = e.getNode('differential-changeset');
|
|
var view = JX.ChangesetViewManager.getForNode(changeset);
|
|
var data = e.getNodeData('show-more');
|
|
var target = e.getNode('context-target');
|
|
|
|
view.loadContext(data.range, target);
|
|
});
|
|
|
|
var highlighted = null;
|
|
var highlight_class = null;
|
|
|
|
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.
|
|
if (!t.className.match(/cov|copy/)) {
|
|
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;
|
|
var align = 'W';
|
|
var sibling = 'previousSibling';
|
|
var width = 120;
|
|
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';
|
|
} else {
|
|
var match = /new-copy|new-move/.exec(t.className);
|
|
if (match) {
|
|
sibling = 'nextSibling';
|
|
width = 500;
|
|
msg = JX.Stratcom.getData(t).msg;
|
|
highlight_class = match[0];
|
|
}
|
|
}
|
|
|
|
if (msg) {
|
|
JX.Tooltip.show(t, width, align, msg);
|
|
}
|
|
|
|
if (highlight_class) {
|
|
highlighted = t[sibling];
|
|
JX.DOM.alterClass(highlighted, highlight_class, true);
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
|
|
});
|