[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 /** 2 * @provides javelin-behavior-differential-show-more 3 * @requires javelin-behavior 4 * javelin-dom 5 * javelin-workflow 6 * javelin-util 7 * javelin-stratcom 8 */ 9 10 JX.behavior('differential-show-more', function(config) { 11 12 function onresponse(context, response) { 13 var table = JX.$H(response.changeset).getNode(); 14 var root = context.parentNode; 15 copyRows(root, table, context); 16 root.removeChild(context); 17 } 18 19 JX.Stratcom.listen( 20 'click', 21 'show-more', 22 function(e) { 23 var event_data = { 24 context : e.getNodes()['context-target'], 25 show : e.getNodes()['show-more'] 26 }; 27 28 JX.Stratcom.invoke('differential-reveal-context', null, event_data); 29 e.kill(); 30 }); 31 32 JX.Stratcom.listen( 33 'differential-reveal-context', 34 null, 35 function(e) { 36 var context = e.getData().context; 37 var data = JX.Stratcom.getData(e.getData().show); 38 39 var container = JX.DOM.scry(context, 'td')[0]; 40 JX.DOM.setContent(container, 'Loading...'); 41 JX.DOM.alterClass(context, 'differential-show-more-loading', true); 42 43 if (!data['whitespace']) { 44 data['whitespace'] = config.whitespace; 45 } 46 47 new JX.Workflow(config.uri, data) 48 .setHandler(JX.bind(null, onresponse, context)) 49 .start(); 50 }); 51 52 }); 53 54 function copyRows(dst, src, before) { 55 var rows = JX.DOM.scry(src, 'tr'); 56 for (var ii = 0; ii < rows.length; ii++) { 57 58 // Find the table this <tr /> belongs to. If it's a sub-table, like a 59 // table in an inline comment, don't copy it. 60 if (JX.DOM.findAbove(rows[ii], 'table') !== src) { 61 continue; 62 } 63 64 if (before) { 65 dst.insertBefore(rows[ii], before); 66 } else { 67 dst.appendChild(rows[ii]); 68 } 69 } 70 return rows; 71 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |