]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - js/util.js
Created NoticeWithAttachment to handle jOverlay for single notice
[quix0rs-gnu-social.git] / js / util.js
index f7f3d5e76a9fda2f2a4d0e2f051854d2fa7fffea..0bd671f8dffd0d268bd6bc91dfa595522ced7994 100644 (file)
@@ -234,8 +234,8 @@ var SN = { // StatusNet
                                 $('#'+notice.id).css({display:'none'});
                                 $('#'+notice.id).fadeIn(2500);
                                 SN.U.NoticeAttachments();
-                                SN.U.NoticeReply();
-                                SN.U.NoticeFavor();
+                                SN.U.NoticeReplyTo($('#'+notice.id));
+                                SN.U.FormXHR($('#'+notice.id+' .form_favor'));
                              }
                         }
                         $('#'+form_id+' #'+SN.C.S.NoticeDataText).val('');
@@ -255,13 +255,20 @@ var SN = { // StatusNet
 
         NoticeReply: function() {
             if ($('#'+SN.C.S.NoticeDataText).length > 0 && $('#content .notice_reply').length > 0) {
-                $('#content .notice').each(function() {
-                    var notice = $(this)[0];
-                    $($('.notice_reply', notice)[0]).click(function() {
-                        var nickname = ($('.author .nickname', notice).length > 0) ? $($('.author .nickname', notice)[0]) : $('.author .nickname.uid');
-                        SN.U.NoticeReplySet(nickname.text(), $($('.notice_id', notice)[0]).text());
-                        return false;
-                    });
+                $('#content .notice').each(function() { SN.U.NoticeReplyTo($(this)); });
+            }
+        },
+
+        NoticeReplyTo: function(notice_item) {
+            var notice = notice_item[0];
+            var notice_reply = $('.notice_reply', notice)[0];
+
+            if (jQuery.data(notice_reply, "ElementData") === undefined) {
+                jQuery.data(notice_reply, "ElementData", {Bind:'submit'});
+                $(notice_reply).bind('click', function() {
+                    var nickname = ($('.author .nickname', notice).length > 0) ? $($('.author .nickname', notice)[0]) : $('.author .nickname.uid');
+                    SN.U.NoticeReplySet(nickname.text(), $($('.notice_id', notice)[0]).text());
+                    return false;
                 });
             }
         },
@@ -289,6 +296,14 @@ var SN = { // StatusNet
         },
 
         NoticeAttachments: function() {
+            $('.notice a.attachment').each(function() { 
+                SN.U.NoticeWithAttachment($(this).closest('.notice'));
+            });
+        },
+
+        NoticeWithAttachment: function(notice) {
+            var notice_id = notice.attr('id');
+
             $.fn.jOverlay.options = {
                 method : 'GET',
                 data : '',
@@ -308,13 +323,13 @@ var SN = { // StatusNet
                 css : {'max-width':'542px', 'top':'5%', 'left':'32.5%'}
             };
 
-            $('#content .notice a.attachment').click(function() {
+            $('#'+notice_id+' a.attachment').click(function() {
                 $().jOverlay({url: $('address .url')[0].href+'attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'});
                 return false;
             });
 
             var t;
-            $("body:not(#shownotice) #content .notice a.thumbnail").hover(
+            $("body:not(#shownotice) #"+notice_id+" a.thumbnail").hover(
                 function() {
                     var anchor = $(this);
                     $("a.thumbnail").children('img').hide();