1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Expand comments on page load only when the anchor points into them

Summary:
Ref T3099. Currently, we expand comments in Differential when //any// anchor is present. This creates a scrolling issue described in T3099. Instead, expand them only when the anchor contains `comment`.

We can go further here, but this should fix the immediate issue.

Test Plan: Viewed `/D22`, `/D22#toc`, and `/D22#comment-3`. The first two did not expand comments; the last one did.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3099

Differential Revision: https://secure.phabricator.com/D5836
This commit is contained in:
epriestley 2013-05-06 11:44:15 -07:00
parent f76ecd9e76
commit 67459092d7
2 changed files with 7 additions and 3 deletions

View file

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

View file

@ -27,14 +27,18 @@ JX.behavior('differential-show-all-comments', function(config) {
// there's an anchor in the URL, since we don't want to link to "#comment-3"
// and have it collapsed.
if (window.location.hash) {
function at_comment_hash() {
return window.location.hash && window.location.hash.match(/comment/);
}
if (at_comment_hash()) {
reveal();
} else {
JX.Stratcom.listen(
'hashchange',
null,
function(e) {
if (window.location.hash.match(/comment/) && reveal()) {
if (at_comment_hash() && reveal()) {
try {
var target = JX.$(window.location.hash.replace(/^#/, ''));
window.scrollTo(0, target.offsetTop);