Add “mark as read” buttons to new post, reply, and Sone notifications.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 19 Jan 2011 14:57:00 +0000 (15:57 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 19 Jan 2011 14:57:00 +0000 (15:57 +0100)
src/main/resources/i18n/sone.en.properties
src/main/resources/static/css/sone.css
src/main/resources/static/javascript/sone.js
src/main/resources/templates/include/head.html
src/main/resources/templates/notify/newPostNotification.html
src/main/resources/templates/notify/newReplyNotification.html
src/main/resources/templates/notify/newSoneNotification.html

index 7b8450f..e608358 100644 (file)
@@ -233,6 +233,7 @@ Notification.NewSone.ShortText=New Sones have been discovered:
 Notification.NewSone.Text=New Sones have been discovered:
 Notification.NewPost.ShortText=New posts have been discovered.
 Notification.NewPost.Text=New posts have been discovered by the following Sones:
+Notification.NewPost.Button.MarkRead=Mark as read
 Notification.NewReply.ShortText=New replies have been discovered.
 Notification.NewReply.Text=New replies have been discovered by the following Sones:
 Notification.SoneIsBeingRescued.Text=The following Sones are currently being rescued:
index 323cb0e..a83d3a1 100644 (file)
@@ -108,6 +108,10 @@ textarea {
        margin-left: 1ex;
 }
 
+#sone #notification-area .notification .mark-as-read {
+       float: right;
+}
+
 #sone #plugin-warning {
        border: solid 0.5em red;
        padding: 0.5em;
index 9d00c5a..b48dac3 100644 (file)
@@ -680,6 +680,11 @@ function ajaxifyNotification(notification) {
        notification.find("form.dismiss").submit(function() {
                return false;
        });
+       notification.find("input[name=returnPage]").val($.url.attr("relative"));
+       if (notification.find(".short-text").length > 0) {
+               notification.find(".short-text").removeClass("hidden");
+               notification.find(".text").addClass("hidden");
+       }
        notification.find("form.dismiss button").click(function() {
                $.getJSON("dismissNotification.ajax", { "formPassword" : getFormPassword(), "notification" : notification.attr("id") }, function(data, textStatus) {
                        /* dismiss in case of error, too. */
index 4e43da4..aec46cf 100644 (file)
@@ -27,7 +27,7 @@
                                                        <button type="submit"><%= Notification.Button.Dismiss|l10n|html></button>
                                                </form>
                                        <%/if>
-                                       <% notification>
+                                       <%include notification request=request>
                                </div>
                        <%/foreach>
                </div>
index 94f7a1f..e5d7792 100644 (file)
@@ -1,8 +1,15 @@
-<div class="short-text">
+<div class="short-text hidden">
        <%= Notification.NewPost.ShortText|l10n|html>
        <a class="link" onclick="showNotificationDetails('<%notification.id|html>'); return false;"><%= Notification.ClickHereToRead|l10n|html></a>
 </div>
-<div class="text hidden">
+<div class="text">
+       <form class="mark-as-read" action="markAsKnown.html" method="post">
+               <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+               <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+               <input type="hidden" name="type" value="post" />
+               <input type="hidden" name="id" value="<%foreach posts post><% post.id|html><%notlast> <%/notlast><%/foreach>" />
+               <button type="submit" name="mark-read" value="true"><%= Notification.NewPost.Button.MarkRead|l10n|html></button>
+       </form>
        <%= Notification.NewPost.Text|l10n|html>
        <%foreach posts post>
                <a href="viewPost.html?post=<% post.id|html>"><% post.sone.niceName|html></a><%notlast>,<%/notlast><%last>.<%/last>
index d6d0670..2a194f2 100644 (file)
@@ -1,8 +1,15 @@
-<div class="short-text">
+<div class="short-text hidden">
        <%= Notification.NewReply.ShortText|l10n|html>
        <a class="link" onclick="showNotificationDetails('<%notification.id|html>'); return false;"><%= Notification.ClickHereToRead|l10n|html></a>
 </div>
-<div class="text hidden">
+<div class="text">
+       <form class="mark-as-read" action="markAsKnown.html" method="post">
+               <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+               <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+               <input type="hidden" name="type" value="reply" />
+               <input type="hidden" name="id" value="<%foreach replies reply><% reply.id|html><%notlast> <%/notlast><%/foreach>" />
+               <button type="submit" name="mark-read" value="true"><%= Notification.NewPost.Button.MarkRead|l10n|html></button>
+       </form>
        <%= Notification.NewReply.Text|l10n|html>
        <%foreach replies reply>
                <a href="viewPost.html?post=<% reply.post.id|html>"><% reply.sone.niceName|html></a><%notlast>,<%/notlast><%last>.<%/last>
index 8389f7a..45357b1 100644 (file)
@@ -1,8 +1,15 @@
-<div class="short-text">
+<div class="short-text hidden">
        <%= Notification.NewSone.ShortText|l10n|html>
        <a class="link" onclick="showNotificationDetails('<%notification.id|html>'); return false;"><%= Notification.ClickHereToRead|l10n|html></a>
 </div>
-<div class="text hidden">
+<div class="text">
+       <form class="mark-as-read" action="markAsKnown.html" method="post">
+               <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+               <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+               <input type="hidden" name="type" value="sone" />
+               <input type="hidden" name="id" value="<%foreach sones sone><% sone.id|html><%notlast> <%/notlast><%/foreach>" />
+               <button type="submit" name="mark-read" value="true"><%= Notification.NewPost.Button.MarkRead|l10n|html></button>
+       </form>
        <%= Notification.NewSone.Text|l10n|html>
        <%foreach sones sone>
                <a href="viewSone.html?sone=<% sone.id|html>" title="<% sone.requestUri|html>"><% sone.niceName|html></a><%notlast>,<%/notlast><%last>.<%/last>