Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffChangeset.js
| /** | /** | ||||
| * @provides phabricator-diff-changeset | * @provides phabricator-diff-changeset | ||||
| * @requires javelin-dom | * @requires javelin-dom | ||||
| * javelin-util | * javelin-util | ||||
| * javelin-stratcom | * javelin-stratcom | ||||
| * javelin-install | * javelin-install | ||||
| * javelin-workflow | * javelin-workflow | ||||
| * javelin-router | * javelin-router | ||||
| * javelin-behavior-device | * javelin-behavior-device | ||||
| * javelin-vector | * javelin-vector | ||||
| * phabricator-diff-inline | * phabricator-diff-inline | ||||
| * phabricator-diff-path-view | * phabricator-diff-path-view | ||||
| * phuix-button-view | |||||
| * @javelin | * @javelin | ||||
| */ | */ | ||||
| JX.install('DiffChangeset', { | JX.install('DiffChangeset', { | ||||
| construct : function(node) { | construct : function(node) { | ||||
| this._node = node; | this._node = node; | ||||
| Show All 22 Lines | construct : function(node) { | ||||
| this._isOwned = data.isOwned; | this._isOwned = data.isOwned; | ||||
| this._isLoading = true; | this._isLoading = true; | ||||
| this._inlines = []; | this._inlines = []; | ||||
| if (data.changesetState) { | if (data.changesetState) { | ||||
| this._loadChangesetState(data.changesetState); | this._loadChangesetState(data.changesetState); | ||||
| } | } | ||||
| var onselect = JX.bind(this, this._onClickHeader); | |||||
| JX.DOM.listen(this._node, 'mousedown', 'changeset-header', onselect); | |||||
| }, | }, | ||||
| members: { | members: { | ||||
| _node: null, | _node: null, | ||||
| _loaded: false, | _loaded: false, | ||||
| _sequence: 0, | _sequence: 0, | ||||
| _stabilize: false, | _stabilize: false, | ||||
| _renderURI: null, | _renderURI: null, | ||||
| _ref: null, | _ref: null, | ||||
| _rendererKey: null, | _rendererKey: null, | ||||
| _highlight: null, | _highlight: null, | ||||
| _documentEngine: null, | _documentEngine: null, | ||||
| _characterEncoding: null, | _characterEncoding: null, | ||||
| _undoTemplates: null, | _undoTemplates: null, | ||||
| _leftID: null, | _leftID: null, | ||||
| _rightID: null, | _rightID: null, | ||||
| _inlines: null, | _inlines: null, | ||||
| _visible: true, | _visible: true, | ||||
| _undoNode: null, | |||||
| _displayPath: null, | _displayPath: null, | ||||
| _changesetList: null, | _changesetList: null, | ||||
| _icon: null, | _icon: null, | ||||
| _editorURI: null, | _editorURI: null, | ||||
| _editorConfigureURI: null, | _editorConfigureURI: null, | ||||
| _showPathURI: null, | _showPathURI: null, | ||||
| _showDirectoryURI: null, | _showDirectoryURI: null, | ||||
| _pathView: null, | _pathView: null, | ||||
| _pathIconIcon: null, | _pathIconIcon: null, | ||||
| _pathIconColor: null, | _pathIconColor: null, | ||||
| _isLowImportance: null, | _isLowImportance: null, | ||||
| _isOwned: null, | _isOwned: null, | ||||
| _isHidden: null, | _isHidden: null, | ||||
| _isSelected: false, | |||||
| _viewMenu: null, | |||||
| getEditorURI: function() { | getEditorURI: function() { | ||||
| return this._editorURI; | return this._editorURI; | ||||
| }, | }, | ||||
| getEditorConfigureURI: function() { | getEditorConfigureURI: function() { | ||||
| return this._editorConfigureURI; | return this._editorConfigureURI; | ||||
| }, | }, | ||||
| Show All 14 Lines | getRightChangesetID: function() { | ||||
| return this._rightID; | return this._rightID; | ||||
| }, | }, | ||||
| setChangesetList: function(list) { | setChangesetList: function(list) { | ||||
| this._changesetList = list; | this._changesetList = list; | ||||
| return this; | return this; | ||||
| }, | }, | ||||
| setViewMenu: function(menu) { | |||||
| this._viewMenu = menu; | |||||
| return this; | |||||
| }, | |||||
| getIcon: function() { | getIcon: function() { | ||||
| if (!this._visible) { | if (!this._visible) { | ||||
| return 'fa-file-o'; | return 'fa-file-o'; | ||||
| } | } | ||||
| return this._icon; | return this._icon; | ||||
| }, | }, | ||||
| ▲ Show 20 Lines • Show All 737 Lines • ▼ Show 20 Lines | redrawFileTree: function() { | ||||
| var node = this.getPathView().getInlineNode(); | var node = this.getPathView().getInlineNode(); | ||||
| JX.DOM.setContent(node, hint); | JX.DOM.setContent(node, hint); | ||||
| JX.DOM.alterClass(node, 'diff-tree-path-inlines-visible', is_visible); | JX.DOM.alterClass(node, 'diff-tree-path-inlines-visible', is_visible); | ||||
| JX.DOM.alterClass(node, 'diff-tree-path-inlines-completed', is_completed); | JX.DOM.alterClass(node, 'diff-tree-path-inlines-completed', is_completed); | ||||
| }, | }, | ||||
| _onClickHeader: function(e) { | |||||
| e.prevent(); | |||||
| if (this._isSelected) { | |||||
| this.getChangesetList().selectChangeset(null); | |||||
| } else { | |||||
| this.select(false); | |||||
| } | |||||
| }, | |||||
| toggleVisibility: function() { | toggleVisibility: function() { | ||||
| this.setVisible(!this._visible); | this.setVisible(!this._visible); | ||||
| var attrs = { | var attrs = { | ||||
| hidden: this.isVisible() ? 0 : 1, | hidden: this.isVisible() ? 0 : 1, | ||||
| discard: 1 | discard: 1 | ||||
| }; | }; | ||||
| var workflow = this._newReloadWorkflow(attrs) | var workflow = this._newReloadWorkflow(attrs) | ||||
| .setHandler(JX.bag); | .setHandler(JX.bag); | ||||
| this._startContentWorkflow(workflow); | this._startContentWorkflow(workflow); | ||||
| }, | }, | ||||
| setVisible: function(visible) { | setVisible: function(visible) { | ||||
| this._visible = visible; | this._visible = visible; | ||||
| var diff = JX.DOM.find(this._node, 'table', 'differential-diff'); | var diff = this._getDiffNode(); | ||||
| var undo = this._getUndoNode(); | var options = this._getViewButtonNode(); | ||||
| var show = this._getShowButtonNode(); | |||||
| if (this._visible) { | if (this._visible) { | ||||
| JX.DOM.show(diff); | JX.DOM.show(diff); | ||||
| JX.DOM.remove(undo); | JX.DOM.show(options); | ||||
| JX.DOM.hide(show); | |||||
| } else { | } else { | ||||
| JX.DOM.hide(diff); | JX.DOM.hide(diff); | ||||
| JX.DOM.appendContent(diff.parentNode, undo); | JX.DOM.hide(options); | ||||
| JX.DOM.show(show); | |||||
| if (this._viewMenu) { | |||||
| this._viewMenu.close(); | |||||
| } | |||||
| } | } | ||||
| JX.Stratcom.invoke('resize'); | JX.Stratcom.invoke('resize'); | ||||
| var node = this._node; | |||||
| JX.DOM.alterClass(node, 'changeset-content-hidden', !this._visible); | |||||
| this.getPathView().setIsHidden(!this._visible); | this.getPathView().setIsHidden(!this._visible); | ||||
| }, | }, | ||||
| isVisible: function() { | setIsSelected: function(is_selected) { | ||||
| return this._visible; | this._isSelected = !!is_selected; | ||||
| }, | |||||
| _getUndoNode: function() { | var node = this._node; | ||||
| if (!this._undoNode) { | JX.DOM.alterClass(node, 'changeset-selected', this._isSelected); | ||||
| var pht = this.getChangesetList().getTranslations(); | |||||
| var link_attributes = { | return this; | ||||
| href: '#' | }, | ||||
| }; | |||||
| var undo_link = JX.$N('a', link_attributes, pht('Show Content')); | _getDiffNode: function() { | ||||
| if (!this._diffNode) { | |||||
| this._diffNode = JX.DOM.find(this._node, 'table', 'differential-diff'); | |||||
| } | |||||
| return this._diffNode; | |||||
| }, | |||||
| var onundo = JX.bind(this, this._onundo); | _getViewButtonNode: function() { | ||||
| JX.DOM.listen(undo_link, 'click', null, onundo); | if (!this._viewButtonNode) { | ||||
| this._viewButtonNode = JX.DOM.find( | |||||
| this._node, | |||||
| 'a', | |||||
| 'differential-view-options'); | |||||
| } | |||||
| return this._viewButtonNode; | |||||
| }, | |||||
| var node_attributes = { | _getShowButtonNode: function() { | ||||
| className: 'differential-collapse-undo' | if (!this._showButtonNode) { | ||||
| }; | var pht = this.getChangesetList().getTranslations(); | ||||
| var show_button = new JX.PHUIXButtonView() | |||||
| .setIcon('fa-angle-double-down') | |||||
| .setText(pht('Show Changeset')) | |||||
| .setColor('grey'); | |||||
| var node_content = [ | var button_node = show_button.getNode(); | ||||
| pht('This file content has been collapsed.'), | this._getViewButtonNode().parentNode.appendChild(button_node); | ||||
| ' ', | |||||
| undo_link | |||||
| ]; | |||||
| var undo_node = JX.$N('div', node_attributes, node_content); | var onshow = JX.bind(this, this._onClickShowButton); | ||||
| JX.DOM.listen(button_node, 'click', null, onshow); | |||||
| this._undoNode = undo_node; | this._showButtonNode = button_node; | ||||
| } | } | ||||
| return this._showButtonNode; | |||||
| }, | |||||
| return this._undoNode; | _onClickShowButton: function(e) { | ||||
| e.prevent(); | |||||
| this.setVisible(true); | |||||
| }, | |||||
| isVisible: function() { | |||||
| return this._visible; | |||||
| }, | }, | ||||
| _onundo: function(e) { | _onundo: function(e) { | ||||
| e.kill(); | e.kill(); | ||||
| this.toggleVisibility(); | this.toggleVisibility(); | ||||
| }, | }, | ||||
| getPathView: function() { | getPathView: function() { | ||||
| Show All 34 Lines | |||||