/[drupal]/contributions/modules/bbcode_wysiwyg/bbcode_wysiwyg.js
ViewVC logotype

Diff of /contributions/modules/bbcode_wysiwyg/bbcode_wysiwyg.js

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

revision 1.1.2.2, Fri Nov 16 17:59:56 2007 UTC revision 1.1.2.3, Mon Apr 14 18:40:02 2008 UTC
# Line 1  Line 1 
1  var BBC_CTRL = false;  var BBC_CTRL = false;
2  var BBC_SHFT = false;  var BBC_SHFT = false;
3    var BBC_SEL_TEXT = '';
4    var BBC_SEL_USER = '';
5    
6  Drupal.bbcodeAutoAttach = function() {  Drupal.bbcodeAutoAttach = function() {
7    var out = '', settings = Drupal.settings.bbcode_wysiwyg;    var out = '', settings = Drupal.settings.bbcode_wysiwyg;
# Line 10  Drupal.bbcodeAutoAttach = function() { Line 12  Drupal.bbcodeAutoAttach = function() {
12      }      }
13    }    }
14    out += '</div>';    out += '</div>';
15    
16      // Attach events:
17      // Button clicks
18    $('label[@for="' + settings.attachTo +'"]').before(out);    $('label[@for="' + settings.attachTo +'"]').before(out);
19    $('.bbcode_wysiwyg input').click(function() {    $('.bbcode_wysiwyg input').click(function() {
20      Drupal.bbcodeClick($(this).attr('value'));      Drupal.bbcodeClick($(this).attr('value'));
21    });    });
22      // Keyup / Keydown
23    $('#'+ settings.attachTo).keydown(function(event) {    $('#'+ settings.attachTo).keydown(function(event) {
24      Drupal.bbcodeKeydown(event.keyCode);      Drupal.bbcodeKeydown(event.keyCode);
25    });    });
26    $('#'+ settings.attachTo).keyup(function(event) {    $('#'+ settings.attachTo).keyup(function(event) {
27      Drupal.bbcodeKeyup(event.keyCode);      Drupal.bbcodeKeyup(event.keyCode);
28    });    });
29      $('.comment').mouseup(function(event) {
30        var selection = Drupal.bbcodeGetDomSelection();
31        if (selection) {
32          BBC_SEL_USER = $('.bbcode-username', event.currentTarget).text();
33          BBC_SEL_TEXT = selection;
34        }
35        else {
36          BBC_SEL_USER = '';
37        }
38      })
39  }  }
40    
41    
# Line 44  Drupal.bbcodeClick = function(button) { Line 60  Drupal.bbcodeClick = function(button) {
60    
61    // Quote    // Quote
62    if (button == 'quote') {    if (button == 'quote') {
63      before = '[quote=]';      before = '[quote='+ BBC_SEL_USER +']';
64        if (BBC_SEL_TEXT) {
65          before += BBC_SEL_TEXT;
66        }
67      after = '[/quote]';      after = '[/quote]';
68    }    }
69    
# Line 123  Drupal.bbcodeGetTextareaSelection = func Line 142  Drupal.bbcodeGetTextareaSelection = func
142    return text;    return text;
143  }  }
144    
145    Drupal.bbcodeQuoteLink = function(username, body) {
146      var area = $('#' + Drupal.settings.bbcode_wysiwyg.attachTo)[0];
147      Drupal.bbcodeInsertAtCursor(area, '[quote='+ username +']'+ body +'[/quote]');
148      area.focus();
149    }
150    
151    Drupal.bbcodeGetDomSelection = function() {
152      var txt = '';
153      if (window.getSelection) {
154        txt = window.getSelection();
155      }
156      else if (document.getSelection) {
157        txt = document.getSelection();
158      }
159      else if (document.selection) {
160        txt = document.selection.createRange().text;
161      }
162      return txt;
163    }
164    
165    
166  Drupal.bbcodeInsertAtCursor = function(field, value) {  Drupal.bbcodeInsertAtCursor = function(field, value) {
167    //MOZILLA/NETSCAPE support    //MOZILLA/NETSCAPE support

Legend:
Removed from v.1.1.2.2  
changed lines
  Added in v.1.1.2.3

  ViewVC Help
Powered by ViewVC 1.1.2