[bugzilla-gnome-org-extensions] Indicate when there is an outstanding draft



commit bf50a448c20bbf83b8d74a17d1652d55695f88b1
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sat Oct 3 15:30:35 2009 -0400

    Indicate when there is an outstanding draft
    
    When there is a draft in progress, add "Draft" in bold red to the end of the
    navigation header.

 js/splinter.js   |   31 +++++++++++++++++++++++++++++--
 web/splinter.css |    6 ++++++
 2 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/js/splinter.js b/js/splinter.js
index e378bdf..386fa95 100644
--- a/js/splinter.js
+++ b/js/splinter.js
@@ -14,6 +14,7 @@ var theReview;
 
 var reviewers = {};
 
+var updateHaveDraftTimeoutId;
 var saveDraftTimeoutId;
 var saveDraftNoticeTimeoutId;
 var savingDraft = false;
@@ -160,6 +161,21 @@ function haveDraft() {
     return false;
 }
 
+function updateHaveDraft() {
+    clearTimeout(updateHaveDraftTimeoutId);
+    updateHaveDraftTimeoutId = null;
+
+    if (haveDraft())
+        $("#haveDraftNotice").show();
+    else
+        $("#haveDraftNotice").hide();
+}
+
+function queueUpdateHaveDraft() {
+    if (updateHaveDraftTimeoutId == null)
+        updateHaveDraftTimeoutId = setTimeout(updateHaveDraft, 0);
+}
+
 function hideSaveDraftNotice() {
     clearTimeout(saveDraftNoticeTimeoutId);
     saveDraftNoticeTimeoutId = null;
@@ -351,6 +367,7 @@ function saveComment() {
 
     currentEditComment = null;
     saveDraft();
+    queueUpdateHaveDraft();
 }
 
 function cancelComment(previousText) {
@@ -368,8 +385,10 @@ function insertCommentEditor(commentArea, file, location, type) {
 
     var reviewFile = theReview.getFile(file.filename);
     var comment = reviewFile.getComment(location, type);
-    if (!comment)
+    if (!comment) {
         comment = reviewFile.addComment(location, type, "");
+        queueUpdateHaveDraft();
+    }
 
     var previousText = comment.comment;
 
@@ -620,6 +639,9 @@ function start(xml) {
     for (i = 0; i < thePatch.files.length; i++)
         addFileNavigationLink(thePatch.files[i]);
 
+    $("<div id='haveDraftNotice'style='display: none;'>Draft</div>"
+      + "<div class='clear'></div>").appendTo("#navigation");
+
     var numReviewers = 0;
     for (i = 0; i < theBug.comments.length; i++) {
         var comment = theBug.comments[i];
@@ -674,7 +696,12 @@ function start(xml) {
 
     $("#myComment")
         .val(theReview.intro)
-        .keypress(queueSaveDraft);
+        .keypress(function() {
+                      queueSaveDraft();
+                      queueUpdateHaveDraft();
+                  });
+
+    queueUpdateHaveDraft();
 
     $("#publishButton").click(publishReview);
 }
diff --git a/web/splinter.css b/web/splinter.css
index 650d03a..3fbdae1 100644
--- a/web/splinter.css
+++ b/web/splinter.css
@@ -81,6 +81,12 @@ body {
     color: black;
 }
 
+#haveDraftNotice {
+    float: right;
+    color: #bb0000;
+    font-weight: bold;
+}
+
 #overview {
     margin-top: 0.5em;
     margin-bottom: 0.5em;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]