Created
March 14, 2009 01:40
-
-
Save entombedvirus/78874 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CommentBox.prototype = { | |
| refresh: function() { | |
| var textarea = this.text; | |
| if (textarea.val().trim() == "" && !this.hasFocus) { | |
| textarea.addClass("empty").val("write something..."); | |
| } else if (textarea.val().trim() == "write something...") { | |
| textarea.val("").removeClass("empty"); | |
| }; | |
| }, | |
| expand: function() { | |
| this.text.animate({height: "+=50px"}); | |
| return false; | |
| }, | |
| clear: function() { | |
| this.text.focus().val(""); | |
| return false; | |
| }, | |
| ajaxify: function() { | |
| this.form.submit(this.ajaxSubmitHandler.bind(this)); | |
| }, | |
| ajaxSubmitHandler: function() { | |
| var ajax = new Ajax(); | |
| ajax.responseType = Ajax.FBML; | |
| ajax.requireLogin = true; | |
| var that = this; | |
| ajax.ondone = function(data) { | |
| that.activateLoadingScreen(false); | |
| that.clear(); | |
| var container = document.createElement("div"); | |
| container.setInnerFBML(data); | |
| $("#comments").prepend(container); | |
| refreshCommentDeleteButtons(); | |
| $(container). | |
| animate({backgroundColor: "#ffff99"}, 500, function() { $(container). | |
| animate({backgroundColor: "transparent"}, 1000); | |
| }); | |
| }; | |
| ajax.onerror = function() { | |
| that.activateLoadingScreen(false); | |
| new Dialog().showMessage("You can't comment yet", | |
| "Please wait a while and then try again."); | |
| }; | |
| this.activateLoadingScreen(true); | |
| ajax.post( | |
| rewriteUrl(this.form.attr("action"), AJAX_HOST), | |
| this.form[0].serialize() | |
| ); | |
| return false; | |
| }, | |
| activateLoadingScreen: function(loading) { | |
| if (loading) { | |
| this.form.addClass("posting"); | |
| } else{ | |
| this.form.removeClass("posting"); | |
| }; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment