1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-26 23:40:57 +01:00

Go to correct position after revealing comments

Test Plan:
Go to revision with lots of comments in Firefox.
Click on one of the last three comments permalink.
Repeat in Chrome.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1702
This commit is contained in:
vrana 2012-02-26 03:54:17 -08:00
parent 991fee2118
commit da892bde7c
2 changed files with 9 additions and 4 deletions

View file

@ -546,7 +546,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-differential-show-all-comments' =>
array(
'uri' => '/res/bcc990f0/rsrc/js/application/differential/behavior-show-all-comments.js',
'uri' => '/res/eaa12efc/rsrc/js/application/differential/behavior-show-all-comments.js',
'type' => 'js',
'requires' =>
array(

View file

@ -10,7 +10,7 @@ JX.behavior('differential-show-all-comments', function(config) {
var shown = false;
function reveal(node) {
if (shown) {
return;
return false;
}
shown = true;
node = node || JX.DOM.find(
@ -20,6 +20,7 @@ JX.behavior('differential-show-all-comments', function(config) {
if (node) {
JX.DOM.setContent(node, JX.$H(config.markup));
}
return true;
}
// Reveal the hidden comments if the user clicks "Show All Comments", or if
@ -33,8 +34,12 @@ JX.behavior('differential-show-all-comments', function(config) {
'hashchange',
null,
function(e) {
if (window.location.hash.match(/comment/)) {
reveal();
if (window.location.hash.match(/comment/) && reveal()) {
try {
var target = JX.$(window.location.hash.replace(/^#/, ''));
window.scrollTo(0, target.offsetTop);
} catch (e) {
}
}
});
}