1 /* Sone JavaScript functions. */
3 function registerInputTextareaSwap(inputSelector, defaultText, inputFieldName) {
4 $(inputSelector).each(function() {
5 textarea = $("<textarea name=\"" + inputFieldName + "\"></textarea>").blur(function() {
6 if ($(this).val() == "") {
8 $(this).data("inputField").show().removeAttr("disabled");
10 }).hide().data("inputField", $(this));
11 $(this).after(textarea);
12 (function(inputField, textarea) {
13 $(inputField).focus(function() {
14 $(this).hide().attr("disabled", "disabled");
15 textarea.show().focus();
16 }).addClass("default").val(defaultText);
17 $(inputField.form).submit(function() {
18 if (textarea.val() == "") {
21 $(inputField).val(textarea.val());
27 /* hide all the “create reply” forms until a link is clicked. */
28 function addCommentLinks() {
29 $("#sone .post").each(function() {
30 postId = $(this).attr("id");
31 commentElement = (function(postId) {
32 var commentElement = $("<div><span>Comment</span></div>").addClass("show-reply-form").click(function() {
33 replyElement = $("#sone .post#" + postId + " .create-reply");
34 replyElement.removeClass("hidden");
35 replyElement.removeClass("light");
36 (function(replyElement) {
37 replyElement.find("input.reply-input").blur(function() {
38 if ($(this).hasClass("default")) {
39 replyElement.addClass("light");
42 replyElement.removeClass("light");
45 replyElement.find("input.reply-input").focus();
47 return commentElement;
49 $(this).find(".create-reply").addClass("hidden");
50 $(this).find(".status-line .time").each(function() {
51 $(this).after(commentElement.clone(true));