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() == "") {
26 /* hide all the “create reply” forms until a link is clicked. */
27 function addCommentLinks() {
28 $("#sone .post").each(function() {
29 postId = $(this).attr("id");
30 commentElement = (function(postId) {
31 var commentElement = $("<div><span>Comment</span></div>").addClass("show-reply-form").click(function() {
32 replyElement = $("#sone .post#" + postId + " .create-reply");
33 replyElement.removeClass("hidden");
34 replyElement.removeClass("light");
35 (function(replyElement) {
36 replyElement.find("input.reply-input").blur(function() {
37 if ($(this).hasClass("default")) {
38 replyElement.addClass("light");
41 replyElement.removeClass("light");
44 replyElement.find("input.reply-input").focus();
46 return commentElement;
48 $(this).find(".create-reply").addClass("hidden");
49 $(this).find(".status-line .time").each(function() {
50 $(this).after(commentElement.clone(true));