Files
phabricator/webroot/rsrc/js/application/differential/behavior-show-more.js
epriestley 2a39fd09eb 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-08 13:20:10 -07:00

47 lines
1.2 KiB
JavaScript

/**
* @provides javelin-behavior-differential-show-more
* @requires javelin-behavior
* javelin-dom
* javelin-request
* javelin-util
* javelin-stratcom
*/
JX.behavior('differential-show-more', function(config) {
function onresponse(origin, response) {
var div = JX.$N('div', {}, JX.$H(response));
var anchor = origin.getNode('context-target');
var root = anchor.parentNode;
copyRows(root, div, anchor);
root.removeChild(anchor);
}
JX.Stratcom.listen(
'click',
'show-more',
function(e) {
var context = e.getNodes()['context-target'];
var container = JX.DOM.find(context, 'td');
JX.DOM.setContent(container, 'Loading...');
JX.DOM.alterClass(context, 'differential-show-more-loading', true);
var data = e.getNodeData('show-more');
new JX.Request(config.uri, JX.bind(null, onresponse, e))
.setData(data)
.send();
e.kill();
});
});
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]);
}
}
}