Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffChangeset.js
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | members: { | ||||
_highlight: null, | _highlight: null, | ||||
_encoding: null, | _encoding: null, | ||||
_undoTemplates: null, | _undoTemplates: null, | ||||
_leftID: null, | _leftID: null, | ||||
_rightID: null, | _rightID: null, | ||||
_inlines: null, | _inlines: null, | ||||
_visible: true, | |||||
_undoNode: null, | |||||
getLeftChangesetID: function() { | getLeftChangesetID: function() { | ||||
return this._leftID; | return this._leftID; | ||||
}, | }, | ||||
getRightChangesetID: function() { | getRightChangesetID: function() { | ||||
return this._rightID; | return this._rightID; | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 274 Lines • ▼ Show 20 Lines | getSelectableItems: function() { | ||||
changeset: this, | changeset: this, | ||||
target: this, | target: this, | ||||
nodes: { | nodes: { | ||||
begin: this._node, | begin: this._node, | ||||
end: null | end: null | ||||
} | } | ||||
}); | }); | ||||
if (!this._visible) { | |||||
return items; | |||||
} | |||||
var rows = JX.DOM.scry(this._node, 'tr'); | var rows = JX.DOM.scry(this._node, 'tr'); | ||||
var blocks = []; | var blocks = []; | ||||
var block; | var block; | ||||
var ii; | var ii; | ||||
for (ii = 0; ii < rows.length; ii++) { | for (ii = 0; ii < rows.length; ii++) { | ||||
var type = this._getRowType(rows[ii]); | var type = this._getRowType(rows[ii]); | ||||
▲ Show 20 Lines • Show All 274 Lines • ▼ Show 20 Lines | _rebuildAllInlines: function() { | ||||
if (this._getRowType(row) != 'comment') { | if (this._getRowType(row) != 'comment') { | ||||
continue; | continue; | ||||
} | } | ||||
// As a side effect, this builds any missing inline objects and adds | // As a side effect, this builds any missing inline objects and adds | ||||
// them to this Changeset's list of inlines. | // them to this Changeset's list of inlines. | ||||
this.getInlineForRow(row); | this.getInlineForRow(row); | ||||
} | } | ||||
}, | |||||
toggleVisibility: function() { | |||||
this._visible = !this._visible; | |||||
var diff = JX.DOM.find(this._node, 'table', 'differential-diff'); | |||||
var undo = this._getUndoNode(); | |||||
if (this._visible) { | |||||
JX.DOM.show(diff); | |||||
JX.DOM.remove(undo); | |||||
} else { | |||||
JX.DOM.hide(diff); | |||||
JX.DOM.appendContent(diff.parentNode, undo); | |||||
} | |||||
JX.Stratcom.invoke('resize'); | |||||
}, | |||||
_getUndoNode: function() { | |||||
if (!this._undoNode) { | |||||
var pht = this.getChangesetList().getTranslations(); | |||||
var link_attributes = { | |||||
href: '#' | |||||
}; | |||||
var undo_link = JX.$N('a', link_attributes, pht('Show Content')); | |||||
var onundo = JX.bind(this, this._onundo); | |||||
JX.DOM.listen(undo_link, 'click', null, onundo); | |||||
var node_attributes = { | |||||
className: 'differential-collapse-undo' | |||||
}; | |||||
var node_content = [ | |||||
pht('This file content has been collapsed.'), | |||||
' ', | |||||
undo_link | |||||
]; | |||||
var undo_node = JX.$N('div', node_attributes, node_content); | |||||
this._undoNode = undo_node; | |||||
} | } | ||||
return this._undoNode; | |||||
}, | |||||
_onundo: function(e) { | |||||
e.kill(); | |||||
this.toggleVisibility(); | |||||
} | |||||
}, | }, | ||||
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; | ||||
} | } | ||||
} | } | ||||
}); | }); |