Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffChangesetList.js
| Show First 20 Lines • Show All 349 Lines • ▼ Show 20 Lines | _onkeyreply: function(is_quote) { | ||||
| // If the keyboard cursor is selecting a range of lines, we may have | // If the keyboard cursor is selecting a range of lines, we may have | ||||
| // a mixture of old and new changes on the selected rows. It is not | // a mixture of old and new changes on the selected rows. It is not | ||||
| // entirely unambiguous what the user means when they say they want | // entirely unambiguous what the user means when they say they want | ||||
| // to reply to this, but we use this logic: reply on the new file if | // to reply to this, but we use this logic: reply on the new file if | ||||
| // there are any new lines. Otherwise (if there are only removed | // there are any new lines. Otherwise (if there are only removed | ||||
| // lines) reply on the old file. | // lines) reply on the old file. | ||||
| if (cursor.type == 'change') { | if (cursor.type == 'change') { | ||||
| var origin = cursor.nodes.begin; | var cells = this._getLineNumberCellsForChangeBlock( | ||||
| var target = cursor.nodes.end; | cursor.nodes.begin, | ||||
| cursor.nodes.end); | |||||
| cursor.changeset.newInlineForRange(cells.src, cells.dst); | |||||
| this.setFocus(null); | |||||
| return; | |||||
| } | |||||
| } | |||||
| var pht = this.getTranslations(); | |||||
| this._warnUser(pht('You must select a comment or change to reply to.')); | |||||
| }, | |||||
| _getLineNumberCellsForChangeBlock: function(origin, target) { | |||||
| // The "origin" and "target" are entire rows, but we need to find | // The "origin" and "target" are entire rows, but we need to find | ||||
| // a range of "<th />" nodes to actually create an inline, so go | // a range of cell nodes to actually create an inline, so go | ||||
| // fishing. | // fishing. | ||||
| var old_list = []; | var old_list = []; | ||||
| var new_list = []; | var new_list = []; | ||||
| var row = origin; | var row = origin; | ||||
| while (row) { | while (row) { | ||||
| var header = row.firstChild; | var header = row.firstChild; | ||||
| while (header) { | while (header) { | ||||
| if (this.getLineNumberFromHeader(header)) { | if (this.getLineNumberFromHeader(header)) { | ||||
| if (header.className.indexOf('old') !== -1) { | if (header.className.indexOf('old') !== -1) { | ||||
| old_list.push(header); | old_list.push(header); | ||||
| } else if (header.className.indexOf('new') !== -1) { | } else if (header.className.indexOf('new') !== -1) { | ||||
| new_list.push(header); | new_list.push(header); | ||||
| } | } | ||||
| } | } | ||||
| header = header.nextSibling; | header = header.nextSibling; | ||||
| } | } | ||||
| if (row == target) { | if (row == target) { | ||||
| break; | break; | ||||
| } | } | ||||
| row = row.nextSibling; | row = row.nextSibling; | ||||
| } | } | ||||
| var use_list; | var use_list; | ||||
| if (new_list.length) { | if (new_list.length) { | ||||
| use_list = new_list; | use_list = new_list; | ||||
| } else { | } else { | ||||
| use_list = old_list; | use_list = old_list; | ||||
| } | } | ||||
| var src = use_list[0]; | var src = use_list[0]; | ||||
| var dst = use_list[use_list.length - 1]; | var dst = use_list[use_list.length - 1]; | ||||
| cursor.changeset.newInlineForRange(src, dst); | return { | ||||
| src: src, | |||||
| this.setFocus(null); | dst: dst | ||||
| return; | }; | ||||
| } | |||||
| } | |||||
| var pht = this.getTranslations(); | |||||
| this._warnUser(pht('You must select a comment or change to reply to.')); | |||||
| }, | }, | ||||
| _onkeyedit: function() { | _onkeyedit: function() { | ||||
| var cursor = this._cursorItem; | var cursor = this._cursorItem; | ||||
| if (cursor) { | if (cursor) { | ||||
| if (cursor.type == 'comment') { | if (cursor.type == 'comment') { | ||||
| var inline = cursor.target; | var inline = cursor.target; | ||||
| ▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | _getChangesetForKeyCommand: function() { | ||||
| if (!changeset) { | if (!changeset) { | ||||
| changeset = this._getVisibleChangeset(); | changeset = this._getVisibleChangeset(); | ||||
| } | } | ||||
| return changeset; | return changeset; | ||||
| }, | }, | ||||
| _onkeyopeneditor: function() { | _onkeyopeneditor: function(e) { | ||||
| var pht = this.getTranslations(); | var pht = this.getTranslations(); | ||||
| var changeset = this._getChangesetForKeyCommand(); | var changeset = this._getChangesetForKeyCommand(); | ||||
| if (!changeset) { | if (!changeset) { | ||||
| this._warnUser(pht('You must select a file to edit.')); | this._warnUser(pht('You must select a file to edit.')); | ||||
| return; | return; | ||||
| } | } | ||||
| var editor_uri = changeset.getEditorURI(); | this._openEditor(changeset); | ||||
| }, | |||||
| _openEditor: function(changeset) { | |||||
| var pht = this.getTranslations(); | |||||
| if (editor_uri === null) { | var editor_template = changeset.getEditorURITemplate(); | ||||
| if (editor_template === null) { | |||||
| this._warnUser(pht('No external editor is configured.')); | this._warnUser(pht('No external editor is configured.')); | ||||
| return; | return; | ||||
| } | } | ||||
| var line = null; | |||||
| // See PHI1749. We aren't exactly sure what the user intends when they | |||||
| // use the keyboard to select a change block and then activate the | |||||
| // "Open in Editor" function: they might mean to open the old or new | |||||
| // offset, and may have the old or new state (or some other state) in | |||||
| // their working copy. | |||||
| // For now, pick: the new state line number if one exists; or the old | |||||
| // state line number if one does not. If nothing else, this behavior is | |||||
| // simple. | |||||
| // If there's a document engine, just open the file to the first line. | |||||
| // We currently can not map display blocks to source lines. | |||||
| // If there's an inline, open the file to that line. | |||||
| if (changeset.getResponseDocumentEngineKey() === null) { | |||||
| var cursor = this._cursorItem; | |||||
| if (cursor && (cursor.changeset === changeset)) { | |||||
| if (cursor.type == 'change') { | |||||
| var cells = this._getLineNumberCellsForChangeBlock( | |||||
| cursor.nodes.begin, | |||||
| cursor.nodes.end); | |||||
| line = this.getLineNumberFromHeader(cells.src); | |||||
| } | |||||
| if (cursor.type === 'comment') { | |||||
| var inline = cursor.target; | |||||
| line = inline.getLineNumber(); | |||||
| } | |||||
| } | |||||
| } | |||||
| var variables = { | |||||
| l: line || 1 | |||||
| }; | |||||
| var editor_uri = new JX.ExternalEditorLinkEngine() | |||||
| .setTemplate(editor_template) | |||||
| .setVariables(variables) | |||||
| .newURI(); | |||||
| JX.$U(editor_uri).go(); | JX.$U(editor_uri).go(); | ||||
| }, | }, | ||||
| _onkeyshowpath: function() { | _onkeyshowpath: function() { | ||||
| this._onrepositorykey(false); | this._onrepositorykey(false); | ||||
| }, | }, | ||||
| _onkeyshowdirectory: function() { | _onkeyshowdirectory: function() { | ||||
| ▲ Show 20 Lines • Show All 492 Lines • ▼ Show 20 Lines | _onmenu: function(e) { | ||||
| .setKeyCommand('D'); | .setKeyCommand('D'); | ||||
| add_link( | add_link( | ||||
| 'fa-file-text-o', | 'fa-file-text-o', | ||||
| pht('Show Path in Repository'), | pht('Show Path in Repository'), | ||||
| changeset.getShowPathURI()) | changeset.getShowPathURI()) | ||||
| .setKeyCommand('d'); | .setKeyCommand('d'); | ||||
| var editor_uri = changeset.getEditorURI(); | var editor_template = changeset.getEditorURITemplate(); | ||||
| if (editor_uri !== null) { | if (editor_template !== null) { | ||||
| add_link('fa-i-cursor', pht('Open in Editor'), editor_uri, true) | var editor_item = new JX.PHUIXActionView() | ||||
| .setKeyCommand('\\'); | .setIcon('fa-i-cursor') | ||||
| .setName(pht('Open in Editor')) | |||||
| .setKeyCommand('\\') | |||||
| .setHandler(function(e) { | |||||
| changeset_list._openEditor(changeset); | |||||
| e.prevent(); | |||||
| menu.close(); | |||||
| }); | |||||
| list.addItem(editor_item); | |||||
| } else { | } else { | ||||
| var configure_uri = changeset.getEditorConfigureURI(); | var configure_uri = changeset.getEditorConfigureURI(); | ||||
| if (configure_uri !== null) { | if (configure_uri !== null) { | ||||
| add_link('fa-wrench', pht('Configure Editor'), configure_uri); | add_link('fa-wrench', pht('Configure Editor'), configure_uri); | ||||
| } | } | ||||
| } | } | ||||
| menu.setContent(list.getNode()); | menu.setContent(list.getNode()); | ||||
| ▲ Show 20 Lines • Show All 1,745 Lines • Show Last 20 Lines | |||||