Mercurial > kallithea
diff rhodecode/templates/changeset/changeset.html @ 1787:d4a7b6c82efe beta
code garden for changeset ranges and comments
- disabled (for now) comments on changeset ranges
- code reuse by mako namespaces
- added flag for enabling comments in diffs
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 18 Dec 2011 04:24:53 +0200 |
parents | 22333ddd1a40 |
children | a6a30c919513 61f723ae8722 |
line wrap: on
line diff
--- a/rhodecode/templates/changeset/changeset.html Sun Dec 18 00:12:58 2011 +0200 +++ b/rhodecode/templates/changeset/changeset.html Sun Dec 18 04:24:53 2011 +0200 @@ -114,89 +114,17 @@ </div> </div> - - %for change,filenode,diff,cs1,cs2,stat in c.changes: - %if change !='removed': - <div id="${h.FID(filenode.changeset.raw_id,filenode.path)}" style="clear:both;height:90px;margin-top:-60px"></div> - <div class="diffblock margined comm"> - <div class="code-header"> - <div class="changeset_header"> - <div class="changeset_file"> - ${h.link_to_if(change!='removed',h.safe_unicode(filenode.path),h.url('files_home',repo_name=c.repo_name, - revision=filenode.changeset.raw_id,f_path=h.safe_unicode(filenode.path)))} - </div> - <div class="diff-menu-wrapper"> - <img class="diff-menu-activate" style="margin-bottom:-6px;cursor: pointer" alt="diff-menu" src="${h.url('/images/icons/script_gear.png')}" /> - <div class="diff-menu" style="display:none"> - <ul> - <li>${h.link_to(_('diff'),h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(filenode.path),diff2=cs2,diff1=cs1,diff='diff'))}</li> - <li>${h.link_to(_('raw diff'),h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(filenode.path),diff2=cs2,diff1=cs1,diff='raw'))}</li> - <li>${h.link_to(_('download diff'),h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(filenode.path),diff2=cs2,diff1=cs1,diff='download'))}</li> - <li>${c.ignorews_url(h.FID(filenode.changeset.raw_id,filenode.path))}</li> - <li>${c.context_url(h.FID(filenode.changeset.raw_id,filenode.path))}</li> - </ul> - </div> - </div> - <span style="float:right;margin-top:-3px"> - <label> - ${_('show inline comments')} - ${h.checkbox('',checked="checked",class_="show-inline-comments",id_for=h.FID(filenode.changeset.raw_id,filenode.path))} - </label> - </span> - </div> - </div> - <div class="code-body"> - <div class="full_f_path" path="${filenode.path}"></div> - %if diff: - ${diff|n} - %else: - ${_('No changes in this file')} - %endif - </div> - </div> - %endif - %endfor - + + ## diff block + <%namespace name="diff_block" file="/changeset/diff_block.html"/> + ${diff_block.diff_block(c.changes)} + + ## template for inline comment form <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> - ## template for inline comment form - ${comment.comment_inline_form()} + ${comment.comment_inline_form(c.changeset)} - <div class="comments"> - <div class="comments-number">${len(c.comments)} comment(s) (${c.inline_cnt} ${_('inline')})</div> - - %for path, lines in c.inline_comments: - <div style="display:none" class="inline-comment-placeholder" path="${path}" target_id="${h.FID(c.changeset.raw_id,path)}"> - % for line,comments in lines.iteritems(): - <div class="inline-comment-placeholder-line" line="${line}" target_id="${h.safeid(h.safe_unicode(path))}"> - %for co in comments: - ${comment.comment_block(co)} - %endfor - </div> - %endfor - </div> - %endfor - - %for co in c.comments: - ${comment.comment_block(co)} - %endfor - %if c.rhodecode_user.username != 'default': - <div class="comment-form"> - ${h.form(h.url('changeset_comment', repo_name=c.repo_name, revision=c.changeset.raw_id))} - <strong>${_('Leave a comment')}</strong> - <div class="clearfix"> - <div class="comment-help"> - ${_('Comments parsed using')} <a href="${h.url('rst_help')}">RST</a> ${_('syntax')} - ${_('with')} <span style="color:#003367" class="tooltip" title="${_('Use @username inside this text to send notification to this RhodeCode user')}">@mention</span> ${_('support')} - </div> - ${h.textarea('text')} - </div> - <div class="comment-button"> - ${h.submit('save', _('Comment'), class_='ui-button')} - </div> - ${h.end_form()} - </div> - %endif - </div> + ${comment.comments(c.changeset)} + <script type="text/javascript"> var deleteComment = function(comment_id){ @@ -211,52 +139,52 @@ YUE.onDOMReady(function(){ - YUE.on(YUQ('.diff-menu-activate'),'click',function(e){ + YUE.on(YUQ('.diff-menu-activate'),'click',function(e){ var act = e.currentTarget.nextElementSibling; if(YUD.hasClass(act,'active')){ - YUD.removeClass(act,'active'); - YUD.setStyle(act,'display','none'); + YUD.removeClass(act,'active'); + YUD.setStyle(act,'display','none'); }else{ - YUD.addClass(act,'active'); - YUD.setStyle(act,'display',''); + YUD.addClass(act,'active'); + YUD.setStyle(act,'display',''); } }); - - YUE.on(YUQ('.show-inline-comments'),'change',function(e){ - var show = 'none'; - var target = e.currentTarget; - if(target.checked){ - var show = '' - } - var boxid = YUD.getAttribute(target,'id_for'); - var comments = YUQ('#{0} .inline-comments'.format(boxid)); - for(c in comments){ - YUD.setStyle(comments[c],'display',show); - } - var btns = YUQ('#{0} .inline-comments-button'.format(boxid)); + + YUE.on(YUQ('.show-inline-comments'),'change',function(e){ + var show = 'none'; + var target = e.currentTarget; + if(target.checked){ + var show = '' + } + var boxid = YUD.getAttribute(target,'id_for'); + var comments = YUQ('#{0} .inline-comments'.format(boxid)); + for(c in comments){ + YUD.setStyle(comments[c],'display',show); + } + var btns = YUQ('#{0} .inline-comments-button'.format(boxid)); for(c in btns){ YUD.setStyle(btns[c],'display',show); - } - }) + } + }) YUE.on(YUQ('.line'),'click',function(e){ - var tr = e.currentTarget; - injectInlineForm(tr); + var tr = e.currentTarget; + injectInlineForm(tr); }); // inject comments into they proper positions var file_comments = YUQ('.inline-comment-placeholder'); for (f in file_comments){ - var box = file_comments[f]; - var inlines = box.children; - for(var i=0; i<inlines.length; i++){ - try{ + var box = file_comments[f]; + var inlines = box.children; + for(var i=0; i<inlines.length; i++){ + try{ - var inline = inlines[i]; - var lineno = YUD.getAttribute(inlines[i],'line'); - var lineid = "{0}_{1}".format(YUD.getAttribute(inline,'target_id'),lineno); + var inline = inlines[i]; + var lineno = YUD.getAttribute(inlines[i],'line'); + var lineid = "{0}_{1}".format(YUD.getAttribute(inline,'target_id'),lineno); var target_line = YUD.get(lineid); var add = createInlineAddButton(target_line.parentNode,'${_("add another comment")}'); @@ -264,11 +192,14 @@ var comment = new YAHOO.util.Element(tableTr('inline-comments',inline.innerHTML)) YUD.insertAfter(comment,target_line.parentNode); - }catch(e){} - } + }catch(e){ + console.log(e); + } + } } }) - </script> - </div> + </script> + + </div> </%def>