/[drupal]/contributions/sandbox/GurpartapSingh/modules/smileys/smileys.js
ViewVC logotype

Contents of /contributions/sandbox/GurpartapSingh/modules/smileys/smileys.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Thu Nov 9 08:58:09 2006 UTC (3 years ago) by Gurpartap
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/javascript
New smileys module for Drupal 5.x. Development commit.
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 }

  ViewVC Help
Powered by ViewVC 1.1.2