| 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; |
| 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 |
|
|
| 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 |
|
|
| 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 |