Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffChangesetList.js
| Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | members: { | ||||
| _unsavedButton: null, | _unsavedButton: null, | ||||
| _unsubmittedButton: null, | _unsubmittedButton: null, | ||||
| _doneButton: null, | _doneButton: null, | ||||
| _doneMode: null, | _doneMode: null, | ||||
| _dropdownMenu: null, | _dropdownMenu: null, | ||||
| _menuButton: null, | _menuButton: null, | ||||
| _menuItems: null, | _menuItems: null, | ||||
| _selectedChangeset: null, | |||||
| sleep: function() { | sleep: function() { | ||||
| this._asleep = true; | this._asleep = true; | ||||
| this._redrawFocus(); | this._redrawFocus(); | ||||
| this._redrawSelection(); | this._redrawSelection(); | ||||
| this.resetHover(); | this.resetHover(); | ||||
| Show All 25 Lines | wake: function() { | ||||
| // make sense and do not function. | // make sense and do not function. | ||||
| var standalone = this.getIsStandalone(); | var standalone = this.getIsStandalone(); | ||||
| var label; | var label; | ||||
| if (!standalone) { | if (!standalone) { | ||||
| label = pht('Jump to the table of contents.'); | label = pht('Jump to the table of contents.'); | ||||
| this._installKey('t', 'diff-nav', label, this._ontoc); | this._installKey('t', 'diff-nav', label, this._ontoc); | ||||
| label = pht('Jump to the comment area.'); | |||||
| this._installKey('x', 'diff-nav', label, this._oncomments); | |||||
| } | } | ||||
| label = pht('Jump to next change.'); | label = pht('Jump to next change.'); | ||||
| this._installJumpKey('j', label, 1); | this._installJumpKey('j', label, 1); | ||||
| label = pht('Jump to previous change.'); | label = pht('Jump to previous change.'); | ||||
| this._installJumpKey('k', label, -1); | this._installJumpKey('k', label, -1); | ||||
| Show All 22 Lines | wake: function() { | ||||
| if (formation) { | if (formation) { | ||||
| var filetree = formation.getColumn(0); | var filetree = formation.getColumn(0); | ||||
| var toggletree = JX.bind(filetree, filetree.toggleVisibility); | var toggletree = JX.bind(filetree, filetree.toggleVisibility); | ||||
| label = pht('Hide or show the paths panel.'); | label = pht('Hide or show the paths panel.'); | ||||
| this._installKey('f', 'diff-vis', label, toggletree); | this._installKey('f', 'diff-vis', label, toggletree); | ||||
| } | } | ||||
| if (!standalone) { | if (!standalone) { | ||||
| label = pht('Hide or show the current file.'); | label = pht('Hide or show the current changeset.'); | ||||
| this._installKey('h', 'diff-vis', label, this._onkeytogglefile); | this._installKey('h', 'diff-vis', label, this._onkeytogglefile); | ||||
| } | } | ||||
| label = pht('Reply to selected inline comment or change.'); | label = pht('Reply to selected inline comment or change.'); | ||||
| this._installKey('r', 'inline', label, | this._installKey('r', 'inline', label, | ||||
| JX.bind(this, this._onkeyreply, false)); | JX.bind(this, this._onkeyreply, false)); | ||||
| label = pht('Reply and quote selected inline comment.'); | label = pht('Reply and quote selected inline comment.'); | ||||
| ▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | _installJumpKey: function(key, label, delta, filter, show_collapsed) { | ||||
| return this._installKey(key, 'diff-nav', label, handler); | return this._installKey(key, 'diff-nav', label, handler); | ||||
| }, | }, | ||||
| _ontoc: function(manager) { | _ontoc: function(manager) { | ||||
| var toc = JX.$('toc'); | var toc = JX.$('toc'); | ||||
| manager.scrollTo(toc); | manager.scrollTo(toc); | ||||
| }, | }, | ||||
| _oncomments: function(manager) { | |||||
| var reply = JX.$('reply'); | |||||
| manager.scrollTo(reply); | |||||
| }, | |||||
| getSelectedInline: function() { | getSelectedInline: function() { | ||||
| var cursor = this._cursorItem; | var cursor = this._cursorItem; | ||||
| if (cursor) { | if (cursor) { | ||||
| if (cursor.type == 'comment') { | if (cursor.type == 'comment') { | ||||
| return cursor.target; | return cursor.target; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 358 Lines • ▼ Show 20 Lines | selectChangeset: function(changeset, scroll) { | ||||
| if (changeset === item.target) { | if (changeset === item.target) { | ||||
| cursor = ii; | cursor = ii; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (cursor !== null) { | if (cursor !== null) { | ||||
| this._setSelectionState(items[cursor], scroll); | this._setSelectionState(items[cursor], scroll); | ||||
| } else { | |||||
| this._setSelectionState(null, false); | |||||
| } | } | ||||
| return this; | return this; | ||||
| }, | }, | ||||
| _setSelectionState: function(item, scroll) { | _setSelectionState: function(item, scroll) { | ||||
| this._cursorItem = item; | this._cursorItem = item; | ||||
| this._redrawSelection(scroll); | this._redrawSelection(scroll); | ||||
| Show All 12 Lines | _redrawSelection: function(scroll) { | ||||
| // a new empty comment, then use the "Unsaved" button to select it, then | // a new empty comment, then use the "Unsaved" button to select it, then | ||||
| // cancel it), we can still keep the cursor here but do not want to show | // cancel it), we can still keep the cursor here but do not want to show | ||||
| // a selection reticle over an invisible node. | // a selection reticle over an invisible node. | ||||
| if (cursor.deleted) { | if (cursor.deleted) { | ||||
| this.setFocus(null); | this.setFocus(null); | ||||
| return; | return; | ||||
| } | } | ||||
| var changeset = cursor.changeset; | |||||
| var tree = this._getTreeView(); | var tree = this._getTreeView(); | ||||
| if (cursor.changeset) { | if (changeset) { | ||||
| tree.setSelectedPath(cursor.changeset.getPathView()); | tree.setSelectedPath(cursor.changeset.getPathView()); | ||||
| } else { | } else { | ||||
| tree.setSelectedPath(null); | tree.setSelectedPath(null); | ||||
| } | } | ||||
| this._selectChangeset(changeset); | |||||
| this.setFocus(cursor.nodes.begin, cursor.nodes.end); | this.setFocus(cursor.nodes.begin, cursor.nodes.end); | ||||
| if (scroll) { | if (scroll) { | ||||
| var pos = JX.$V(cursor.nodes.begin); | var pos = JX.$V(cursor.nodes.begin); | ||||
| JX.DOM.scrollToPosition(0, pos.y - 60); | JX.DOM.scrollToPosition(0, pos.y - 60); | ||||
| } | } | ||||
| return this; | return this; | ||||
| ▲ Show 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | _onmenu: function(e) { | ||||
| } else { | } else { | ||||
| up_item | up_item | ||||
| .setIcon('fa-refresh') | .setIcon('fa-refresh') | ||||
| .setName(pht('Load Changes')); | .setName(pht('Load Changes')); | ||||
| } | } | ||||
| visible_item | visible_item | ||||
| .setDisabled(true) | .setDisabled(true) | ||||
| .setIcon('fa-expand') | .setIcon('fa-eye-slash') | ||||
| .setName(pht('Can\'t Toggle Unloaded File')); | .setName(pht('Hide Changeset')); | ||||
| var diffs = JX.DOM.scry( | var diffs = JX.DOM.scry( | ||||
| JX.$(data.containerID), | JX.$(data.containerID), | ||||
| 'table', | 'table', | ||||
| 'differential-diff'); | 'differential-diff'); | ||||
| if (diffs.length > 1) { | if (diffs.length > 1) { | ||||
| JX.$E( | JX.$E( | ||||
| 'More than one node with sigil "differential-diff" was found in "'+ | 'More than one node with sigil "differential-diff" was found in "'+ | ||||
| data.containerID+'."'); | data.containerID+'."'); | ||||
| } else if (diffs.length == 1) { | } else if (diffs.length == 1) { | ||||
| var diff = diffs[0]; | |||||
| visible_item.setDisabled(false); | visible_item.setDisabled(false); | ||||
| if (!changeset.isVisible()) { | |||||
| visible_item | |||||
| .setName(pht('Expand File')) | |||||
| .setIcon('fa-expand'); | |||||
| } else { | |||||
| visible_item | |||||
| .setName(pht('Collapse File')) | |||||
| .setIcon('fa-compress'); | |||||
| } | |||||
| } else { | } else { | ||||
| // Do nothing when there is no diff shown in the table. For example, | // Do nothing when there is no diff shown in the table. For example, | ||||
| // the file is binary. | // the file is binary. | ||||
| } | } | ||||
| }); | }); | ||||
| data.menu = menu; | data.menu = menu; | ||||
| changeset.setViewMenu(menu); | |||||
| menu.open(); | menu.open(); | ||||
| }, | }, | ||||
| _oncollapse: function(is_collapse, e) { | _oncollapse: function(is_collapse, e) { | ||||
| e.kill(); | e.kill(); | ||||
| var inline = this._getInlineForEvent(e); | var inline = this._getInlineForEvent(e); | ||||
| ▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | redrawPreview: function() { | ||||
| // after an edit. | // after an edit. | ||||
| this.resetHover(); | this.resetHover(); | ||||
| }, | }, | ||||
| setFocus: function(node, extended_node) { | setFocus: function(node, extended_node) { | ||||
| if (!node) { | if (!node) { | ||||
| var tree = this._getTreeView(); | var tree = this._getTreeView(); | ||||
| tree.setSelectedPath(null); | tree.setSelectedPath(null); | ||||
| this._selectChangeset(null); | |||||
| } | } | ||||
| this._focusStart = node; | this._focusStart = node; | ||||
| this._focusEnd = extended_node; | this._focusEnd = extended_node; | ||||
| this._redrawFocus(); | this._redrawFocus(); | ||||
| }, | }, | ||||
| _selectChangeset: function(changeset) { | |||||
| if (this._selectedChangeset === changeset) { | |||||
| return; | |||||
| } | |||||
| if (this._selectedChangeset !== null) { | |||||
| this._selectedChangeset.setIsSelected(false); | |||||
| this._selectedChangeset = null; | |||||
| } | |||||
| this._selectedChangeset = changeset; | |||||
| if (this._selectedChangeset !== null) { | |||||
| this._selectedChangeset.setIsSelected(true); | |||||
| } | |||||
| }, | |||||
| _redrawFocus: function() { | _redrawFocus: function() { | ||||
| var node = this._focusStart; | var node = this._focusStart; | ||||
| var extended_node = this._focusEnd || node; | var extended_node = this._focusEnd || node; | ||||
| var reticle = this._getFocusNode(); | var reticle = this._getFocusNode(); | ||||
| if (!node || this.isAsleep()) { | if (!node || this.isAsleep()) { | ||||
| JX.DOM.remove(reticle); | JX.DOM.remove(reticle); | ||||
| return; | return; | ||||
| } | } | ||||
| // Outset the reticle some pixels away from the element, so there's some | // Outset the reticle some pixels away from the element, so there's some | ||||
| // space between the focused element and the outline. | // space between the focused element and the outline. | ||||
| var p = JX.Vector.getPos(node); | var p = JX.Vector.getPos(node); | ||||
| var s = JX.Vector.getAggregateScrollForNode(node); | var s = JX.Vector.getAggregateScrollForNode(node); | ||||
| var d = JX.Vector.getDim(node); | var d = JX.Vector.getDim(node); | ||||
| p.add(s).add(d.x + 1, 0).setPos(reticle); | p.add(s).add(d.x + 1, 4).setPos(reticle); | ||||
| // Compute the size we need to extend to the full extent of the focused | // Compute the size we need to extend to the full extent of the focused | ||||
| // nodes. | // nodes. | ||||
| JX.Vector.getPos(extended_node) | JX.Vector.getPos(extended_node) | ||||
| .add(-p.x, -p.y) | .add(-p.x, -p.y) | ||||
| .add(0, JX.Vector.getDim(extended_node).y) | .add(0, JX.Vector.getDim(extended_node).y) | ||||
| .add(10, 0) | .add(10, -4) | ||||
| .setDim(reticle); | .setDim(reticle); | ||||
| JX.DOM.getContentFrame().appendChild(reticle); | JX.DOM.getContentFrame().appendChild(reticle); | ||||
| }, | }, | ||||
| _getFocusNode: function() { | _getFocusNode: function() { | ||||
| if (!this._focusNode) { | if (!this._focusNode) { | ||||
| var node = JX.$N('div', {className : 'keyboard-focus-focus-reticle'}); | var node = JX.$N('div', {className : 'keyboard-focus-focus-reticle'}); | ||||
| ▲ Show 20 Lines • Show All 857 Lines • Show Last 20 Lines | |||||