Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffInline.js
| Show First 20 Lines • Show All 695 Lines • ▼ Show 20 Lines | _drawRows: function(rows, cursor, type) { | ||||
| // typing a comment immediately after a "new", "edit", or "reply" | // typing a comment immediately after a "new", "edit", or "reply" | ||||
| // action. | // action. | ||||
| // (When simulating an "edit" on page load, we don't do this.) | // (When simulating an "edit" on page load, we don't do this.) | ||||
| var textareas = JX.DOM.scry( | var textareas = JX.DOM.scry( | ||||
| row, | row, | ||||
| 'textarea', | 'textarea', | ||||
| 'differential-inline-comment-edit-textarea'); | 'inline-content-text'); | ||||
| if (textareas.length) { | if (textareas.length) { | ||||
| var area = textareas[0]; | var area = textareas[0]; | ||||
| area.focus(); | area.focus(); | ||||
| var length = area.value.length; | var length = area.value.length; | ||||
| JX.TextAreaUtils.setSelectionRange(area, length, length); | JX.TextAreaUtils.setSelectionRange(area, length, length); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | _onCancelResponse: function(response) { | ||||
| JX.DOM.remove(this._row); | JX.DOM.remove(this._row); | ||||
| this._row = null; | this._row = null; | ||||
| this._didUpdate(); | this._didUpdate(); | ||||
| } | } | ||||
| }, | }, | ||||
| _readFormState: function(row) { | _readFormState: function(row) { | ||||
| var textarea; | var state = this._newContentState(); | ||||
| var node; | |||||
| try { | try { | ||||
| textarea = JX.DOM.find( | node = JX.DOM.find(row, 'textarea', 'inline-content-text'); | ||||
| row, | state.text = node.value; | ||||
| 'textarea', | |||||
| 'differential-inline-comment-edit-textarea'); | |||||
| } catch (ex) { | } catch (ex) { | ||||
| return null; | // Ignore. | ||||
| } | } | ||||
| return { | try { | ||||
| text: textarea.value | node = JX.DOM.find(row, 'textarea', 'inline-content-suggestion'); | ||||
| }; | state.suggestionText = node.value; | ||||
| } catch (ex) { | |||||
| // Ignore. | |||||
| } | |||||
| return state; | |||||
| }, | }, | ||||
| _onsubmitresponse: function(response) { | _onsubmitresponse: function(response) { | ||||
| if (this._editRow) { | if (this._editRow) { | ||||
| JX.DOM.remove(this._editRow); | JX.DOM.remove(this._editRow); | ||||
| this._editRow = null; | this._editRow = null; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | |||||
| }, | }, | ||||
| _closeMenu: function() { | _closeMenu: function() { | ||||
| if (this._menu) { | if (this._menu) { | ||||
| this._menu.close(); | this._menu.close(); | ||||
| } | } | ||||
| }, | }, | ||||
| _isVoidContentState: function(state) { | _newContentState: function() { | ||||
| return !state.text.length; | return { | ||||
| text: '', | |||||
| suggestionText: '', | |||||
| hasSuggestion: true | |||||
| }; | |||||
| }, | }, | ||||
| _isSameContentState: function(u, v) { | _isVoidContentState: function(state) { | ||||
| return (u.text === v.text); | return (!state.text.length && !state.suggestionText.length); | ||||
| }, | }, | ||||
| _newContentState: function() { | _isSameContentState: function(u, v) { | ||||
| return { | return ( | ||||
| text: '' | (u.text === v.text) && | ||||
| }; | (u.suggestionText === v.suggestionText) && | ||||
| (u.hasSuggestion === v.hasSuggestion)); | |||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||