1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 08:20:57 +01:00
phorge-phorge/webroot/rsrc/js/application/differential/behavior-show-all-comments.js

51 lines
1.1 KiB
JavaScript
Raw Normal View History

2011-02-05 20:06:56 +01:00
/**
* @provides javelin-behavior-differential-show-all-comments
* @requires javelin-behavior
* javelin-stratcom
* javelin-dom
2011-02-05 20:06:56 +01:00
*/
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();
}
});
}
2011-02-05 20:06:56 +01:00
JX.Stratcom.listen(
'click',
'differential-show-all-comments',
function(e) {
reveal(e.getNode('differential-all-comments-container'));
2011-02-05 20:06:56 +01:00
e.kill();
});
});