Projet

Général

Profil

Paste
Télécharger (672 octets) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / token_insert / token_insert_text / token_insert_text.js @ 74f6bef0

1

    
2
/**
3
 * Behavior to add "Insert" buttons.
4
 */
5
(function ($) {
6
Drupal.behaviors.TokenInsertText = {
7
  attach: function(context) {
8
    // Add the click handler to the insert button.
9
    if(!(typeof(Drupal.settings.token_insert) == 'undefined')){
10
      for(var key in Drupal.settings.token_insert.buttons){
11
        $("#" + key, context).click(insert);
12
      }
13
    }
14

    
15
    function insert() {
16
      var field = $(this).attr('id');
17
      var selectbox = field.replace('button', 'select');
18
      var content = '[' + $('#' + selectbox ).val() + ']';
19
      $('#' + Drupal.settings.token_insert.buttons[field]).insertAtCursor(content);
20
      return false;
21
    }
22
  }
23
};
24
})(jQuery);
25