Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffChangesetList.js
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | construct: function() { | ||||
var onresize = JX.bind(this, this._ifawake, this._onresize); | var onresize = JX.bind(this, this._ifawake, this._onresize); | ||||
JX.Stratcom.listen('resize', null, onresize); | JX.Stratcom.listen('resize', null, onresize); | ||||
var onselect = JX.bind(this, this._ifawake, this._onselect); | var onselect = JX.bind(this, this._ifawake, this._onselect); | ||||
JX.Stratcom.listen( | JX.Stratcom.listen( | ||||
'mousedown', | 'mousedown', | ||||
['differential-inline-comment', 'differential-inline-header'], | ['differential-inline-comment', 'differential-inline-header'], | ||||
onselect); | onselect); | ||||
var onhover = JX.bind(this, this._ifawake, this._onhover); | |||||
JX.Stratcom.listen( | |||||
['mouseover', 'mouseout'], | |||||
'differential-inline-comment', | |||||
onhover); | |||||
}, | }, | ||||
properties: { | properties: { | ||||
translations: null, | translations: null, | ||||
inlineURI: null | inlineURI: null | ||||
}, | }, | ||||
members: { | members: { | ||||
_initialized: false, | _initialized: false, | ||||
_asleep: true, | _asleep: true, | ||||
_changesets: null, | _changesets: null, | ||||
_cursorItem: null, | _cursorItem: null, | ||||
_focusNode: null, | _focusNode: null, | ||||
_focusStart: null, | _focusStart: null, | ||||
_focusEnd: null, | _focusEnd: null, | ||||
_hoverNode: null, | |||||
_hoverInline: null, | |||||
_hoverOrigin: null, | |||||
_hoverTarget: null, | |||||
sleep: function() { | sleep: function() { | ||||
this._asleep = true; | this._asleep = true; | ||||
this._redrawFocus(); | this._redrawFocus(); | ||||
this._redrawSelection(); | |||||
this.resetHover(); | |||||
}, | }, | ||||
wake: function() { | wake: function() { | ||||
this._asleep = false; | this._asleep = false; | ||||
this._redrawFocus(); | this._redrawFocus(); | ||||
this._redrawSelection(); | |||||
if (this._initialized) { | if (this._initialized) { | ||||
return; | return; | ||||
} | } | ||||
this._initialized = true; | this._initialized = true; | ||||
var pht = this.getTranslations(); | var pht = this.getTranslations(); | ||||
▲ Show 20 Lines • Show All 328 Lines • ▼ Show 20 Lines | _getSelectableItems: function() { | ||||
for (var jj = 0; jj < items.length; jj++) { | for (var jj = 0; jj < items.length; jj++) { | ||||
result.push(items[jj]); | result.push(items[jj]); | ||||
} | } | ||||
} | } | ||||
return result; | return result; | ||||
}, | }, | ||||
_onhover: function(e) { | |||||
if (e.getIsTouchEvent()) { | |||||
return; | |||||
} | |||||
var inline; | |||||
if (e.getType() == 'mouseout') { | |||||
inline = null; | |||||
} else { | |||||
inline = this._getInlineForEvent(e); | |||||
} | |||||
this._setHoverInline(inline); | |||||
}, | |||||
_onmore: function(e) { | _onmore: function(e) { | ||||
e.kill(); | e.kill(); | ||||
var node = e.getNode('differential-changeset'); | var node = e.getNode('differential-changeset'); | ||||
var changeset = this.getChangesetForNode(node); | var changeset = this.getChangesetForNode(node); | ||||
var data = e.getNodeData('show-more'); | var data = e.getNodeData('show-more'); | ||||
var target = e.getNode('context-target'); | var target = e.getNode('context-target'); | ||||
▲ Show 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | _onhidereveal: function(e, is_hide) { | ||||
var inline = this._getInlineForEvent(e); | var inline = this._getInlineForEvent(e); | ||||
inline.setHidden(is_hide); | inline.setHidden(is_hide); | ||||
}, | }, | ||||
_onresize: function() { | _onresize: function() { | ||||
this._redrawFocus(); | this._redrawFocus(); | ||||
this._redrawSelection(); | |||||
this._redrawHover(); | |||||
}, | }, | ||||
_onselect: function(e) { | _onselect: function(e) { | ||||
// If the user clicked some element inside the header, like an action | // If the user clicked some element inside the header, like an action | ||||
// icon, ignore the event. They have to click the header element itself. | // icon, ignore the event. They have to click the header element itself. | ||||
if (e.getTarget() !== e.getNode('differential-inline-header')) { | if (e.getTarget() !== e.getNode('differential-inline-header')) { | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | members: { | ||||
redrawPreview: function() { | redrawPreview: function() { | ||||
// TODO: This isn't the cleanest way to find the preview form, but | // TODO: This isn't the cleanest way to find the preview form, but | ||||
// rendering no longer has direct access to it. | // rendering no longer has direct access to it. | ||||
var forms = JX.DOM.scry(document.body, 'form', 'transaction-append'); | var forms = JX.DOM.scry(document.body, 'form', 'transaction-append'); | ||||
if (forms.length) { | if (forms.length) { | ||||
JX.DOM.invoke(forms[0], 'shouldRefresh'); | JX.DOM.invoke(forms[0], 'shouldRefresh'); | ||||
} | } | ||||
// Clear the mouse hover reticle after a substantive edit: we don't get | |||||
// a "mouseout" event if the row vanished because of row being removed | |||||
// after an edit. | |||||
this.reseHover(); | |||||
}, | }, | ||||
setFocus: function(node, extended_node) { | setFocus: function(node, extended_node) { | ||||
this._focusStart = node; | this._focusStart = node; | ||||
this._focusEnd = extended_node; | this._focusEnd = extended_node; | ||||
this._redrawFocus(); | this._redrawFocus(); | ||||
}, | }, | ||||
Show All 27 Lines | members: { | ||||
_getFocusNode: function() { | _getFocusNode: function() { | ||||
if (!this._focusNode) { | if (!this._focusNode) { | ||||
var node = JX.$N('div', {className : 'keyboard-focus-focus-reticle'}); | var node = JX.$N('div', {className : 'keyboard-focus-focus-reticle'}); | ||||
this._focusNode = node; | this._focusNode = node; | ||||
} | } | ||||
return this._focusNode; | return this._focusNode; | ||||
}, | }, | ||||
_setHoverInline: function(inline) { | |||||
this._hoverInline = inline; | |||||
if (inline) { | |||||
var changeset = inline.getChangeset(); | |||||
var changeset_id; | |||||
var side = inline.getDisplaySide(); | |||||
if (side == 'right') { | |||||
changeset_id = changeset.getRightChangesetID(); | |||||
} else { | |||||
changeset_id = changeset.getLeftChangesetID(); | |||||
} | |||||
var new_part; | |||||
if (inline.isNewFile()) { | |||||
new_part = 'N'; | |||||
} else { | |||||
new_part = 'O'; | |||||
} | |||||
var prefix = 'C' + changeset_id + new_part + 'L'; | |||||
var number = inline.getLineNumber(); | |||||
var length = inline.getLineLength(); | |||||
var origin = JX.$(prefix + number); | |||||
var target = JX.$(prefix + (number + length)); | |||||
this._hoverOrigin = origin; | |||||
this._hoverTarget = target; | |||||
} else { | |||||
this._hoverOrigin = null; | |||||
this._hoverTarget = null; | |||||
} | |||||
this._redrawHover(); | |||||
}, | |||||
resetHover: function() { | |||||
this._setHoverInline(null); | |||||
}, | |||||
_redrawHover: function() { | |||||
var reticle = this._getHoverNode(); | |||||
if (!this._hoverOrigin || this.isAsleep()) { | |||||
JX.DOM.remove(reticle); | |||||
return; | |||||
} | |||||
JX.DOM.getContentFrame().appendChild(reticle); | |||||
var top = this._hoverOrigin; | |||||
var bot = this._hoverTarget; | |||||
if (JX.$V(top).y > JX.$V(bot).y) { | |||||
var tmp = top; | |||||
top = bot; | |||||
bot = tmp; | |||||
} | |||||
// Find the leftmost cell that we're going to highlight: this is the next | |||||
// <td /> in the row. In 2up views, it should be directly adjacent. In | |||||
// 1up views, we may have to skip over the other line number column. | |||||
var l = top; | |||||
while (JX.DOM.isType(l, 'th')) { | |||||
l = l.nextSibling; | |||||
} | |||||
// Find the rightmost cell that we're going to highlight: this is the | |||||
// farthest consecutive, adjacent <td /> in the row. Sometimes the left | |||||
// and right nodes are the same (left side of 2up view); sometimes we're | |||||
// going to highlight several nodes (copy + code + coverage). | |||||
var r = l; | |||||
while (r.nextSibling && JX.DOM.isType(r.nextSibling, 'td')) { | |||||
r = r.nextSibling; | |||||
} | |||||
var pos = JX.$V(l) | |||||
.add(JX.Vector.getAggregateScrollForNode(l)); | |||||
var dim = JX.$V(r) | |||||
.add(JX.Vector.getAggregateScrollForNode(r)) | |||||
.add(-pos.x, -pos.y) | |||||
.add(JX.Vector.getDim(r)); | |||||
var bpos = JX.$V(bot) | |||||
.add(JX.Vector.getAggregateScrollForNode(bot)); | |||||
dim.y = (bpos.y - pos.y) + JX.Vector.getDim(bot).y; | |||||
pos.setPos(reticle); | |||||
dim.setDim(reticle); | |||||
JX.DOM.show(reticle); | |||||
}, | |||||
_getHoverNode: function() { | |||||
if (!this._hoverNode) { | |||||
var attributes = { | |||||
className: 'differential-reticle' | |||||
}; | |||||
this._hoverNode = JX.$N('div', attributes); | |||||
} | |||||
return this._hoverNode; | |||||
}, | |||||
_deleteInlineByID: function(id) { | _deleteInlineByID: function(id) { | ||||
var uri = this.getInlineURI(); | var uri = this.getInlineURI(); | ||||
var data = { | var data = { | ||||
op: 'refdelete', | op: 'refdelete', | ||||
id: id | id: id | ||||
}; | }; | ||||
var handler = JX.bind(this, this.redrawPreview); | var handler = JX.bind(this, this.redrawPreview); | ||||
Show All 21 Lines |