]> git.decadent.org.uk Git - memories.git/blobdiff - templates/photo/comment
Merge commit 'trunk'
[memories.git] / templates / photo / comment
index 498e5b6adaf73c6126eb2e9c177216f824c42db5..6b867220d708c5e86bda2e4d41d99ad0f3b5c889 100644 (file)
@@ -1,3 +1,44 @@
+<p style="background:#fff">Rate this photo!
+<span class="inline-rating">
+<ul class="star-rating">
+   [% IF photo.approx_rating %]
+   <li class='current-rating' style="width:[% photo.approx_rating * 25 %]px">Currently [%photo.approx_rating%]/5 Stars.</li>
+   [% END %]
+   <li><a href='javascript:add_rating(1)' title='1 star out of 5' class='one-star'>1</a></li>
+   <li><a href='javascript:add_rating(2)' title='2 stars out of 5' class='two-stars'>2</a></li>
+   <li><a href='javascript:add_rating(3)' title='3 stars out of 5' class='three-stars'>3</a></li>
+   <li><a href='javascript:add_rating(4)' title='4 stars out of 5' class='four-stars'>4</a></li>
+   <li><a href='javascript:add_rating(5)' title='5 stars out of 5' class='five-stars'>5</a></li>
+   </ul>
+</span>
+ [% IF photo.rated > 0%]
+ ([%photo.approx_rating%] out of [%photo.rated%] votes) 
+ [% END %]
+</p>
+<script>
+add_rating = function (rank) {
+    new Ajax.Request("[%base%]/photo/add_rating/[%photo.id%]",
+      { method: "get", parameters: {rating: rank },
+        onSuccess: function () {
+          new Ajax.Updater("content", "[%base%]/photo/comment/[%photo.id%]")
+        }
+      });
+    add_rating = function (rank) { alert("You've already rated this photo")  }
+}
+
+
+function post_comment () {
+    new Ajax.Request("[%base%]/photo/add_comment/[%photo.id%]",
+      { method: "post",
+        parameters: { name: $("commentname").value,
+                      content: $("newcomment").value
+                    },
+        onSuccess: function () {
+          new Ajax.Updater("content", "[%base%]/photo/comment/[%photo.id%]")
+        }
+      });
+}
+</script>
 <div class="comments">
 [% FOR comment = photo.comments %]
     <div class="comment">
     </div>
 [% END %]
     <div class="comment">
-        <form action="[%base%]/photo/add_comment/[%photo.id%]" method="post">
-        Name: <input name="name" /> <hr>
-        <textarea name="content" cols="60" rows="5"/>
-        </textarea>
+        <form action="javascript:post_comment()" method="post">
+        [% IF request.user %]
+        <input id="commentname" name="name" type="hidden" value="[% request.user |html %]"/> 
+        [% ELSE %]
+        Name: <input id="commentname" name="name" /> 
+        <hr>
+        [% END %]
+        <textarea id="newcomment" name="content" cols="60" rows="5"/></textarea>
         <p>
         <input type="submit" name="Comment on this picture" value="Comment on this picture">
         </p>