Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffInline.js
/** | /** | ||||
* @provides phabricator-diff-inline | * @provides phabricator-diff-inline | ||||
* @requires javelin-dom | * @requires javelin-dom | ||||
* phabricator-diff-inline-content-state | * phabricator-diff-inline-content-state | ||||
* @javelin | * @javelin | ||||
*/ | */ | ||||
JX.install('DiffInline', { | JX.install('DiffInline', { | ||||
construct : function() { | construct : function() { | ||||
this._activeContentState = new JX.DiffInlineContentState(); | this._state = {}; | ||||
this._committedContentState = new JX.DiffInlineContentState(); | |||||
}, | }, | ||||
members: { | members: { | ||||
_id: null, | _id: null, | ||||
_phid: null, | _phid: null, | ||||
_changesetID: null, | _changesetID: null, | ||||
_row: null, | _row: null, | ||||
_number: null, | _number: null, | ||||
Show All 30 Lines | members: { | ||||
_skipFocus: false, | _skipFocus: false, | ||||
_menu: null, | _menu: null, | ||||
_startOffset: null, | _startOffset: null, | ||||
_endOffset: null, | _endOffset: null, | ||||
_isSelected: false, | _isSelected: false, | ||||
_canSuggestEdit: false, | _canSuggestEdit: false, | ||||
_committedContentState: null, | _state: null, | ||||
_activeContentState: null, | |||||
bindToRow: function(row) { | bindToRow: function(row) { | ||||
this._row = row; | this._row = row; | ||||
var row_data = JX.Stratcom.getData(row); | var row_data = JX.Stratcom.getData(row); | ||||
row_data.inline = this; | row_data.inline = this; | ||||
this._isCollapsed = row_data.hidden || false; | this._isCollapsed = row_data.hidden || false; | ||||
▲ Show 20 Lines • Show All 528 Lines • ▼ Show 20 Lines | _oncreateresponse: function(response) { | ||||
this._readInlineState(response.inline); | this._readInlineState(response.inline); | ||||
this._drawEditRows(rows); | this._drawEditRows(rows); | ||||
}, | }, | ||||
_readInlineState: function(state) { | _readInlineState: function(state) { | ||||
this._id = state.id; | this._id = state.id; | ||||
// TODO: This is not the correct content state after a reload: it is | this._state = { | ||||
// the draft state. | initial: this._newContentStateFromWireFormat(state.state.initial), | ||||
this._getCommittedContentState().readWireFormat(state.contentState); | committed: this._newContentStateFromWireFormat(state.state.committed), | ||||
active: this._newContentStateFromWireFormat(state.state.active) | |||||
this._getActiveContentState().readWireFormat(state.contentState); | }; | ||||
this._canSuggestEdit = state.canSuggestEdit; | this._canSuggestEdit = state.canSuggestEdit; | ||||
}, | }, | ||||
_newContentStateFromWireFormat: function(map) { | |||||
if (map === null) { | |||||
return null; | |||||
} | |||||
return new JX.DiffInlineContentState().readWireFormat(map); | |||||
}, | |||||
_ondeleteresponse: function() { | _ondeleteresponse: function() { | ||||
// If there's an existing "unedit" undo element, remove it. | // If there's an existing "unedit" undo element, remove it. | ||||
if (this._undoRow) { | if (this._undoRow) { | ||||
JX.DOM.remove(this._undoRow); | JX.DOM.remove(this._undoRow); | ||||
this._undoRow = null; | this._undoRow = null; | ||||
} | } | ||||
// If there's an existing editor, remove it. This happens when you | // If there's an existing editor, remove it. This happens when you | ||||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | _onSuggestEdit: function(e) { | ||||
} | } | ||||
} | } | ||||
// Save the "hasSuggestion" part of the content state. | // Save the "hasSuggestion" part of the content state. | ||||
this.triggerDraft(); | this.triggerDraft(); | ||||
}, | }, | ||||
_getActiveContentState: function() { | _getActiveContentState: function() { | ||||
var state = this._activeContentState; | var state = this._state.active; | ||||
if (this._editRow) { | if (this._editRow) { | ||||
state.readForm(this._editRow); | state.readForm(this._editRow); | ||||
} | } | ||||
return state; | return state; | ||||
}, | }, | ||||
_getCommittedContentState: function() { | _getCommittedContentState: function() { | ||||
return this._committedContentState; | return this._state.committed; | ||||
}, | |||||
_getInitialContentState: function() { | |||||
return this._state.initial; | |||||
}, | }, | ||||
setHasSuggestion: function(has_suggestion) { | setHasSuggestion: function(has_suggestion) { | ||||
var state = this._getActiveContentState(); | var state = this._getActiveContentState(); | ||||
state.setHasSuggestion(has_suggestion); | state.setHasSuggestion(has_suggestion); | ||||
var button = this._getSuggestionButton(); | var button = this._getSuggestionButton(); | ||||
var pht = this.getChangeset().getChangesetList().getTranslations(); | var pht = this.getChangeset().getChangesetList().getTranslations(); | ||||
▲ Show 20 Lines • Show All 396 Lines • Show Last 20 Lines |