All pastes #237165 Raw Edit

kkaefer

public javascript v1 · immutable
·published 2006-11-04 11:28 UTC
rendered paste body
Drupal.smileysAutoAttach = function() {  $('img.smiley-hand').click(function(){    var smiley = ' ' + this.alt + ' ';    $('textarea#edit-body, textarea#edit-comment').each(function() {      if (document.selection) {        this.focus();        document.selection.createRange().text = smiley;      }       else if (this.selectionStart || this.selectionStart == '0') {        var cursorPos = this.selectionEnd + smiley.length;        this.value = this.value.substring(0, this.selectionStart) + smiley + this.value.substring(this.selectionEnd);        this.selectionStart = this.selectionEnd = cursorPos;      }      else {        this.value = this.value + smiley      }      this.focus();    });  });}if (Drupal.jsEnabled) {  $(document).ready(Drupal.smileysAutoAttach);}