1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
(function ($, Drupal) {
|
7
|
"use strict";
|
8
|
Drupal.behaviors.TokenInsertText = {
|
9
|
attach: function(context) {
|
10
|
function insert (e){
|
11
|
var $self = $(this);
|
12
|
e.preventDefault();
|
13
|
var token = $self.text();
|
14
|
var id = $self.closest('.token-insert-text-table').attr('id');
|
15
|
$('#' + Drupal.settings.token_insert.tables[id]).insertAtCursor(token);
|
16
|
}
|
17
|
function bindInsert(id) {
|
18
|
$(context).find("#" + key).find('.token-insert-table .token-key').once('token-insert-table', function() {
|
19
|
var newThis = $('<a href="javascript:void(0);" title="' + Drupal.t('Insert this token into your form') + '">' + $(this).html() + '</a>').click(insert);
|
20
|
$(this).html(newThis);
|
21
|
});
|
22
|
}
|
23
|
|
24
|
|
25
|
if (typeof(Drupal.settings.token_insert) !== 'undefined') {
|
26
|
for (var key in Drupal.settings.token_insert.tables) {
|
27
|
if (Drupal.settings.token_insert.tables.hasOwnProperty(key)) {
|
28
|
bindInsert(key, context);
|
29
|
}
|
30
|
}
|
31
|
}
|
32
|
}
|
33
|
};
|
34
|
})(jQuery, Drupal);
|