Files
@ e8229d389948
Branch filter:
Location: kallithea/kallithea/templates/changeset/diff_block.html
e8229d389948
8.7 KiB
text/html
js: move .diff-collapse-button handling from the global base.js to the special diff js
Move it where it belongs and avoid adding more stuff to the global js later.
Move it where it belongs and avoid adding more stuff to the global js later.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | ## -*- coding: utf-8 -*-
##usage:
## <%namespace name="diff_block" file="/changeset/diff_block.html"/>
## ${diff_block.diff_block(change)}
##
<%def name="diff_block(change)">
<div class="diff-collapse">
<span target="${'diff-container-%s' % (id(change))}" class="diff-collapse-button">↑ ${_('Collapse Diff')} ↑</span>
</div>
<div class="diff-container" id="${'diff-container-%s' % (id(change))}">
%for FID,(cs1, cs2, change, path, diff, stats) in change.iteritems():
<div id="${FID}_target" style="clear:both;margin-top:25px"></div>
<div id="${FID}" class="diffblock margined comm">
<div class="code-header">
<div class="changeset_header">
<div class="changeset_file">
${h.link_to_if(change!='D',h.safe_unicode(path),h.url('files_home',repo_name=c.repo_name,
revision=cs2,f_path=h.safe_unicode(path)))}
</div>
<div class="diff-actions">
<a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(path),diff2=cs2,diff1=cs1,diff='diff',fulldiff=1)}" class="tooltip" title="${_('Show full diff for this file')}">
<i class="icon-file-code"></i>
</a>
<a href="${h.url('files_diff_2way_home',repo_name=c.repo_name,f_path=h.safe_unicode(path),diff2=cs2,diff1=cs1,diff='diff',fulldiff=1)}" class="tooltip" title="${_('Show full side-by-side diff for this file')}">
<i class="icon-docs"></i>
</a>
<a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(path),diff2=cs2,diff1=cs1,diff='raw')}" class="tooltip" title="${_('Raw diff')}">
<i class="icon-diff"></i>
</a>
<a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(path),diff2=cs2,diff1=cs1,diff='download')}" class="tooltip" title="${_('Download diff')}">
<i class="icon-floppy"></i>
</a>
${c.ignorews_url(request.GET, h.FID(cs2,path))}
${c.context_url(request.GET, h.FID(cs2,path))}
</div>
<span style="float:right;margin-top:-3px">
<label>
${_('Show inline comments')}
${h.checkbox('',checked="checked",class_="show-inline-comments",id_for=h.FID(cs2,path))}
</label>
</span>
</div>
</div>
<div class="code-body full_f_path" data-f_path="${h.safe_unicode(path)}">
${diff|n}
%if path.rsplit('.')[-1] in ['png', 'gif', 'jpg', 'bmp']:
<div class="btn btn-image-diff-show">Show images</div>
%if change =='M':
<div id="${FID}_image-diff" class="btn btn-image-diff-swap" style="display:none">Press to swap images</div>
%endif
<div style="font-size: 0">
%if change in 'DM':
<img id="${FID}_image-diff-img-a" class="img-diff img-diff-swapable" style="display:none"
realsrc="${h.url('files_raw_home',repo_name=c.repo_name,revision=cs1,f_path=path)}" />
%endif
%if change in 'AM':
<img id="${FID}_image-diff-img-b" class="img-diff img-diff-swapable" style="display:none"
realsrc="${h.url('files_raw_home',repo_name=c.repo_name,revision=cs2,f_path=path)}" />
%endif
</div>
%endif
</div>
</div>
%endfor
</div>
</%def>
<%def name="diff_block_simple(files, changes)">
%for fid, ch, f, stat in files:
<%
op, filenode_path, diff = changes[fid]
%>
<div id="${h.FID('',filenode_path)}_target" style="clear:both;margin-top:25px"></div>
<div id="${h.FID('',filenode_path)}" class="diffblock margined comm">
<div class="code-header">
<div class="changeset_header">
<div class="changeset_file">
${h.safe_unicode(filenode_path)} |
## TODO: link to ancestor and head of other instead of exactly other
%if op == 'A':
${_('Added')}
<a class="spantag" href="${h.url('files_home', repo_name=c.cs_repo.repo_name, f_path=filenode_path, revision=c.cs_rev)}">${h.short_ref(c.cs_ref_type, c.cs_ref_name)}</a>
%elif op == 'M':
<a class="spantag" href="${h.url('files_home', repo_name=c.a_repo.repo_name, f_path=filenode_path, revision=c.a_rev)}">${h.short_ref(c.a_ref_type, c.a_ref_name)}</a>
<i class="icon-right"></i>
<a class="spantag" href="${h.url('files_home', repo_name=c.cs_repo.repo_name, f_path=filenode_path, revision=c.cs_rev)}">${h.short_ref(c.cs_ref_type, c.cs_ref_name)}</a>
%elif op == 'D':
${_('Deleted')}
<a class="spantag" href="${h.url('files_home', repo_name=c.a_repo.repo_name, f_path=filenode_path, revision=c.a_rev)}">${h.short_ref(c.a_ref_type, c.a_ref_name)}</a>
%elif op == 'R':
${_('Renamed')}
<a class="spantag" href="${h.url('files_home', repo_name=c.a_repo.repo_name, f_path=filenode_path, revision=c.a_rev)}">${h.short_ref(c.a_ref_type, c.a_ref_name)}</a>
<i class="icon-right"></i>
<a class="spantag" href="${h.url('files_home', repo_name=c.cs_repo.repo_name, f_path=filenode_path, revision=c.cs_rev)}">${h.short_ref(c.cs_ref_type, c.cs_ref_name)}</a>
%else:
${op}???
%endif
</div>
<div class="diff-actions">
<a href="${h.url('files_diff_2way_home',repo_name=c.cs_repo.repo_name,f_path=h.safe_unicode(filenode_path),diff1=c.a_rev,diff2=c.cs_rev,diff='diff',fulldiff=1)}" class="tooltip" title="${_('Show full side-by-side diff for this file')}">
<i class="icon-docs"></i>
</a>
${c.ignorews_url(request.GET)}
${c.context_url(request.GET)}
</div>
</div>
</div>
<div class="code-body full_f_path" data-f_path="${h.safe_unicode(filenode_path)}">
${diff|n}
%if filenode_path.rsplit('.')[-1] in ['png', 'gif', 'jpg', 'bmp']:
<div class="btn btn-image-diff-show">Show images</div>
%if op == 'M':
<div id="${h.FID('',filenode_path)}_image-diff" class="btn btn-image-diff-swap" style="display:none">Press to swap images</div>
%endif
<div style="font-size: 0">
%if op in 'DM':
<img id="${h.FID('',filenode_path)}_image-diff-img-a" class="img-diff img-diff-swapable" style="display:none"
realsrc="${h.url('files_raw_home',repo_name=c.a_repo.repo_name,revision=c.a_rev,f_path=filenode_path) if op in 'DM' else ''}" />
%endif
%if op in 'AM':
<img id="${h.FID('',filenode_path)}_image-diff-img-b" class="img-diff img-diff-swapable" style="display:none"
realsrc="${h.url('files_raw_home',repo_name=c.cs_repo.repo_name,revision=c.cs_rev,f_path=filenode_path) if op in 'AM' else ''}" />
%endif
</div>
%endif
</div>
</div>
%endfor
</%def>
<%def name="diff_block_js()">
<script type="text/javascript">
$(document).ready(function(){
$('.btn-image-diff-show').click(function(e){
$('.btn-image-diff-show').hide();
$('.btn-image-diff-swap').show();
$('.img-diff-swapable')
.each(function(i,e){
$(e).prop('src', $(e).attr('realsrc'));
})
.show();
});
$('.btn-image-diff-swap').mousedown(function(e){
$('#'+e.currentTarget.id+'-img-a.img-diff-swapable')
.before($('#'+e.currentTarget.id+'-img-b.img-diff-swapable'));
});
var reset = function(e){
$('#'+e.currentTarget.id+'-img-a.img-diff-swapable')
.after($('#'+e.currentTarget.id+'-img-b.img-diff-swapable'));
};
$('.btn-image-diff-swap').mouseup(reset);
$('.btn-image-diff-swap').mouseleave(reset);
$('.diff-collapse-button').click(function(e) {
var $button = $(e.currentTarget);
var $target = $('#' + $button.attr('target'));
if($target.hasClass('hidden')){
$target.removeClass('hidden');
$button.html("↑ {0} ↑".format(_TM['Collapse Diff']));
}
else if(!$target.hasClass('hidden')){
$target.addClass('hidden');
$button.html("↓ {0} ↓".format(_TM['Expand Diff']));
}
});
});
</script>
</%def>
|