1 /* Sone JavaScript functions. */
3 function registerInputTextareaSwap(inputSelector, defaultText) {
4 $(inputSelector).focus(function() {
5 if ($(this).val() == defaultText) {
6 $(this).val("").removeClass("default");
9 if ($(this).val() == "") {
10 $(this).val(defaultText).addClass("default");
12 }).addClass("default").val(defaultText);
13 $($(inputSelector).get(0).form).submit(function() {
14 if ($(inputSelector).hasClass("default")) {
15 $(inputSelector).val("");
20 /* hide all the “create reply” forms until a link is clicked. */
21 function addCommentLinks() {
22 $("#sone .post").each(function() {
23 postId = $(this).attr("id");
24 commentElement = (function(postId) {
25 var commentElement = $("<div>Comment</div>").addClass("show-reply-form").click(function() {
26 replyElement = $("#sone .post#" + postId + " .create-reply");
27 replyElement.removeClass("hidden");
28 replyElement.removeClass("light");
29 (function(replyElement) {
30 replyElement.find("input.reply-input").blur(function() {
31 if ($(this).hasClass("default")) {
32 replyElement.addClass("light");
35 replyElement.removeClass("light");
38 replyElement.find("input.reply-input").focus();
40 return commentElement;
42 $(this).find(".create-reply").addClass("hidden");
43 $(this).find(".status-line .time").each(function() {
44 $(this).after(commentElement.clone(true));