]> git.decadent.org.uk Git - memories.git/blob - templates/photo/comment
6b867220d708c5e86bda2e4d41d99ad0f3b5c889
[memories.git] / templates / photo / comment
1 <p style="background:#fff">Rate this photo!
2 <span class="inline-rating">
3 <ul class="star-rating">
4    [% IF photo.approx_rating %]
5    <li class='current-rating' style="width:[% photo.approx_rating * 25 %]px">Currently [%photo.approx_rating%]/5 Stars.</li>
6    [% END %]
7    <li><a href='javascript:add_rating(1)' title='1 star out of 5' class='one-star'>1</a></li>
8    <li><a href='javascript:add_rating(2)' title='2 stars out of 5' class='two-stars'>2</a></li>
9    <li><a href='javascript:add_rating(3)' title='3 stars out of 5' class='three-stars'>3</a></li>
10    <li><a href='javascript:add_rating(4)' title='4 stars out of 5' class='four-stars'>4</a></li>
11    <li><a href='javascript:add_rating(5)' title='5 stars out of 5' class='five-stars'>5</a></li>
12    </ul>
13 </span>
14  [% IF photo.rated > 0%]
15  ([%photo.approx_rating%] out of [%photo.rated%] votes) 
16  [% END %]
17 </p>
18 <script>
19 add_rating = function (rank) {
20     new Ajax.Request("[%base%]/photo/add_rating/[%photo.id%]",
21       { method: "get", parameters: {rating: rank },
22         onSuccess: function () {
23           new Ajax.Updater("content", "[%base%]/photo/comment/[%photo.id%]")
24         }
25       });
26     add_rating = function (rank) { alert("You've already rated this photo")  }
27 }
28
29
30 function post_comment () {
31     new Ajax.Request("[%base%]/photo/add_comment/[%photo.id%]",
32       { method: "post",
33         parameters: { name: $("commentname").value,
34                       content: $("newcomment").value
35                     },
36         onSuccess: function () {
37           new Ajax.Updater("content", "[%base%]/photo/comment/[%photo.id%]")
38         }
39       });
40 }
41 </script>
42 <div class="comments">
43 [% FOR comment = photo.comments %]
44     <div class="comment">
45         [% comment.name | html %] writes...<hr>
46         [% comment.content %]
47     </div>
48 [% END %]
49     <div class="comment">
50         <form action="javascript:post_comment()" method="post">
51         [% IF request.user %]
52         <input id="commentname" name="name" type="hidden" value="[% request.user |html %]"/> 
53         [% ELSE %]
54         Name: <input id="commentname" name="name" /> 
55         <hr>
56         [% END %]
57         <textarea id="newcomment" name="content" cols="60" rows="5"/></textarea>
58         <p>
59         <input type="submit" name="Comment on this picture" value="Comment on this picture">
60         </p>
61         </form>
62     </div>
63 </div>