Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffChangeset.js
Show First 20 Lines • Show All 575 Lines • ▼ Show 20 Lines | newInlineReply: function(original, text) { | ||||
this._inlines.push(inline); | this._inlines.push(inline); | ||||
inline.create(text); | inline.create(text); | ||||
return inline; | return inline; | ||||
}, | }, | ||||
getInlineByID: function(id) { | getInlineByID: function(id) { | ||||
// TODO: Currently, this will only find inlines which the user has | // First, look for the inline in the objects we've already built. | ||||
// already interacted with! Inlines are built lazily as events arrive. | var inline = this._findInlineByID(id); | ||||
// This can not yet find inlines which are passively present in the | if (inline) { | ||||
// document. | return inline; | ||||
} | |||||
// If we haven't found a matching inline yet, rebuild all the inlines | |||||
// present in the document, then look again. | |||||
this._rebuildAllInlines(); | |||||
return this._findInlineByID(id); | |||||
}, | |||||
_findInlineByID: function(id) { | |||||
for (var ii = 0; ii < this._inlines.length; ii++) { | for (var ii = 0; ii < this._inlines.length; ii++) { | ||||
var inline = this._inlines[ii]; | var inline = this._inlines[ii]; | ||||
if (inline.getID() == id) { | if (inline.getID() == id) { | ||||
return inline; | return inline; | ||||
} | } | ||||
} | } | ||||
return null; | return null; | ||||
}, | |||||
_rebuildAllInlines: function() { | |||||
var rows = JX.DOM.scry(this._node, 'tr'); | |||||
for (var ii = 0; ii < rows.length; ii++) { | |||||
var row = rows[ii]; | |||||
if (this._getRowType(row) != 'comment') { | |||||
continue; | |||||
} | } | ||||
// As a side effect, this builds any missing inline objects and adds | |||||
// them to this Changeset's list of inlines. | |||||
this.getInlineForRow(row); | |||||
} | |||||
} | |||||
}, | }, | ||||
statics: { | statics: { | ||||
getForNode: function(node) { | getForNode: function(node) { | ||||
var data = JX.Stratcom.getData(node); | var data = JX.Stratcom.getData(node); | ||||
if (!data.changesetViewManager) { | if (!data.changesetViewManager) { | ||||
data.changesetViewManager = new JX.DiffChangeset(node); | data.changesetViewManager = new JX.DiffChangeset(node); | ||||
} | } | ||||
return data.changesetViewManager; | return data.changesetViewManager; | ||||
} | } | ||||
} | } | ||||
}); | }); |