Files
@ 97b8db701355
Branch filter:
Location: kallithea/kallithea/templates/changeset/diff_block.html
97b8db701355
7.5 KiB
text/html
templates: replace invalid metatag attributes with data attributes
(We could also use plain classes ... but stick to the plan ...)
(We could also use plain classes ... but stick to the plan ...)
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 | ## -*- coding: utf-8 -*-
<%def name="diff_block(a_repo_name, a_ref_type, a_ref_name, a_rev,
cs_repo_name, cs_ref_name, cs_ref_type, cs_rev,
file_diff_data)">
<div class="diff-collapse">
<span target="${'diff-container-%s' % (id(file_diff_data))}" class="diff-collapse-button">↑ ${_('Collapse Diff')} ↑</span>
</div>
<div class="diff-container" id="${'diff-container-%s' % (id(file_diff_data))}">
%for id_fid, url_fid, op, a_filename, cs_filename, diff, stats in file_diff_data:
${diff_block_diffblock(id_fid, url_fid, op, diff,
a_repo_name, a_rev, a_ref_type, a_ref_name, a_filename,
cs_repo_name, cs_rev, cs_ref_type, cs_ref_name, cs_filename)}
%endfor
</div>
</%def>
<%def name="diff_block_diffblock(id_fid, url_fid, op, diff,
a_repo_name, a_rev, a_ref_type, a_ref_name, a_filename,
cs_repo_name, cs_rev, cs_ref_type, cs_ref_name, cs_filename)"
>
<div id="${id_fid}_target" style="clear:both;margin-top:25px"></div>
<div id="${id_fid}" class="diffblock margined comm">
<div class="code-header">
<div class="changeset_header">
<div class="changeset_file">
${h.safe_unicode(cs_filename)}
</div>
<div class="diff-actions">
<span style="margin: 0 10px">
%if op == 'A':
<span class="no-file" data-toggle="tooltip" title="${_("No file before")}">
<i class="icon-minus-circled"></i></span>
%else:
<a href="${h.url('files_home', repo_name=a_repo_name, f_path=a_filename, revision=a_rev)}" data-toggle="tooltip" title="${_("File before")}">
<i class="icon-doc"></i></a>
%endif
%if op == 'A':
<span class="arrow" data-toggle="tooltip" title="${_("Added")}">➞</span>
%elif op == 'M':
<span class="arrow" data-toggle="tooltip" title="${_("Modified")}">➞</span>
%elif op == 'D':
<span class="arrow" data-toggle="tooltip" title="${_("Deleted")}">➞</span>
%elif op == 'R':
<span class="arrow" data-toggle="tooltip" title="${_("Renamed")}">➞</span>
%elif op is None:
<span class="arrow" data-toggle="tooltip" title="${_("No change")}">➞</span>
%else:
<span class="arrow" data-toggle="tooltip" title="${_("Unknown operation: %r") % op}">➞</span>
%endif
%if op == 'D':
<span class="no-file" data-toggle="tooltip" title="${_("No file after")}">
<i class="icon-minus-circled"></i></span>
%else:
<a href="${h.url('files_home', repo_name=cs_repo_name, f_path=cs_filename, revision=cs_rev)}" data-toggle="tooltip" title="${_("File after")}">
<i class="icon-doc"></i></a>
%endif
</span>
<a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(cs_filename),diff2=cs_rev,diff1=a_rev,diff='diff',fulldiff=1)}" data-toggle="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=cs_repo_name,f_path=h.safe_unicode(cs_filename),diff2=cs_rev,diff1=a_rev,diff='diff',fulldiff=1)}" data-toggle="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=cs_repo_name,f_path=h.safe_unicode(cs_filename),diff2=cs_rev,diff1=a_rev,diff='raw')}" data-toggle="tooltip" title="${_('Raw diff')}">
<i class="icon-diff"></i></a>
<a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(cs_filename),diff2=cs_rev,diff1=a_rev,diff='download')}" data-toggle="tooltip" title="${_('Download diff')}">
<i class="icon-floppy"></i></a>
${c.ignorews_url(request.GET, url_fid)}
${c.context_url(request.GET, url_fid)}
</div>
<span style="float:right;margin-top:-3px">
<label>
${_('Show inline comments')}
${h.checkbox('',checked="checked",class_="show-inline-comments",id_for=url_fid)}
</label>
</span>
</div>
</div>
<div class="code-body" data-f_path="${h.safe_unicode(cs_filename)}">
${diff|n}
%if cs_filename.rsplit('.')[-1] in ['png', 'gif', 'jpg', 'bmp']:
<div class="btn btn-image-diff-show">Show images</div>
%if op == 'M':
<div id="${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 op in 'DM':
<img id="${id_fid}_image-diff-img-a" class="img-diff img-diff-swapable" style="display:none"
realsrc="${h.url('files_raw_home',repo_name=a_repo_name,revision=a_rev,f_path=a_filename)}" />
%endif
%if op in 'AM':
<img id="${id_fid}_image-diff-img-b" class="img-diff img-diff-swapable" style="display:none"
realsrc="${h.url('files_raw_home',repo_name=cs_repo_name,revision=cs_rev,f_path=cs_filename)}" />
%endif
</div>
%endif
</div>
</div>
</%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']));
}
});
$('.show-inline-comments').change(function(e){
var target = e.currentTarget;
if(target == null){
target = this;
}
var boxid = $(target).attr('id_for');
if(target.checked){
$('#{0} .inline-comments'.format(boxid)).show();
}else{
$('#{0} .inline-comments'.format(boxid)).hide();
}
});
});
</script>
</%def>
|