Newer
Older
Sascha Grossenbacher
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// $Id$
Drupal.behaviors.PrivatemsgAlternatives = function (context) {
// Replace span with a link.
$("span.privatemsg-recipient-alternative").each(function() {
$(this).after(
// Replace the span with a link, add href and class.
$('<a>')
.attr({'href' : '#'})
.addClass('privatemsg-recipient-alternative')
.text($(this).text())
// Add a on click function.
.click(function () {
// Replace the value of the recipient field with the
// previous content but replace the unclear recipient
// with the one that user clicked on.
$('#edit-recipient')
.val(
$('#edit-recipient')
.val()
.replace(
// Get the original recipient string for this suggestion.
Drupal.settings.privatemsg_duplicates[$(this).text()],
$(this).text()
))
// Add a new status message.
$(this).parents('div.messages')
.after('<div class="messages status">' + Drupal.t('The recipient field has been updated. You may now send your message.') + '</div>');
// Hide the error message. Hide the parent of the span, this is
// either div if there is only a single message or the li.
$(this).parents('.privatemsg-alternative-description').parent().hide();
}));
// Remove the span.
$(this).remove();
})
}