Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffInline.js
| Show All 23 Lines | members: { | ||||
| _originalText: null, | _originalText: null, | ||||
| _snippet: null, | _snippet: null, | ||||
| _isDeleted: false, | _isDeleted: false, | ||||
| _isInvisible: false, | _isInvisible: false, | ||||
| _isLoading: false, | _isLoading: false, | ||||
| _changeset: null, | _changeset: null, | ||||
| _objective: null, | |||||
| _isDraft: null, | _isDraft: null, | ||||
| _isFixed: null, | _isFixed: null, | ||||
| _isEditing: false, | _isEditing: false, | ||||
| _isNew: false, | _isNew: false, | ||||
| bindToRow: function(row) { | bindToRow: function(row) { | ||||
| this._row = row; | this._row = row; | ||||
| this._objective.setAnchor(this._row); | |||||
| var row_data = JX.Stratcom.getData(row); | var row_data = JX.Stratcom.getData(row); | ||||
| row_data.inline = this; | row_data.inline = this; | ||||
| this._hidden = row_data.hidden || false; | this._hidden = 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 | ||||
| // hacky. | // hacky. | ||||
| var comment = JX.DOM.find(row, 'div', 'differential-inline-comment'); | var comment = JX.DOM.find(row, 'div', 'differential-inline-comment'); | ||||
| Show All 25 Lines | bindToRow: function(row) { | ||||
| this._isGhost = data.isGhost; | this._isGhost = data.isGhost; | ||||
| this._changesetID = data.changesetID; | this._changesetID = data.changesetID; | ||||
| this._isNew = false; | this._isNew = false; | ||||
| this._snippet = data.snippet; | this._snippet = data.snippet; | ||||
| this.setInvisible(false); | this.setInvisible(false); | ||||
| this.updateObjective(); | |||||
| return this; | return this; | ||||
| }, | }, | ||||
| 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; | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | bindToReply: function(inline) { | ||||
| this.setInvisible(true); | this.setInvisible(true); | ||||
| return this; | return this; | ||||
| }, | }, | ||||
| setChangeset: function(changeset) { | setChangeset: function(changeset) { | ||||
| this._changeset = changeset; | this._changeset = changeset; | ||||
| var objectives = changeset.getChangesetList().getObjectives(); | |||||
| // Create this inline's objective, but don't show it yet. | |||||
| this._objective = objectives.newObjective() | |||||
| .setCallback(JX.bind(this, this._onobjective)) | |||||
| .hide(); | |||||
| return this; | return this; | ||||
| }, | }, | ||||
| getChangeset: function() { | getChangeset: function() { | ||||
| return this._changeset; | return this._changeset; | ||||
| }, | }, | ||||
| setEditing: function(editing) { | setEditing: function(editing) { | ||||
| this._isEditing = editing; | this._isEditing = editing; | ||||
| this.updateObjective(); | |||||
| return this; | return this; | ||||
| }, | }, | ||||
| _onobjective: function() { | |||||
| this.getChangeset().getChangesetList().selectInline(this); | |||||
| }, | |||||
| updateObjective: function() { | |||||
| var objective = this._objective; | |||||
| if (this.isHidden() || this._isDeleted) { | |||||
| objective.hide(); | |||||
| return; | |||||
| } | |||||
| // If this is a new comment which we aren't editing, don't show anything: | |||||
| // the use started a comment or reply, then cancelled it. | |||||
| if (this._isNew && !this._isEditing) { | |||||
| objective.hide(); | |||||
| return; | |||||
| } | |||||
| var changeset = this.getChangeset(); | |||||
| if (!changeset.isVisible()) { | |||||
| objective.hide(); | |||||
| return; | |||||
| } | |||||
| var pht = changeset.getChangesetList().getTranslations(); | |||||
| var icon = 'fa-comment'; | |||||
| var color = 'bluegrey'; | |||||
| var tooltip = this._snippet; | |||||
| var anchor = this._row; | |||||
| var should_stack = false; | |||||
| if (this._isEditing) { | |||||
| icon = 'fa-star'; | |||||
| color = 'pink'; | |||||
| tooltip = pht('Editing Comment'); | |||||
| // If we're editing, anchor to the row with the editor instead of the | |||||
| // actual comment row (which is invisible and can have a misleading | |||||
| // position). | |||||
| anchor = this._row.nextSibling; | |||||
| } else if (this._isDraft) { | |||||
| // This inline is an unsubmitted draft. | |||||
| icon = 'fa-pencil'; | |||||
| color = 'indigo'; | |||||
| } else if (this._isFixed) { | |||||
| // This inline has been marked done. | |||||
| icon = 'fa-check'; | |||||
| color = 'grey'; | |||||
| } else if (this._isGhost) { | |||||
| icon = 'fa-comment-o'; | |||||
| color = 'grey'; | |||||
| } else if (this._replyToCommentPHID) { | |||||
| icon = 'fa-reply'; | |||||
| should_stack = true; | |||||
| } | |||||
| if (changeset.getChangesetList().getSelectedInline() === this) { | |||||
| // TODO: Maybe add some other kind of effect here, since we're only | |||||
| // using color to show this? | |||||
| color = 'yellow'; | |||||
| } | |||||
| objective | |||||
| .setAnchor(anchor) | |||||
| .setIcon(icon) | |||||
| .setColor(color) | |||||
| .setTooltip(tooltip) | |||||
| .setShouldStack(should_stack) | |||||
| .show(); | |||||
| }, | |||||
| canReply: function() { | canReply: function() { | ||||
| if (!this._hasAction('reply')) { | if (!this._hasAction('reply')) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return true; | return true; | ||||
| }, | }, | ||||
| Show All 34 Lines | _newRow: function() { | ||||
| var attributes = { | var attributes = { | ||||
| sigil: 'inline-row' | sigil: 'inline-row' | ||||
| }; | }; | ||||
| var row = JX.$N('tr', attributes); | var row = JX.$N('tr', attributes); | ||||
| JX.Stratcom.getData(row).inline = this; | JX.Stratcom.getData(row).inline = this; | ||||
| this._row = row; | this._row = row; | ||||
| this._objective.setAnchor(this._row); | |||||
| this._id = null; | this._id = null; | ||||
| this._phid = null; | this._phid = null; | ||||
| this._hidden = false; | this._hidden = false; | ||||
| this._originalText = null; | this._originalText = null; | ||||
| return row; | return row; | ||||
| ▲ Show 20 Lines • Show All 426 Lines • ▼ Show 20 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.updateObjective(); | |||||
| this.getChangeset().getChangesetList().redrawCursor(); | this.getChangeset().getChangesetList().redrawCursor(); | ||||
| this.getChangeset().getChangesetList().resetHover(); | this.getChangeset().getChangesetList().resetHover(); | ||||
| // Emit a resize event so that UI elements like the keyboard 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'); | ||||
| }, | }, | ||||
| Show All 24 Lines | |||||