Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffChangeset.js
| Show All 16 Lines | JX.install('DiffChangeset', { | ||||
| construct : function(node) { | construct : function(node) { | ||||
| this._node = node; | this._node = node; | ||||
| var data = this._getNodeData(); | var data = this._getNodeData(); | ||||
| this._renderURI = data.renderURI; | this._renderURI = data.renderURI; | ||||
| this._ref = data.ref; | this._ref = data.ref; | ||||
| this._renderer = data.renderer; | |||||
| this._highlight = data.highlight; | |||||
| this._documentEngine = data.documentEngine; | |||||
| this._encoding = data.encoding; | |||||
| this._loaded = data.loaded; | this._loaded = data.loaded; | ||||
| this._treeNodeID = data.treeNodeID; | this._treeNodeID = data.treeNodeID; | ||||
| this._leftID = data.left; | this._leftID = data.left; | ||||
| this._rightID = data.right; | this._rightID = data.right; | ||||
| this._displayPath = JX.$H(data.displayPath); | this._displayPath = JX.$H(data.displayPath); | ||||
| this._icon = data.icon; | this._icon = data.icon; | ||||
| this._editorURI = data.editorURI; | this._editorURI = data.editorURI; | ||||
| this._editorConfigureURI = data.editorConfigureURI; | this._editorConfigureURI = data.editorConfigureURI; | ||||
| this._inlines = []; | this._inlines = []; | ||||
| if (data.changesetState) { | |||||
| this._loadChangesetState(data.changesetState); | |||||
| } | |||||
| }, | }, | ||||
| members: { | members: { | ||||
| _node: null, | _node: null, | ||||
| _loaded: false, | _loaded: false, | ||||
| _sequence: 0, | _sequence: 0, | ||||
| _stabilize: false, | _stabilize: false, | ||||
| _renderURI: null, | _renderURI: null, | ||||
| _ref: null, | _ref: null, | ||||
| _renderer: null, | _rendererKey: null, | ||||
| _highlight: null, | _highlight: null, | ||||
| _documentEngine: null, | _documentEngine: null, | ||||
| _encoding: null, | _characterEncoding: null, | ||||
| _undoTemplates: null, | _undoTemplates: null, | ||||
| _leftID: null, | _leftID: null, | ||||
| _rightID: null, | _rightID: null, | ||||
| _inlines: null, | _inlines: null, | ||||
| _visible: true, | _visible: true, | ||||
| ▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | members: { | ||||
| /** | /** | ||||
| * Reload the changeset content. | * Reload the changeset content. | ||||
| * | * | ||||
| * This method always issues a request, even if the content is already | * This method always issues a request, even if the content is already | ||||
| * loading. To load conditionally, use @{method:load}. | * loading. To load conditionally, use @{method:load}. | ||||
| * | * | ||||
| * @return this | * @return this | ||||
| */ | */ | ||||
| reload: function() { | reload: function(state) { | ||||
| this._loaded = true; | this._loaded = true; | ||||
| this._sequence++; | this._sequence++; | ||||
| var params = this._getViewParameters(); | var params = this._getViewParameters(state); | ||||
| var pht = this.getChangesetList().getTranslations(); | var pht = this.getChangesetList().getTranslations(); | ||||
| var workflow = new JX.Workflow(this._renderURI, params) | var workflow = new JX.Workflow(this._renderURI, params) | ||||
| .setHandler(JX.bind(this, this._onresponse, this._sequence)); | .setHandler(JX.bind(this, this._onresponse, this._sequence)); | ||||
| this._startContentWorkflow(workflow); | this._startContentWorkflow(workflow); | ||||
| JX.DOM.setContent( | JX.DOM.setContent( | ||||
| ▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | _moveRows: function(src, dst, before) { | ||||
| dst.appendChild(rows[ii]); | dst.appendChild(rows[ii]); | ||||
| } | } | ||||
| } | } | ||||
| }, | }, | ||||
| /** | /** | ||||
| * Get parameters which define the current rendering options. | * Get parameters which define the current rendering options. | ||||
| */ | */ | ||||
| _getViewParameters: function() { | _getViewParameters: function(state) { | ||||
| return { | var parameters = { | ||||
| ref: this._ref, | ref: this._ref, | ||||
| renderer: this.getRenderer() || '', | device: this._getDefaultDeviceRenderer() | ||||
| highlight: this._highlight || '', | |||||
| engine: this._documentEngine || '', | |||||
| encoding: this._encoding || '' | |||||
| }; | }; | ||||
| if (state) { | |||||
| JX.copy(parameters, state); | |||||
| } | |||||
| return parameters; | |||||
| }, | }, | ||||
| /** | /** | ||||
| * Get the active @{class:JX.Routable} for this changeset. | * Get the active @{class:JX.Routable} for this changeset. | ||||
| * | * | ||||
| * After issuing a request with @{method:load} or @{method:reload}, you | * After issuing a request with @{method:load} or @{method:reload}, you | ||||
| * can adjust routable settings (like priority) by querying the routable | * can adjust routable settings (like priority) by querying the routable | ||||
| * with this method. Note that there may not be a current routable. | * with this method. Note that there may not be a current routable. | ||||
| * | * | ||||
| * @return JX.Routable|null Active routable, if one exists. | * @return JX.Routable|null Active routable, if one exists. | ||||
| */ | */ | ||||
| getRoutable: function() { | getRoutable: function() { | ||||
| return JX.Router.getInstance().getRoutableByKey(this._getRoutableKey()); | return JX.Router.getInstance().getRoutableByKey(this._getRoutableKey()); | ||||
| }, | }, | ||||
| setRenderer: function(renderer) { | getRendererKey: function() { | ||||
| this._renderer = renderer; | return this._rendererKey; | ||||
| return this; | |||||
| }, | }, | ||||
| getRenderer: function() { | _getDefaultDeviceRenderer: function() { | ||||
| if (this._renderer !== null) { | |||||
| return this._renderer; | |||||
| } | |||||
| // NOTE: If you load the page at one device resolution and then resize to | // NOTE: If you load the page at one device resolution and then resize to | ||||
| // a different one we don't re-render the diffs, because it's a | // a different one we don't re-render the diffs, because it's a | ||||
| // complicated mess and you could lose inline comments, cursor positions, | // complicated mess and you could lose inline comments, cursor positions, | ||||
| // etc. | // etc. | ||||
| return (JX.Device.getDevice() == 'desktop') ? '2up' : '1up'; | return (JX.Device.getDevice() == 'desktop') ? '2up' : '1up'; | ||||
| }, | }, | ||||
| getUndoTemplates: function() { | getUndoTemplates: function() { | ||||
| return this._undoTemplates; | return this._undoTemplates; | ||||
| }, | }, | ||||
| setEncoding: function(encoding) { | getCharacterEncoding: function() { | ||||
| this._encoding = encoding; | return this._characterEncoding; | ||||
| return this; | |||||
| }, | |||||
| getEncoding: function() { | |||||
| return this._encoding; | |||||
| }, | |||||
| setHighlight: function(highlight) { | |||||
| this._highlight = highlight; | |||||
| return this; | |||||
| }, | }, | ||||
| getHighlight: function() { | getHighlight: function() { | ||||
| return this._highlight; | return this._highlight; | ||||
| }, | }, | ||||
| setDocumentEngine: function(engine) { | |||||
| this._documentEngine = engine; | |||||
| }, | |||||
| getDocumentEngine: function(engine) { | getDocumentEngine: function(engine) { | ||||
| return this._documentEngine; | return this._documentEngine; | ||||
| }, | }, | ||||
| getSelectableItems: function() { | getSelectableItems: function() { | ||||
| var items = []; | var items = []; | ||||
| items.push({ | items.push({ | ||||
| ▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | _onresponse: function(sequence, response) { | ||||
| } | } | ||||
| this._onchangesetresponse(response); | this._onchangesetresponse(response); | ||||
| }, | }, | ||||
| _onchangesetresponse: function(response) { | _onchangesetresponse: function(response) { | ||||
| // Code shared by autoload and context responses. | // Code shared by autoload and context responses. | ||||
| if (response.coverage) { | this._loadChangesetState(response); | ||||
| for (var k in response.coverage) { | |||||
| JX.Stratcom.invoke('differential-inline-comment-refresh'); | |||||
| this._rebuildAllInlines(); | |||||
| JX.Stratcom.invoke('resize'); | |||||
| }, | |||||
| _loadChangesetState: function(state) { | |||||
| if (state.coverage) { | |||||
| for (var k in state.coverage) { | |||||
| try { | try { | ||||
| JX.DOM.replace(JX.$(k), JX.$H(response.coverage[k])); | JX.DOM.replace(JX.$(k), JX.$H(state.coverage[k])); | ||||
| } catch (ignored) { | } catch (ignored) { | ||||
| // Not terribly important. | // Not terribly important. | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (response.undoTemplates) { | if (state.undoTemplates) { | ||||
| this._undoTemplates = response.undoTemplates; | this._undoTemplates = state.undoTemplates; | ||||
| } | } | ||||
| JX.Stratcom.invoke('differential-inline-comment-refresh'); | this._rendererKey = state.rendererKey; | ||||
| this._highlight = state.highlight; | |||||
| this._rebuildAllInlines(); | this._characterEncoding = state.characterEncoding; | ||||
| this._documentEngine = state.documentEngine; | |||||
| JX.Stratcom.invoke('resize'); | |||||
| }, | }, | ||||
| _getContentFrame: function() { | _getContentFrame: function() { | ||||
| return JX.DOM.find(this._node, 'div', 'changeset-view-content'); | return JX.DOM.find(this._node, 'div', 'changeset-view-content'); | ||||
| }, | }, | ||||
| _getRoutableKey: function() { | _getRoutableKey: function() { | ||||
| return 'changeset-view.' + this._ref + '.' + this._sequence; | return 'changeset-view.' + this._ref + '.' + this._sequence; | ||||
| ▲ Show 20 Lines • Show All 270 Lines • Show Last 20 Lines | |||||