mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Jump back to original place on traversing history
Summary: If I click on some file in ToC and then go back in browser history then it currently does nothing. Test Plan: Collapsed file, jumped on it in ToC, collapsed it again, jumped to inline comment in it, went back in history. Reviewers: alanh Reviewed By: alanh CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D3328
This commit is contained in:
parent
772a942366
commit
269a151f7a
2 changed files with 20 additions and 14 deletions
|
@ -1179,14 +1179,13 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'javelin-behavior-differential-toggle-files' =>
|
||||
array(
|
||||
'uri' => '/res/431b4915/rsrc/js/application/differential/behavior-toggle-files.js',
|
||||
'uri' => '/res/fb94e3f5/rsrc/js/application/differential/behavior-toggle-files.js',
|
||||
'type' => 'js',
|
||||
'requires' =>
|
||||
array(
|
||||
0 => 'javelin-behavior',
|
||||
1 => 'javelin-dom',
|
||||
2 => 'javelin-stratcom',
|
||||
3 => 'phabricator-keyboard-shortcut',
|
||||
),
|
||||
'disk' => '/rsrc/js/application/differential/behavior-toggle-files.js',
|
||||
),
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* @requires javelin-behavior
|
||||
* javelin-dom
|
||||
* javelin-stratcom
|
||||
* phabricator-keyboard-shortcut
|
||||
*/
|
||||
|
||||
JX.behavior('differential-toggle-files', function(config) {
|
||||
|
@ -35,17 +34,23 @@ JX.behavior('differential-toggle-files', function(config) {
|
|||
while (elt !== document.body) {
|
||||
if (JX.Stratcom.hasSigil(elt, 'differential-changeset')) {
|
||||
var diffs = JX.DOM.scry(elt, 'table', 'differential-diff');
|
||||
var invoked = false;
|
||||
for (var i = 0; i < diffs.length; ++i) {
|
||||
if (JX.Stratcom.getData(diffs[i]).hidden) {
|
||||
JX.Stratcom.invoke('differential-toggle-file', null, {
|
||||
diff: [ diffs[i] ],
|
||||
diff: [ diffs[i] ]
|
||||
});
|
||||
invoked = true;
|
||||
}
|
||||
}
|
||||
if (!invoked) {
|
||||
e.prevent();
|
||||
}
|
||||
return;
|
||||
}
|
||||
elt = elt.parentNode;
|
||||
}
|
||||
e.prevent();
|
||||
});
|
||||
|
||||
JX.Stratcom.listen(
|
||||
|
@ -63,23 +68,25 @@ JX.behavior('differential-toggle-files', function(config) {
|
|||
target = JX.$(id.substr(1));
|
||||
} catch(err) {
|
||||
var named = document.getElementsByName(id.substr(1));
|
||||
var matches = [];
|
||||
for (var i = 0; i < named.length; ++i) {
|
||||
if (named[i].tagName.toLowerCase() == 'a') {
|
||||
matches.push(named[i]);
|
||||
if (target) {
|
||||
return;
|
||||
}
|
||||
target = named[i];
|
||||
}
|
||||
}
|
||||
if (matches.length == 1) {
|
||||
target = matches[0];
|
||||
} else {
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
JX.Stratcom.invoke('differential-toggle-file-request', null, {
|
||||
element: target,
|
||||
var event = JX.Stratcom.invoke('differential-toggle-file-request', null, {
|
||||
element: target
|
||||
});
|
||||
// This event is processed after the hash has changed, so it doesn't
|
||||
// automatically jump there like we want.
|
||||
JX.DOM.scrollTo(target);
|
||||
if (!event.getPrevented()) {
|
||||
// This event is processed after the hash has changed, so it doesn't
|
||||
// automatically jump there like we want.
|
||||
JX.DOM.scrollTo(target);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue