Differential D17861 Diff 43049 webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js
Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js
Show First 20 Lines • Show All 419 Lines • ▼ Show 20 Lines | JX.behavior('differential-edit-inline-comments', function(config) { | ||||
JX.Stratcom.listen( | JX.Stratcom.listen( | ||||
'differential-inline-action', | 'differential-inline-action', | ||||
null, | null, | ||||
function(e) { | function(e) { | ||||
var data = e.getData(); | var data = e.getData(); | ||||
handle_inline_action(data.node, data.op); | handle_inline_action(data.node, data.op); | ||||
}); | }); | ||||
// Respond to the user clicking the "Hide Inline" button on an inline | |||||
// comment. | |||||
JX.Stratcom.listen('click', 'hide-inline', function(e) { | |||||
e.kill(); | |||||
var row = e.getNode('inline-row'); | |||||
JX.DOM.hide(row); | |||||
var prev = row.previousSibling; | |||||
while (prev && JX.Stratcom.hasSigil(prev, 'inline-row')) { | |||||
prev = prev.previousSibling; | |||||
} | |||||
if (!prev) { | |||||
return; | |||||
} | |||||
var comment = e.getNodeData('differential-inline-comment'); | |||||
var slots = []; | |||||
for (var ii = 0; ii < prev.childNodes.length; ii++) { | |||||
if (JX.DOM.isType(prev.childNodes[ii], 'th')) { | |||||
slots.push(prev.childNodes[ii]); | |||||
} | |||||
} | |||||
// Select the right-hand side if the comment is on the right. | |||||
var slot = (comment.on_right && slots[1]) || slots[0]; | |||||
var reveal = JX.DOM.scry(slot, 'a', 'reveal-inlines')[0]; | |||||
if (!reveal) { | |||||
reveal = JX.$N( | |||||
'a', | |||||
{ | |||||
className: 'reveal-inlines', | |||||
sigil: 'reveal-inlines' | |||||
}, | |||||
JX.$H(config.revealIcon)); | |||||
JX.DOM.prependContent(slot, reveal); | |||||
} | |||||
new JX.Workflow(config.uri, {op: 'hide', ids: comment.id}) | |||||
.setHandler(JX.bag) | |||||
.start(); | |||||
}); | |||||
JX.Stratcom.listen('click', 'reveal-inlines', function(e) { | |||||
e.kill(); | |||||
var row = e.getNode('tag:tr'); | |||||
var next = row.nextSibling; | |||||
var ids = []; | |||||
var ii; | |||||
// Show any hidden inline comment rows directly below this one. | |||||
while (next && JX.Stratcom.hasSigil(next, 'inline-row')) { | |||||
JX.DOM.show(next); | |||||
var comments = JX.DOM.scry(next, 'div', 'differential-inline-comment'); | |||||
for (ii = 0; ii < comments.length; ii++) { | |||||
var id = JX.Stratcom.getData(comments[ii]).id; | |||||
if (id) { | |||||
ids.push(id); | |||||
} | |||||
} | |||||
next = next.nextSibling; | |||||
} | |||||
// Remove any "reveal" icons on the row. | |||||
var reveals = JX.DOM.scry(row, 'a', 'reveal-inlines'); | |||||
for (ii = 0; ii < reveals.length; ii++) { | |||||
JX.DOM.remove(reveals[ii]); | |||||
} | |||||
new JX.Workflow(config.uri, {op: 'show', ids: ids.join(',')}) | |||||
.setHandler(JX.bag) | |||||
.start(); | |||||
}); | |||||
}); | }); |