Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffInline.js
| Show First 20 Lines • Show All 432 Lines • ▼ Show 20 Lines | delete: function(is_ref) { | ||||
| var op; | var op; | ||||
| if (is_ref) { | if (is_ref) { | ||||
| op = 'refdelete'; | op = 'refdelete'; | ||||
| } else { | } else { | ||||
| op = 'delete'; | op = 'delete'; | ||||
| } | } | ||||
| // If there's an existing "unedit" undo element, remove it. | |||||
| if (this._undoRow) { | |||||
| JX.DOM.remove(this._undoRow); | |||||
| this._undoRow = null; | |||||
| } | |||||
| var data = this._newRequestData(op); | var data = this._newRequestData(op); | ||||
| this.setLoading(true); | this.setLoading(true); | ||||
| new JX.Workflow(uri, data) | new JX.Workflow(uri, data) | ||||
| .setHandler(handler) | .setHandler(handler) | ||||
| .start(); | .start(); | ||||
| }, | }, | ||||
| ▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | _oncreateresponse: function(response) { | ||||
| this._drawEditRows(rows); | this._drawEditRows(rows); | ||||
| }, | }, | ||||
| _readInlineState: function(state) { | _readInlineState: function(state) { | ||||
| this._id = state.id; | this._id = state.id; | ||||
| }, | }, | ||||
| _ondeleteresponse: function() { | _ondeleteresponse: function() { | ||||
| this._drawUndeleteRows(); | // If there's an existing "unedit" undo element, remove it. | ||||
| if (this._undoRow) { | |||||
| JX.DOM.remove(this._undoRow); | |||||
| this._undoRow = null; | |||||
| } | |||||
| // If there's an existing editor, remove it. This happens when you | |||||
| // delete a comment from the comment preview area. In this case, we | |||||
| // read and preserve the text so "Undo" restores it. | |||||
| var text; | |||||
| if (this._editRow) { | |||||
| text = this._readText(this._editRow); | |||||
| JX.DOM.remove(this._editRow); | |||||
| this._editRow = null; | |||||
| } | |||||
| this._drawUndeleteRows(text); | |||||
| this.setLoading(false); | this.setLoading(false); | ||||
| this.setDeleted(true); | this.setDeleted(true); | ||||
| this._didUpdate(); | this._didUpdate(); | ||||
| }, | }, | ||||
| _drawUndeleteRows: function() { | _drawUndeleteRows: function(text) { | ||||
| this._undoType = 'undelete'; | this._undoType = 'undelete'; | ||||
| this._undoText = null; | this._undoText = text || null; | ||||
| return this._drawUndoRows('undelete', this._row); | return this._drawUndoRows('undelete', this._row); | ||||
| }, | }, | ||||
| _drawUneditRows: function(text) { | _drawUneditRows: function(text) { | ||||
| this._undoType = 'unedit'; | this._undoType = 'unedit'; | ||||
| this._undoText = text; | this._undoText = text; | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | save: function(form) { | ||||
| this.setLoading(true); | this.setLoading(true); | ||||
| JX.Workflow.newFromForm(form) | JX.Workflow.newFromForm(form) | ||||
| .setHandler(handler) | .setHandler(handler) | ||||
| .start(); | .start(); | ||||
| }, | }, | ||||
| undo: function() { | undo: function() { | ||||
| JX.DOM.remove(this._undoRow); | JX.DOM.remove(this._undoRow); | ||||
| this._undoRow = null; | this._undoRow = null; | ||||
| if (this._undoType === 'undelete') { | if (this._undoType === 'undelete') { | ||||
| var uri = this._getInlineURI(); | var uri = this._getInlineURI(); | ||||
| var data = this._newRequestData('undelete'); | var data = this._newRequestData('undelete'); | ||||
| var handler = JX.bind(this, this._onundelete); | var handler = JX.bind(this, this._onundelete); | ||||
| this.setDeleted(false); | this.setDeleted(false); | ||||
| this.setLoading(true); | this.setLoading(true); | ||||
| new JX.Request(uri, handler) | new JX.Request(uri, handler) | ||||
| .setData(data) | .setData(data) | ||||
| .send(); | .send(); | ||||
| } | } | ||||
| if (this._undoType === 'unedit') { | if (this._undoText !== null) { | ||||
| this.edit(this._undoText); | this.edit(this._undoText); | ||||
| } | } | ||||
| }, | }, | ||||
| _onundelete: function() { | _onundelete: function() { | ||||
| this.setLoading(false); | this.setLoading(false); | ||||
| this._didUpdate(); | this._didUpdate(); | ||||
| }, | }, | ||||
| cancel: function() { | cancel: function() { | ||||
| ▲ Show 20 Lines • Show All 191 Lines • Show Last 20 Lines | |||||