]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - js/util.js
Merge branch '0.8.x' of git@gitorious.org:+laconica-developers/laconica/dev into...
[quix0rs-gnu-social.git] / js / util.js
index 15a14625c7b5bb643fb4a2031a5e70230ac28b54..b1b6ec82bd93e21d268aa3129f33d5f617dc2780 100644 (file)
  */
 
 $(document).ready(function(){
+    $('a.attachment').click(function() {$().jOverlay({url: $('address .url')[0].href+'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; });
+    $("a.thumbnail").hover(
+        function() {
+            var anchor = $(this);
+            $("a.thumbnail").children('img').remove();
+
+            setTimeout(function() {
+                anchor.closest(".entry-title").addClass('ov');
+                $.get($('address .url')[0].href+'/attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) {
+                    anchor.append(data);
+                });
+            }, 250);
+
+            setTimeout(function() {
+                anchor.children('img').remove();
+                anchor.closest(".entry-title").removeClass('ov');
+            }, 3000);
+        },
+        function() {
+            $(this).children('img').remove();
+            $(this).closest(".entry-title").removeClass('ov');
+        }
+    );
+
        // count character on keyup
        function counter(event){
                var maxLength = 140;
@@ -166,14 +190,20 @@ $(document).ready(function(){
                                                                                                                                                   $("#notice_action-submit").addClass("disabled");
                                                                                                                                                   return true;
                                                                                                                                                 },
+                                          timeout: '60000',
                                           error: function (xhr, textStatus, errorThrown) {     $("#form_notice").removeClass("processing");
                                                                                                                                                $("#notice_action-submit").removeAttr("disabled");
                                                                                                                                                $("#notice_action-submit").removeClass("disabled");
-                                                                                                                                               if ($(".error", xhr.responseXML).length > 0) {
-                                                                                                                                                       $('#form_notice').append(document._importNode($(".error", xhr.responseXML).get(0), true));
+                                                                                                                                               if (textStatus == "timeout") {
+                                                                                                                                                       alert ("Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists");
                                                                                                                                                }
                                                                                                                                                else {
-                                                                                                                                                       alert("Sorry! We had trouble sending your notice ("+xhr.status+" "+xhr.statusText+"). Please report the problem to the site administrator if this happens again.");
+                                                                                                                                                       if ($(".error", xhr.responseXML).length > 0) {
+                                                                                                                                                               $('#form_notice').append(document._importNode($(".error", xhr.responseXML).get(0), true));
+                                                                                                                                                       }
+                                                                                                                                                       else {
+                                                                                                                                                               alert("Sorry! We had trouble sending your notice ("+xhr.status+" "+xhr.statusText+"). Please report the problem to the site administrator if this happens again.");
+                                                                                                                                                       }
                                                                                                                                                }
                                                                                                                                          },
                                           success: function(xml) {     if ($("#error", xml).length > 0) {
@@ -188,11 +218,13 @@ $(document).ready(function(){
                                                                                                            alert(result);
                                                     }
                                                     else {
-                                                                                                           $("#notices_primary .notices").prepend(document._importNode($("li", xml).get(0), true));
-                                                                                                           $("#notices_primary .notice:first").css({display:"none"});
-                                                                                                           $("#notices_primary .notice:first").fadeIn(2500);
-                                                                                                           NoticeHover();
-                                                                                                           NoticeReply();
+                                                         li = $("li", xml).get(0);
+                                                         if ($("#"+li.id).length == 0) {
+                                                              $("#notices_primary .notices").prepend(document._importNode(li, true));
+                                                              $("#notices_primary .notice:first").css({display:"none"});
+                                                              $("#notices_primary .notice:first").fadeIn(2500);
+                                                              NoticeReply();
+                                                         }
                                                                                                        }
                                                                                                        $("#notice_data-text").val("");
                                                     counter();
@@ -208,24 +240,23 @@ $(document).ready(function(){
     NoticeReply();
 });
 
+
 function NoticeHover() {
-    $("#content .notice").hover(
-        function () {
-            $(this).addClass('hover');
-        },
-        function () {
-            $(this).removeClass('hover');
-        }
-    );
+    function mouseHandler(e) {
+        $(e.target).closest('li.hentry')[(e.type === 'mouseover') ? 'addClass' : 'removeClass']('hover');
+    };
+    $('#content .notices').mouseover(mouseHandler);
+    $('#content .notices').mouseout(mouseHandler);
 }
 
+
 function NoticeReply() {
     if ($('#notice_data-text').length > 0) {
         $('#content .notice').each(function() {
-            var notice = $(this);
-            $('.notice_reply', $(this)).click(function() {
-                var nickname = ($('.author .nickname', notice).length > 0) ? $('.author .nickname', notice) : $('.author .nickname');
-                NoticeReplySet(nickname.text(), $('.notice_id', notice).text());
+            var notice = $(this)[0];
+            $($('.notice_reply', notice)[0]).click(function() {
+                var nickname = ($('.author .nickname', notice).length > 0) ? $($('.author .nickname', notice)[0]) : $('.author .nickname');
+                NoticeReplySet(nickname.text(), $($('.notice_id', notice)[0]).text());
                 return false;
             });
         });