Skip to content

Commit d60ce00

Browse files
committed
Automatically show the ident for the in-reply-to message id on loading
1 parent 51b82f3 commit d60ce00

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

app/views/fragments/sendTabContent.scala.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@
8181
empty: '<div class="empty-message">Unable to find any Messages that match that Id</div>',
8282
suggestion: Handlebars.compile(jQuery("#entry-template").html())
8383
}
84-
});
85-
inReplyToFieldContainer.find(".input-group .typeahead").bind('typeahead:select', function (ev, suggestion) {
84+
}, function (suggestion) {
8685
jQuery("#@mailType.slug-subject-prefix input").changeVal(suggestion.suggestsPrefix);
8786
});
8887
});

public/javascript/messageIdPicker.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(function ( jQ ) {
22

3-
jQ.fn.messageIdPicker = function(options, datasets) {
3+
jQ.fn.messageIdPicker = function(options, datasets, onSelect) {
44
return this.each(function(index, elem) {
55
var inputGroup = jQ(elem).find(".input-group");
66
var messageIdent = jQ(elem).find(".message-ident");
@@ -21,12 +21,22 @@
2121
input.bind('typeahead:render', function () {
2222
inputGroup.find("time.timeago").timeago();
2323
});
24-
input.bind('typeahead:select', function (ev, suggestion) {
24+
var showIdent = function (suggestion) {
2525
messageIdentContent.html(suggestionTemplate(suggestion));
2626
messageIdentContent.find("time.timeago").timeago();
2727
inputGroup.hide();
2828
messageIdent.show();
29-
});
29+
onSelect(suggestion);
30+
};
31+
input.bind('typeahead:select', function (ev, suggestion) { showIdent(suggestion) });
32+
33+
var initialMessageId = input.val();
34+
if (initialMessageId !== "") {
35+
function showIdentIfSingleResult(datums) {
36+
if (datums.length == 1) { showIdent(datums[0]); }
37+
}
38+
datasets.source(initialMessageId, showIdentIfSingleResult, showIdentIfSingleResult);
39+
}
3040

3141
input.typeahead(options, datasets);
3242
});

0 commit comments

Comments
 (0)