Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffInline.js
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | members: { | ||||
_undoRow: null, | _undoRow: null, | ||||
_undoType: null, | _undoType: null, | ||||
_undoText: null, | _undoText: null, | ||||
_draftRequest: null, | _draftRequest: null, | ||||
_skipFocus: false, | _skipFocus: false, | ||||
_menu: null, | _menu: null, | ||||
_startOffset: null, | |||||
_endOffset: 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; | ||||
// TODO: Get smarter about this once we do more editing, this is pretty | // TODO: Get smarter about this once we do more editing, this is pretty | ||||
Show All 29 Lines | bindToRow: function(row) { | ||||
this._isSynthetic = data.isSynthetic; | this._isSynthetic = data.isSynthetic; | ||||
this._isDraftDone = data.isDraftDone; | this._isDraftDone = data.isDraftDone; | ||||
this._changesetID = data.changesetID; | this._changesetID = data.changesetID; | ||||
this._isNew = false; | this._isNew = false; | ||||
this._snippet = data.snippet; | this._snippet = data.snippet; | ||||
this._menuItems = data.menuItems; | this._menuItems = data.menuItems; | ||||
this._documentEngineKey = data.documentEngineKey; | this._documentEngineKey = data.documentEngineKey; | ||||
this._startOffset = data.startOffset; | |||||
this._endOffset = data.endOffset; | |||||
this._isEditing = data.isEditing; | this._isEditing = data.isEditing; | ||||
if (this._isEditing) { | if (this._isEditing) { | ||||
// NOTE: The "original" shipped down in the DOM may reflect a draft | // NOTE: The "original" shipped down in the DOM may reflect a draft | ||||
// which we're currently editing. This flow is a little clumsy, but | // which we're currently editing. This flow is a little clumsy, but | ||||
// reasonable until some future change moves away from "send down | // reasonable until some future change moves away from "send down | ||||
// the inline, then immediately click edit". | // the inline, then immediately click edit". | ||||
Show All 38 Lines | members: { | ||||
isHidden: function() { | isHidden: function() { | ||||
return this._isHidden; | return this._isHidden; | ||||
}, | }, | ||||
isGhost: function() { | isGhost: function() { | ||||
return this._isGhost; | return this._isGhost; | ||||
}, | }, | ||||
getStartOffset: function() { | |||||
return this._startOffset; | |||||
}, | |||||
getEndOffset: function() { | |||||
return this._endOffset; | |||||
}, | |||||
bindToRange: function(data) { | bindToRange: function(data) { | ||||
this._displaySide = data.displaySide; | this._displaySide = data.displaySide; | ||||
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._isNewFile = data.isNewFile; | this._isNewFile = data.isNewFile; | ||||
this._changesetID = data.changesetID; | this._changesetID = data.changesetID; | ||||
this._isNew = true; | this._isNew = true; | ||||
this._startOffset = data.startOffset; | |||||
this._endOffset = data.endOffset; | |||||
// Insert the comment after any other comments which already appear on | // Insert the comment after any other comments which already appear on | ||||
// the same row. | // the same row. | ||||
var parent_row = JX.DOM.findAbove(data.target, 'tr'); | var parent_row = JX.DOM.findAbove(data.target, 'tr'); | ||||
var target_row = parent_row.nextSibling; | var target_row = parent_row.nextSibling; | ||||
while (target_row && JX.Stratcom.hasSigil(target_row, 'inline-row')) { | while (target_row && JX.Stratcom.hasSigil(target_row, 'inline-row')) { | ||||
target_row = target_row.nextSibling; | target_row = target_row.nextSibling; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 336 Lines • ▼ Show 20 Lines | members: { | ||||
setLoading: function(loading) { | setLoading: function(loading) { | ||||
this._isLoading = loading; | this._isLoading = loading; | ||||
this._redraw(); | this._redraw(); | ||||
return this; | return this; | ||||
}, | }, | ||||
_newRequestData: function(operation, text) { | _newRequestData: function(operation, text) { | ||||
return { | var data = { | ||||
op: operation, | op: operation, | ||||
id: this._id, | is_new: this.isNewFile(), | ||||
on_right: ((this.getDisplaySide() == 'right') ? 1 : 0), | on_right: ((this.getDisplaySide() == 'right') ? 1 : 0), | ||||
renderer: this.getChangeset().getRendererKey(), | renderer: this.getChangeset().getRendererKey(), | ||||
number: this.getLineNumber(), | text: text || null | ||||
length: this.getLineLength(), | }; | ||||
is_new: this.isNewFile(), | |||||
if (operation === 'new') { | |||||
var create_data = { | |||||
changesetID: this.getChangesetID(), | changesetID: this.getChangesetID(), | ||||
replyToCommentPHID: this.getReplyToCommentPHID(), | |||||
text: text || null, | |||||
documentEngineKey: this._documentEngineKey, | documentEngineKey: this._documentEngineKey, | ||||
replyToCommentPHID: this.getReplyToCommentPHID(), | |||||
startOffset: this._startOffset, | |||||
endOffset: this._endOffset, | |||||
number: this.getLineNumber(), | |||||
length: this.getLineLength() | |||||
}; | }; | ||||
JX.copy(data, create_data); | |||||
} else { | |||||
var edit_data = { | |||||
id: this._id | |||||
}; | |||||
JX.copy(data, edit_data); | |||||
} | |||||
return data; | |||||
}, | }, | ||||
_oneditresponse: function(response) { | _oneditresponse: function(response) { | ||||
var rows = JX.$H(response.view).getNode(); | var rows = JX.$H(response.view).getNode(); | ||||
this._readInlineState(response.inline); | this._readInlineState(response.inline); | ||||
this._drawEditRows(rows); | this._drawEditRows(rows); | ||||
▲ Show 20 Lines • Show All 458 Lines • Show Last 20 Lines |