X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=view%2Ftheme%2Fquattro%2Fjs%2Fquattro.js;h=9ef66e220e42b4139e5cf2cb3668f3583b94d165;hb=187a81f159c26faa0b135a38a655de019f99d337;hp=259874a299d4fb634852ead2c2fc19dc221bf90b;hpb=9ab5bfb5074ddba22777c3b043bb539a473288a5;p=friendica.git diff --git a/view/theme/quattro/js/quattro.js b/view/theme/quattro/js/quattro.js index 259874a299..9ef66e220e 100644 --- a/view/theme/quattro/js/quattro.js +++ b/view/theme/quattro/js/quattro.js @@ -59,33 +59,33 @@ $(document).ready(function(){ }); }); -function insertFormatting(comment,BBcode,id) { - - var tmpStr = $("#comment-edit-text-" + id).val(); - if(tmpStr == comment) { - tmpStr = ""; - $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); - $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); - openMenu("comment-edit-submit-wrapper-" + id); - $("#comment-edit-text-" + id).val(tmpStr); - } +function insertFormatting(BBcode, id) { + var tmpStr = $("#comment-edit-text-" + id).val(); + if (tmpStr == "") { + $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); + $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); + openMenu("comment-edit-submit-wrapper-" + id); + } textarea = document.getElementById("comment-edit-text-" +id); if (document.selection) { textarea.focus(); selected = document.selection.createRange(); - if (BBcode == "url"){ + if (BBcode == "url") { selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]"; - } else - selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; + } else { + selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; + } } else if (textarea.selectionStart || textarea.selectionStart == "0") { var start = textarea.selectionStart; var end = textarea.selectionEnd; - if (BBcode == "url"){ + if (BBcode == "url") { textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); - } else - textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); + } else { + textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); + } } + return true; }