+2011-02-09 Ojan Vafai <ojan@chromium.org>
+
+ Reviewed by Adam Barth.
+
+ only erase draft comments after publish is successful
+ https://bugs.webkit.org/show_bug.cgi?id=54163
+
+ If there is a conflict or 500, then draft comments will survive.
+ One drawback here is that the form post is now to the iframe,
+ so to break out of the iframe we redirect to the bug page, which
+ loses the information of who the email was sent to.
+
+ Once WebKit supports seamless iframes we should be able to avoid
+ the redirect.
+
+ * code-review.js:
+
2011-02-09 Ojan Vafai <ojan@chromium.org>
Reviewed by Adam Barth.
});
function handleReviewFormLoad() {
- var form = $('#reviewform').contents().find('form')[0];
- form.addEventListener('submit', eraseDraftComments);
+ var review_form_contents = $('#reviewform').contents();
+ if (review_form_contents[0].querySelector('#form-controls #flags')) {
+ // This is the intial load of the review form iframe.
+ var form = review_form_contents.find('form')[0];
+ form.addEventListener('submit', eraseDraftComments);
+ form.target = '';
+ return;
+ }
+
+ // Review form iframe have the publish button has been pressed.
+ var email_sent_to = review_form_contents[0].querySelector('#bugzilla-body dl');
+ // If the email_send_to DL is not in the tree that means the publish failed for some reason,
+ // e.g., you're not logged in. Show the comment form to allow you to login.
+ if (!email_sent_to) {
+ showCommentForm();
+ return;
+ }
+
+ eraseDraftComments();
+ // FIXME: Once WebKit supports seamless iframes, we can just make the review-form
+ // iframe fill the page instead of redirecting back to the bug.
+ window.location.replace($('#toolbar .bugLink a').attr('href'));
}
function eraseDraftComments() {
});
}
+ function showCommentForm() {
+ $('#comment_form').removeClass('inactive');
+ }
+
$('#preview_comments').live('click', function() {
fillInReviewForm();
- $('#comment_form').removeClass('inactive');
+ showCommentForm();
});
$('#post_comments').live('click', function() {
fillInReviewForm();
- eraseDraftComments();
$('#reviewform').contents().find('form').submit();
});
})();