From 04a4e883f0df50064f480eb062d900764ba1a172 Mon Sep 17 00:00:00 2001 From: csarven Date: Sat, 22 Nov 2008 20:55:59 -0500 Subject: [PATCH] PostNotice AJAX working in all browsers except IE darcs-hash:20081123015559-eefa4-5ce05e6e79236c6d5ebc87f0aa3ec4de51bae130.gz --- actions/newnotice.php | 1 - js/util.js | 32 +++++++++++++++++++++++++++++--- js/xbImportNode.js | 2 +- theme/default/display.css | 15 +++++++++++++-- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/actions/newnotice.php b/actions/newnotice.php index 3c336d3b08..0c1ad9523b 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -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); diff --git a/js/util.js b/js/util.js index aa9585029f..541b4ec0dd 100644 --- a/js/util.js +++ b/js/util.js @@ -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) { diff --git a/js/xbImportNode.js b/js/xbImportNode.js index 4ba332a68f..1da6bae69a 100644 --- a/js/xbImportNode.js +++ b/js/xbImportNode.js @@ -43,4 +43,4 @@ document._importNode = function(node, allChildren) { return document.createTextNode(node.nodeValue); break; } -}; \ No newline at end of file +}; diff --git a/theme/default/display.css b/theme/default/display.css index 5dcc5708a4..47560b16b7 100644 --- a/theme/default/display.css +++ b/theme/default/display.css @@ -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 + } -- 2.39.5