##// END OF EJS Templates
js: offsetScroll to elements that are found
ergo -
r794:6ce205ff default
parent child Browse files
Show More
@@ -1,393 +1,395 b''
1 1 ## -*- coding: utf-8 -*-
2 2
3 3 <%inherit file="/base/base.html"/>
4 4 <%namespace name="diff_block" file="/changeset/diff_block.html"/>
5 5
6 6 <%def name="title()">
7 7 ${_('%s Commit') % c.repo_name} - ${h.show_id(c.commit)}
8 8 %if c.rhodecode_name:
9 9 &middot; ${h.branding(c.rhodecode_name)}
10 10 %endif
11 11 </%def>
12 12
13 13 <%def name="menu_bar_nav()">
14 14 ${self.menu_items(active='repositories')}
15 15 </%def>
16 16
17 17 <%def name="menu_bar_subnav()">
18 18 ${self.repo_menu(active='changelog')}
19 19 </%def>
20 20
21 21 <%def name="main()">
22 22 <script>
23 23 // TODO: marcink switch this to pyroutes
24 24 AJAX_COMMENT_DELETE_URL = "${url('changeset_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}";
25 25 templateContext.commit_data.commit_id = "${c.commit.raw_id}";
26 26 </script>
27 27 <div class="box">
28 28 <div class="title">
29 29 ${self.repo_page_title(c.rhodecode_db_repo)}
30 30 </div>
31 31
32 32 <div id="changeset_compare_view_content" class="summary changeset">
33 33 <div class="summary-detail">
34 34 <div class="summary-detail-header">
35 35 <span class="breadcrumbs files_location">
36 36 <h4>${_('Commit')}
37 37 <code>
38 38 ${h.show_id(c.commit)}
39 39 </code>
40 40 </h4>
41 41 </span>
42 42 <span id="parent_link">
43 43 <a href="#" title="${_('Parent Commit')}">${_('Parent')}</a>
44 44 </span>
45 45 |
46 46 <span id="child_link">
47 47 <a href="#" title="${_('Child Commit')}">${_('Child')}</a>
48 48 </span>
49 49 </div>
50 50
51 51 <div class="fieldset">
52 52 <div class="left-label">
53 53 ${_('Description')}:
54 54 </div>
55 55 <div class="right-content">
56 56 <div id="trimmed_message_box" class="commit">${h.urlify_commit_message(c.commit.message,c.repo_name)}</div>
57 57 <div id="message_expand" style="display:none;">
58 58 ${_('Expand')}
59 59 </div>
60 60 </div>
61 61 </div>
62 62
63 63 %if c.statuses:
64 64 <div class="fieldset">
65 65 <div class="left-label">
66 66 ${_('Commit status')}:
67 67 </div>
68 68 <div class="right-content">
69 69 <div class="changeset-status-ico">
70 70 <div class="${'flag_status %s' % c.statuses[0]} pull-left"></div>
71 71 </div>
72 72 <div title="${_('Commit status')}" class="changeset-status-lbl">[${h.commit_status_lbl(c.statuses[0])}]</div>
73 73 </div>
74 74 </div>
75 75 %endif
76 76
77 77 <div class="fieldset">
78 78 <div class="left-label">
79 79 ${_('References')}:
80 80 </div>
81 81 <div class="right-content">
82 82 <div class="tags">
83 83
84 84 %if c.commit.merge:
85 85 <span class="mergetag tag">
86 86 ${_('merge')}
87 87 </span>
88 88 %endif
89 89
90 90 %if h.is_hg(c.rhodecode_repo):
91 91 %for book in c.commit.bookmarks:
92 92 <span class="booktag tag" title="${_('Bookmark %s') % book}">
93 93 <a href="${h.url('files_home',repo_name=c.repo_name,revision=c.commit.raw_id)}"><i class="icon-bookmark"></i>${h.shorter(book)}</a>
94 94 </span>
95 95 %endfor
96 96 %endif
97 97
98 98 %for tag in c.commit.tags:
99 99 <span class="tagtag tag" title="${_('Tag %s') % tag}">
100 100 <a href="${h.url('files_home',repo_name=c.repo_name,revision=c.commit.raw_id)}"><i class="icon-tag"></i>${tag}</a>
101 101 </span>
102 102 %endfor
103 103
104 104 %if c.commit.branch:
105 105 <span class="branchtag tag" title="${_('Branch %s') % c.commit.branch}">
106 106 <a href="${h.url('files_home',repo_name=c.repo_name,revision=c.commit.raw_id)}"><i class="icon-code-fork"></i>${h.shorter(c.commit.branch)}</a>
107 107 </span>
108 108 %endif
109 109 </div>
110 110 </div>
111 111 </div>
112 112
113 113 <div class="fieldset">
114 114 <div class="left-label">
115 115 ${_('Diffs')}:
116 116 </div>
117 117 <div class="right-content">
118 118 <div class="diff-actions">
119 119 <a href="${h.url('changeset_raw_home',repo_name=c.repo_name,revision=c.commit.raw_id)}" class="tooltip" title="${h.tooltip(_('Raw diff'))}">
120 120 ${_('Raw Diff')}
121 121 </a>
122 122 |
123 123 <a href="${h.url('changeset_patch_home',repo_name=c.repo_name,revision=c.commit.raw_id)}" class="tooltip" title="${h.tooltip(_('Patch diff'))}">
124 124 ${_('Patch Diff')}
125 125 </a>
126 126 |
127 127 <a href="${h.url('changeset_download_home',repo_name=c.repo_name,revision=c.commit.raw_id,diff='download')}" class="tooltip" title="${h.tooltip(_('Download diff'))}">
128 128 ${_('Download Diff')}
129 129 </a>
130 130 |
131 131 ${c.ignorews_url(request.GET)}
132 132 |
133 133 ${c.context_url(request.GET)}
134 134 </div>
135 135 </div>
136 136 </div>
137 137
138 138 <div class="fieldset">
139 139 <div class="left-label">
140 140 ${_('Comments')}:
141 141 </div>
142 142 <div class="right-content">
143 143 <div class="comments-number">
144 144 %if c.comments:
145 145 <a href="#comments">${ungettext("%d Commit comment", "%d Commit comments", len(c.comments)) % len(c.comments)}</a>,
146 146 %else:
147 147 ${ungettext("%d Commit comment", "%d Commit comments", len(c.comments)) % len(c.comments)}
148 148 %endif
149 149 %if c.inline_cnt:
150 150 ## this is replaced with a proper link to first comment via JS linkifyComments() func
151 151 <a href="#inline-comments" id="inline-comments-counter">${ungettext("%d Inline Comment", "%d Inline Comments", c.inline_cnt) % c.inline_cnt}</a>
152 152 %else:
153 153 ${ungettext("%d Inline Comment", "%d Inline Comments", c.inline_cnt) % c.inline_cnt}
154 154 %endif
155 155 </div>
156 156 </div>
157 157 </div>
158 158
159 159 </div> <!-- end summary-detail -->
160 160
161 161 <div id="commit-stats" class="sidebar-right">
162 162 <div class="summary-detail-header">
163 163 <h4 class="item">
164 164 ${_('Author')}
165 165 </h4>
166 166 </div>
167 167 <div class="sidebar-right-content">
168 168 ${self.gravatar_with_user(c.commit.author)}
169 169 <div class="user-inline-data">- ${h.age_component(c.commit.date)}</div>
170 170 </div>
171 171 </div><!-- end sidebar -->
172 172 </div> <!-- end summary -->
173 173 <div class="cs_files_title">
174 174 <span class="cs_files_expand">
175 175 <span id="files_link"><a href="#" title="${_('Browse files at current commit')}">${_('Browse files')}</a></span> |
176 176
177 177 <span id="expand_all_files">${_('Expand All')}</span> | <span id="collapse_all_files">${_('Collapse All')}</span>
178 178 </span>
179 179 <h2>
180 180 ${diff_block.diff_summary_text(len(c.files), c.lines_added, c.lines_deleted, c.limited_diff)}
181 181 </h2>
182 182 </div>
183 183 </div>
184 184
185 185 <div class="cs_files">
186 186
187 187 %if not c.files:
188 188 <p class="empty_data">${_('No files')}</p>
189 189 %endif
190 190
191 191 <table class="compare_view_files commit_diff">
192 192 %for FID, (cs1, cs2, change, path, diff, stats, file) in c.changes[c.commit.raw_id].iteritems():
193 193 <tr class="cs_${change} collapse_file" fid="${FID}">
194 194 <td class="cs_icon_td">
195 195 <span class="collapse_file_icon" fid="${FID}"></span>
196 196 </td>
197 197 <td class="cs_icon_td">
198 198 <div class="flag_status not_reviewed hidden"></div>
199 199 </td>
200 200 <td class="cs_${change}" id="a_${FID}">
201 201 <div class="node">
202 202 <a href="#a_${FID}">
203 203 <i class="icon-file-${change.lower()}"></i>
204 204 ${h.safe_unicode(path)}
205 205 </a>
206 206 </div>
207 207 </td>
208 208 <td>
209 209 <div class="changes pull-right">${h.fancy_file_stats(stats)}</div>
210 210 <div class="comment-bubble pull-right" data-path="${path}">
211 211 <i class="icon-comment"></i>
212 212 </div>
213 213 </td>
214 214 </tr>
215 215 <tr fid="${FID}" id="diff_${FID}" class="diff_links">
216 216 <td></td>
217 217 <td></td>
218 218 <td class="cs_${change}">
219 219 ${diff_block.diff_menu(c.repo_name, h.safe_unicode(path), cs1, cs2, change, file)}
220 220 </td>
221 221 <td class="td-actions rc-form">
222 222 ${c.ignorews_url(request.GET, h.FID(cs2,path))} |
223 223 ${c.context_url(request.GET, h.FID(cs2,path))} |
224 224 <div data-comment-id="${h.FID(cs2,path)}" class="btn-link show-inline-comments comments-visible">
225 225 <span class="comments-show">${_('Show comments')}</span>
226 226 <span class="comments-hide">${_('Hide comments')}</span>
227 227 </div>
228 228 </td>
229 229 </tr>
230 230 <tr id="tr_${FID}">
231 231 <td></td>
232 232 <td></td>
233 233 <td class="injected_diff" colspan="2">
234 234 <div class="diff-container" id="${'diff-container-%s' % (id(change))}">
235 235 <div id="${FID}" class="diffblock margined comm">
236 236 <div class="code-body">
237 237 <div class="full_f_path" path="${h.safe_unicode(path)}"></div>
238 238 ${diff|n}
239 239 % if file and file["is_limited_diff"]:
240 240 % if file["exceeds_limit"]:
241 241 ${diff_block.file_message()}
242 242 % else:
243 243 <h5>${_('Diff was truncated. File content available only in full diff.')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a></h5>
244 244 % endif
245 245 % endif
246 246 </div>
247 247 </div>
248 248 </div>
249 249 </td>
250 250 </tr>
251 251 %endfor
252 252 </table>
253 253 </div>
254 254
255 255 % if c.limited_diff:
256 256 ${diff_block.changeset_message()}
257 257 % endif
258 258
259 259 ## template for inline comment form
260 260 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
261 261 ${comment.comment_inline_form()}
262 262
263 263 ## render comments and inlines
264 264 ${comment.generate_comments()}
265 265
266 266 ## main comment form and it status
267 267 ${comment.comments(h.url('changeset_comment', repo_name=c.repo_name, revision=c.commit.raw_id),
268 268 h.commit_status(c.rhodecode_db_repo, c.commit.raw_id))}
269 269
270 270 ## FORM FOR MAKING JS ACTION AS CHANGESET COMMENTS
271 271 <script type="text/javascript">
272 272
273 273 $(document).ready(function() {
274 274
275 275 var boxmax = parseInt($('#trimmed_message_box').css('max-height'), 10);
276 276 if($('#trimmed_message_box').height() === boxmax){
277 277 $('#message_expand').show();
278 278 }
279 279
280 280 $('#message_expand').on('click', function(e){
281 281 $('#trimmed_message_box').css('max-height', 'none');
282 282 $(this).hide();
283 283 });
284 284
285 285 $('.show-inline-comments').on('click', function(e){
286 286 var boxid = $(this).attr('data-comment-id');
287 287 var button = $(this);
288 288
289 289 if(button.hasClass("comments-visible")) {
290 290 $('#{0} .inline-comments'.format(boxid)).each(function(index){
291 291 $(this).hide();
292 292 })
293 293 button.removeClass("comments-visible");
294 294 } else {
295 295 $('#{0} .inline-comments'.format(boxid)).each(function(index){
296 296 $(this).show();
297 297 })
298 298 button.addClass("comments-visible");
299 299 }
300 300 });
301 301
302 302
303 303 // next links
304 304 $('#child_link').on('click', function(e){
305 305 // fetch via ajax what is going to be the next link, if we have
306 306 // >1 links show them to user to choose
307 307 if(!$('#child_link').hasClass('disabled')){
308 308 $.ajax({
309 309 url: '${h.url('changeset_children',repo_name=c.repo_name, revision=c.commit.raw_id)}',
310 310 success: function(data) {
311 311 if(data.results.length === 0){
312 312 $('#child_link').html('${_('No Child Commits')}').addClass('disabled');
313 313 }
314 314 if(data.results.length === 1){
315 315 var commit = data.results[0];
316 316 window.location = pyroutes.url('changeset_home', {'repo_name': '${c.repo_name}','revision': commit.raw_id});
317 317 }
318 318 else if(data.results.length === 2){
319 319 $('#child_link').addClass('disabled');
320 320 $('#child_link').addClass('double');
321 321 var _html = '';
322 322 _html +='<a title="__title__" href="__url__">__rev__</a> '
323 323 .replace('__rev__','r{0}:{1}'.format(data.results[0].revision, data.results[0].raw_id.substr(0,6)))
324 324 .replace('__title__', data.results[0].message)
325 325 .replace('__url__', pyroutes.url('changeset_home', {'repo_name': '${c.repo_name}','revision': data.results[0].raw_id}));
326 326 _html +=' | '
327 327 _html +='<a title="__title__" href="__url__">__rev__</a> '
328 328 .replace('__rev__','r{0}:{1}'.format(data.results[1].revision, data.results[1].raw_id.substr(0,6)))
329 329 .replace('__title__', data.results[1].message)
330 330 .replace('__url__', pyroutes.url('changeset_home', {'repo_name': '${c.repo_name}','revision': data.results[1].raw_id}));
331 331 $('#child_link').html(_html);
332 332 }
333 333 }
334 334 });
335 335 e.preventDefault();
336 336 }
337 337 });
338 338
339 339 // prev links
340 340 $('#parent_link').on('click', function(e){
341 341 // fetch via ajax what is going to be the next link, if we have
342 342 // >1 links show them to user to choose
343 343 if(!$('#parent_link').hasClass('disabled')){
344 344 $.ajax({
345 345 url: '${h.url('changeset_parents',repo_name=c.repo_name, revision=c.commit.raw_id)}',
346 346 success: function(data) {
347 347 if(data.results.length === 0){
348 348 $('#parent_link').html('${_('No Parent Commits')}').addClass('disabled');
349 349 }
350 350 if(data.results.length === 1){
351 351 var commit = data.results[0];
352 352 window.location = pyroutes.url('changeset_home', {'repo_name': '${c.repo_name}','revision': commit.raw_id});
353 353 }
354 354 else if(data.results.length === 2){
355 355 $('#parent_link').addClass('disabled');
356 356 $('#parent_link').addClass('double');
357 357 var _html = '';
358 358 _html +='<a title="__title__" href="__url__">Parent __rev__</a>'
359 359 .replace('__rev__','r{0}:{1}'.format(data.results[0].revision, data.results[0].raw_id.substr(0,6)))
360 360 .replace('__title__', data.results[0].message)
361 361 .replace('__url__', pyroutes.url('changeset_home', {'repo_name': '${c.repo_name}','revision': data.results[0].raw_id}));
362 362 _html +=' | '
363 363 _html +='<a title="__title__" href="__url__">Parent __rev__</a>'
364 364 .replace('__rev__','r{0}:{1}'.format(data.results[1].revision, data.results[1].raw_id.substr(0,6)))
365 365 .replace('__title__', data.results[1].message)
366 366 .replace('__url__', pyroutes.url('changeset_home', {'repo_name': '${c.repo_name}','revision': data.results[1].raw_id}));
367 367 $('#parent_link').html(_html);
368 368 }
369 369 }
370 370 });
371 371 e.preventDefault();
372 372 }
373 373 });
374 374
375 375 if (location.hash) {
376 376 var result = splitDelimitedHash(location.hash);
377 377 var line = $('html').find(result.loc);
378 if (line.length > 0){
378 379 offsetScroll(line, 70);
379 380 }
381 }
380 382
381 383 // browse tree @ revision
382 384 $('#files_link').on('click', function(e){
383 385 window.location = '${h.url('files_home',repo_name=c.repo_name, revision=c.commit.raw_id, f_path='')}';
384 386 e.preventDefault();
385 387 });
386 388
387 389 // inject comments into their proper positions
388 390 var file_comments = $('.inline-comment-placeholder');
389 391 renderInlineComments(file_comments, true);
390 392 })
391 393 </script>
392 394
393 395 </%def>
@@ -1,322 +1,324 b''
1 1 <%inherit file="/base/base.html"/>
2 2
3 3 <%def name="title(*args)">
4 4 ${_('%s Files') % c.repo_name}
5 5 %if hasattr(c,'file'):
6 6 &middot; ${h.safe_unicode(c.file.path) or '\\'}
7 7 %endif
8 8
9 9 %if c.rhodecode_name:
10 10 &middot; ${h.branding(c.rhodecode_name)}
11 11 %endif
12 12 </%def>
13 13
14 14 <%def name="breadcrumbs_links()">
15 15 ${_('Files')}
16 16 %if c.file:
17 17 @ ${h.show_id(c.commit)}
18 18 %endif
19 19 </%def>
20 20
21 21 <%def name="menu_bar_nav()">
22 22 ${self.menu_items(active='repositories')}
23 23 </%def>
24 24
25 25 <%def name="menu_bar_subnav()">
26 26 ${self.repo_menu(active='files')}
27 27 </%def>
28 28
29 29 <%def name="main()">
30 30 <div class="title">
31 31 ${self.repo_page_title(c.rhodecode_db_repo)}
32 32 </div>
33 33
34 34 <div id="pjax-container" class="summary">
35 35 <div id="files_data">
36 36 <%include file='files_pjax.html'/>
37 37 </div>
38 38 </div>
39 39 <script>
40 40 var curState = {
41 41 commit_id: "${c.commit.raw_id}"
42 42 };
43 43
44 44 var getState = function(context) {
45 45 var url = $(location).attr('href');
46 46 var _base_url = '${h.url("files_home",repo_name=c.repo_name,revision='',f_path='')}';
47 47 var _annotate_url = '${h.url("files_annotate_home",repo_name=c.repo_name,revision='',f_path='')}';
48 48 _base_url = _base_url.replace('//', '/');
49 49 _annotate_url = _annotate_url.replace('//', '/');
50 50
51 51 //extract f_path from url.
52 52 var parts = url.split(_base_url);
53 53 if (parts.length != 2) {
54 54 parts = url.split(_annotate_url);
55 55 if (parts.length != 2) {
56 56 var rev = "tip";
57 57 var f_path = "";
58 58 } else {
59 59 var parts2 = parts[1].split('/');
60 60 var rev = parts2.shift(); // pop the first element which is the revision
61 61 var f_path = parts2.join('/');
62 62 }
63 63
64 64 } else {
65 65 var parts2 = parts[1].split('/');
66 66 var rev = parts2.shift(); // pop the first element which is the revision
67 67 var f_path = parts2.join('/');
68 68 }
69 69
70 70 var _node_list_url = pyroutes.url('files_nodelist_home',
71 71 {repo_name: templateContext.repo_name,
72 72 revision: rev, f_path: f_path});
73 73 var _url_base = pyroutes.url('files_home',
74 74 {repo_name: templateContext.repo_name,
75 75 revision: rev, f_path:'__FPATH__'});
76 76 return {
77 77 url: url,
78 78 f_path: f_path,
79 79 rev: rev,
80 80 commit_id: curState.commit_id,
81 81 node_list_url: _node_list_url,
82 82 url_base: _url_base
83 83 };
84 84 };
85 85
86 86 var metadataRequest = null;
87 87 var getFilesMetadata = function() {
88 88 if (metadataRequest && metadataRequest.readyState != 4) {
89 89 metadataRequest.abort();
90 90 }
91 91 if (source_page) {
92 92 return false;
93 93 }
94 94
95 95 if ($('#file-tree-wrapper').hasClass('full-load')) {
96 96 // in case our HTML wrapper has full-load class we don't
97 97 // trigger the async load of metadata
98 98 return false;
99 99 }
100 100
101 101 var state = getState('metadata');
102 102 var url_data = {
103 103 'repo_name': templateContext.repo_name,
104 104 'commit_id': state.commit_id,
105 105 'f_path': state.f_path
106 106 };
107 107
108 108 var url = pyroutes.url('files_nodetree_full', url_data);
109 109
110 110 metadataRequest = $.ajax({url: url});
111 111
112 112 metadataRequest.done(function(data) {
113 113 $('#file-tree').html(data);
114 114 timeagoActivate();
115 115 });
116 116 metadataRequest.fail(function (data, textStatus, errorThrown) {
117 117 console.log(data);
118 118 if (data.status != 0) {
119 119 alert("Error while fetching metadata.\nError code {0} ({1}).Please consider reloading the page".format(data.status,data.statusText));
120 120 }
121 121 });
122 122 };
123 123
124 124 var callbacks = function() {
125 125 var state = getState('callbacks');
126 126 timeagoActivate();
127 127
128 128 // used for history, and switch to
129 129 var initialCommitData = {
130 130 id: null,
131 131 text: '${_("Switch To Commit")}',
132 132 type: 'sha',
133 133 raw_id: null,
134 134 files_url: null
135 135 };
136 136
137 137 if ($('#trimmed_message_box').height() < 50) {
138 138 $('#message_expand').hide();
139 139 }
140 140
141 141 $('#message_expand').on('click', function(e) {
142 142 $('#trimmed_message_box').css('max-height', 'none');
143 143 $(this).hide();
144 144 });
145 145
146 146
147 147 if (source_page) {
148 148 // variants for with source code, not tree view
149 149
150 150 if (location.href.indexOf('#') != -1) {
151 151 page_highlights = location.href.substring(location.href.indexOf('#') + 1).split('L');
152 152 if (page_highlights.length == 2) {
153 153 highlight_ranges = page_highlights[1].split(",");
154 154
155 155 var h_lines = [];
156 156 for (pos in highlight_ranges) {
157 157 var _range = highlight_ranges[pos].split('-');
158 158 if (_range.length == 2) {
159 159 var start = parseInt(_range[0]);
160 160 var end = parseInt(_range[1]);
161 161 if (start < end) {
162 162 for (var i = start; i <= end; i++) {
163 163 h_lines.push(i);
164 164 }
165 165 }
166 166 }
167 167 else {
168 168 h_lines.push(parseInt(highlight_ranges[pos]));
169 169 }
170 170 }
171 171
172 172 for (pos in h_lines) {
173 173 // @comment-highlight-color
174 174 $('#L' + h_lines[pos]).css('background-color', '#ffd887');
175 175 }
176 176
177 177 var _first_line = $('#L' + h_lines[0]).get(0);
178 178 if (_first_line) {
179 179 var line = $('#L' + h_lines[0]);
180 if (line.length > 0){
180 181 offsetScroll(line, 70);
181 182 }
182 183 }
183 184 }
185 }
184 186
185 187 // select code link event
186 188 $("#hlcode").mouseup(getSelectionLink);
187 189
188 190 // file history select2
189 191 select2FileHistorySwitcher('#diff1', initialCommitData, state);
190 192 $('#diff1').on('change', function(e) {
191 193 $('#diff').removeClass('disabled').removeAttr("disabled");
192 194 $('#show_rev').removeClass('disabled').removeAttr("disabled");
193 195 });
194 196
195 197 // show more authors
196 198 $('#show_authors').on('click', function(e) {
197 199 e.preventDefault();
198 200 var url = pyroutes.url('files_authors_home',
199 201 {'repo_name': templateContext.repo_name,
200 202 'revision': state.rev, 'f_path': state.f_path});
201 203
202 204 $.pjax({
203 205 url: url,
204 206 data: 'annotate=${"1" if c.annotate else "0"}',
205 207 container: '#file_authors',
206 208 push: false,
207 209 timeout: pjaxTimeout
208 210 }).complete(function(){
209 211 $('#show_authors').hide();
210 212 })
211 213 });
212 214
213 215 // load file short history
214 216 $('#file_history_overview').on('click', function(e) {
215 217 e.preventDefault();
216 218 path = state.f_path;
217 219 if (path.indexOf("#") >= 0) {
218 220 path = path.slice(0, path.indexOf("#"));
219 221 }
220 222 var url = pyroutes.url('changelog_file_home',
221 223 {'repo_name': templateContext.repo_name,
222 224 'revision': state.rev, 'f_path': path, 'limit': 6});
223 225 $('#file_history_container').show();
224 226 $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...')));
225 227
226 228 $.pjax({
227 229 url: url,
228 230 container: '#file_history_container',
229 231 push: false,
230 232 timeout: pjaxTimeout
231 233 })
232 234 });
233 235
234 236 }
235 237 else {
236 238 getFilesMetadata();
237 239
238 240 // fuzzy file filter
239 241 fileBrowserListeners(state.node_list_url, state.url_base);
240 242
241 243 // switch to widget
242 244 select2RefSwitcher('#refs_filter', initialCommitData);
243 245 $('#refs_filter').on('change', function(e) {
244 246 var data = $('#refs_filter').select2('data');
245 247 curState.commit_id = data.raw_id;
246 248 $.pjax({url: data.files_url, container: '#pjax-container', timeout: pjaxTimeout});
247 249 });
248 250
249 251 $("#prev_commit_link").on('click', function(e) {
250 252 var data = $(this).data();
251 253 curState.commit_id = data.commitId;
252 254 });
253 255
254 256 $("#next_commit_link").on('click', function(e) {
255 257 var data = $(this).data();
256 258 curState.commit_id = data.commitId;
257 259 });
258 260
259 261 $('#at_rev').on("keypress", function(e) {
260 262 /* ENTER PRESSED */
261 263 if (e.keyCode === 13) {
262 264 var rev = $('#at_rev').val();
263 265 // explicit reload page here. with pjax entering bad input
264 266 // produces not so nice results
265 267 window.location = pyroutes.url('files_home',
266 268 {'repo_name': templateContext.repo_name,
267 269 'revision': rev, 'f_path': state.f_path});
268 270 }
269 271 });
270 272 }
271 273 };
272 274
273 275 var pjaxTimeout = 5000;
274 276
275 277 $(document).pjax(".pjax-link", "#pjax-container", {
276 278 "fragment": "#pjax-content",
277 279 "maxCacheLength": 1000,
278 280 "timeout": pjaxTimeout
279 281 });
280 282
281 283 // define global back/forward states
282 284 var isPjaxPopState = false;
283 285 $(document).on('pjax:popstate', function() {
284 286 isPjaxPopState = true;
285 287 });
286 288
287 289 $(document).on('pjax:end', function(xhr, options) {
288 290 if (isPjaxPopState) {
289 291 isPjaxPopState = false;
290 292 callbacks();
291 293 _NODEFILTER.resetFilter();
292 294 }
293 295
294 296 // run callback for tracking if defined for google analytics etc.
295 297 // this is used to trigger tracking on pjax
296 298 if (typeof window.rhodecode_statechange_callback !== 'undefined') {
297 299 var state = getState('statechange');
298 300 rhodecode_statechange_callback(state.url, null)
299 301 }
300 302 });
301 303
302 304 $(document).on('pjax:success', function(event, xhr, options) {
303 305 if (event.target.id == "file_history_container") {
304 306 $('#file_history_overview').hide();
305 307 $('#file_history_overview_full').show();
306 308 timeagoActivate();
307 309 } else {
308 310 callbacks();
309 311 }
310 312 });
311 313
312 314 $(document).ready(function() {
313 315 callbacks();
314 316 var search_GET = "${request.GET.get('search','')}";
315 317 if (search_GET == "1") {
316 318 _NODEFILTER.initFilter();
317 319 }
318 320 });
319 321
320 322 </script>
321 323
322 324 </%def>
@@ -1,589 +1,591 b''
1 1 <%inherit file="/base/base.html"/>
2 2
3 3 <%def name="title()">
4 4 ${_('%s Pull Request #%s') % (c.repo_name, c.pull_request.pull_request_id)}
5 5 %if c.rhodecode_name:
6 6 &middot; ${h.branding(c.rhodecode_name)}
7 7 %endif
8 8 </%def>
9 9
10 10 <%def name="breadcrumbs_links()">
11 11 <span id="pr-title">
12 12 ${c.pull_request.title}
13 13 %if c.pull_request.is_closed():
14 14 (${_('Closed')})
15 15 %endif
16 16 </span>
17 17 <div id="pr-title-edit" class="input" style="display: none;">
18 18 ${h.text('pullrequest_title', id_="pr-title-input", class_="large", value=c.pull_request.title)}
19 19 </div>
20 20 </%def>
21 21
22 22 <%def name="menu_bar_nav()">
23 23 ${self.menu_items(active='repositories')}
24 24 </%def>
25 25
26 26 <%def name="menu_bar_subnav()">
27 27 ${self.repo_menu(active='showpullrequest')}
28 28 </%def>
29 29
30 30 <%def name="main()">
31 31 <script type="text/javascript">
32 32 // TODO: marcink switch this to pyroutes
33 33 AJAX_COMMENT_DELETE_URL = "${url('pullrequest_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}";
34 34 templateContext.pull_request_data.pull_request_id = ${c.pull_request.pull_request_id};
35 35 </script>
36 36 <div class="box">
37 37 <div class="title">
38 38 ${self.repo_page_title(c.rhodecode_db_repo)}
39 39 </div>
40 40
41 41 ${self.breadcrumbs()}
42 42
43 43
44 44 <div class="box pr-summary">
45 45 <div class="summary-details block-left">
46 46 <%summary = lambda n:{False:'summary-short'}.get(n)%>
47 47 <div class="pr-details-title">
48 48 ${_('Pull request #%s') % c.pull_request.pull_request_id} ${_('From')} ${h.format_date(c.pull_request.created_on)}
49 49 %if c.allowed_to_update:
50 50 <span id="open_edit_pullrequest" class="block-right action_button">${_('Edit')}</span>
51 51 <span id="close_edit_pullrequest" class="block-right action_button" style="display: none;">${_('Close')}</span>
52 52 %endif
53 53 </div>
54 54
55 55 <div id="summary" class="fields pr-details-content">
56 56 <div class="field">
57 57 <div class="label-summary">
58 58 <label>${_('Origin')}:</label>
59 59 </div>
60 60 <div class="input">
61 61 <div class="pr-origininfo">
62 62 ## branch link is only valid if it is a branch
63 63 <span class="tag">
64 64 %if c.pull_request.source_ref_parts.type == 'branch':
65 65 <a href="${h.url('changelog_home', repo_name=c.pull_request.source_repo.repo_name, branch=c.pull_request.source_ref_parts.name)}">${c.pull_request.source_ref_parts.type}: ${c.pull_request.source_ref_parts.name}</a>
66 66 %else:
67 67 ${c.pull_request.source_ref_parts.type}: ${c.pull_request.source_ref_parts.name}
68 68 %endif
69 69 </span>
70 70 <span class="clone-url">
71 71 <a href="${h.url('summary_home', repo_name=c.pull_request.source_repo.repo_name)}">${c.pull_request.source_repo.clone_url()}</a>
72 72 </span>
73 73 </div>
74 74 <div class="pr-pullinfo">
75 75 %if h.is_hg(c.pull_request.source_repo):
76 76 <input type="text" value="hg pull -r ${h.short_id(c.source_ref)} ${c.pull_request.source_repo.clone_url()}" readonly="readonly">
77 77 %elif h.is_git(c.pull_request.source_repo):
78 78 <input type="text" value="git pull ${c.pull_request.source_repo.clone_url()} ${c.pull_request.source_ref_parts.name}" readonly="readonly">
79 79 %endif
80 80 </div>
81 81 </div>
82 82 </div>
83 83 <div class="field">
84 84 <div class="label-summary">
85 85 <label>${_('Target')}:</label>
86 86 </div>
87 87 <div class="input">
88 88 <div class="pr-targetinfo">
89 89 ## branch link is only valid if it is a branch
90 90 <span class="tag">
91 91 %if c.pull_request.target_ref_parts.type == 'branch':
92 92 <a href="${h.url('changelog_home', repo_name=c.pull_request.target_repo.repo_name, branch=c.pull_request.target_ref_parts.name)}">${c.pull_request.target_ref_parts.type}: ${c.pull_request.target_ref_parts.name}</a>
93 93 %else:
94 94 ${c.pull_request.target_ref_parts.type}: ${c.pull_request.target_ref_parts.name}
95 95 %endif
96 96 </span>
97 97 <span class="clone-url">
98 98 <a href="${h.url('summary_home', repo_name=c.pull_request.target_repo.repo_name)}">${c.pull_request.target_repo.clone_url()}</a>
99 99 </span>
100 100 </div>
101 101 </div>
102 102 </div>
103 103 <div class="field">
104 104 <div class="label-summary">
105 105 <label>${_('Review')}:</label>
106 106 </div>
107 107 <div class="input">
108 108 %if c.pull_request_review_status:
109 109 <div class="${'flag_status %s' % c.pull_request_review_status} tooltip pull-left"></div>
110 110 <span class="changeset-status-lbl tooltip">
111 111 %if c.pull_request.is_closed():
112 112 ${_('Closed')},
113 113 %endif
114 114 ${h.commit_status_lbl(c.pull_request_review_status)}
115 115 </span>
116 116 - ${ungettext('calculated based on %s reviewer vote', 'calculated based on %s reviewers votes', len(c.pull_request_reviewers)) % len(c.pull_request_reviewers)}
117 117 %endif
118 118 </div>
119 119 </div>
120 120 <div class="field">
121 121 <div class="pr-description-label label-summary">
122 122 <label>${_('Description')}:</label>
123 123 </div>
124 124 <div id="pr-desc" class="input">
125 125 <div class="pr-description">${h.urlify_commit_message(c.pull_request.description, c.repo_name)}</div>
126 126 </div>
127 127 <div id="pr-desc-edit" class="input textarea editor" style="display: none;">
128 128 <textarea id="pr-description-input" size="30">${c.pull_request.description}</textarea>
129 129 </div>
130 130 </div>
131 131 <div class="field">
132 132 <div class="label-summary">
133 133 <label>${_('Comments')}:</label>
134 134 </div>
135 135 <div class="input">
136 136 <div>
137 137 <div class="comments-number">
138 138 %if c.comments:
139 139 <a href="#comments">${ungettext("%d Pull request comment", "%d Pull request comments", len(c.comments)) % len(c.comments)}</a>,
140 140 %else:
141 141 ${ungettext("%d Pull request comment", "%d Pull request comments", len(c.comments)) % len(c.comments)}
142 142 %endif
143 143 %if c.inline_cnt:
144 144 ## this is replaced with a proper link to first comment via JS linkifyComments() func
145 145 <a href="#inline-comments" id="inline-comments-counter">${ungettext("%d Inline Comment", "%d Inline Comments", c.inline_cnt) % c.inline_cnt}</a>
146 146 %else:
147 147 ${ungettext("%d Inline Comment", "%d Inline Comments", c.inline_cnt) % c.inline_cnt}
148 148 %endif
149 149
150 150 % if c.outdated_cnt:
151 151 ,${ungettext("%d Outdated Comment", "%d Outdated Comments", c.outdated_cnt) % c.outdated_cnt} <span id="show-outdated-comments" class="btn btn-link">${_('(Show)')}</span>
152 152 % endif
153 153 </div>
154 154 </div>
155 155 </div>
156 156 </div>
157 157 <div id="pr-save" class="field" style="display: none;">
158 158 <div class="label-summary"></div>
159 159 <div class="input">
160 160 <span id="edit_pull_request" class="btn btn-small">${_('Save Changes')}</span>
161 161 </div>
162 162 </div>
163 163 </div>
164 164 </div>
165 165 <div>
166 166 ## AUTHOR
167 167 <div class="reviewers-title block-right">
168 168 <div class="pr-details-title">
169 169 ${_('Author')}
170 170 </div>
171 171 </div>
172 172 <div class="block-right pr-details-content reviewers">
173 173 <ul class="group_members">
174 174 <li>
175 175 ${self.gravatar_with_user(c.pull_request.author.email, 16)}
176 176 </li>
177 177 </ul>
178 178 </div>
179 179 ## REVIEWERS
180 180 <div class="reviewers-title block-right">
181 181 <div class="pr-details-title">
182 182 ${_('Pull request reviewers')}
183 183 %if c.allowed_to_update:
184 184 <span id="open_edit_reviewers" class="block-right action_button">${_('Edit')}</span>
185 185 <span id="close_edit_reviewers" class="block-right action_button" style="display: none;">${_('Close')}</span>
186 186 %endif
187 187 </div>
188 188 </div>
189 189 <div id="reviewers" class="block-right pr-details-content reviewers">
190 190 ## members goes here !
191 191 <ul id="review_members" class="group_members">
192 192 %for member,status in c.pull_request_reviewers:
193 193 <li id="reviewer_${member.user_id}">
194 194 <div class="reviewers_member">
195 195 <div class="reviewer_status tooltip" title="${h.tooltip(h.commit_status_lbl(status[0][1].status if status else 'not_reviewed'))}">
196 196 <div class="${'flag_status %s' % (status[0][1].status if status else 'not_reviewed')} pull-left reviewer_member_status"></div>
197 197 </div>
198 198 <div id="reviewer_${member.user_id}_name" class="reviewer_name">
199 199 ${self.gravatar_with_user(member.email, 16)} <div class="reviewer">(${_('owner') if c.pull_request.user_id == member.user_id else _('reviewer')})</div>
200 200 </div>
201 201 <input id="reviewer_${member.user_id}_input" type="hidden" value="${member.user_id}" name="review_members" />
202 202 %if c.allowed_to_update:
203 203 <div class="reviewer_member_remove action_button" onclick="removeReviewMember(${member.user_id}, true)" style="visibility: hidden;">
204 204 <i class="icon-remove-sign" ></i>
205 205 </div>
206 206 %endif
207 207 </div>
208 208 </li>
209 209 %endfor
210 210 </ul>
211 211 %if not c.pull_request.is_closed():
212 212 <div id="add_reviewer_input" class='ac' style="display: none;">
213 213 %if c.allowed_to_update:
214 214 <div class="reviewer_ac">
215 215 ${h.text('user', class_='ac-input', placeholder=_('Add reviewer'))}
216 216 <div id="reviewers_container"></div>
217 217 </div>
218 218 <div>
219 219 <span id="update_pull_request" class="btn btn-small">${_('Save Changes')}</span>
220 220 </div>
221 221 %endif
222 222 </div>
223 223 %endif
224 224 </div>
225 225 </div>
226 226 </div>
227 227 <div class="box">
228 228 ##DIFF
229 229 <div class="table" >
230 230 <div id="changeset_compare_view_content">
231 231 ##CS
232 232 % if c.missing_requirements:
233 233 <div class="box">
234 234 <div class="alert alert-warning">
235 235 <div>
236 236 <strong>${_('Missing requirements:')}</strong>
237 237 ${_('These commits cannot be displayed, because this repository uses the Mercurial largefiles extension, which was not enabled.')}
238 238 </div>
239 239 </div>
240 240 </div>
241 241 % elif c.missing_commits:
242 242 <div class="box">
243 243 <div class="alert alert-warning">
244 244 <div>
245 245 <strong>${_('Missing commits')}:</strong>
246 246 ${_('This pull request cannot be displayed, because one or more commits no longer exist in the source repository.')}
247 247 ${_('Please update this pull request, push the commits back into the source repository, or consider closing this pull request.')}
248 248 </div>
249 249 </div>
250 250 </div>
251 251 % endif
252 252 <div class="compare_view_commits_title">
253 253 % if c.allowed_to_update and not c.pull_request.is_closed():
254 254 <button id="update_commits" class="btn btn-small">${_('Update commits')}</button>
255 255 % endif
256 256 % if len(c.commit_ranges):
257 257 <h2>${ungettext('Compare View: %s commit','Compare View: %s commits', len(c.commit_ranges)) % len(c.commit_ranges)}</h2>
258 258 % endif
259 259 </div>
260 260 % if not c.missing_commits:
261 261 <%include file="/compare/compare_commits.html" />
262 262 ## FILES
263 263 <div class="cs_files_title">
264 264 <span class="cs_files_expand">
265 265 <span id="expand_all_files">${_('Expand All')}</span> | <span id="collapse_all_files">${_('Collapse All')}</span>
266 266 </span>
267 267 <h2>
268 268 ${diff_block.diff_summary_text(len(c.files), c.lines_added, c.lines_deleted, c.limited_diff)}
269 269 </h2>
270 270 </div>
271 271 % endif
272 272 <div class="cs_files">
273 273 %if not c.files and not c.missing_commits:
274 274 <span class="empty_data">${_('No files')}</span>
275 275 %endif
276 276 <table class="compare_view_files">
277 277 <%namespace name="diff_block" file="/changeset/diff_block.html"/>
278 278 %for FID, change, path, stats in c.files:
279 279 <tr class="cs_${change} collapse_file" fid="${FID}">
280 280 <td class="cs_icon_td">
281 281 <span class="collapse_file_icon" fid="${FID}"></span>
282 282 </td>
283 283 <td class="cs_icon_td">
284 284 <div class="flag_status not_reviewed hidden"></div>
285 285 </td>
286 286 <td class="cs_${change}" id="a_${FID}">
287 287 <div class="node">
288 288 <a href="#a_${FID}">
289 289 <i class="icon-file-${change.lower()}"></i>
290 290 ${h.safe_unicode(path)}
291 291 </a>
292 292 </div>
293 293 </td>
294 294 <td>
295 295 <div class="changes pull-right">${h.fancy_file_stats(stats)}</div>
296 296 <div class="comment-bubble pull-right" data-path="${path}">
297 297 <i class="icon-comment"></i>
298 298 </div>
299 299 </td>
300 300 </tr>
301 301 <tr fid="${FID}" id="diff_${FID}" class="diff_links">
302 302 <td></td>
303 303 <td></td>
304 304 <td class="cs_${change}">
305 305 %if c.target_repo.repo_name == c.repo_name:
306 306 ${diff_block.diff_menu(c.repo_name, h.safe_unicode(path), c.target_ref, c.source_ref, change)}
307 307 %else:
308 308 ## this is slightly different case later, since the other repo can have this
309 309 ## file in other state than the origin repo
310 310 ${diff_block.diff_menu(c.target_repo.repo_name, h.safe_unicode(path), c.target_ref, c.source_ref, change)}
311 311 %endif
312 312 </td>
313 313 <td class="td-actions rc-form">
314 314 <div data-comment-id="${FID}" class="btn-link show-inline-comments comments-visible">
315 315 <span class="comments-show">${_('Show comments')}</span>
316 316 <span class="comments-hide">${_('Hide comments')}</span>
317 317 </div>
318 318 </td>
319 319 </tr>
320 320 <tr id="tr_${FID}">
321 321 <td></td>
322 322 <td></td>
323 323 <td class="injected_diff" colspan="2">
324 324 ${diff_block.diff_block_simple([c.changes[FID]])}
325 325 </td>
326 326 </tr>
327 327
328 328 ## Loop through inline comments
329 329 % if c.outdated_comments.get(path,False):
330 330 <tr class="outdated">
331 331 <td></td>
332 332 <td></td>
333 333 <td colspan="2">
334 334 <p>${_('Outdated Inline Comments')}:</p>
335 335 </td>
336 336 </tr>
337 337 <tr class="outdated">
338 338 <td></td>
339 339 <td></td>
340 340 <td colspan="2" class="outdated_comment_block">
341 341 % for line, comments in c.outdated_comments[path].iteritems():
342 342 <div class="inline-comment-placeholder" path="${path}" target_id="${h.safeid(h.safe_unicode(path))}">
343 343 % for co in comments:
344 344 ${comment.comment_block_outdated(co)}
345 345 % endfor
346 346 </div>
347 347 % endfor
348 348 </td>
349 349 </tr>
350 350 % endif
351 351 %endfor
352 352 ## Loop through inline comments for deleted files
353 353 %for path in c.deleted_files:
354 354 <tr class="outdated deleted">
355 355 <td></td>
356 356 <td></td>
357 357 <td>${path}</td>
358 358 </tr>
359 359 <tr class="outdated deleted">
360 360 <td></td>
361 361 <td></td>
362 362 <td>(${_('Removed')})</td>
363 363 </tr>
364 364 % if path in c.outdated_comments:
365 365 <tr class="outdated deleted">
366 366 <td></td>
367 367 <td></td>
368 368 <td colspan="2">
369 369 <p>${_('Outdated Inline Comments')}:</p>
370 370 </td>
371 371 </tr>
372 372 <tr class="outdated">
373 373 <td></td>
374 374 <td></td>
375 375 <td colspan="2" class="outdated_comment_block">
376 376 % for line, comments in c.outdated_comments[path].iteritems():
377 377 <div class="inline-comment-placeholder" path="${path}" target_id="${h.safeid(h.safe_unicode(path))}">
378 378 % for co in comments:
379 379 ${comment.comment_block_outdated(co)}
380 380 % endfor
381 381 </div>
382 382 % endfor
383 383 </td>
384 384 </tr>
385 385 % endif
386 386 %endfor
387 387 </table>
388 388 </div>
389 389 % if c.limited_diff:
390 390 <h5>${_('Commit was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}" onclick="return confirm('${_("Showing a huge diff might take some time and resources")}')">${_('Show full diff')}</a></h5>
391 391 % endif
392 392 </div>
393 393 </div>
394 394
395 395 % if c.limited_diff:
396 396 <p>${_('Commit was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}" onclick="return confirm('${_("Showing a huge diff might take some time and resources")}')">${_('Show full diff')}</a></p>
397 397 % endif
398 398
399 399 ## template for inline comment form
400 400 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
401 401 ${comment.comment_inline_form()}
402 402
403 403 ## render comments and inlines
404 404 ${comment.generate_comments(include_pull_request=True, is_pull_request=True)}
405 405
406 406 % if not c.pull_request.is_closed():
407 407 ## main comment form and it status
408 408 ${comment.comments(h.url('pullrequest_comment', repo_name=c.repo_name,
409 409 pull_request_id=c.pull_request.pull_request_id),
410 410 c.pull_request_review_status,
411 411 is_pull_request=True, change_status=c.allowed_to_change_status)}
412 412 %endif
413 413
414 414 <script type="text/javascript">
415 415 if (location.hash) {
416 416 var result = splitDelimitedHash(location.hash);
417 417 var line = $('html').find(result.loc);
418 if (line.length > 0){
418 419 offsetScroll(line, 70);
419 420 }
421 }
420 422 $(function(){
421 423 ReviewerAutoComplete('user');
422 424 // custom code mirror
423 425 var codeMirrorInstance = initPullRequestsCodeMirror('#pr-description-input');
424 426
425 427 var PRDetails = {
426 428 editButton: $('#open_edit_pullrequest'),
427 429 closeButton: $('#close_edit_pullrequest'),
428 430 viewFields: $('#pr-desc, #pr-title'),
429 431 editFields: $('#pr-desc-edit, #pr-title-edit, #pr-save'),
430 432
431 433 init: function() {
432 434 var that = this;
433 435 this.editButton.on('click', function(e) { that.edit(); });
434 436 this.closeButton.on('click', function(e) { that.view(); });
435 437 },
436 438
437 439 edit: function(event) {
438 440 this.viewFields.hide();
439 441 this.editButton.hide();
440 442 this.editFields.show();
441 443 codeMirrorInstance.refresh();
442 444 },
443 445
444 446 view: function(event) {
445 447 this.editFields.hide();
446 448 this.closeButton.hide();
447 449 this.viewFields.show();
448 450 }
449 451 };
450 452
451 453 var ReviewersPanel = {
452 454 editButton: $('#open_edit_reviewers'),
453 455 closeButton: $('#close_edit_reviewers'),
454 456 addButton: $('#add_reviewer_input'),
455 457 removeButtons: $('.reviewer_member_remove'),
456 458
457 459 init: function() {
458 460 var that = this;
459 461 this.editButton.on('click', function(e) { that.edit(); });
460 462 this.closeButton.on('click', function(e) { that.close(); });
461 463 },
462 464
463 465 edit: function(event) {
464 466 this.editButton.hide();
465 467 this.closeButton.show();
466 468 this.addButton.show();
467 469 this.removeButtons.css('visibility', 'visible');
468 470 },
469 471
470 472 close: function(event) {
471 473 this.editButton.show();
472 474 this.closeButton.hide();
473 475 this.addButton.hide();
474 476 this.removeButtons.css('visibility', 'hidden');
475 477 }
476 478 };
477 479
478 480 PRDetails.init();
479 481 ReviewersPanel.init();
480 482
481 483 $('#show-outdated-comments').on('click', function(e){
482 484 var button = $(this);
483 485 var outdated = $('.outdated');
484 486 if (button.html() === "(Show)") {
485 487 button.html("(Hide)");
486 488 outdated.show();
487 489 } else {
488 490 button.html("(Show)");
489 491 outdated.hide();
490 492 }
491 493 });
492 494
493 495 $('.show-inline-comments').on('change', function(e){
494 496 var show = 'none';
495 497 var target = e.currentTarget;
496 498 if(target.checked){
497 499 show = ''
498 500 }
499 501 var boxid = $(target).attr('id_for');
500 502 var comments = $('#{0} .inline-comments'.format(boxid));
501 503 var fn_display = function(idx){
502 504 $(this).css('display', show);
503 505 };
504 506 $(comments).each(fn_display);
505 507 var btns = $('#{0} .inline-comments-button'.format(boxid));
506 508 $(btns).each(fn_display);
507 509 });
508 510
509 511 // inject comments into their proper positions
510 512 var file_comments = $('.inline-comment-placeholder');
511 513 %if c.pull_request.is_closed():
512 514 renderInlineComments(file_comments, false);
513 515 %else:
514 516 renderInlineComments(file_comments, true);
515 517 %endif
516 518 var commentTotals = {};
517 519 $.each(file_comments, function(i, comment) {
518 520 var path = $(comment).attr('path');
519 521 var comms = $(comment).children().length;
520 522 if (path in commentTotals) {
521 523 commentTotals[path] += comms;
522 524 } else {
523 525 commentTotals[path] = comms;
524 526 }
525 527 });
526 528 $.each(commentTotals, function(path, total) {
527 529 var elem = $('.comment-bubble[data-path="'+ path +'"]');
528 530 elem.css('visibility', 'visible');
529 531 elem.html(elem.html() + ' ' + total );
530 532 });
531 533
532 534 $('#merge_pull_request_form').submit(function() {
533 535 if (!$('#merge_pull_request').attr('disabled')) {
534 536 $('#merge_pull_request').attr('disabled', 'disabled');
535 537 }
536 538 return true;
537 539 });
538 540
539 541 $('#edit_pull_request').on('click', function(e){
540 542 var title = $('#pr-title-input').val();
541 543 var description = codeMirrorInstance.getValue();
542 544 editPullRequest(
543 545 "${c.repo_name}", "${c.pull_request.pull_request_id}",
544 546 title, description);
545 547 });
546 548
547 549 $('#update_pull_request').on('click', function(e){
548 550 updateReviewers(undefined, "${c.repo_name}", "${c.pull_request.pull_request_id}");
549 551 });
550 552
551 553 $('#update_commits').on('click', function(e){
552 554 var isDisabled = !$(e.currentTarget).attr('disabled');
553 555 $(e.currentTarget).text(_gettext('Updating...'));
554 556 $(e.currentTarget).attr('disabled', 'disabled');
555 557 if(isDisabled){
556 558 updateCommits("${c.repo_name}", "${c.pull_request.pull_request_id}");
557 559 }
558 560
559 561 });
560 562 // fixing issue with caches on firefox
561 563 $('#update_commits').removeAttr("disabled");
562 564
563 565 $('#close_pull_request').on('click', function(e){
564 566 closePullRequest("${c.repo_name}", "${c.pull_request.pull_request_id}");
565 567 });
566 568
567 569 $('.show-inline-comments').on('click', function(e){
568 570 var boxid = $(this).attr('data-comment-id');
569 571 var button = $(this);
570 572
571 573 if(button.hasClass("comments-visible")) {
572 574 $('#{0} .inline-comments'.format(boxid)).each(function(index){
573 575 $(this).hide();
574 576 })
575 577 button.removeClass("comments-visible");
576 578 } else {
577 579 $('#{0} .inline-comments'.format(boxid)).each(function(index){
578 580 $(this).show();
579 581 })
580 582 button.addClass("comments-visible");
581 583 }
582 584 });
583 585 })
584 586 </script>
585 587
586 588 </div>
587 589 </div>
588 590
589 591 </%def>
General Comments 0
You need to be logged in to leave comments. Login now