Make formatbar work

This commit is contained in:
Jonny Tischbein 2018-09-20 17:20:57 +02:00
parent f590d31b4b
commit 9bc6238b59
2 changed files with 20 additions and 5 deletions

View file

@ -27,6 +27,22 @@ function insertFormatting(BBcode, id) {
return true; return true;
} }
function insertFormattingToPost(BBcode) {
textarea = document.getElementById("#profile-jot-text");
if (document.selection) {
textarea.focus();
selected = document.selection.createRange();
selected.text = "[" + BBcode + "]" + selected.text + "[/" + BBcode + "]";
} else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart;
var end = textarea.selectionEnd;
textarea.value = textarea.value.substring(0, start) + "[" + BBcode + "]" + textarea.value.substring(start, end) + "[/" + BBcode + "]" + textarea.value.substring(end, textarea.value.length);
}
$(textarea).trigger('change');
return true;
}
function showThread(id) { function showThread(id) {
$("#collapsed-comments-" + id).show() $("#collapsed-comments-" + id).show()

View file

@ -93,11 +93,10 @@
</div> </div>
<ul id="profile-jot-submit-wrapper" class="jothidden nav nav-pills"> <ul id="profile-jot-submit-wrapper" class="jothidden nav nav-pills">
<li role="presentation"><button type="button" class="btn-link icon underline" style="cursor: pointer;" aria-label="{{$eduline}}" title="{{$eduline}}" onclick="insertFormatting('u',{{$id}});"><i class="fa fa-underline"></i></button></li> <li role="presentation"><button type="button" class="btn-link icon underline" style="cursor: pointer;" aria-label="{{$eduline}}" title="{{$eduline}}" onclick="insertFormattingToPost('u');"><i class="fa fa-underline"></i></button></li>
<li role="presentation"><button type="button" class="btn-link icon italic" style="cursor: pointer;" aria-label="{{$editalic}}" title="{{$editalic}}" onclick="insertFormatting('i',{{$id}});"><i class="fa fa-italic"></i></button></li> <li role="presentation"><button type="button" class="btn-link icon italic" style="cursor: pointer;" aria-label="{{$editalic}}" title="{{$editalic}}" onclick="insertFormattingToPost('i');"><i class="fa fa-italic"></i></button></li>
<li role="presentation"><button type="button" class="btn-link icon bold" style="cursor: pointer;" aria-label="{{$edbold}}" title="{{$edbold}}" onclick="insertFormatting('b',{{$id}});"><i class="fa fa-bold"></i></button></li> <li role="presentation"><button type="button" class="btn-link icon bold" style="cursor: pointer;" aria-label="{{$edbold}}" title="{{$edbold}}" onclick="insertFormattingToPost('b');"><i class="fa fa-bold"></i></button></li>
<li role="presentation"><button type="button" class="btn-link icon quote" style="cursor: pointer;" aria-label="{{$edquote}}" title="{{$edquote}}" onclick="insertFormatting('quote',{{$id}});"><i class="fa fa-quote-left"></i></button></li> <li role="presentation"><button type="button" class="btn-link icon quote" style="cursor: pointer;" aria-label="{{$edquote}}" title="{{$edquote}}" onclick="insertFormattingToPost('quote');"><i class="fa fa-quote-left"></i></button></li>
<li role="presentation"><button type="button" class="btn-link" id="profile-link" ondragenter="return linkdropper(event);" ondragover="return linkdropper(event);" ondrop="linkdrop(event);" onclick="jotGetLink();" title="{{$weblink}}"><i class="fa fa-link"></i></button></li> <li role="presentation"><button type="button" class="btn-link" id="profile-link" ondragenter="return linkdropper(event);" ondragover="return linkdropper(event);" ondrop="linkdrop(event);" onclick="jotGetLink();" title="{{$weblink}}"><i class="fa fa-link"></i></button></li>
<li role="presentation"><button type="button" class="btn-link" id="profile-video" onclick="jotVideoURL();" title="{{$video}}"><i class="fa fa-film" aria-hidden="true"></i></button></li> <li role="presentation"><button type="button" class="btn-link" id="profile-video" onclick="jotVideoURL();" title="{{$video}}"><i class="fa fa-film" aria-hidden="true"></i></button></li>
<li role="presentation"><button type="button" class="btn-link" id="profile-audio" onclick="jotAudioURL();" title="{{$audio}}"><i class="fa fa-music" aria-hidden="true"></i></button></li> <li role="presentation"><button type="button" class="btn-link" id="profile-audio" onclick="jotAudioURL();" title="{{$audio}}"><i class="fa fa-music" aria-hidden="true"></i></button></li>