Projet

Général

Profil

Paste
Télécharger (1,67 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / privatemsg / privatemsg-alternatives.js @ 87dbc3bf

1

    
2
(function ($) {
3
  Drupal.behaviors.PrivatemsgAlternatives = {
4
    attach: function (context) {
5
      // Replace span with a link.
6
      $("span.privatemsg-recipient-alternative").each(function() {
7
        $(this).after(
8
          // Replace the span with a link, add href and class.
9
          $('<a>')
10
            .attr({'href' : '#'})
11
            .addClass('privatemsg-recipient-alternative')
12
            .text($(this).text())
13
            // Add a on click function.
14
            .click(function () {
15
              // Replace the value of the recipient field with the
16
              // previous content but replace the unclear recipient
17
              // with the one that user clicked on.
18
              $('#edit-recipient')
19
                .val(
20
                  $('#edit-recipient')
21
                    .val()
22
                    .replace(
23
                      // Get the original recipient string for this suggestion.
24
                      Drupal.settings.privatemsg_duplicates[$(this).text()],
25
                      $(this).text()
26
                ))
27

    
28
              // Add a new status message.
29
              $(this).closest('div.messages')
30
                .after('<div class="messages status"><h2 class="element-invisible">' + Drupal.t('Status message') + '</h2>' + Drupal.t('The recipient field has been updated. You may now send your message.') + '</div>');
31

    
32
              // Hide the error message. Hide the parent of the span, this is
33
              // either div if there is only a single message or the li.
34
              $(this).closest('span.privatemsg-alternative-description').parent().hide();
35
            }));
36
        // Remove the span.
37
        $(this).remove();
38
      })
39
    }
40
  }
41

    
42
})(jQuery);