Only show reply form when “comment” is clicked.
[Sone.git] / src / main / resources / templates / index.html
1 <%include include/head.html>
2
3         <script language="javascript">
4                 /* register input field/textarea swap. */
5                 $(document).ready(function() {
6                         registerInputTextareaSwap("#sone input.createpost", "What are you doing?");
7                         registerInputTextareaSwap("#sone input.reply-input", "Write a Reply…");
8
9                         /* hide all the “create reply” forms until a link is clicked. */
10                         $("#sone .post").each(function() {
11                                 postId = $(this).attr("id");
12                                 (function(postId) {
13                                         commentElement = $("<div>Comment</div>").addClass("show-reply-form").click(function() {
14                                                 replyElement = $("#sone .post#" + postId + " .create-reply");
15                                                 replyElement.removeClass("hidden");
16                                                 replyElement.removeClass("light");
17                                                 (function(replyElement) {
18                                                         replyElement.find("input.reply-input").blur(function() {
19                                                                 if ($(this).hasClass("default")) {
20                                                                         replyElement.addClass("light");
21                                                                 }
22                                                         }).focus(function() {
23                                                                 replyElement.removeClass("light");
24                                                         });
25                                                 })(replyElement);
26                                                 replyElement.find("input.create-reply").focus();
27                                         });
28                                 })(postId);
29                                 $(this).find(".create-reply").addClass("hidden");
30                                 $(this).find(".status-line .time").after(commentElement);
31                         });
32                 });
33         </script>
34
35         <h1><%= Page.Index.Page.Title|l10n|insert needle="{sone}" key=currentSone.name|html></h1>
36
37         <div>
38                 <form action="createPost.html" method="post">
39                         <div>
40                                 <label for="text"><%= Page.Index.Label.Text|l10n|html></label>
41                                 <input class="createpost" name="text" />
42                         </div>
43                         <div>
44                                 <button type="submit"><%= Page.Index.Button.Post|l10n|html></button>
45                         </div>
46                 </form>
47         </div>
48
49         <h1><%= Page.Index.PostList.Title|l10n|html></h1>
50
51         <div id="posts">
52                 <%foreach posts post>
53                         <%include include/viewPost.html>
54                 <%foreachelse>
55                         <div><%= Page.Index.PostList.Text.NoPostYet|l10n|html></div>
56                 <%/foreach>
57         </div>
58         
59         <h1><%= Page.Index.AddSone.Title|l10n|html></h1>
60         
61         <div><%= Page.Index.AddSone.Description|l10n|html></div>
62
63         <form action="addSone.html" method="post">
64                 <input type="hidden" name="formPassword" value="<% formPassword|html>" />
65                 <input id="addsone" type="text" name="request-uri" />
66                 <button type="submit"><%= Page.Index.AddSone.Button.Add|l10n|html></button>
67         </form>
68
69 <%include include/tail.html>