]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
PostNotice AJAX working in all browsers except IE
authorcsarven <csarven@controlyourself.ca>
Sun, 23 Nov 2008 01:55:59 +0000 (20:55 -0500)
committercsarven <csarven@controlyourself.ca>
Sun, 23 Nov 2008 01:55:59 +0000 (20:55 -0500)
darcs-hash:20081123015559-eefa4-5ce05e6e79236c6d5ebc87f0aa3ec4de51bae130.gz

actions/newnotice.php
js/util.js
js/xbImportNode.js
theme/default/display.css

index 3c336d3b0862e4e58c525e0fd78b8b3f0e41b28b..0c1ad9523bec501fbf849e63a2e0fba4c4fe3587 100644 (file)
@@ -50,7 +50,6 @@ class NewnoticeAction extends Action {
                if (!$content) {
                        $this->show_form(_('No content!'));
                        return;
-//             } else if (mb_strlen($content) > 140) {
                } else {
                        $content = common_shorten_links($content);
 
index aa9585029feccb98c2dbb7217c20f4fb6025463d..541b4ec0dd4863e3d6faec893a8b60e2a638cfa6 100644 (file)
@@ -26,9 +26,9 @@ $(document).ready(function(){
                counter.text(remaining);
                
                if (remaining <= 0) {
-                       counter.addClass("toomuch");
+                       $("#status_form").addClass("response_error");
                } else {
-                       counter.removeClass("toomuch");
+                       $("#status_form").removeClass("response_error");
                }
        }
 
@@ -56,7 +56,7 @@ $(document).ready(function(){
        // XXX: refactor this code
 
        var favoptions = { dataType: 'xml',
-                                          success: function(xml) { var new_form = document._importNode($('form', xml).get(0), true);
+                                          success: function(xml) { alert("success");var new_form = document._importNode($('form', xml).get(0), true);
                                                                                                var dis = new_form.id;
                                                                                                var fav = dis.replace('disfavor', 'favor');
                                                                                                $('form#'+fav).replaceWith(new_form);
@@ -117,6 +117,32 @@ $(document).ready(function(){
        $("form.unsubscribe").ajaxForm(UnSubscribe);
        $("form.subscribe").each(addAjaxHidden);
        $("form.unsubscribe").each(addAjaxHidden);
+
+
+       var PostNotice = { dataType: 'xml',
+                                          beforeSubmit: function(formData, jqForm, options) { if ($("#status_textarea").get(0).value.length == 0) {
+                                                                                                                                                               $("#status_form").addClass("response_error");
+                                                                                                                                                               return false;
+                                                                                                                                                  }
+                                                                                                                                                  return true;
+                                                                                                                                                },
+                                          success: function(xml) { 
+                                                                                               if ($(".error", xml).length > 0) {
+                                                                                                       var response_error = document._importNode($(".error", xml).get(0), true);
+                                                                                                       response_error = response_error.textContent || response_error.innerHTML;
+                                                                                                       alert(response_error);
+                                                                                               }
+                                                                                               else {
+                                                                                                       $("#notices").prepend(document._importNode($("li", xml).get(0), true));
+                                                                                                       $("#status_textarea").val("");
+                                                                                                       counter();
+                                                                                                       $(".notice_single:first").css({display:"none"});
+                                                                                                       $(".notice_single:first").fadeIn(2500);
+                                                                                               }
+                                                                                        }
+                                          }
+       $("#status_form").ajaxForm(PostNotice);
+       $("#status_form").each(addAjaxHidden);
 });
 
 function doreply(nick,id) {
index 4ba332a68f9f14c81fabf52466ffd16bbbf0c00a..1da6bae69a08ab95ec2ffe6b4f6489df530dd0e5 100644 (file)
@@ -43,4 +43,4 @@ document._importNode = function(node, allChildren) {
                        return document.createTextNode(node.nodeValue);
                        break;
        }
-};
\ No newline at end of file
+};
index 5dcc5708a42257c0c9fd14cfcd9a294ebd2ae244..47560b16b7b838c7837757daa9813542b71851fa 100644 (file)
@@ -189,6 +189,7 @@ form#favor, form.favor  {
 input#favor, input.favor,
 input#disfavor, input.disfavor  {
        background-color:#fcfff5;
+       background-color:transparent;
        background-image:url(icon_heart-02.gif);
        background-repeat:no-repeat;
        cursor: pointer;
@@ -339,6 +340,8 @@ font-size:14px;
        font-size: 13px;
        line-height: 16px;
        border-bottom: 1px solid #dec5b5;
+       background-color:#FCFFF5;
+       opacity:1;
        }
 .notice_single:hover {
        background-color: #f7ebcc;
@@ -349,10 +352,11 @@ font-size:14px;
        padding: 0;
        }
 #notice_delete_form #confirmation_text {
-        display: block;
+    display: block;
        font-size: 14px;
        font-weight: bold;
        }
+
 input#submit_yes, input#submit_no {
        margin: 18px 10px 0px 0px;
        padding: 4px;
@@ -673,6 +677,13 @@ textarea {
        font-weight: bold;
        text-align: right;
 }
+.response_error textarea,
+.response_error .on_max {
+background-color:#fee;
+}
+
+
+
 /* ----- Subscribe Form ----- */
 #content .subscribe .submit, #content .unsubscribe .submit, #remotesubscribe .button, #remotesubscribe {
        clear: left;
@@ -964,4 +975,4 @@ margin-left:4.5em;
        display: inline;
        margin: 0;
        padding: 0;
-       }
\ No newline at end of file
+       }