Merge commit '0.3.1-RC3' into message-recipient
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 26 Nov 2010 22:02:14 +0000 (23:02 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 26 Nov 2010 22:02:14 +0000 (23:02 +0100)
1  2 
src/main/resources/static/javascript/sone.js
src/main/resources/templates/include/viewPost.html

@@@ -63,7 -63,7 +63,7 @@@ function registerInputTextareaSwap(inpu
   * @param element
   *            The element to add a “comment” link to
   */
- function addCommentLink(postId, element) {
+ function addCommentLink(postId, element, insertAfterThisElement) {
        if ($(element).find(".show-reply-form").length > 0) {
                return;
        }
@@@ -86,9 -86,7 +86,7 @@@
                });
                return commentElement;
        })(postId);
-       $(element).find(".status-line .time").each(function() {
-               $(this).after(commentElement.clone(true));
-       });
+       $(insertAfterThisElement).after(commentElement.clone(true));
  }
  
  var translations = {};
@@@ -484,6 -482,9 +482,9 @@@ function ajaxifyPost(postElement) 
                return false;
        });
  
+       /* add “comment” link. */
+       addCommentLink(getPostId(postElement), postElement, $(postElement).find(".post-status-line .time"));
        /* process all replies. */
        $(postElement).find(".reply").each(function() {
                ajaxifyReply(this);
        getTranslation("WebInterface.DefaultText.Reply", function(text) {
                $(postElement).find("input.reply-input").each(function() {
                        registerInputTextareaSwap(this, text, "text", false, false);
-                       addCommentLink(getPostId(postElement), postElement);
                });
        });
  
-       /* add “comment” link. */
-       addCommentLink(getPostId(postElement), postElement);
+       /* mark everything as known on click. */
+       $(postElement).click(function() {
+               markPostAsKnown(this);
+       });
  
        /* hide reply input field. */
        $(postElement).find(".create-reply").addClass("hidden");
@@@ -528,7 -530,12 +530,12 @@@ function ajaxifyReply(replyElement) 
                        });
                });
        })(replyElement);
-       addCommentLink(getPostId(replyElement), replyElement);
+       addCommentLink(getPostId(replyElement), replyElement, $(replyElement).find(".reply-status-line .time"));
+       /* mark post and all replies as known on click. */
+       $(replyElement).click(function() {
+               markPostAsKnown(getPostElement(replyElement));
+       });
  }
  
  /**
@@@ -693,9 -700,11 +700,11 @@@ function resetActivity() 
  }
  
  function setActivity() {
-       title = document.title;
-       if (title.indexOf('(') != 0) {
-               document.title = "(!) " + title;
+       if (!focus) {
+               title = document.title;
+               if (title.indexOf('(') != 0) {
+                       document.title = "(!) " + title;
+               }
        }
  }
  
@@@ -725,6 -734,8 +734,8 @@@ function createNotification(id, text, d
  // EVERYTHING BELOW HERE IS EXECUTED AFTER LOADING THE PAGE
  //
  
+ var focus = true;
  $(document).ready(function() {
  
        /* this initializes the status update input field. */
                });
        });
  
 +      /* ajaxify input field on “view Sone” page. */
 +      getTranslation("WebInterface.DefaultText.Message", function(defaultText) {
 +              registerInputTextareaSwap("#sone #post-message input[name=text]", defaultText, "text", false, false);
 +              $("#sone #post-message").submit(function() {
 +                      text = $(this).find(":input:enabled").val();
 +                      $.getJSON("ajax/createPost.ajax", { "formPassword": getFormPassword(), "recipient": $("#sone #sone-id").text(), "text": text }, function(data, textStatus) {
 +                              if ((data != null) && data.success) {
 +                                      loadNewPost(data.postId);
 +                              }
 +                      });
 +                      $(this).find(":input:enabled").val("").blur();
 +                      return false;
 +              });
 +      });
 +
        /* Ajaxifies all posts. */
        /* calling getTranslation here will cache the necessary values. */
        getTranslation("WebInterface.Confirmation.DeletePostButton", function(text) {
  
        /* reset activity counter when the page has focus. */
        $(window).focus(function() {
+               focus = true;
                resetActivity();
-       });
+       }).blur(function() {
+               focus = false;
+       })
  
  });
@@@ -7,17 -7,9 +7,17 @@@
        <div class="inner-part">
                <div>
                        <div class="author profile-link"><a href="viewSone.html?sone=<% post.sone.id|html>"><% post.sone.niceName|html></a></div>
 +                      <%ifnull !post.recipient>
 +                              <span class="recipient-to">→</span>
 +                              <%ifnull post.recipient.identity>
 +                                      <div class="recipient profile-link"><a href="viewSone.html?sone=<% post.recipient.id|html>"><% View.Post.UnknownAuthor|l10n|html></a></div>
 +                              <%else>
 +                                      <div class="recipient profile-link"><a href="viewSone.html?sone=<% post.recipient.id|html>"><% post.recipient.niceName|html></a></div>
 +                              <%/if>
 +                      <%/if>
                        <div class="text"><% post.text|html></div>
                </div>
-               <div class="status-line">
+               <div class="post-status-line status-line">
                        <div class="time"><a href="viewPost.html?post=<% post.id|html>"><% post.time|date format="MMM d, yyyy, HH:mm:ss"></a></div>
                        <div class="likes<%if post.likes.size|match value=0> hidden<%/if>"><span title="<% post.likes.soneNames|html>">⬆<span class="like-count"><% post.likes.size></span></span></div>
                        <%ifnull ! currentSone>