Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffInline.js
| Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | bindToRow: function(row) { | ||||
| if (data.on_right) { | if (data.on_right) { | ||||
| this._displaySide = 'right'; | this._displaySide = 'right'; | ||||
| } else { | } else { | ||||
| this._displaySide = 'left'; | this._displaySide = 'left'; | ||||
| } | } | ||||
| this._number = parseInt(data.number, 10); | this._number = parseInt(data.number, 10); | ||||
| this._length = parseInt(data.length, 10); | this._length = parseInt(data.length, 10); | ||||
| this._originalText = data.original; | |||||
| var original = '' + data.original; | |||||
| if (original.length) { | |||||
| this._originalText = original; | |||||
| } else { | |||||
| this._originalText = null; | |||||
| } | |||||
| this._isNewFile = data.isNewFile; | this._isNewFile = data.isNewFile; | ||||
| this._replyToCommentPHID = data.replyToCommentPHID; | this._replyToCommentPHID = data.replyToCommentPHID; | ||||
| this._isDraft = data.isDraft; | this._isDraft = data.isDraft; | ||||
| this._isFixed = data.isFixed; | this._isFixed = data.isFixed; | ||||
| this._isGhost = data.isGhost; | this._isGhost = data.isGhost; | ||||
| this._isSynthetic = data.isSynthetic; | this._isSynthetic = data.isSynthetic; | ||||
| Show All 21 Lines | members: { | ||||
| isDone: function() { | isDone: function() { | ||||
| return this._isFixed; | return this._isFixed; | ||||
| }, | }, | ||||
| isEditing: function() { | isEditing: function() { | ||||
| return this._isEditing; | return this._isEditing; | ||||
| }, | }, | ||||
| isUndo: function() { | |||||
| return !!this._undoRow; | |||||
| }, | |||||
| isDeleted: function() { | isDeleted: function() { | ||||
| return this._isDeleted; | return this._isDeleted; | ||||
| }, | }, | ||||
| isSynthetic: function() { | isSynthetic: function() { | ||||
| return this._isSynthetic; | return this._isSynthetic; | ||||
| }, | }, | ||||
| ▲ Show 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | members: { | ||||
| }, | }, | ||||
| reply: function(text) { | reply: function(text) { | ||||
| var changeset = this.getChangeset(); | var changeset = this.getChangeset(); | ||||
| return changeset.newInlineReply(this, text); | return changeset.newInlineReply(this, text); | ||||
| }, | }, | ||||
| edit: function(text) { | edit: function(text) { | ||||
| // If you edit an inline ("A"), modify the text ("AB"), cancel, and then | |||||
| // edit it again: discard the undo state ("AB"). Otherwise we end up | |||||
| // with an open editor and an active "Undo" link, which is weird. | |||||
| if (this._undoRow) { | |||||
| JX.DOM.remove(this._undoRow); | |||||
| this._undoRow = null; | |||||
| this._undoType = null; | |||||
| this._undoText = null; | |||||
| } | |||||
| var uri = this._getInlineURI(); | var uri = this._getInlineURI(); | ||||
| var handler = JX.bind(this, this._oneditresponse); | var handler = JX.bind(this, this._oneditresponse); | ||||
| var data = this._newRequestData('edit', text || null); | var data = this._newRequestData('edit', text || null); | ||||
| this.setLoading(true); | this.setLoading(true); | ||||
| new JX.Request(uri, handler) | new JX.Request(uri, handler) | ||||
| .setData(data) | .setData(data) | ||||
| .send(); | .send(); | ||||
| }, | }, | ||||
| ▲ Show 20 Lines • Show All 259 Lines • ▼ Show 20 Lines | cancel: function() { | ||||
| JX.DOM.remove(this._editRow); | JX.DOM.remove(this._editRow); | ||||
| this._editRow = null; | this._editRow = null; | ||||
| if (text && text.length && (text != this._originalText)) { | if (text && text.length && (text != this._originalText)) { | ||||
| this._drawUneditRows(text); | this._drawUneditRows(text); | ||||
| } | } | ||||
| this.setEditing(false); | this.setEditing(false); | ||||
| // If this was an empty box and we typed some text and then hit cancel, | |||||
| // don't show the empty concrete inline. | |||||
| if (!this._originalText) { | |||||
| this.setInvisible(true); | |||||
| } else { | |||||
| this.setInvisible(false); | this.setInvisible(false); | ||||
| } | |||||
| // If you "undo" to restore text ("AB") and then "Cancel", we put you | |||||
| // back in the original text state ("A"). We also send the original | |||||
| // text ("A") to the server as the current persistent state. | |||||
| var uri = this._getInlineURI(); | var uri = this._getInlineURI(); | ||||
| var data = this._newRequestData('cancel'); | var data = this._newRequestData('cancel', this._originalText); | ||||
| var handler = JX.bind(this, this._onCancelResponse); | var handler = JX.bind(this, this._onCancelResponse); | ||||
| this.setLoading(true); | this.setLoading(true); | ||||
| new JX.Request(uri, handler) | new JX.Request(uri, handler) | ||||
| .setData(data) | .setData(data) | ||||
| .send(); | .send(); | ||||
| this._didUpdate(true); | this._didUpdate(true); | ||||
| }, | }, | ||||
| _onCancelResponse: function(response) { | _onCancelResponse: function(response) { | ||||
| this.setLoading(false); | this.setLoading(false); | ||||
| // If the comment was empty when we started editing it (there's no | |||||
| // original text) and empty when we finished editing it (there's no | |||||
| // undo row), just delete the comment. | |||||
| if (!this._originalText && !this.isUndo()) { | |||||
| this.setDeleted(true); | |||||
| JX.DOM.remove(this._row); | |||||
| this._row = null; | |||||
| this._didUpdate(); | |||||
| } | |||||
| }, | }, | ||||
| _readText: function(row) { | _readText: function(row) { | ||||
| var textarea; | var textarea; | ||||
| try { | try { | ||||
| textarea = JX.DOM.find( | textarea = JX.DOM.find( | ||||
| row, | row, | ||||
| 'textarea', | 'textarea', | ||||
| ▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines | |||||