mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 17:30:59 +01:00
da892bde7c
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
55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-differential-show-all-comments
|
|
* @requires javelin-behavior
|
|
* javelin-stratcom
|
|
* javelin-dom
|
|
*/
|
|
|
|
JX.behavior('differential-show-all-comments', function(config) {
|
|
|
|
var shown = false;
|
|
function reveal(node) {
|
|
if (shown) {
|
|
return false;
|
|
}
|
|
shown = true;
|
|
node = node || JX.DOM.find(
|
|
document.body,
|
|
'div',
|
|
'differential-all-comments-container');
|
|
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
|
|
// 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) {
|
|
reveal();
|
|
} else {
|
|
JX.Stratcom.listen(
|
|
'hashchange',
|
|
null,
|
|
function(e) {
|
|
if (window.location.hash.match(/comment/) && reveal()) {
|
|
try {
|
|
var target = JX.$(window.location.hash.replace(/^#/, ''));
|
|
window.scrollTo(0, target.offsetTop);
|
|
} catch (e) {
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
JX.Stratcom.listen(
|
|
'click',
|
|
'differential-show-all-comments',
|
|
function(e) {
|
|
reveal(e.getNode('differential-all-comments-container'));
|
|
e.kill();
|
|
});
|
|
|
|
});
|