| 13 |
} |
} |
| 14 |
out += '</div>'; |
out += '</div>'; |
| 15 |
|
|
| 16 |
// Attach events: |
/** |
| 17 |
|
* Attach events: |
| 18 |
|
*/ |
| 19 |
// Button clicks |
// Button clicks |
| 20 |
$('label[@for="' + settings.attachTo +'"]').before(out); |
$('label[@for="' + settings.attachTo +'"]').before(out); |
| 21 |
$('.bbcode_wysiwyg input').click(function() { |
$('.bbcode_wysiwyg input').click(function() { |
| 22 |
Drupal.bbcodeClick($(this).attr('value')); |
Drupal.bbcodeClick($(this).attr('value')); |
| 23 |
}); |
}); |
| 24 |
// Keyup / Keydown |
// Keyup / Keydown - detect hotkeys |
| 25 |
$('#'+ settings.attachTo).keydown(function(event) { |
$('#'+ settings.attachTo).keydown(function(event) { |
| 26 |
Drupal.bbcodeKeydown(event.keyCode); |
Drupal.bbcodeKeydown(event.keyCode); |
| 27 |
}); |
}); |
| 28 |
$('#'+ settings.attachTo).keyup(function(event) { |
$('#'+ settings.attachTo).keyup(function(event) { |
| 29 |
Drupal.bbcodeKeyup(event.keyCode); |
Drupal.bbcodeKeyup(event.keyCode); |
| 30 |
}); |
}); |
| 31 |
|
// Mouseup - store current quoted user |
| 32 |
|
$('.node').mouseup(function(event) { |
| 33 |
|
BBC_SEL_TEXT = Drupal.bbcodeGetDomSelection(); |
| 34 |
|
var node = $(event.target).parents('.node')[0]; |
| 35 |
|
if (BBC_SEL_TEXT) { |
| 36 |
|
BBC_SEL_USER = $('.bbcode-username', node).text(); |
| 37 |
|
} |
| 38 |
|
else { |
| 39 |
|
BBC_SEL_USER = ''; |
| 40 |
|
} |
| 41 |
|
}); |
| 42 |
$('.comment').mouseup(function(event) { |
$('.comment').mouseup(function(event) { |
| 43 |
var selection = Drupal.bbcodeGetDomSelection(); |
BBC_SEL_TEXT = Drupal.bbcodeGetDomSelection(); |
| 44 |
if (selection) { |
var comment = $(event.target).parents('.comment')[0]; |
| 45 |
BBC_SEL_USER = $('.bbcode-username', event.currentTarget).text(); |
if (BBC_SEL_TEXT) { |
| 46 |
BBC_SEL_TEXT = selection; |
BBC_SEL_USER = $('.bbcode-username', comment).text(); |
| 47 |
} |
} |
| 48 |
else { |
else { |
| 49 |
BBC_SEL_USER = ''; |
BBC_SEL_USER = ''; |
| 50 |
} |
} |
| 51 |
}) |
}); |
| 52 |
} |
} |
| 53 |
|
|
| 54 |
|
|
| 164 |
Drupal.bbcodeGetDomSelection = function() { |
Drupal.bbcodeGetDomSelection = function() { |
| 165 |
var txt = ''; |
var txt = ''; |
| 166 |
if (window.getSelection) { |
if (window.getSelection) { |
| 167 |
txt = window.getSelection(); |
var selection = window.getSelection(); |
| 168 |
|
txt = selection.toString(); |
| 169 |
} |
} |
| 170 |
else if (document.getSelection) { |
else if (document.getSelection) { |
| 171 |
txt = document.getSelection(); |
txt = document.getSelection(); |