[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/token/ -> token.js (source)

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


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7