mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
7a96de10f0
Summary: Ref T2222. This restores the "N older comments are hidden." shield to all ApplicationTransactions applications. Roughly the rule this uses is that transactions older than your most recent comment are hidden, under the assumption that you've already read and dealt with them, since you replied afterward. Then we show your last comment to remind/contextualize you, and anything afterward. We also don't hide transactions if we'd only be hiding a handfull, and we never hide the few most recent transactions. This might need some #design help. Test Plan: The tricky part here is the anchor rule, which deals with the case where you follow a link to `T123#4`, but that would normally be hidden. We simulate a click on "show all" if you hit an anchor which is hidden. Here's what it looks like in Maniphest: {F112891} Reviewers: btrahan, chad Reviewed By: btrahan CC: chad, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D8229
66 lines
1.3 KiB
JavaScript
66 lines
1.3 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-phabricator-show-all-transactions
|
|
* @requires javelin-behavior
|
|
* javelin-stratcom
|
|
* javelin-dom
|
|
*/
|
|
|
|
/**
|
|
* 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) {
|
|
|
|
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),
|
|
'click',
|
|
null,
|
|
function (e) {
|
|
e.kill();
|
|
reveal();
|
|
});
|
|
|
|
JX.Stratcom.listen('hashchange', null, check_hash);
|
|
check_hash();
|
|
});
|