Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffChangeset.js
Show First 20 Lines • Show All 510 Lines • ▼ Show 20 Lines | _onresponse: function(sequence, response) { | ||||
near_bot = false; | near_bot = false; | ||||
} | } | ||||
var target_pos = JX.Vector.getPos(target); | var target_pos = JX.Vector.getPos(target); | ||||
var target_dim = JX.Vector.getDim(target); | var target_dim = JX.Vector.getDim(target); | ||||
var target_bot = (target_pos.y + target_dim.y); | var target_bot = (target_pos.y + target_dim.y); | ||||
// Detect if the changeset is entirely (or, at least, almost entirely) | // Detect if the changeset is entirely (or, at least, almost entirely) | ||||
// above us. | // above us. The height here is roughly the height of the persistent | ||||
var above_screen = (target_bot < old_pos.y + 128); | // banner. | ||||
var above_screen = (target_bot < old_pos.y + 64); | |||||
// If we have a URL anchor and are currently nearby, stick to it | |||||
// no matter what. | |||||
var on_target = null; | |||||
if (window.location.hash) { | |||||
try { | |||||
var anchor = JX.$(window.location.hash.replace('#', '')); | |||||
if (anchor) { | |||||
var anchor_pos = JX.$V(anchor); | |||||
if ((anchor_pos.y > old_pos.y) && | |||||
(anchor_pos.y < old_pos.y + 96)) { | |||||
on_target = anchor; | |||||
} | |||||
} | |||||
} catch (ignored) { | |||||
// If we have a bogus anchor, just ignore it. | |||||
} | |||||
} | |||||
var frame = this._getContentFrame(); | var frame = this._getContentFrame(); | ||||
JX.DOM.setContent(frame, JX.$H(response.changeset)); | JX.DOM.setContent(frame, JX.$H(response.changeset)); | ||||
if (this._stabilize) { | if (this._stabilize) { | ||||
if (!near_top) { | if (on_target) { | ||||
JX.DOM.scrollToPosition(old_pos.x, JX.$V(on_target).y - 60); | |||||
} else if (!near_top) { | |||||
if (near_bot || above_screen) { | if (near_bot || above_screen) { | ||||
// Figure out how much taller the document got. | // Figure out how much taller the document got. | ||||
var delta = (JX.Vector.getDocument().y - old_dim.y); | var delta = (JX.Vector.getDocument().y - old_dim.y); | ||||
JX.DOM.scrollToPosition(old_pos.x, old_pos.y + delta); | JX.DOM.scrollToPosition(old_pos.x, old_pos.y + delta); | ||||
} | } | ||||
} | } | ||||
this._stabilize = false; | this._stabilize = false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 234 Lines • Show Last 20 Lines |