changeset 5392:5cc8e1d7ee21

comments: fix warning when unloading page with unsaved comments e87baa8f1c5b broke the existing check. Instead, only set the comment-inline-form class when it actually is an inline form and use that class for finding comments.
author Mads Kiilerich <madski@unity3d.com>
date Mon, 17 Aug 2015 01:11:42 +0200
parents 09f58befd9f1
children 8c38b8a5a1ac
files kallithea/public/js/base.js kallithea/templates/changeset/changeset_file_comment.html
diffstat 2 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/js/base.js	Mon Aug 17 01:11:39 2015 +0200
+++ b/kallithea/public/js/base.js	Mon Aug 17 01:11:42 2015 +0200
@@ -683,7 +683,8 @@
 
 // append a comment form to $comment_div
 function _comment_div_append_form($comment_div, f_path, line_no) {
-    var $form_div = $($('#comment-inline-form-template').html().format(f_path, line_no));
+    var $form_div = $($('#comment-inline-form-template').html().format(f_path, line_no))
+        .addClass('comment-inline-form');
     $comment_div.append($form_div);
     var $form = $comment_div.find("form");
 
--- a/kallithea/templates/changeset/changeset_file_comment.html	Mon Aug 17 01:11:39 2015 +0200
+++ b/kallithea/templates/changeset/changeset_file_comment.html	Mon Aug 17 01:11:42 2015 +0200
@@ -52,7 +52,7 @@
 ## TODO: don't assume line_no is globally unique ...
 <%def name="comment_inline_form()">
 <div id='comment-inline-form-template' style="display:none">
-  <div class="comment-inline-form ac">
+  <div class="ac">
   %if c.authuser.username != 'default':
     ${h.form('#', class_='inline-form')}
       <div id="edit-container_{1}" class="clearfix">
@@ -202,7 +202,8 @@
    MentionsAutoComplete($('#text'), $('#mentions_container'), _USERS_AC_DATA, _GROUPS_AC_DATA);
 
    $(window).on('beforeunload', function(){
-      if($('.form-open').size() || $('textarea#text').val()){
+      if($('.comment-inline-form textarea[name=text]').size() ||
+         $('textarea#text').val()) {
          // this message will not be displayed on all browsers
          // (e.g. some versions of Firefox), but the user will still be warned
          return 'There are uncommitted comments.';