Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/core/behavior-line-linker.js
| Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | function(e) { | ||||
| uri = JX.$U(uri); | uri = JX.$U(uri); | ||||
| path = uri.getPath(); | path = uri.getPath(); | ||||
| path = path + '$' + lines; | path = path + '$' + lines; | ||||
| uri = uri.setPath(path).toString(); | uri = uri.setPath(path).toString(); | ||||
| JX.History.replace(uri); | JX.History.replace(uri); | ||||
| if (editor_link) { | if (editor_link) { | ||||
| if (editor_link.href) { | var data = JX.Stratcom.getData(editor_link); | ||||
| var editdata = JX.Stratcom.getData(editor_link); | var template = data.template; | ||||
| editor_link.href = editdata.link_template.replace('%25l', o); | |||||
| var variables = { | |||||
| l: parseInt(Math.min(o, t), 10), | |||||
| }; | |||||
| var parts = []; | |||||
| for (var ii = 0; ii < template.length; ii++) { | |||||
| var part = template[ii]; | |||||
| var value = part.value; | |||||
| if (part.type === 'literal') { | |||||
| parts.push(value); | |||||
| continue; | |||||
| } | |||||
| if (part.type === 'variable') { | |||||
| if (variables.hasOwnProperty(value)) { | |||||
| var replacement = variables[value]; | |||||
| replacement = encodeURIComponent(replacement); | |||||
| parts.push(replacement); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| editor_link.href = parts.join(''); | |||||
| } | |||||
| }); | }); | ||||
| // Try to jump to the highlighted lines if we don't have an explicit anchor | // Try to jump to the highlighted lines if we don't have an explicit anchor | ||||
| // in the URI. | // in the URI. | ||||
| if (!window.location.hash.length) { | if (!window.location.hash.length) { | ||||
| try { | try { | ||||
| var anchor = JX.$('phabricator-line-linker-anchor'); | var anchor = JX.$('phabricator-line-linker-anchor'); | ||||
| JX.DOM.scrollToPosition(0, JX.$V(anchor).y - 60); | JX.DOM.scrollToPosition(0, JX.$V(anchor).y - 60); | ||||
| } catch (ex) { | } catch (ex) { | ||||
| // If we didn't hit an element on the page, just move on. | // If we didn't hit an element on the page, just move on. | ||||
| } | } | ||||
| } | } | ||||
| if (editor_link) { | |||||
| // TODO: This should be pht()'d, but this behavior is weird enough to | |||||
| // make that a bit tricky. | |||||
| new JX.KeyboardShortcut('\\', 'Open File in External Editor') | |||||
| .setGroup('diff-nav') | |||||
| .setHandler(function() { | |||||
| JX.$U(editor_link.href).go(); | |||||
| }) | |||||
| .register(); | |||||
| } | |||||
| }); | }); | ||||