X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=js%2Fmain.js;h=e1e852cbaf655935fce69142f87ca02c642e5c86;hb=ffc9f941496031d61442f4fe2a0f562ad4087d63;hp=b812e25089f5d18ca5174673ce24f4f803f0b293;hpb=e29d05ce4a2d33d03a72ac190aeab727bb0bc409;p=friendica.git diff --git a/js/main.js b/js/main.js index b812e25089..e1e852cbaf 100644 --- a/js/main.js +++ b/js/main.js @@ -51,6 +51,38 @@ e.tipTip({defaultPosition: pos, edgeOffset: 8}); });*/ + /* setup comment textarea buttons */ + /* comment textarea buttons needs some "data-*" attributes to work: + * data-role="insert-formatting" : to mark the element as a formatting button + * data-comment="" : string for "Comment", used by insertFormatting() function + * data-bbcode="" : name of the bbcode element to insert. insertFormatting() will insert it as "[name][/name]" + * data-id="" : id of the comment, used to find other comment-related element, like the textarea + * */ + $('body').on('click','[data-role="insert-formatting"]', 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 */ @@ -186,13 +218,20 @@ var notification_id = 0; eNotif.children("note").each(function(){ e = $(this); - text = e.text().format(""+e.attr('name')+""); - html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'), e.attr('seen')); + var text = e.text().format(""+e.attr('name')+""); + var seenclass = (e.attr('seen')==1)?"notify-seen":"notify-unseen"; + var html = notifications_tpl.format(e.attr('href'), + e.attr('photo'), // {0} + text, // {1} + e.attr('date'), // {2} + seenclass, // {3} + new Date(e.attr('timestamp')*1000) // {4} + ); nnm.append(html); }); $(eNotif.children("note").get().reverse()).each(function(){ e = $(this); - notification_id = parseInt(e.attr('href').match(/\d+$/)[0]); + notification_id = parseInt(e.attr('timestamp')); if (notification_lastitem!== null && notification_id > notification_lastitem) { if (getNotificationPermission()==="granted") { var notification = new Notification(document.title, {