1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 16:00:59 +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' => 'javelin-behavior-differential-show-all-comments' =>
array( 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', 'type' => 'js',
'requires' => 'requires' =>
array( array(

View file

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