Component.ForumTopicForm=Class.create(Component.Form,{onSubmit:function(A){if(!TextUtils.hasText($F(this.element.down("input[name=title]")))){A.stop();
new View.ErrorPopup(this.element,{title:"Whoops",content:"Don't forget your topic title!"});
return false;
}else{this.element.down("input[type=submit]").disable();
return true;
}}});
Component.ForumCommentForm=Class.create(Component.Form,{onSubmit:function(A){if(!TextUtils.hasText($F(this.element.down("textarea")))){A.stop();
new View.ErrorPopup(this.element,{title:"Whoops",content:"Don't forget to put in a comment"});
return false;
}else{this.element.down("input[type=submit]").disable();
return true;
}}});
Component.TextCounter=Class.create({initialize:function(A){this.element=$(A);
this.target=$(this.element.readAttribute("text"));
this.limit=parseInt(this.target.readAttribute("maxlength"));
this.target.observe("keyup",this.onKeyUp.bindAsEventListener(this));
},onKeyUp:function(A){this.element.update(this.limit-this.target.value.length);
}});
Component.WarnUserLink=Class.create(Component.Link,{onClick:function(A){new View.ConfirmationPopup(this.element,{content:"Are you sure you want to flag this user's comment?",onConfirm:this.onWarn.bindAsEventListener(this)});
},onWarn:function(B){var A=this.element.readAttribute("user");
var C={comment:$(this.element.readAttribute("for")).innerHTML};
new Ajax.Request("/api/v1/users/"+A+"/warnings.json",{parameters:C,method:"post",onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
this.element.replace("Warning...");
},onSuccess:function(A){this.element.replace("Thanks!");
},onFailure:function(A){var B=A.responseText.evalJSON();
new View.ErrorPopup(this.element,{title:"Error",content:B.error});
}});




