вот че намутил ))
if ($(".mytextarea").length) {
$(".mytextarea").wrap("<div class='wrasp_t'></div>");
$(".mytextarea").before(
'<ul class="redactor_toolbar">' +
'<li><a href="javascript:;" data-id="b" class="redactor_bold"></a></li>' +
'<li><a href="javascript:;" class="redactor_underlined"></a></li>' +
'<li><a href="javascript:;" class="redactor_italic"></a></li>' +
'<li><a href="javascript:;" class="redactor_image"></a></li>' +
'<li><a href="javascript:;" class="redactor_link"></a></li>' +
'<li><a href="javascript:;" class="redactor_video"></a></li>' +
'</ul>'
);
}
$(".form .redactor_toolbar li a").click(function(e) {
var myKey = $(this).attr('data-id');
console.log(this.parentNode.parentNode.parentNode.children[1]);
var allCodes = {
b: {Open: '[b]', Close: '[/b]'},
u: {Open: '[u]', Close: '[/u]'},
i: {Open: '[i]', Close: '[/i]'},
php: {Open: '[php]', Close: '[/php]'},
img: {Open: '[img]', Close: '[/img]'}
};
var myField = this.parentNode.parentNode.parentNode.children[1];
var myValue = allCodes[myKey].Open + allCodes[myKey].Close;
if (document.selection) {
myField.focus();
document.selection.createRange().text = myValue;
}
else if (myField.selectionStart || myField.selectionStart == '0') {
var position = myField.selectionStart;
myField.value = myField.value.substring(0,myField.selectionStart) + myValue + myField.value.substring(myField.selectionEnd,myField.value.length);
myField.selectionStart = myField.selectionEnd = position + allCodes[myKey].Open.length;
} else {
myField.value += myValue;
}
myField.focus();
});