2011-02-05 20:06:56 +01:00
|
|
|
/**
|
2014-02-14 19:23:07 +01:00
|
|
|
* @provides javelin-behavior-phabricator-show-all-transactions
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-stratcom
|
|
|
|
* javelin-dom
|
2011-02-05 20:06:56 +01:00
|
|
|
*/
|
|
|
|
|
2014-02-14 19:23:07 +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
|
|
|
|
2014-02-14 19:23:07 +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;
|
|
|
|
}
|
2011-05-31 19:23:31 +02:00
|
|
|
}
|
2014-02-14 19:23:07 +01:00
|
|
|
return false;
|
2011-05-31 19:23:31 +02:00
|
|
|
}
|
|
|
|
|
2014-02-14 19:23:07 +01:00
|
|
|
function reveal() {
|
|
|
|
if (revealed) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
JX.DOM.hide(JX.$(config.hideID));
|
|
|
|
JX.DOM.show(JX.$(config.showID));
|
|
|
|
revealed = true;
|
2011-05-31 19:23:31 +02:00
|
|
|
|
2014-02-14 19:23:07 +01:00
|
|
|
return true;
|
2013-05-06 20:44:15 +02:00
|
|
|
}
|
|
|
|
|
2014-02-14 19:23:07 +01:00
|
|
|
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.
|
2011-05-31 19:23:31 +02:00
|
|
|
}
|
2014-02-14 19:23:07 +01:00
|
|
|
}
|
|
|
|
}
|
2011-05-31 19:23:31 +02:00
|
|
|
}
|
|
|
|
|
2014-02-14 19:23:07 +01:00
|
|
|
JX.DOM.listen(
|
|
|
|
JX.$(config.linkID),
|
2011-02-05 20:06:56 +01:00
|
|
|
'click',
|
2014-02-14 19:23:07 +01:00
|
|
|
null,
|
|
|
|
function (e) {
|
2011-02-05 20:06:56 +01:00
|
|
|
e.kill();
|
2014-02-14 19:23:07 +01:00
|
|
|
reveal();
|
2011-02-05 20:06:56 +01:00
|
|
|
});
|
|
|
|
|
2014-02-14 19:23:07 +01:00
|
|
|
JX.Stratcom.listen('hashchange', null, check_hash);
|
|
|
|
check_hash();
|
2011-02-05 20:06:56 +01:00
|
|
|
});
|