Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffInline.js
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | bindToRow: function(row) { | ||||
var td = comment.parentNode; | var td = comment.parentNode; | ||||
var th = td.previousSibling; | var th = td.previousSibling; | ||||
if (th.parentNode.firstChild != th) { | if (th.parentNode.firstChild != th) { | ||||
this._displaySide = 'right'; | this._displaySide = 'right'; | ||||
} else { | } else { | ||||
this._displaySide = 'left'; | this._displaySide = 'left'; | ||||
} | } | ||||
this._number = data.number; | this._number = parseInt(data.number, 10); | ||||
this._length = data.length; | this._length = parseInt(data.length, 10); | ||||
this._originalText = data.original; | this._originalText = data.original; | ||||
this._isNewFile = | this._isNewFile = | ||||
(this.getDisplaySide() == 'right') || | (this.getDisplaySide() == 'right') || | ||||
(data.left != data.right); | (data.left != data.right); | ||||
this.setInvisible(false); | this.setInvisible(false); | ||||
return this; | return this; | ||||
}, | }, | ||||
bindToRange: function(data) { | bindToRange: function(data) { | ||||
this._displaySide = data.displaySide; | this._displaySide = data.displaySide; | ||||
this._number = data.number; | this._number = parseInt(data.number, 10); | ||||
this._length = data.length; | this._length = parseInt(data.length, 10); | ||||
this._isNewFile = data.isNewFile; | this._isNewFile = data.isNewFile; | ||||
this._changesetID = data.changesetID; | this._changesetID = data.changesetID; | ||||
// 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')) { | ||||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | _oneditresponse: function(response) { | ||||
this._drawEditRows(rows); | this._drawEditRows(rows); | ||||
this.setLoading(false); | this.setLoading(false); | ||||
this.setInvisible(true); | this.setInvisible(true); | ||||
}, | }, | ||||
_oncreateresponse: function(response) { | _oncreateresponse: function(response) { | ||||
try { | |||||
var rows = JX.$H(response).getNode(); | var rows = JX.$H(response).getNode(); | ||||
this._drawEditRows(rows); | this._drawEditRows(rows); | ||||
} catch (e) { | |||||
JX.log(e); | |||||
} | |||||
}, | }, | ||||
_ondeleteresponse: function() { | _ondeleteresponse: function() { | ||||
this._drawUndeleteRows(); | this._drawUndeleteRows(); | ||||
this.setLoading(false); | this.setLoading(false); | ||||
this.setDeleted(true); | this.setDeleted(true); | ||||
Show All 25 Lines | members: { | ||||
_drawEditRows: function(rows) { | _drawEditRows: function(rows) { | ||||
return this._drawRows(rows, null, 'edit'); | return this._drawRows(rows, null, 'edit'); | ||||
}, | }, | ||||
_drawRows: function(rows, cursor, type, text) { | _drawRows: function(rows, cursor, type, text) { | ||||
var first_row = JX.DOM.scry(rows, 'tr')[0]; | var first_row = JX.DOM.scry(rows, 'tr')[0]; | ||||
var first_meta; | var first_meta; | ||||
var row = first_row; | var row = first_row; | ||||
var anchor = cursor || this._row; | |||||
cursor = cursor || this._row.nextSibling; | cursor = cursor || this._row.nextSibling; | ||||
var next_row; | var next_row; | ||||
while (row) { | while (row) { | ||||
// Grab this first, since it's going to change once we insert the row | // Grab this first, since it's going to change once we insert the row | ||||
// into the document. | // into the document. | ||||
next_row = row.nextSibling; | next_row = row.nextSibling; | ||||
cursor.parentNode.insertBefore(row, cursor); | // Bind edit and undo rows to this DiffInline object so that | ||||
// interactions like hovering work properly. | |||||
JX.Stratcom.getData(row).inline = this; | |||||
anchor.parentNode.insertBefore(row, cursor); | |||||
cursor = row; | cursor = row; | ||||
var row_meta = { | var row_meta = { | ||||
node: row, | node: row, | ||||
type: type, | type: type, | ||||
text: text || null, | text: text || null, | ||||
listeners: [] | listeners: [] | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | _oncancel: function(row, e) { | ||||
var text = this._readText(row.node); | var text = this._readText(row.node); | ||||
if (text && text.length && (text != this._originalText)) { | if (text && text.length && (text != this._originalText)) { | ||||
this._drawUneditRows(text); | this._drawUneditRows(text); | ||||
} | } | ||||
this._removeRow(row); | this._removeRow(row); | ||||
this.setInvisible(false); | this.setInvisible(false); | ||||
this._didUpdate(true); | |||||
}, | }, | ||||
_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 All 35 Lines | members: { | ||||
_didUpdate: function(local_only) { | _didUpdate: function(local_only) { | ||||
// After making changes to inline comments, refresh the transaction | // After making changes to inline comments, refresh the transaction | ||||
// preview at the bottom of the page. | // preview at the bottom of the page. | ||||
if (!local_only) { | if (!local_only) { | ||||
this.getChangeset().getChangesetList().redrawPreview(); | this.getChangeset().getChangesetList().redrawPreview(); | ||||
} | } | ||||
this.getChangeset().getChangesetList().redrawCursor(); | this.getChangeset().getChangesetList().redrawCursor(); | ||||
this.getChangeset().getChangesetList().resetHover(); | |||||
// Emit a resize event so that UI elements like the keyboad focus | // Emit a resize event so that UI elements like the keyboard focus | ||||
// reticle can redraw properly. | // reticle can redraw properly. | ||||
JX.Stratcom.invoke('resize'); | JX.Stratcom.invoke('resize'); | ||||
}, | }, | ||||
_redraw: function() { | _redraw: function() { | ||||
var is_invisible = (this._isInvisible || this._isDeleted); | var is_invisible = (this._isInvisible || this._isDeleted); | ||||
var is_loading = (this._isLoading); | var is_loading = (this._isLoading); | ||||
Show All 20 Lines |