Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffChangesetList.js
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | construct: function() { | ||||
var onhover = JX.bind(this, this._ifawake, this._onhover); | var onhover = JX.bind(this, this._ifawake, this._onhover); | ||||
JX.Stratcom.listen( | JX.Stratcom.listen( | ||||
['mouseover', 'mouseout'], | ['mouseover', 'mouseout'], | ||||
'differential-inline-comment', | 'differential-inline-comment', | ||||
onhover); | onhover); | ||||
var onrangedown = JX.bind(this, this._ifawake, this._onrangedown); | var onrangedown = JX.bind(this, this._ifawake, this._onrangedown); | ||||
JX.Stratcom.listen( | JX.Stratcom.listen( | ||||
'mousedown', | ['touchstart', 'mousedown'], | ||||
['differential-changeset', 'tag:th'], | ['differential-changeset', 'tag:th'], | ||||
onrangedown); | onrangedown); | ||||
var onrangemove = JX.bind(this, this._ifawake, this._onrangemove); | var onrangemove = JX.bind(this, this._ifawake, this._onrangemove); | ||||
JX.Stratcom.listen( | JX.Stratcom.listen( | ||||
['mouseover', 'mouseout'], | ['mouseover', 'mouseout'], | ||||
['differential-changeset', 'tag:th'], | ['differential-changeset', 'tag:th'], | ||||
onrangemove); | onrangemove); | ||||
var onrangetouchmove = JX.bind(this, this._ifawake, this._onrangetouchmove); | |||||
JX.Stratcom.listen( | |||||
'touchmove', | |||||
null, | |||||
onrangetouchmove); | |||||
var onrangeup = JX.bind(this, this._ifawake, this._onrangeup); | var onrangeup = JX.bind(this, this._ifawake, this._onrangeup); | ||||
JX.Stratcom.listen('mouseup', null, onrangeup); | JX.Stratcom.listen( | ||||
['touchend', 'mouseup'], | |||||
null, | |||||
onrangeup); | |||||
}, | }, | ||||
properties: { | properties: { | ||||
translations: null, | translations: null, | ||||
inlineURI: null | inlineURI: null | ||||
}, | }, | ||||
members: { | members: { | ||||
▲ Show 20 Lines • Show All 995 Lines • ▼ Show 20 Lines | getLineNumberFromHeader: function(th) { | ||||
} | } | ||||
}, | }, | ||||
getDisplaySideFromHeader: function(th) { | getDisplaySideFromHeader: function(th) { | ||||
return (th.parentNode.firstChild != th) ? 'right' : 'left'; | return (th.parentNode.firstChild != th) ? 'right' : 'left'; | ||||
}, | }, | ||||
_onrangedown: function(e) { | _onrangedown: function(e) { | ||||
if (!e.isNormalMouseEvent()) { | // NOTE: We're allowing touch events through, including "touchstart". We | ||||
return; | // need to kill the "touchstart" event so the page doesn't scroll. | ||||
} | if (e.isRightButton()) { | ||||
if (e.getIsTouchEvent()) { | |||||
return; | return; | ||||
} | } | ||||
if (this._rangeActive) { | if (this._rangeActive) { | ||||
return; | return; | ||||
} | } | ||||
var target = e.getTarget(); | var target = e.getTarget(); | ||||
Show All 11 Lines | _onrangedown: function(e) { | ||||
this._setHoverRange(this._rangeOrigin, this._rangeTarget); | this._setHoverRange(this._rangeOrigin, this._rangeTarget); | ||||
}, | }, | ||||
_onrangemove: function(e) { | _onrangemove: function(e) { | ||||
if (e.getIsTouchEvent()) { | if (e.getIsTouchEvent()) { | ||||
return; | return; | ||||
} | } | ||||
var is_out = (e.getType() == 'mouseout'); | |||||
var target = e.getTarget(); | var target = e.getTarget(); | ||||
this._updateRange(target, is_out); | |||||
}, | |||||
_updateRange: function(target, is_out) { | |||||
// Don't update the range if this "<th />" doesn't correspond to a line | // Don't update the range if this "<th />" doesn't correspond to a line | ||||
// number. For instance, this may be a dead line number, like the empty | // number. For instance, this may be a dead line number, like the empty | ||||
// line numbers on the left hand side of a newly added file. | // line numbers on the left hand side of a newly added file. | ||||
var number = this.getLineNumberFromHeader(target); | var number = this.getLineNumberFromHeader(target); | ||||
if (!number) { | if (!number) { | ||||
return; | return; | ||||
} | } | ||||
Show All 16 Lines | _updateRange: function(target, is_out) { | ||||
// multiple files. | // multiple files. | ||||
var origin_table = JX.DOM.findAbove(origin, 'table'); | var origin_table = JX.DOM.findAbove(origin, 'table'); | ||||
var target_table = JX.DOM.findAbove(target, 'table'); | var target_table = JX.DOM.findAbove(target, 'table'); | ||||
if (origin_table != target_table) { | if (origin_table != target_table) { | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
var is_out = (e.getType() == 'mouseout'); | |||||
if (is_out) { | if (is_out) { | ||||
if (this._rangeActive) { | if (this._rangeActive) { | ||||
// If we're dragging a range, just leave the state as it is. This | // If we're dragging a range, just leave the state as it is. This | ||||
// allows you to drag over something invalid while selecting a | // allows you to drag over something invalid while selecting a | ||||
// range without the range flickering or getting lost. | // range without the range flickering or getting lost. | ||||
} else { | } else { | ||||
// Otherwise, clear the current range. | // Otherwise, clear the current range. | ||||
this.resetHover(); | this.resetHover(); | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
if (this._rangeActive) { | if (this._rangeActive) { | ||||
this._rangeTarget = target; | this._rangeTarget = target; | ||||
} else { | } else { | ||||
this._rangeOrigin = target; | this._rangeOrigin = target; | ||||
this._rangeTarget = target; | this._rangeTarget = target; | ||||
} | } | ||||
this._setHoverRange(this._rangeOrigin, this._rangeTarget); | this._setHoverRange(this._rangeOrigin, this._rangeTarget); | ||||
}, | }, | ||||
_onrangetouchmove: function(e) { | |||||
if (!this._rangeActive) { | |||||
return; | |||||
} | |||||
// NOTE: The target of a "touchmove" event is bogus. Use dark magic to | |||||
// identify the actual target. Some day, this might move into the core | |||||
// libraries. If this doesn't work, just bail. | |||||
var target; | |||||
try { | |||||
var raw_event = e.getRawEvent(); | |||||
var touch = raw_event.touches[0]; | |||||
target = document.elementFromPoint(touch.clientX, touch.clientY); | |||||
} catch (ex) { | |||||
return; | |||||
} | |||||
if (!JX.DOM.isType(target, 'th')) { | |||||
return; | |||||
} | |||||
this._updateRange(target, false); | |||||
}, | |||||
_onrangeup: function(e) { | _onrangeup: function(e) { | ||||
if (!this._rangeActive) { | if (!this._rangeActive) { | ||||
return; | return; | ||||
} | } | ||||
e.kill(); | e.kill(); | ||||
var origin = this._rangeOrigin; | var origin = this._rangeOrigin; | ||||
Show All 24 Lines |