mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-13 02:12: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' =>
|
'javelin-behavior-differential-toggle-files' =>
|
||||||
array(
|
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',
|
'type' => 'js',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
0 => 'javelin-behavior',
|
0 => 'javelin-behavior',
|
||||||
1 => 'javelin-dom',
|
1 => 'javelin-dom',
|
||||||
2 => 'javelin-stratcom',
|
2 => 'javelin-stratcom',
|
||||||
3 => 'phabricator-keyboard-shortcut',
|
|
||||||
),
|
),
|
||||||
'disk' => '/rsrc/js/application/differential/behavior-toggle-files.js',
|
'disk' => '/rsrc/js/application/differential/behavior-toggle-files.js',
|
||||||
),
|
),
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* @requires javelin-behavior
|
* @requires javelin-behavior
|
||||||
* javelin-dom
|
* javelin-dom
|
||||||
* javelin-stratcom
|
* javelin-stratcom
|
||||||
* phabricator-keyboard-shortcut
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
JX.behavior('differential-toggle-files', function(config) {
|
JX.behavior('differential-toggle-files', function(config) {
|
||||||
|
@ -35,17 +34,23 @@ JX.behavior('differential-toggle-files', function(config) {
|
||||||
while (elt !== document.body) {
|
while (elt !== document.body) {
|
||||||
if (JX.Stratcom.hasSigil(elt, 'differential-changeset')) {
|
if (JX.Stratcom.hasSigil(elt, 'differential-changeset')) {
|
||||||
var diffs = JX.DOM.scry(elt, 'table', 'differential-diff');
|
var diffs = JX.DOM.scry(elt, 'table', 'differential-diff');
|
||||||
|
var invoked = false;
|
||||||
for (var i = 0; i < diffs.length; ++i) {
|
for (var i = 0; i < diffs.length; ++i) {
|
||||||
if (JX.Stratcom.getData(diffs[i]).hidden) {
|
if (JX.Stratcom.getData(diffs[i]).hidden) {
|
||||||
JX.Stratcom.invoke('differential-toggle-file', null, {
|
JX.Stratcom.invoke('differential-toggle-file', null, {
|
||||||
diff: [ diffs[i] ],
|
diff: [ diffs[i] ]
|
||||||
});
|
});
|
||||||
|
invoked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!invoked) {
|
||||||
|
e.prevent();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
elt = elt.parentNode;
|
elt = elt.parentNode;
|
||||||
}
|
}
|
||||||
|
e.prevent();
|
||||||
});
|
});
|
||||||
|
|
||||||
JX.Stratcom.listen(
|
JX.Stratcom.listen(
|
||||||
|
@ -63,23 +68,25 @@ JX.behavior('differential-toggle-files', function(config) {
|
||||||
target = JX.$(id.substr(1));
|
target = JX.$(id.substr(1));
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
var named = document.getElementsByName(id.substr(1));
|
var named = document.getElementsByName(id.substr(1));
|
||||||
var matches = [];
|
|
||||||
for (var i = 0; i < named.length; ++i) {
|
for (var i = 0; i < named.length; ++i) {
|
||||||
if (named[i].tagName.toLowerCase() == 'a') {
|
if (named[i].tagName.toLowerCase() == 'a') {
|
||||||
matches.push(named[i]);
|
if (target) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
target = named[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (matches.length == 1) {
|
if (!target) {
|
||||||
target = matches[0];
|
|
||||||
} else {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JX.Stratcom.invoke('differential-toggle-file-request', null, {
|
var event = JX.Stratcom.invoke('differential-toggle-file-request', null, {
|
||||||
element: target,
|
element: target
|
||||||
});
|
});
|
||||||
// This event is processed after the hash has changed, so it doesn't
|
if (!event.getPrevented()) {
|
||||||
// automatically jump there like we want.
|
// This event is processed after the hash has changed, so it doesn't
|
||||||
JX.DOM.scrollTo(target);
|
// automatically jump there like we want.
|
||||||
|
JX.DOM.scrollTo(target);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue