Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffInline.js
Show First 20 Lines • Show All 410 Lines • ▼ Show 20 Lines | create: function(content_state) { | ||||
this.setLoading(true); | this.setLoading(true); | ||||
new JX.Request(uri, handler) | new JX.Request(uri, handler) | ||||
.setData(data) | .setData(data) | ||||
.send(); | .send(); | ||||
}, | }, | ||||
_getContentState: function() { | |||||
var state; | |||||
if (this._editRow) { | |||||
state = this._readFormState(this._editRow); | |||||
} else { | |||||
state = this._originalState; | |||||
} | |||||
return state; | |||||
}, | |||||
reply: function(with_quote) { | reply: function(with_quote) { | ||||
this._closeMenu(); | this._closeMenu(); | ||||
var content_state = this._newContentState(); | var content_state = this._newContentState(); | ||||
if (with_quote) { | if (with_quote) { | ||||
var text = this._getContentState().text; | var text = this._getActiveContentState().getTextForQuote(); | ||||
text = '> ' + text.replace(/\n/g, '\n> ') + '\n\n'; | |||||
content_state.text = text; | content_state.text = text; | ||||
} | } | ||||
var changeset = this.getChangeset(); | var changeset = this.getChangeset(); | ||||
return changeset.newInlineReply(this, content_state); | return changeset.newInlineReply(this, content_state); | ||||
}, | }, | ||||
edit: function(content_state, skip_focus) { | edit: function(content_state, skip_focus) { | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | _oncreateresponse: function(response) { | ||||
this._readInlineState(response.inline); | this._readInlineState(response.inline); | ||||
this._drawEditRows(rows); | this._drawEditRows(rows); | ||||
}, | }, | ||||
_readInlineState: function(state) { | _readInlineState: function(state) { | ||||
this._id = state.id; | this._id = state.id; | ||||
this._originalState = state.contentState; | this._originalState = state.contentState; | ||||
this._getActiveContentState().readWireFormat(state.contentState); | |||||
this._canSuggestEdit = state.canSuggestEdit; | this._canSuggestEdit = state.canSuggestEdit; | ||||
}, | }, | ||||
_ondeleteresponse: function() { | _ondeleteresponse: function() { | ||||
// If there's an existing "unedit" undo element, remove it. | // If there's an existing "unedit" undo element, remove it. | ||||
if (this._undoRow) { | if (this._undoRow) { | ||||
JX.DOM.remove(this._undoRow); | JX.DOM.remove(this._undoRow); | ||||
this._undoRow = null; | this._undoRow = null; | ||||
▲ Show 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | _onSuggestEdit: function(e) { | ||||
} | } | ||||
} | } | ||||
// Save the "hasSuggestion" part of the content state. | // Save the "hasSuggestion" part of the content state. | ||||
this.triggerDraft(); | this.triggerDraft(); | ||||
}, | }, | ||||
_getActiveContentState: function() { | _getActiveContentState: function() { | ||||
return this._activeContentState; | var state = this._activeContentState; | ||||
if (this._editRow) { | |||||
state.readForm(this._editRow); | |||||
} | |||||
return state; | |||||
}, | }, | ||||
setHasSuggestion: function(has_suggestion) { | setHasSuggestion: function(has_suggestion) { | ||||
var state = this._getActiveContentState(); | var state = this._getActiveContentState(); | ||||
state.setHasSuggestion(has_suggestion); | state.setHasSuggestion(has_suggestion); | ||||
var button = this._getSuggestionButton(); | var button = this._getSuggestionButton(); | ||||
var pht = this.getChangeset().getChangesetList().getTranslations(); | var pht = this.getChangeset().getChangesetList().getTranslations(); | ||||
Show All 12 Lines | setHasSuggestion: function(has_suggestion) { | ||||
} | } | ||||
}, | }, | ||||
getHasSuggestion: function() { | getHasSuggestion: function() { | ||||
return this._getActiveContentState().getHasSuggestion(); | return this._getActiveContentState().getHasSuggestion(); | ||||
}, | }, | ||||
save: function() { | save: function() { | ||||
var state = this._getActiveContentState(); | |||||
var handler = JX.bind(this, this._onsubmitresponse); | var handler = JX.bind(this, this._onsubmitresponse); | ||||
this.setLoading(true); | this.setLoading(true); | ||||
var uri = this._getInlineURI(); | var uri = this._getInlineURI(); | ||||
var data = this._newRequestData('save', this._getContentState()); | var data = this._newRequestData('save', state.getWireFormat()); | ||||
new JX.Request(uri, handler) | new JX.Request(uri, handler) | ||||
.setData(data) | .setData(data) | ||||
.send(); | .send(); | ||||
}, | }, | ||||
undo: function() { | undo: function() { | ||||
JX.DOM.remove(this._undoRow); | JX.DOM.remove(this._undoRow); | ||||
▲ Show 20 Lines • Show All 355 Lines • Show Last 20 Lines |