mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +01:00
d96d515cc2
Summary: Allows you to link to comments with "D123#3" or "T123#3", then adds a pile of JS to try to make it not terrible. :/ The thing I'm trying to avoid here is when someone says "look at this! http://blog.com/#comment-239291" and you click and your browser jumps somewhere random and you have no idea which comment they meant. Since I really hate this, I've tried to avoid it by making sure the comment is always highlighted. Test Plan: Put T1#1 and D1#1 in remarkup and verified they linked properly. Clicked anchors on individual comments. Faked all comments hidden in Differential and verified they expanded on anchor or anchor change. Reviewed By: aran Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen CC: aran, epriestley Differential Revision: 383
50 lines
1.1 KiB
JavaScript
50 lines
1.1 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;
|
|
}
|
|
shown = true;
|
|
node = node || JX.DOM.find(
|
|
document.body,
|
|
'div',
|
|
'differential-all-comments-container');
|
|
if (node) {
|
|
JX.DOM.setContent(node, JX.$H(config.markup));
|
|
}
|
|
}
|
|
|
|
// 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();
|
|
}
|
|
});
|
|
}
|
|
|
|
JX.Stratcom.listen(
|
|
'click',
|
|
'differential-show-all-comments',
|
|
function(e) {
|
|
reveal(e.getNode('differential-all-comments-container'));
|
|
e.kill();
|
|
});
|
|
|
|
});
|