/** * @provides javelin-behavior-differential-populate * @requires javelin-behavior * javelin-workflow * javelin-util * javelin-dom * javelin-stratcom * javelin-behavior-device * phabricator-tooltip */ JX.behavior('differential-populate', function(config) { function onresponse(target, response) { 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. } } } } // 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'; // TODO: Once 1up works better, figure out when to show it. renderer = '2up'; for (var k in config.registry) { var data = { ref : config.registry[k], whitespace: config.whitespace, renderer: renderer }; new JX.Workflow(config.uri, data) .setHandler(JX.bind(null, onresponse, k)) .start(); } var highlighted = null; var highlight_class = null; JX.Stratcom.listen( 'click', 'differential-load', function(e) { var meta = e.getNodeData('differential-load'); var diff; try { diff = JX.$(meta.id); } catch (e) { // Already loaded. } if (diff) { JX.DOM.setContent( diff, JX.$H('