Summary: We have some complaints on this feature: - It's not clear that the displayed code is context from gap. - It would be better if the context would be displayed with its real indentation. - It's not clear how far the context is from the displayed code. - Links revealing gap aren't on consistent place. This solves all these problems and introduces new one: It now seems that the reveal links works only with the left side. Anyway, I think that this is better overall. I don't want to put the context on a separate line to not waste space. Test Plan: Displayed various contexts, revealed context. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, bh, jwatzman Differential Revision: https://secure.phabricator.com/D3404
61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-differential-show-more
|
|
* @requires javelin-behavior
|
|
* javelin-dom
|
|
* javelin-workflow
|
|
* javelin-util
|
|
* javelin-stratcom
|
|
*/
|
|
|
|
JX.behavior('differential-show-more', function(config) {
|
|
|
|
function onresponse(context, response) {
|
|
var div = JX.$N('div', {}, JX.$H(response.changeset));
|
|
var root = context.parentNode;
|
|
copyRows(root, div, context);
|
|
root.removeChild(context);
|
|
}
|
|
|
|
JX.Stratcom.listen(
|
|
'click',
|
|
'show-more',
|
|
function(e) {
|
|
var event_data = {
|
|
context : e.getNodes()['context-target'],
|
|
show : e.getNodes()['show-more']
|
|
};
|
|
|
|
JX.Stratcom.invoke('differential-reveal-context', null, event_data);
|
|
e.kill();
|
|
});
|
|
|
|
JX.Stratcom.listen(
|
|
'differential-reveal-context',
|
|
null,
|
|
function(e) {
|
|
var context = e.getData().context;
|
|
var data = JX.Stratcom.getData(e.getData().show);
|
|
|
|
var container = JX.DOM.scry(context, 'td')[0];
|
|
JX.DOM.setContent(container, 'Loading...');
|
|
JX.DOM.alterClass(context, 'differential-show-more-loading', true);
|
|
data['whitespace'] = config.whitespace;
|
|
new JX.Workflow(config.uri, data)
|
|
.setHandler(JX.bind(null, onresponse, context))
|
|
.start();
|
|
});
|
|
|
|
});
|
|
|
|
function copyRows(dst, src, before) {
|
|
var rows = JX.DOM.scry(src, 'tr');
|
|
for (var ii = 0; ii < rows.length; ii++) {
|
|
if (before) {
|
|
dst.insertBefore(rows[ii], before);
|
|
} else {
|
|
dst.appendChild(rows[ii]);
|
|
}
|
|
}
|
|
return rows;
|
|
}
|