Differential D15136 Diff 36544 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 All 16 Lines | JX.behavior('differential-edit-inline-comments', function(config) { | ||||
var origin = null; | var origin = null; | ||||
var target = null; | var target = null; | ||||
var root = null; | var root = null; | ||||
var changeset = null; | var changeset = null; | ||||
var editor = null; | var editor = null; | ||||
function updateReticleForComment(e) { | |||||
root = e.getNode('differential-changeset'); | |||||
if (!root) { | |||||
return; | |||||
} | |||||
var data = e.getNodeData('differential-inline-comment'); | |||||
var change = e.getNodeData('differential-changeset'); | |||||
var id_part = data.on_right ? change.right : change.left; | |||||
var new_part = data.isNewFile ? 'N' : 'O'; | |||||
var prefix = 'C' + id_part + new_part + 'L'; | |||||
origin = JX.$(prefix + data.number); | |||||
target = JX.$(prefix + (parseInt(data.number, 10) + | |||||
parseInt(data.length, 10))); | |||||
updateReticle(); | |||||
} | |||||
function updateReticle() { | function updateReticle() { | ||||
JX.DOM.getContentFrame().appendChild(reticle); | JX.DOM.getContentFrame().appendChild(reticle); | ||||
var top = origin; | var top = origin; | ||||
var bot = target; | var bot = target; | ||||
if (JX.$V(top).y > JX.$V(bot).y) { | if (JX.$V(top).y > JX.$V(bot).y) { | ||||
var tmp = top; | var tmp = top; | ||||
top = bot; | top = bot; | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | function(e) { | ||||
e.kill(); | e.kill(); | ||||
}); | }); | ||||
JX.Stratcom.listen( | JX.Stratcom.listen( | ||||
['mouseover', 'mouseout'], | ['mouseover', 'mouseout'], | ||||
['differential-changeset', 'tag:th'], | ['differential-changeset', 'tag:th'], | ||||
function(e) { | function(e) { | ||||
if (e.getIsTouchEvent()) { | |||||
return; | |||||
} | |||||
if (editor) { | if (editor) { | ||||
// Don't update the reticle if we're editing a comment, since this | // Don't update the reticle if we're editing a comment, since this | ||||
// would be distracting and we want to keep the lines corresponding | // would be distracting and we want to keep the lines corresponding | ||||
// to the comment highlighted during the edit. | // to the comment highlighted during the edit. | ||||
return; | return; | ||||
} | } | ||||
if (getRowNumber(e.getTarget()) === undefined) { | if (getRowNumber(e.getTarget()) === undefined) { | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | function(e) { | ||||
e.kill(); | e.kill(); | ||||
}); | }); | ||||
JX.Stratcom.listen( | JX.Stratcom.listen( | ||||
['mouseover', 'mouseout'], | ['mouseover', 'mouseout'], | ||||
'differential-inline-comment', | 'differential-inline-comment', | ||||
function(e) { | function(e) { | ||||
if (e.getIsTouchEvent()) { | |||||
return; | |||||
} | |||||
if (e.getType() == 'mouseout') { | if (e.getType() == 'mouseout') { | ||||
hideReticle(); | hideReticle(); | ||||
} else { | } else { | ||||
root = e.getNode('differential-changeset'); | updateReticleForComment(e); | ||||
if (root) { | |||||
var data = e.getNodeData('differential-inline-comment'); | |||||
var change = e.getNodeData('differential-changeset'); | |||||
var id_part = data.on_right ? change.right : change.left; | |||||
var new_part = data.isNewFile ? 'N' : 'O'; | |||||
var prefix = 'C' + id_part + new_part + 'L'; | |||||
origin = JX.$(prefix + data.number); | |||||
target = JX.$(prefix + (parseInt(data.number, 10) + | |||||
parseInt(data.length, 10))); | |||||
updateReticle(); | |||||
} | |||||
} | } | ||||
}); | }); | ||||
var action_handler = function(op, e) { | var action_handler = function(op, e) { | ||||
e.kill(); | e.kill(); | ||||
if (editor) { | if (editor) { | ||||
return; | return; | ||||
} | } | ||||
var node = e.getNode('differential-inline-comment'); | var node = e.getNode('differential-inline-comment'); | ||||
// If we're on a touch device, we didn't highlight the affected lines | |||||
// earlier because we can't use hover events to mutate the document. | |||||
// Highlight them now. | |||||
aljungberg: Actually, although it's fine either way, I think we did highlight the affected lines.
We did… | |||||
Not Done Inline ActionsL190 is only for clicks on <th> tags (the line numbers), and does not fire for clicks on the inline comment actions (reply, hide, etc). epriestley: L190 is only for clicks on `<th>` tags (the line numbers), and does not fire for clicks on the… | |||||
updateReticleForComment(e); | |||||
handle_inline_action(node, op); | handle_inline_action(node, op); | ||||
}; | }; | ||||
var handle_inline_action = function(node, op) { | var handle_inline_action = function(node, op) { | ||||
var data = JX.Stratcom.getData(node); | var data = JX.Stratcom.getData(node); | ||||
// If you click an action in the preview at the bottom of the page, we | // If you click an action in the preview at the bottom of the page, we | ||||
// find the corresponding node and simulate clicking that, if it's | // find the corresponding node and simulate clicking that, if it's | ||||
▲ Show 20 Lines • Show All 178 Lines • Show Last 20 Lines |
Actually, although it's fine either way, I think we did highlight the affected lines.
We did not on the mouseover event, due to the new L301, but we did later on the mousedown event (L190). mousedown simulation comes before click so at the time of this handler the work should already have been done.
(Incidentally the mousedown does not need to be special cased for touch because changing the DOM at this point does not cancel the event.)