| 1 |
// $Id: smileys.js,v 1.0 2006/11/04 19:51:35 Gurpartap Exp $
|
| 2 |
|
| 3 |
/* Filename: smileys.js
|
| 4 |
* jQuery Smileys Code for Drupal smileys module.
|
| 5 |
* License: GPL (Read LICENSE.txt for more information).
|
| 6 |
* Copyright, authors.
|
| 7 |
*/
|
| 8 |
|
| 9 |
Drupal.smileysAutoAttach = function() {
|
| 10 |
$('img.smiley-class').click(function(){
|
| 11 |
var smiley = ' ' + this.alt + ' ';
|
| 12 |
$('textarea#edit-body, textarea#edit-comment').each(function() {
|
| 13 |
if (document.selection) {
|
| 14 |
this.focus();
|
| 15 |
document.selection.createRange().text = smiley;
|
| 16 |
}
|
| 17 |
else if (this.selectionStart || this.selectionStart == '0') {
|
| 18 |
var cursorPos = this.selectionEnd + smiley.length;
|
| 19 |
this.value = this.value.substring(0, this.selectionStart) + smiley + this.value.substring(this.selectionEnd);
|
| 20 |
this.selectionStart = this.selectionEnd = cursorPos;
|
| 21 |
}
|
| 22 |
else {
|
| 23 |
this.value = this.value + smiley
|
| 24 |
}
|
| 25 |
this.focus();
|
| 26 |
});
|
| 27 |
});
|
| 28 |
}
|
| 29 |
|
| 30 |
if (Drupal.jsEnabled) {
|
| 31 |
$(document).ready(Drupal.smileysAutoAttach);
|
| 32 |
}
|