source: sipes/modules_contrib/token/token.js @ 6e81fb4

stableversion-3.0
Last change on this file since 6e81fb4 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100755
File size: 1.6 KB
Línea 
1
2(function ($) {
3
4Drupal.behaviors.tokenTree = function() {
5  $('table.token-tree').each(function() {
6    $(this).treeTable();
7  });
8};
9
10Drupal.behaviors.tokenInsert = function() {
11  // Keep track of which textfield was last selected/focused.
12  $('textarea, input[type="text"]').focus(function() {
13    Drupal.settings.tokenFocusedField = this;
14  });
15
16  $('.token-click-insert .token-key').each(function() {
17    var newThis = $('<a href="javascript:void(0);" title="' + Drupal.t('Insert this token into your form') + '">' + $(this).html() + '</a>').click(function(){
18      if (typeof Drupal.settings.tokenFocusedField == 'undefined') {
19        alert(Drupal.t('First click a text field to insert your tokens into.'));
20      }
21      else {
22        var myField = Drupal.settings.tokenFocusedField;
23        var myValue = $(this).text();
24
25        //IE support
26        if (document.selection) {
27          myField.focus();
28          sel = document.selection.createRange();
29          sel.text = myValue;
30        }
31
32        //MOZILLA/NETSCAPE support
33        else if (myField.selectionStart || myField.selectionStart == '0') {
34          var startPos = myField.selectionStart;
35          var endPos = myField.selectionEnd;
36          myField.value = myField.value.substring(0, startPos)
37                        + myValue
38                        + myField.value.substring(endPos, myField.value.length);
39        } else {
40          myField.value += myValue;
41        }
42
43        $('html,body').animate({scrollTop: $(myField).offset().top}, 500);
44      }
45      return false;
46    });
47    $(this).html(newThis);
48  });
49};
50
51})(jQuery);
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.