backoffice: insert variable tag in last used textarea (#46097)
This commit is contained in:
parent
b6b343a53d
commit
72db95d069
|
@ -8,13 +8,19 @@ $(function() {
|
|||
$('h4.foldable.folded').next().hide();
|
||||
|
||||
/* insert variable code in textarea when clicking on them */
|
||||
var latest_textarea = null;
|
||||
if ($('textarea').length == 1) {
|
||||
latest_textarea = $('textarea');
|
||||
}
|
||||
$('textarea').on('focus', function() { latest_textarea = this; });
|
||||
$('#substvars td:nth-child(2)').css('cursor', 'pointer').click(function() {
|
||||
var current_val = $('textarea').val();
|
||||
position = $('textarea').get(0).selectionStart;
|
||||
if (latest_textarea === null) return true;
|
||||
var current_val = $(latest_textarea).val();
|
||||
position = $(latest_textarea).get(0).selectionStart;
|
||||
if (position >= 0) {
|
||||
var code = $(this).text();
|
||||
var new_val = current_val.substr(0, position) + code + current_val.substr(position);
|
||||
$('textarea').val(new_val);
|
||||
$(latest_textarea).val(new_val);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue