]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - js/util.js
add a method to Design to show custom CSS
[quix0rs-gnu-social.git] / js / util.js
index 16422df57937311092926ef27a119f171b9eac14..31d9eb4f54706a09a384ca2cf0604ae7904373ef 100644 (file)
  */
 
 $(document).ready(function(){
+    $('.attachments').click(function() {$().jOverlay({zIndex:999, success:function(html) {$('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; });
+        }, url:$(this).attr('href') + '/ajax'}); return false; });
+    $('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; });
+
        // count character on keyup
        function counter(event){
                var maxLength = 140;
@@ -166,22 +170,19 @@ $(document).ready(function(){
                                                                                                                                                   $("#notice_action-submit").addClass("disabled");
                                                                                                                                                   return true;
                                                                                                                                                 },
-                                          timeout: 7000,
+                                          timeout: '60000',
                                           error: function (xhr, textStatus, errorThrown) {     $("#form_notice").removeClass("processing");
                                                                                                                                                $("#notice_action-submit").removeAttr("disabled");
                                                                                                                                                $("#notice_action-submit").removeClass("disabled");
-
                                                                                                                                                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 {
-                                                                                                                                                       switch(xhr.status) {
-                                                                                                                                                               default: case 404:
-                                                                                                                                                                       alert("Sorry! We had trouble sending your notice.  Please report the problem to the site administrator if this happens again.");
-                                                                                                                                                                       break;
-                                                                                                                                                               case 502: case 503: case 504:
-                                                                                                                                                                       alert("Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.");
-                                                                                                                                                                       break;
+                                                                                                                                                       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.");
                                                                                                                                                        }
                                                                                                                                                }
                                                                                                                                          },
@@ -197,11 +198,14 @@ $(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);
+                                                              NoticeHover();
+                                                              NoticeReply();
+                                                         }
                                                                                                        }
                                                                                                        $("#notice_data-text").val("");
                                                     counter();