Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffChangesetList.js
Show First 20 Lines • Show All 1,109 Lines • ▼ Show 20 Lines | _onselect: function(e) { | ||||
// The user definitely clicked an inline, so we're going to handle the | // The user definitely clicked an inline, so we're going to handle the | ||||
// event. | // event. | ||||
e.kill(); | e.kill(); | ||||
this.selectInline(inline); | this.selectInline(inline); | ||||
}, | }, | ||||
selectInline: function(inline) { | selectInline: function(inline, force, scroll) { | ||||
var selection = this._getSelectionState(); | var selection = this._getSelectionState(); | ||||
var item; | var item; | ||||
if (!force) { | |||||
// If the comment the user clicked is currently selected, deselect it. | // If the comment the user clicked is currently selected, deselect it. | ||||
// This makes it easy to undo things if you clicked by mistake. | // This makes it easy to undo things if you clicked by mistake. | ||||
if (selection.cursor !== null) { | if (selection.cursor !== null) { | ||||
item = selection.items[selection.cursor]; | item = selection.items[selection.cursor]; | ||||
if (item.target === inline) { | if (item.target === inline) { | ||||
this._setSelectionState(null, false); | this._setSelectionState(null, false); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
} | |||||
// Otherwise, select the item that the user clicked. This makes it | // Otherwise, select the item that the user clicked. This makes it | ||||
// easier to resume keyboard operations after using the mouse to do | // easier to resume keyboard operations after using the mouse to do | ||||
// something else. | // something else. | ||||
var items = selection.items; | var items = selection.items; | ||||
for (var ii = 0; ii < items.length; ii++) { | for (var ii = 0; ii < items.length; ii++) { | ||||
item = items[ii]; | item = items[ii]; | ||||
if (item.target === inline) { | if (item.target === inline) { | ||||
this._setSelectionState(item, false); | this._setSelectionState(item, scroll); | ||||
} | } | ||||
} | } | ||||
}, | }, | ||||
redrawPreview: function() { | redrawPreview: function() { | ||||
// TODO: This isn't the cleanest way to find the preview form, but | // TODO: This isn't the cleanest way to find the preview form, but | ||||
// rendering no longer has direct access to it. | // rendering no longer has direct access to it. | ||||
var forms = JX.DOM.scry(document.body, 'form', 'transaction-append'); | var forms = JX.DOM.scry(document.body, 'form', 'transaction-append'); | ||||
if (forms.length) { | if (forms.length) { | ||||
JX.DOM.invoke(forms[0], 'shouldRefresh'); | JX.DOM.invoke(forms[0], 'shouldRefresh'); | ||||
▲ Show 20 Lines • Show All 962 Lines • ▼ Show 20 Lines | _setupInlineCommentListeners: function() { | ||||
onreply); | onreply); | ||||
var ondraft = JX.bind(this, this._onInlineEvent, 'draft'); | var ondraft = JX.bind(this, this._onInlineEvent, 'draft'); | ||||
JX.Stratcom.listen( | JX.Stratcom.listen( | ||||
'keydown', | 'keydown', | ||||
['differential-inline-comment', 'tag:textarea'], | ['differential-inline-comment', 'tag:textarea'], | ||||
ondraft); | ondraft); | ||||
var on_preview_view = JX.bind(this, this._onPreviewEvent, 'view'); | |||||
JX.Stratcom.listen( | |||||
'click', | |||||
'differential-inline-preview-jump', | |||||
on_preview_view); | |||||
}, | |||||
_onPreviewEvent: function(action, e) { | |||||
if (this.isAsleep()) { | |||||
return; | |||||
} | |||||
var data = e.getNodeData('differential-inline-preview-jump'); | |||||
var inline = this.getInlineByID(data.inlineCommentID); | |||||
if (!inline) { | |||||
return; | |||||
} | |||||
e.kill(); | |||||
switch (action) { | |||||
case 'view': | |||||
this.selectInline(inline, true, true); | |||||
break; | |||||
} | |||||
}, | }, | ||||
_onInlineEvent: function(action, e) { | _onInlineEvent: function(action, e) { | ||||
if (this.isAsleep()) { | if (this.isAsleep()) { | ||||
return; | return; | ||||
} | } | ||||
if (action !== 'draft') { | if (action !== 'draft') { | ||||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |