]> git.mxchange.org Git - friendica.git/blobdiff - js/main.js
filebrowser fixs, use it in comment textareas
[friendica.git] / js / main.js
index 239a875cb418896f00cbd86458cf322b3f9a84e3..d3cce33040a6d8fc53b0b635fbfa1eb3e19644ab 100644 (file)
                        e.tipTip({defaultPosition: pos, edgeOffset: 8});
                });*/
                
+               /* setup comment textarea buttons */
+               
+               $('[data-role="insert-formatting"]').on('click', function(e) {
+                       e.preventDefault();
+                       var o = $(this);
+                       var comment = o.data('comment');
+                       var bbcode  = o.data('bbcode');
+                       var id = o.data('id');
+                       if (bbcode=="img") {
+                               $.colorbox({href: baseurl + "/fbrowser/image/?mode=minimal#comment-"+id, iframe:true,innerWidth:'500px',innerHeight:'400px'})
+                               return; 
+                       }
+                       
+                       insertFormatting(comment, bbcode, id);
+               });
+
+               /* event from comment textarea button popups */
+               /* insert returned bbcode at cursor position or replace selected text */
+               $("body").on("fbrowser.image.comment", function(e, filename, bbcode, id) {
+                       console.log("on", id);
+                       $.colorbox.close();
+                       var textarea = document.getElementById("comment-edit-text-" +id);
+                       var start = textarea.selectionStart;
+                       var end = textarea.selectionEnd;
+                       textarea.value = textarea.value.substring(0, start) + bbcode + textarea.value.substring(end, textarea.value.length);
+               });
+       
                
                
                /* setup onoff widgets */