]> git.mxchange.org Git - friendica.git/commitdiff
Make formatbar work
authorJonny Tischbein <jonny_tischbein@systemli.org>
Thu, 20 Sep 2018 15:20:57 +0000 (17:20 +0200)
committerJonny Tischbein <jonny_tischbein@systemli.org>
Thu, 20 Sep 2018 15:20:57 +0000 (17:20 +0200)
view/theme/frio/js/textedit.js
view/theme/frio/templates/jot.tpl

index 2079c20cdc40a12080da8546045253ecf25a42af..cc79ea938e11073bd687ff7ba8d46541da7b560b 100644 (file)
@@ -27,6 +27,22 @@ function insertFormatting(BBcode, id) {
        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) {
        $("#collapsed-comments-" + id).show()
index 839cba5837d094ffcf491d93c71ba3d1e49f8e61..f62da279693bd18beb8d8ae98c6497749f5006bb 100644 (file)
                                        </div>
 
                                        <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 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 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 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 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="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="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="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-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>