Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffInline.js
Show First 20 Lines • Show All 606 Lines • ▼ Show 20 Lines | _ondeleteresponse: function() { | ||||
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 | ||||
// delete a comment from the comment preview area. In this case, we | // delete a comment from the comment preview area. In this case, we | ||||
// read and preserve the text so "Undo" restores it. | // read and preserve the text so "Undo" restores it. | ||||
var state = null; | var state = null; | ||||
if (this._editRow) { | if (this._editRow) { | ||||
state = this._readFormState(this._editRow); | state = this._getActiveContentState().getWireFormat(); | ||||
JX.DOM.remove(this._editRow); | JX.DOM.remove(this._editRow); | ||||
this._editRow = null; | this._editRow = null; | ||||
} | } | ||||
this._drawUndeleteRows(state); | this._drawUndeleteRows(state); | ||||
this.setLoading(false); | this.setLoading(false); | ||||
this.setDeleted(true); | this.setDeleted(true); | ||||
▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | members: { | ||||
}, | }, | ||||
_onundelete: function() { | _onundelete: function() { | ||||
this.setLoading(false); | this.setLoading(false); | ||||
this._didUpdate(); | this._didUpdate(); | ||||
}, | }, | ||||
cancel: function() { | cancel: function() { | ||||
var state = this._readFormState(this._editRow); | var state = this._getActiveContentState().getWireFormat(); | ||||
JX.DOM.remove(this._editRow); | JX.DOM.remove(this._editRow); | ||||
this._editRow = null; | this._editRow = null; | ||||
var is_empty = this._isVoidContentState(state); | var is_empty = this._isVoidContentState(state); | ||||
var is_same = this._isSameContentState(state, this._originalState); | var is_same = this._isSameContentState(state, this._originalState); | ||||
if (!is_empty && !is_same) { | if (!is_empty && !is_same) { | ||||
this._drawUneditRows(state); | this._drawUneditRows(state); | ||||
Show All 36 Lines | _onCancelResponse: function(response) { | ||||
JX.DOM.remove(this._row); | JX.DOM.remove(this._row); | ||||
this._row = null; | this._row = null; | ||||
this._didUpdate(); | this._didUpdate(); | ||||
} | } | ||||
}, | }, | ||||
_readFormState: function(row) { | |||||
var state = this._newContentState(); | |||||
var node; | |||||
try { | |||||
node = JX.DOM.find(row, 'textarea', 'inline-content-text'); | |||||
state.text = node.value; | |||||
} catch (ex) { | |||||
// Ignore. | |||||
} | |||||
node = this._getSuggestionNode(row); | |||||
if (node) { | |||||
state.suggestionText = node.value; | |||||
} | |||||
state.hasSuggestion = this._getActiveContentState().getHasSuggestion(); | |||||
return state; | |||||
}, | |||||
_getSuggestionNode: function(row) { | _getSuggestionNode: function(row) { | ||||
try { | try { | ||||
return JX.DOM.find(row, 'textarea', 'inline-content-suggestion'); | return JX.DOM.find(row, 'textarea', 'inline-content-suggestion'); | ||||
} catch (ex) { | } catch (ex) { | ||||
return null; | return null; | ||||
} | } | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | _getDraftState: function() { | ||||
if (this.isDeleted()) { | if (this.isDeleted()) { | ||||
return null; | return null; | ||||
} | } | ||||
if (!this.isEditing()) { | if (!this.isEditing()) { | ||||
return null; | return null; | ||||
} | } | ||||
var state = this._readFormState(this._editRow); | var state = this._getActiveContentState().getWireFormat(); | ||||
if (this._isVoidContentState(state)) { | if (this._isVoidContentState(state)) { | ||||
return null; | return null; | ||||
} | } | ||||
var draft_data = { | var draft_data = { | ||||
op: 'draft', | op: 'draft', | ||||
id: this.getID(), | id: this.getID(), | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |