PostNotice AJAX working in all browsers except IE

darcs-hash:20081123015559-eefa4-5ce05e6e79236c6d5ebc87f0aa3ec4de51bae130.gz
This commit is contained in:
csarven 2008-11-22 20:55:59 -05:00
parent cc10e1505f
commit 04a4e883f0
4 changed files with 43 additions and 7 deletions

View File

@ -50,7 +50,6 @@ class NewnoticeAction extends Action {
if (!$content) { if (!$content) {
$this->show_form(_('No content!')); $this->show_form(_('No content!'));
return; return;
// } else if (mb_strlen($content) > 140) {
} else { } else {
$content = common_shorten_links($content); $content = common_shorten_links($content);

View File

@ -26,9 +26,9 @@ $(document).ready(function(){
counter.text(remaining); counter.text(remaining);
if (remaining <= 0) { if (remaining <= 0) {
counter.addClass("toomuch"); $("#status_form").addClass("response_error");
} else { } else {
counter.removeClass("toomuch"); $("#status_form").removeClass("response_error");
} }
} }
@ -56,7 +56,7 @@ $(document).ready(function(){
// XXX: refactor this code // XXX: refactor this code
var favoptions = { dataType: 'xml', 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 dis = new_form.id;
var fav = dis.replace('disfavor', 'favor'); var fav = dis.replace('disfavor', 'favor');
$('form#'+fav).replaceWith(new_form); $('form#'+fav).replaceWith(new_form);
@ -117,6 +117,32 @@ $(document).ready(function(){
$("form.unsubscribe").ajaxForm(UnSubscribe); $("form.unsubscribe").ajaxForm(UnSubscribe);
$("form.subscribe").each(addAjaxHidden); $("form.subscribe").each(addAjaxHidden);
$("form.unsubscribe").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) { function doreply(nick,id) {

View File

@ -189,6 +189,7 @@ form#favor, form.favor {
input#favor, input.favor, input#favor, input.favor,
input#disfavor, input.disfavor { input#disfavor, input.disfavor {
background-color:#fcfff5; background-color:#fcfff5;
background-color:transparent;
background-image:url(icon_heart-02.gif); background-image:url(icon_heart-02.gif);
background-repeat:no-repeat; background-repeat:no-repeat;
cursor: pointer; cursor: pointer;
@ -339,6 +340,8 @@ font-size:14px;
font-size: 13px; font-size: 13px;
line-height: 16px; line-height: 16px;
border-bottom: 1px solid #dec5b5; border-bottom: 1px solid #dec5b5;
background-color:#FCFFF5;
opacity:1;
} }
.notice_single:hover { .notice_single:hover {
background-color: #f7ebcc; background-color: #f7ebcc;
@ -353,6 +356,7 @@ font-size:14px;
font-size: 14px; font-size: 14px;
font-weight: bold; font-weight: bold;
} }
input#submit_yes, input#submit_no { input#submit_yes, input#submit_no {
margin: 18px 10px 0px 0px; margin: 18px 10px 0px 0px;
padding: 4px; padding: 4px;
@ -673,6 +677,13 @@ textarea {
font-weight: bold; font-weight: bold;
text-align: right; text-align: right;
} }
.response_error textarea,
.response_error .on_max {
background-color:#fee;
}
/* ----- Subscribe Form ----- */ /* ----- Subscribe Form ----- */
#content .subscribe .submit, #content .unsubscribe .submit, #remotesubscribe .button, #remotesubscribe { #content .subscribe .submit, #content .unsubscribe .submit, #remotesubscribe .button, #remotesubscribe {
clear: left; clear: left;