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:
parent
991fee2118
commit
da892bde7c
2 changed files with 9 additions and 4 deletions
|
@ -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(
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue