Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffInline.js
| Show All 26 Lines | members: { | ||||
| _isInvisible: false, | _isInvisible: false, | ||||
| _isLoading: false, | _isLoading: false, | ||||
| _changeset: null, | _changeset: null, | ||||
| _objective: null, | _objective: null, | ||||
| _isDraft: null, | _isDraft: null, | ||||
| _isFixed: null, | _isFixed: null, | ||||
| _isEditing: false, | |||||
| bindToRow: function(row) { | bindToRow: function(row) { | ||||
| this._row = row; | this._row = row; | ||||
| this._objective.setAnchor(this._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; | ||||
| ▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | setChangeset: function(changeset) { | ||||
| return this; | return this; | ||||
| }, | }, | ||||
| getChangeset: function() { | getChangeset: function() { | ||||
| return this._changeset; | return this._changeset; | ||||
| }, | }, | ||||
| setEditing: function(editing) { | |||||
| this._isEditing = editing; | |||||
| this.updateObjective(); | |||||
| return this; | |||||
| }, | |||||
| _onobjective: function() { | _onobjective: function() { | ||||
| this.getChangeset().getChangesetList().selectInline(this); | this.getChangeset().getChangesetList().selectInline(this); | ||||
| }, | }, | ||||
| updateObjective: function() { | updateObjective: function() { | ||||
| var objective = this._objective; | var objective = this._objective; | ||||
| if (this.isHidden() || this._isDeleted) { | if (this.isHidden() || this._isDeleted) { | ||||
| objective.hide(); | objective.hide(); | ||||
| return; | return; | ||||
| } | } | ||||
| var changeset = this.getChangeset(); | var changeset = this.getChangeset(); | ||||
| if (!changeset.isVisible()) { | if (!changeset.isVisible()) { | ||||
| objective.hide(); | objective.hide(); | ||||
| return; | return; | ||||
| } | } | ||||
| var pht = changeset.getChangesetList().getTranslations(); | |||||
| var icon = 'fa-comment'; | var icon = 'fa-comment'; | ||||
| var color = 'bluegrey'; | var color = 'bluegrey'; | ||||
| var tooltip = null; | |||||
| if (this._isDraft) { | if (this._isEditing) { | ||||
| icon = 'fa-star'; | |||||
| color = 'pink'; | |||||
| tooltip = pht('Editing Comment'); | |||||
| } else if (this._isDraft) { | |||||
| // This inline is an unsubmitted draft. | // This inline is an unsubmitted draft. | ||||
| icon = 'fa-pencil'; | icon = 'fa-pencil'; | ||||
| color = 'indigo'; | |||||
| } else if (this._isFixed) { | } else if (this._isFixed) { | ||||
| // This inline has been marked done. | // This inline has been marked done. | ||||
| icon = 'fa-check'; | icon = 'fa-check'; | ||||
| color = 'grey'; | color = 'grey'; | ||||
| } else if (this._isGhost) { | } else if (this._isGhost) { | ||||
| icon = 'fa-comment-o'; | icon = 'fa-comment-o'; | ||||
| color = 'grey'; | color = 'grey'; | ||||
| } | } | ||||
| objective | objective | ||||
| .setIcon(icon) | .setIcon(icon) | ||||
| .setColor(color) | .setColor(color) | ||||
| .setTooltip(tooltip) | |||||
| .show(); | .show(); | ||||
| }, | }, | ||||
| canReply: function() { | canReply: function() { | ||||
| if (!this._hasAction('reply')) { | if (!this._hasAction('reply')) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | _drawUndoRows: function(mode, cursor, text) { | ||||
| } else { | } else { | ||||
| template = templates.l; | template = templates.l; | ||||
| } | } | ||||
| template = JX.$H(template).getNode(); | template = JX.$H(template).getNode(); | ||||
| this._undoRow = this._drawRows(template, cursor, mode, text); | this._undoRow = this._drawRows(template, cursor, mode, text); | ||||
| }, | }, | ||||
| _drawContentRows: function(rows) { | |||||
| return this._drawRows(rows, null, 'content'); | |||||
| }, | |||||
| _drawEditRows: function(rows) { | _drawEditRows: function(rows) { | ||||
| this.setEditing(true); | |||||
| 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; | var anchor = cursor || this._row; | ||||
| Show All 32 Lines | _drawRows: function(rows, cursor, type, text) { | ||||
| JX.bind(this, this._onsubmit, row_meta))); | JX.bind(this, this._onsubmit, row_meta))); | ||||
| row_meta.listeners.push( | row_meta.listeners.push( | ||||
| JX.DOM.listen( | JX.DOM.listen( | ||||
| row, | row, | ||||
| 'click', | 'click', | ||||
| 'inline-edit-cancel', | 'inline-edit-cancel', | ||||
| JX.bind(this, this._oncancel, row_meta))); | JX.bind(this, this._oncancel, row_meta))); | ||||
| } else if (type == 'content') { | |||||
| // No special listeners for these rows. | |||||
| } else { | } else { | ||||
| row_meta.listeners.push( | row_meta.listeners.push( | ||||
| JX.DOM.listen( | JX.DOM.listen( | ||||
| row, | row, | ||||
| 'click', | 'click', | ||||
| 'differential-inline-comment-undo', | 'differential-inline-comment-undo', | ||||
| JX.bind(this, this._onundo, row_meta))); | JX.bind(this, this._onundo, row_meta))); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | _oncancel: function(row, e) { | ||||
| e.kill(); | e.kill(); | ||||
| 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.setEditing(false); | |||||
| this.setInvisible(false); | this.setInvisible(false); | ||||
| this._didUpdate(true); | this._didUpdate(true); | ||||
| }, | }, | ||||
| _readText: function(row) { | _readText: function(row) { | ||||
| var textarea; | var textarea; | ||||
| Show All 9 Lines | _readText: function(row) { | ||||
| return textarea.value; | return textarea.value; | ||||
| }, | }, | ||||
| _onsubmitresponse: function(row, response) { | _onsubmitresponse: function(row, response) { | ||||
| this._removeRow(row); | this._removeRow(row); | ||||
| this.setLoading(false); | this.setLoading(false); | ||||
| this.setInvisible(false); | this.setInvisible(false); | ||||
| this.setEditing(false); | |||||
| this._onupdate(response); | this._onupdate(response); | ||||
| }, | }, | ||||
| _onupdate: function(response) { | _onupdate: function(response) { | ||||
| var new_row; | var new_row; | ||||
| if (response.markup) { | if (response.markup) { | ||||
| new_row = this._drawEditRows(JX.$H(response.markup).getNode()).node; | new_row = this._drawContentRows(JX.$H(response.markup).getNode()).node; | ||||
| } | } | ||||
| // TODO: Save the old row so the action it's undo-able if it was a | // TODO: Save the old row so the action it's undo-able if it was a | ||||
| // delete. | // delete. | ||||
| var remove_old = true; | var remove_old = true; | ||||
| if (remove_old) { | if (remove_old) { | ||||
| JX.DOM.remove(this._row); | JX.DOM.remove(this._row); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines | |||||