1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 21:40:55 +01:00
phorge-phorge/webroot/rsrc/js/application/differential/behavior-show-all-comments.js

67 lines
1.3 KiB
JavaScript
Raw Normal View History

2011-02-05 20:06:56 +01:00
/**
* @provides javelin-behavior-phabricator-show-all-transactions
* @requires javelin-behavior
* javelin-stratcom
* javelin-dom
2011-02-05 20:06:56 +01:00
*/
/**
* Automatically show older transactions if the user follows an anchor to a
* transaction which is hidden by the "N older changes are hidden." shield.
*/
JX.behavior('phabricator-show-all-transactions', function(config) {
2011-02-05 20:06:56 +01:00
var revealed = false;
function get_hash() {
return window.location.hash.replace(/^#/, '');
}
function hash_is_hidden() {
var hash = get_hash();
for (var ii = 0; ii < config.anchors.length; ii++) {
if (config.anchors[ii] == hash) {
return true;
}
}
return false;
}
function reveal() {
if (revealed) {
return false;
}
JX.DOM.hide(JX.$(config.hideID));
JX.DOM.show(JX.$(config.showID));
revealed = true;
return true;
}
function check_hash() {
if (hash_is_hidden()) {
if (reveal()) {
try {
var target = JX.$(get_hash());
JX.DOM.scrollTo(target);
} catch (ignored) {
// We did our best.
}
}
}
}
JX.DOM.listen(
JX.$(config.linkID),
2011-02-05 20:06:56 +01:00
'click',
null,
function (e) {
2011-02-05 20:06:56 +01:00
e.kill();
reveal();
2011-02-05 20:06:56 +01:00
});
JX.Stratcom.listen('hashchange', null, check_hash);
check_hash();
2011-02-05 20:06:56 +01:00
});