Changeset - a0443f20a5ec
[Not reviewed]
default
0 1 0
Jan Heylen - 11 years ago 2015-02-11 21:10:43
heyleke@gmail.com
javascript: on submit, don't warn for open form if the main form is the only one
1 file changed with 9 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/templates/changeset/changeset_file_comment.html
Show inline comments
 
@@ -148,25 +148,25 @@
 
          ${comment_block(co)}
 
        </div>
 
    %endfor
 
</div>
 
</%def>
 

	
 
## MAIN COMMENT FORM
 
<%def name="comments(post_url, cur_status, is_pr=False, change_status=True)">
 

	
 
<div class="comments">
 
    %if c.authuser.username != 'default':
 
    <div class="comment-form ac">
 
      ${h.form(post_url)}
 
      ${h.form(post_url, id="main_form")}
 
        <div id="edit-container" class="clearfix">
 
            <div class="comment-help">
 
                ${(_('Comments parsed using %s syntax with %s support.') % (('<a href="%s">RST</a>' % h.url('rst_help')),
 
                  '<span style="color:#577632" class="tooltip" title="%s">@mention</span>' %
 
                  _('Use @username inside this text to send notification to another local user.')))|n}
 
            </div>
 
            <div class="mentions-container" id="mentions_container"></div>
 
            ${h.textarea('text', class_="comment-block-ta")}
 
            %if change_status:
 
              <div id="status_block_container" class="status-block">
 
                %if is_pr:
 
                  ${_('Vote for pull request status')}:
 
@@ -212,24 +212,32 @@
 

	
 
$(document).ready(function () {
 
   MentionsAutoComplete('text', 'mentions_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
 

	
 
   $(window).on('beforeunload', function(){
 
      if($('.form-open').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.';
 
      }
 
   });
 

	
 
   $('form#main_form').submit(function(){
 
      // if no open inline forms, disable the beforeunload check - it would
 
      // fail in the check for the textarea we are about to submit
 
      if(!$('.form-open').size()){
 
          $(window).off('beforeunload');
 
      }
 
   });
 

	
 
   $('#preview-btn').click(function(){
 
       var _text = $('#text').val();
 
       if(!_text){
 
           return;
 
       }
 
       var post_data = {'text': _text};
 
       $('#preview-box').addClass('unloaded');
 
       $('#preivew-box').html(_TM['Loading ...']);
 
       $('#edit-container').hide();
 
       $('#edit-btn').show();
 
       $('#preview-container').show();
 
       $('#preview-btn').hide();
0 comments (0 inline, 0 general)