3
function make_unified(chunk) {
4
var pending_added = [];
5
function flush_adds(before) {
6
for (var i = 0; i < pending_added.length; i++) {
7
before.ancestor().insertBefore(pending_added[i], before);
9
pending_added.length = 0;
11
chunk.get('children').filter(".pseudorow").each(
13
if (line.hasClass("context-row")) {
15
line.removeChild(line.query('.code'));
17
else if (line.hasClass("both-row")) {
18
var added_line = line.create('<div class="pseudorow insert-row"><div class="lineNumber first"> </div><div class="clear"> </div></div>');
19
var clear = added_line.query('.clear');
20
added_line.insertBefore(line.query('.lineNumber.second'), clear);
21
added_line.insertBefore(line.query('.code.insert'), clear);
22
pending_added[pending_added.length] = added_line;
23
line.insertBefore(line.create('<div class="lineNumber second"> </div>'), line.query('.code.delete'));
24
line.replaceClass("both-row", "delete-row");
26
else if (line.hasClass("insert-row")) {
28
line.removeChild(line.query('.blank'));
30
else if (line.hasClass("delete-row")) {
31
line.removeChild(line.query('.blank'));
32
line.insertBefore(line.query('.lineNumber.second'), line.query('.code.delete'));
36
chunk.replaceClass('sbs', 'unified');
39
function make_sbs(chunk) {
42
function clear_bufs(before) {
43
if (!added.length && !removed.length) return;
44
var common = Math.min(added.length, removed.length);
45
for (var i = 0; i < common; i++) {
48
a.ancestor().removeChild(a);
49
r.removeChild(r.query('.lineNumber.second'));
50
r.insertBefore(a.query('.lineNumber.second'), r.query('.clear'));
51
r.insertBefore(a.query('.code.insert'), r.query('.clear'));
52
r.replaceClass('removed-row', 'both-row');
54
if (added.length > removed.length) {
55
for (var j = common; j < added.length; j++) {
57
a.insertBefore(a.create('<div class="blank"> </div>'), a.query('.lineNumber.second'));
60
else if (added.length < removed.length) {
61
for (var j = common; j < removed.length; j++) {
63
r.insertBefore(r.query('.code.delete'), r.query('.lineNumber.second'));
64
r.insertBefore(r.create('<div class="blank"> </div>'), r.query('.clear'));
70
chunk.get('children').filter(".pseudorow").each(
72
if (line.hasClass("context-row")) {
74
line.insertBefore(line.query('.code').cloneNode(true), line.query(".second"));
76
else if (line.hasClass("insert-row")) {
77
added[added.length] = line;
79
else if (line.hasClass("delete-row")) {
80
removed[removed.length] = line;
84
chunk.replaceClass('unified', 'sbs');
88
function toggle_unified_sbs(event) {
89
event.preventDefault();
90
var pts = Y.all(".pseudotable");
92
pts && pts.each(make_sbs);
94
Y.get("#toggle_unified_sbs").set('innerHTML', "Show unified diffs");
97
pts && pts.each(make_unified);
99
Y.get("#toggle_unified_sbs").set('innerHTML', "Show diffs side-by-side");
103
Y.on("click", toggle_unified_sbs, '#toggle_unified_sbs');
105
function toggle_expand_all_revisionview(action)
107
var diffs = Y.all('.diff');
108
if (diffs == null) return;
112
var collapsable = item.collapsable;
113
if(action == 'close')
115
Y.get('#expand_all').setStyle('display','block');
116
Y.get('#collapse_all').setStyle('display','none');
119
else if(action == 'open')
121
Y.get('#expand_all').setStyle('display','none');
122
Y.get('#collapse_all').setStyle('display','block');
131
event.preventDefault();
132
toggle_expand_all_revisionview('open');
140
event.preventDefault();
141
toggle_expand_all_revisionview('close');
146
function node_process(node) {
148
node.get('children').filter('.pseudotable').each(make_sbs);
152
function zoom_to_diff (path) {
153
var collapsable = Y.get('#' + path_to_id[path]).collapsable;
154
if (!collapsable.is_open) {
157
window.location.hash = '#' + path;
163
"domready", function () {
164
Y.all(".show_if_js").removeClass("show_if_js");
165
if (!specific_path) {
166
Y.all("#list-files a").on(
170
var path = decodeURIComponent(e.target.get('href').split('#')[1]);
171
window.location.hash = '#' + path;
175
var diffs = Y.all('.diff');
176
if (diffs == null) return;
180
var source_url = null;
182
source_url = global_path + '+filediff/' + link_data[item.get('id')];
183
item.query('.the-link').on(
187
collapsable.toggle();
189
var collapsable = new Collapsable(
191
expand_icon: item.query('.expand_diff'),
192
open_node: item.query('.diffinfo'),
195
is_open: specific_path != null,
196
loading: item.query('.loading'),
197
node_process: node_process
199
item.collapsable=collapsable;
201
if (window.location.hash && !specific_path) {
202
zoom_to_diff(window.location.hash.substring(1));