diff options
Diffstat (limited to 'view')
-rw-r--r-- | view/js/main.js | 36 | ||||
-rw-r--r-- | view/tpl/comment_item.tpl | 22 | ||||
-rw-r--r-- | view/tpl/jot-header.tpl | 47 |
3 files changed, 53 insertions, 52 deletions
diff --git a/view/js/main.js b/view/js/main.js index cfdd82315..43f0333ed 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1729,42 +1729,6 @@ function loadText(textRegion,data) { $(textRegion).val(currentText + data); } -function addeditortext(data) { - if(plaintext == 'none') { - var currentText = $("#profile-jot-text").val(); - $("#profile-jot-text").val(currentText + data); - } -} - -// Add text to active comment region if set, otherwise add to main editor -function addActiveEditorText(data) { - if (activeCommentID) { - const textarea = document.getElementById('comment-edit-text-' + activeCommentID); - - if (textarea) { - let currentText = textarea.value; - - // Clear the textarea if it matches the active comment text - if (currentText === activeCommentText) { - currentText = ''; - } - - textarea.classList.add('expanded'); - openMenu('comment-tools-' + activeCommentID); - textarea.value = currentText + data; - textarea.focus(); - textarea.click(); - preview_comment(activeCommentID); - } - - // Reset activeCommentID after processing - activeCommentID = 0; - } else { - addeditortext(data); - preview_post(); - } -} - function makeid(length) { var result = ''; var characters = 'abcdef0123456789'; diff --git a/view/tpl/comment_item.tpl b/view/tpl/comment_item.tpl index 0a59f8831..6b7e163eb 100644 --- a/view/tpl/comment_item.tpl +++ b/view/tpl/comment_item.tpl @@ -22,41 +22,41 @@ <div id="comment-tools-{{$id}}" class="pt-2 comment-tools"> <div id="comment-edit-bb-{{$id}}" class="btn-toolbar float-start"> <div class="btn-group me-2"> - <button class="btn btn-outline-secondary btn-sm border-0" title="{{$edbold}}" onclick="insertbbcomment('{{$comment}}','b', {{$id}}); return false;"> + <button type="button" class="btn btn-outline-secondary btn-sm border-0" title="{{$edbold}}" onclick="insertbbcomment('{{$comment}}','b', {{$id}});"> <i class="bi bi-type-bold comment-icon"></i> </button> - <button class="btn btn-outline-secondary btn-sm border-0" title="{{$editalic}}" onclick="insertbbcomment('{{$comment}}','i', {{$id}}); return false;"> + <button type="button" class="btn btn-outline-secondary btn-sm border-0" title="{{$editalic}}" onclick="insertbbcomment('{{$comment}}','i', {{$id}});"> <i class="bi bi-type-italic comment-icon"></i> </button> - <button class="btn btn-outline-secondary btn-sm border-0" title="{{$eduline}}" onclick="insertbbcomment('{{$comment}}','u', {{$id}}); return false;"> + <button type="button" class="btn btn-outline-secondary btn-sm border-0" title="{{$eduline}}" onclick="insertbbcomment('{{$comment}}','u', {{$id}});"> <i class="bi bi-type-underline comment-icon"></i> </button> - <button class="btn btn-outline-secondary btn-sm border-0" title="{{$edquote}}" onclick="insertbbcomment('{{$comment}}','quote', {{$id}}); return false;"> + <button type="button" class="btn btn-outline-secondary btn-sm border-0" title="{{$edquote}}" onclick="insertbbcomment('{{$comment}}','quote', {{$id}});"> <i class="bi bi-quote comment-icon"></i> </button> - <button class="btn btn-outline-secondary btn-sm border-0" title="{{$edcode}}" onclick="insertbbcomment('{{$comment}}','code', {{$id}}); return false;"> + <button type="button" class="btn btn-outline-secondary btn-sm border-0" title="{{$edcode}}" onclick="insertbbcomment('{{$comment}}','code', {{$id}});"> <i class="bi bi-code comment-icon"></i> </button> - <button class="btn btn-outline-secondary btn-sm border-0" title="{{$edhighlighter}}" onclick="insertbbcomment('{{$comment}}','mark', {{$id}}); return false;"> + <button type="button" class="btn btn-outline-secondary btn-sm border-0" title="{{$edhighlighter}}" onclick="insertbbcomment('{{$comment}}','mark', {{$id}});"> <i class="bi bi-highlighter comment-icon"></i> </button> </div> <div class="btn-group me-2"> {{if $can_upload}} - <button class="btn btn-outline-secondary btn-sm border-0" title="{{$edatt}}" onclick="insertCommentAttach('{{$comment}}', {{$id}}); return false;"> + <button type="button" class="btn btn-outline-secondary btn-sm border-0" title="{{$edatt}}" onclick="insertCommentAttach('{{$comment}}', {{$id}});"> <i class="bi bi-paperclip comment-icon"></i> </button> - <button title="{{$edimg}}" class="btn btn-outline-secondary btn-sm border-0" onclick="insertCommentEmbed('{{$comment}}', {{$id}}); return false;"> + <button type="button" title="{{$edimg}}" class="btn btn-outline-secondary btn-sm border-0" onclick="insertCommentEmbed('{{$comment}}', {{$id}});"> <i class="bi bi-file-image comment-icon"></i> </button> {{/if}} - <button class="btn btn-outline-secondary btn-sm border-0" title="{{$edurl}}" onclick="insertCommentURL('{{$comment}}',{{$id}}); return false;"> + <button type="button" class="btn btn-outline-secondary btn-sm border-0" title="{{$edurl}}" onclick="insertCommentURL('{{$comment}}',{{$id}});"> <i class="bi bi-link-45deg comment-icon"></i> </button> </div> {{if $feature_encrypt}} <div class="btn-group me-2"> - <button class="btn btn-outline-secondary btn-sm border-0" title="{{$encrypt}}" onclick="sodium_encrypt('#comment-edit-text-' + '{{$id}}'); return false;"> + <button type="button" class="btn btn-outline-secondary btn-sm border-0" title="{{$encrypt}}" onclick="sodium_encrypt('#comment-edit-text-' + '{{$id}}');"> <i class="bi bi-key comment-icon"></i> </button> </div> @@ -65,7 +65,7 @@ </div> <div class="btn-group float-end" id="comment-edit-submit-wrapper-{{$id}}"> {{if $preview}} - <button id="comment-edit-presubmit-{{$id}}" class="btn btn-outline-secondary btn-sm" onclick="preview_comment({{$id}}); return false;" title="{{$preview}}"> + <button type="button" id="comment-edit-presubmit-{{$id}}" class="btn btn-outline-secondary btn-sm" onclick="preview_comment({{$id}});" title="{{$preview}}"> <i class="bi bi-eye comment-icon" ></i> </button> {{/if}} diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index 399b9e27b..c84a9c1e2 100644 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -47,8 +47,8 @@ function enableOnUser(){ <script src="vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js"></script> <script> -var activeCommentID = 0; -var activeCommentText = ''; + var activeCommentID = 0; + var activeCommentText = ''; $(document).ready(function() { @@ -418,8 +418,14 @@ var activeCommentText = ''; modalBodyAlbumDialog.replaceWith(modalBodyAlbumDialog.cloneNode(true)); // This effectively removes all event listeners // Show the modal - const modal = new bootstrap.Modal(document.getElementById('embedPhotoModal')); + const modalEl = document.getElementById('embedPhotoModal'); + const modal = new bootstrap.Modal(modalEl); modal.show(); + + // Reset activeCommentID when the modal is closed + modalEl.addEventListener('hide.bs.modal', event => { + activeCommentID = 0; + }); }; const choosePhotoFromAlbum = (album) => { @@ -487,7 +493,6 @@ var activeCommentText = ''; }); }; - const getPhotoAlbumList = () => { fetch('embedphotos/albumlist', { method: 'POST', @@ -520,8 +525,40 @@ var activeCommentText = ''; }); }; + function addeditortext(data) { + if(plaintext == 'none') { + var currentText = $("#profile-jot-text").val(); + $("#profile-jot-text").val(currentText + data); + } + } + + // Add text to active comment region if set, otherwise add to main editor + function addActiveEditorText(data) { + if (activeCommentID) { + const textarea = document.getElementById('comment-edit-text-' + activeCommentID); + + if (textarea) { + let currentText = textarea.value; + + // Clear the textarea if it matches the active comment text + if (currentText === activeCommentText) { + currentText = ''; + } + + textarea.classList.add('expanded'); + openMenu('comment-tools-' + activeCommentID); + textarea.value = currentText + data; + textarea.focus(); + textarea.click(); + preview_comment(activeCommentID); + } + } else { + addeditortext(data); + preview_post(); + } + } + - // // initialize drag-drop function DragDropUploadInit() { |