Changeset - a21668fe545b
[Not reviewed]
default
0 2 0
Mads Kiilerich - 11 years ago 2014-07-18 19:22:01
madski@unity3d.com
comments: make preview button more obvious - show it next to other buttons
2 files changed with 31 insertions and 23 deletions:
0 comments (0 inline, 0 general)
kallithea/public/js/base.js
Show inline comments
 
@@ -731,24 +731,28 @@ var injectInlineForm = function(tr){
 
        if(!text){
 
            return
 
        }
 
        $('#preview-box_'+lineno).addClass('unloaded');
 
        $('#preview-box_'+lineno).html(_TM['Loading ...']);
 
        $('#edit-container_'+lineno).hide();
 
        $('#edit-btn_'+lineno).show();
 
        $('#preview-container_'+lineno).show();
 
        $('#preview-btn_'+lineno).hide();
 

	
 
        var url = pyroutes.url('changeset_comment_preview', {'repo_name': REPO_NAME});
 
        var post_data = {'text': text};
 
        ajaxPOST(url, post_data, function(o){
 
            $('#preview-box_'+lineno).html(o.responseText);
 
            $('#preview-box_'+lineno).removeClass('unloaded');
 
        })
 
    })
 
    $('#edit-btn_'+lineno).click(function(e){
 
        $('#edit-container_'+lineno).show();
 
        $('#edit-btn_'+lineno).hide();
 
        $('#preview-container_'+lineno).hide();
 
        $('#preview-btn_'+lineno).show();
 
    })
 

	
 
    setTimeout(function(){
 
        // callbacks
 
        tooltip_activate();
 
        MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno,
kallithea/templates/changeset/changeset_file_comment.html
Show inline comments
 
@@ -57,41 +57,41 @@
 

	
 

	
 
<%def name="comment_inline_form()">
 
<div id='comment-inline-form-template' style="display:none">
 
  <div class="comment-inline-form ac">
 
  %if c.authuser.username != 'default':
 
      ${h.form('#', class_='inline-form')}
 
    ${h.form('#', class_='inline-form')}
 
      <div id="edit-container_{1}" class="clearfix">
 
          <div class="comment-help">${_('Commenting on line {1}.')}
 
        <div class="comment-help">${_('Commenting on line {1}.')}
 
          ${(_('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 notify another user'))
 
               )
 
            )|n
 
           }
 
          <div id="preview-btn_{1}" class="preview-btn btn btn-mini">${_('Preview')}</div>
 
          </div>
 
            <div class="mentions-container" id="mentions_container_{1}"></div>
 
            <textarea id="text_{1}" name="text" class="comment-block-ta yui-ac-input"></textarea>
 
        </div>
 
        <div class="mentions-container" id="mentions_container_{1}"></div>
 
        <textarea id="text_{1}" name="text" class="comment-block-ta yui-ac-input"></textarea>
 
      </div>
 
      <div id="preview-container_{1}" class="clearfix" style="display:none">
 
         <div class="comment-help">
 
              ${_('Comment preview')}
 
            <div id="edit-btn_{1}" class="edit-btn btn btn-mini">${_('Edit')}</div>
 
          </div>
 
          <div id="preview-box_{1}" class="preview-box"></div>
 
        <div class="comment-help">
 
            ${_('Comment preview')}
 
        </div>
 
        <div id="preview-box_{1}" class="preview-box"></div>
 
      </div>
 
      <div class="comment-button">
 
      <div class="submitting-overlay">${_('Submitting ...')}</div>
 
      <input type="hidden" name="f_path" value="{0}">
 
      <input type="hidden" name="line" value="{1}">
 
      ${h.submit('save', _('Comment'), class_='btn btn-small save-inline-form')}
 
      ${h.reset('hide-inline-form', _('Cancel'), class_='btn btn-small hide-inline-form')}
 
        <div class="submitting-overlay">${_('Submitting ...')}</div>
 
        <input type="hidden" name="f_path" value="{0}">
 
        <input type="hidden" name="line" value="{1}">
 
        ${h.submit('save', _('Comment'), class_='btn btn-small save-inline-form')}
 
        ${h.reset('hide-inline-form', _('Cancel'), class_='btn btn-small hide-inline-form')}
 
        <div id="preview-btn_{1}" class="preview-btn btn btn-small">${_('Preview')}</div>
 
        <div id="edit-btn_{1}" class="edit-btn btn btn-small" style="display:none">${_('Edit')}</div>
 
      </div>
 
      ${h.end_form()}
 
    ${h.end_form()}
 
  %else:
 
      ${h.form('')}
 
      <div class="clearfix">
 
          <div class="comment-help">
 
            ${_('You need to be logged in to comment.')} <a href="${h.url('login_home',came_from=h.url.current())}">${_('Login now')}</a>
 
          </div>
 
@@ -140,19 +140,18 @@
 
## 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)}
 
        <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 this Kallithea user')))|n}
 
                <div id="preview-btn" class="preview-btn btn btn-mini">${_('Preview')}</div>
 
            </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:
 
@@ -176,23 +175,24 @@
 
                %endif
 
              </div>
 
            %endif
 
        </div>
 

	
 
        <div id="preview-container" class="clearfix" style="display:none">
 
           <div class="comment-help">
 
            <div class="comment-help">
 
                ${_('Comment preview')}
 
              <div id="edit-btn" class="edit-btn btn btn-mini">${_('Edit')}</div>
 
            </div>
 
            <div id="preview-box" class="preview-box"></div>
 
        </div>
 

	
 
        <div class="comment-button">
 
        ${h.submit('save', _('Comment'), class_="btn")}
 
            ${h.submit('save', _('Comment'), class_="btn")}
 
            <div id="preview-btn" class="preview-btn btn">${_('Preview')}</div>
 
            <div id="edit-btn" class="edit-btn btn" style="display:none">${_('Edit')}</div>
 
        </div>
 
        ${h.end_form()}
 
      ${h.end_form()}
 
    </div>
 
    %endif
 
</div>
 

	
 
<script>
 

	
 
@@ -205,22 +205,26 @@ YUE.onDOMReady(function () {
 
           return
 
       }
 
       var post_data = {'text': _text};
 
       YUD.addClass('preview-box', 'unloaded');
 
       YUD.get('preview-box').innerHTML = _TM['Loading ...'];
 
       YUD.setStyle('edit-container', 'display', 'none');
 
       YUD.setStyle('edit-btn', 'display', '');
 
       YUD.setStyle('preview-container', 'display', '');
 
       YUD.setStyle('preview-btn', 'display', 'none');
 

	
 
       var url = pyroutes.url('changeset_comment_preview', {'repo_name': '${c.repo_name}'});
 
       ajaxPOST(url,post_data,function(o){
 
           YUD.get('preview-box').innerHTML = o.responseText;
 
           YUD.removeClass('preview-box', 'unloaded');
 
       })
 
   })
 
   YUE.on('edit-btn', 'click', function(e){
 
       YUD.setStyle('edit-container', 'display', '');
 
       YUD.setStyle('edit-btn', 'display', 'none');
 
       YUD.setStyle('preview-container', 'display', 'none');
 
       YUD.setStyle('preview-btn', 'display', '');
 
   })
 

	
 
});
 
</script>
 
</%def>
0 comments (0 inline, 0 general)