1 /* Sone JavaScript functions. */
3 function registerInputTextareaSwap(inputSelector, defaultText) {
4 (function(inputSelector, defaultText) {
5 $(inputSelector).focus(function() {
6 if ($(this).hasClass("default")) {
7 $(this).removeClass("default").val("");
11 if ($(this).val() == "") {
12 alert("setting default");
13 $(this).val(defaultText).addClass("default");
15 }).addClass("default").val(defaultText);
16 $($(inputSelector).get(0).form).submit(function() {
17 if ($(inputSelector).hasClass("default")) {
18 $(inputSelector).val("");
20 alert(($(inputSelector).hasClass("default") ? "def: ": "ok: ") + $(inputSelector).val());
22 })(inputSelector, defaultText);
25 /* hide all the “create reply” forms until a link is clicked. */
26 function addCommentLinks() {
27 $("#sone .post").each(function() {
28 postId = $(this).attr("id");
29 commentElement = (function(postId) {
30 var commentElement = $("<div>Comment</div>").addClass("show-reply-form").click(function() {
31 replyElement = $("#sone .post#" + postId + " .create-reply");
32 replyElement.removeClass("hidden");
33 replyElement.removeClass("light");
34 (function(replyElement) {
35 replyElement.find("input.reply-input").blur(function() {
36 if ($(this).hasClass("default")) {
37 replyElement.addClass("light");
40 replyElement.removeClass("light");
43 replyElement.find("input.reply-input").focus();
45 return commentElement;
47 $(this).find(".create-reply").addClass("hidden");
48 $(this).find(".status-line .time").each(function() {
49 $(this).after(commentElement.clone(true));