Show More
@@ -1,422 +1,467 b'' | |||
|
1 | 1 | |
|
2 | 2 | <%inherit file="/base/base.mako"/> |
|
3 | 3 | <%namespace name="base" file="/base/base.mako"/> |
|
4 | 4 | <%namespace name="diff_block" file="/changeset/diff_block.mako"/> |
|
5 | 5 | <%namespace name="file_base" file="/files/base.mako"/> |
|
6 | 6 | <%namespace name="sidebar" file="/base/sidebar.mako"/> |
|
7 | 7 | |
|
8 | 8 | |
|
9 | 9 | <%def name="title()"> |
|
10 | 10 | ${_('{} Commit').format(c.repo_name)} - ${h.show_id(c.commit)} |
|
11 | 11 | %if c.rhodecode_name: |
|
12 | 12 | · ${h.branding(c.rhodecode_name)} |
|
13 | 13 | %endif |
|
14 | 14 | </%def> |
|
15 | 15 | |
|
16 | 16 | <%def name="menu_bar_nav()"> |
|
17 | 17 | ${self.menu_items(active='repositories')} |
|
18 | 18 | </%def> |
|
19 | 19 | |
|
20 | 20 | <%def name="menu_bar_subnav()"> |
|
21 | 21 | ${self.repo_menu(active='commits')} |
|
22 | 22 | </%def> |
|
23 | 23 | |
|
24 | 24 | <%def name="main()"> |
|
25 | 25 | <script type="text/javascript"> |
|
26 | 26 | templateContext.commit_data.commit_id = "${c.commit.raw_id}"; |
|
27 | 27 | </script> |
|
28 | 28 | |
|
29 | 29 | <div class="box"> |
|
30 | 30 | |
|
31 | 31 | <div class="summary"> |
|
32 | 32 | |
|
33 | 33 | <div class="fieldset"> |
|
34 | 34 | <div class="left-content"> |
|
35 | 35 | <% |
|
36 | 36 | rc_user = h.discover_user(c.commit.author_email) |
|
37 | 37 | %> |
|
38 | 38 | <div class="left-content-avatar"> |
|
39 | 39 | <% |
|
40 | 40 | email = h.email_or_none(c.commit.author) |
|
41 | 41 | rc_user = h.discover_user(c.commit.author) |
|
42 | 42 | %> |
|
43 | 43 | ${base.gravatar(email, 30, tooltip=(True if rc_user else False), user=rc_user)} |
|
44 | 44 | |
|
45 | 45 | </div> |
|
46 | 46 | |
|
47 | 47 | <div class="left-content-message"> |
|
48 | 48 | <div class="fieldset collapsable-content no-hide" data-toggle="summary-details"> |
|
49 | 49 | <div class="commit truncate-wrap">${h.urlify_commit_message(h.chop_at_smart(c.commit.message, '\n', suffix_if_chopped='...'), c.repo_name)}</div> |
|
50 | 50 | </div> |
|
51 | 51 | |
|
52 | 52 | <div class="fieldset collapsable-content" data-toggle="summary-details" style="display: none"> |
|
53 | 53 | |
|
54 | 54 | <div class="commit">${h.urlify_commit_message(c.commit.message,c.repo_name)}</div> |
|
55 | 55 | </div> |
|
56 | 56 | |
|
57 | 57 | <div class="fieldset" data-toggle="summary-details"> |
|
58 | 58 | <div class=""> |
|
59 | 59 | <table> |
|
60 | 60 | <tr class="file_author"> |
|
61 | 61 | |
|
62 | 62 | <td> |
|
63 | 63 | <span class="user commit-author">${h.link_to_user(rc_user or c.commit.author)}</span> |
|
64 | 64 | <span class="commit-date">- ${h.age_component(c.commit.date)}</span> |
|
65 | 65 | </td> |
|
66 | 66 | |
|
67 | 67 | <td> |
|
68 | 68 | ## second cell for consistency with files |
|
69 | 69 | </td> |
|
70 | 70 | </tr> |
|
71 | 71 | </table> |
|
72 | 72 | </div> |
|
73 | 73 | </div> |
|
74 | 74 | |
|
75 | 75 | </div> |
|
76 | 76 | </div> |
|
77 | 77 | |
|
78 | 78 | <div class="right-content"> |
|
79 | 79 | |
|
80 | 80 | <div data-toggle="summary-details"> |
|
81 | 81 | <div class="tags tags-main"> |
|
82 | 82 | <code><a href="${h.route_path('repo_commit',repo_name=c.repo_name,commit_id=c.commit.raw_id)}">${h.show_id(c.commit)}</a></code> |
|
83 | 83 | <i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.commit.raw_id}" title="${_('Copy the full commit id')}"></i> |
|
84 | 84 | ${file_base.refs(c.commit)} |
|
85 | 85 | |
|
86 | 86 | |
|
87 | 87 | ## phase |
|
88 | 88 | % if hasattr(c.commit, 'phase') and getattr(c.commit, 'phase') != 'public': |
|
89 | 89 | <span class="tag phase-${c.commit.phase} tooltip" title="${_('Commit phase')}"> |
|
90 | 90 | <i class="icon-info"></i>${c.commit.phase} |
|
91 | 91 | </span> |
|
92 | 92 | % endif |
|
93 | 93 | |
|
94 | 94 | ## obsolete commits |
|
95 | 95 | % if getattr(c.commit, 'obsolete', False): |
|
96 | 96 | <span class="tag obsolete-${c.commit.obsolete} tooltip" title="${_('Evolve State')}"> |
|
97 | 97 | ${_('obsolete')} |
|
98 | 98 | </span> |
|
99 | 99 | % endif |
|
100 | 100 | |
|
101 | 101 | ## hidden commits |
|
102 | 102 | % if getattr(c.commit, 'hidden', False): |
|
103 | 103 | <span class="tag hidden-${c.commit.hidden} tooltip" title="${_('Evolve State')}"> |
|
104 | 104 | ${_('hidden')} |
|
105 | 105 | </span> |
|
106 | 106 | % endif |
|
107 | 107 | </div> |
|
108 | 108 | |
|
109 | 109 | <span id="parent_link" class="tag tagtag"> |
|
110 | 110 | <a href="#parentCommit" title="${_('Parent Commit')}"><i class="icon-left icon-no-margin"></i>${_('parent')}</a> |
|
111 | 111 | </span> |
|
112 | 112 | |
|
113 | 113 | <span id="child_link" class="tag tagtag"> |
|
114 | 114 | <a href="#childCommit" title="${_('Child Commit')}">${_('child')}<i class="icon-right icon-no-margin"></i></a> |
|
115 | 115 | </span> |
|
116 | 116 | <span class="tag tooltip" title="${_('Browse files at this commit')}"> |
|
117 | 117 | <i class="icon-code"></i> |
|
118 | 118 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path='')}">${_('Browse files')}</a> |
|
119 | 119 | </span> |
|
120 | 120 | |
|
121 | 121 | </div> |
|
122 | 122 | |
|
123 | 123 | </div> |
|
124 | 124 | </div> |
|
125 | 125 | |
|
126 | 126 | <div class="fieldset collapsable-content" data-toggle="summary-details" style="display: none;"> |
|
127 | 127 | </div> |
|
128 | 128 | |
|
129 | 129 | <div class="clear-fix"></div> |
|
130 | 130 | |
|
131 | <div class="btn-collapse" data-toggle="summary-details"> | |
|
131 | <div class="btn-collapse" id="break-button" data-toggle="summary-details"> | |
|
132 | 132 | ${_('Show More')} |
|
133 | 133 | </div> |
|
134 | 134 | |
|
135 | 135 | </div> |
|
136 | 136 | |
|
137 | 137 | <div class="cs_files"> |
|
138 | 138 | <%namespace name="cbdiffs" file="/codeblocks/diffs.mako"/> |
|
139 | 139 | ${cbdiffs.render_diffset_menu(c.changes[c.commit.raw_id], commit=c.commit)} |
|
140 | 140 | ${cbdiffs.render_diffset( |
|
141 | 141 | c.changes[c.commit.raw_id], commit=c.commit, use_comments=True, |
|
142 | 142 | inline_comments=c.inline_comments, |
|
143 | 143 | show_todos=False)} |
|
144 | 144 | </div> |
|
145 | 145 | |
|
146 | 146 | ## template for inline comment form |
|
147 | 147 | <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/> |
|
148 | 148 | |
|
149 | 149 | ## comments heading with count |
|
150 | 150 | <div class="comments-heading"> |
|
151 | 151 | <i class="icon-comment"></i> |
|
152 | 152 | ${_('General Comments')} ${len(c.comments)} |
|
153 | 153 | </div> |
|
154 | 154 | |
|
155 | 155 | ## render comments |
|
156 | 156 | ${comment.generate_comments(c.comments)} |
|
157 | 157 | |
|
158 | 158 | ## main comment form and it status |
|
159 | 159 | ${comment.comments(h.route_path('repo_commit_comment_create', repo_name=c.repo_name, commit_id=c.commit.raw_id), |
|
160 | 160 | h.commit_status(c.rhodecode_db_repo, c.commit.raw_id))} |
|
161 | 161 | </div> |
|
162 | 162 | |
|
163 | 163 | ### NAV SIDEBAR |
|
164 | 164 | <aside class="right-sidebar right-sidebar-expanded" id="commit-nav-sticky" style="display: none"> |
|
165 | 165 | <div class="sidenav navbar__inner" > |
|
166 | 166 | ## TOGGLE |
|
167 | 167 | <div class="sidebar-toggle" onclick="toggleSidebar(); return false"> |
|
168 | 168 | <a href="#toggleSidebar" class="grey-link-action"> |
|
169 | 169 | |
|
170 | 170 | </a> |
|
171 | 171 | </div> |
|
172 | 172 | |
|
173 | 173 | ## CONTENT |
|
174 | 174 | <div class="sidebar-content"> |
|
175 | 175 | |
|
176 | 176 | ## RULES SUMMARY/RULES |
|
177 | 177 | <div class="sidebar-element clear-both"> |
|
178 | 178 | <% vote_title = _ungettext( |
|
179 | 179 | 'Status calculated based on votes from {} reviewer', |
|
180 | 180 | 'Status calculated based on votes from {} reviewers', c.reviewers_count).format(c.reviewers_count) |
|
181 | 181 | %> |
|
182 | 182 | |
|
183 | 183 | <div class="tooltip right-sidebar-collapsed-state" style="display: none" onclick="toggleSidebar(); return false" title="${vote_title}"> |
|
184 | 184 | <i class="icon-circle review-status-${c.commit_review_status}"></i> |
|
185 | 185 | ${c.reviewers_count} |
|
186 | 186 | </div> |
|
187 | 187 | </div> |
|
188 | 188 | |
|
189 | 189 | ## REVIEWERS |
|
190 | 190 | <div class="right-sidebar-expanded-state pr-details-title"> |
|
191 | 191 | <span class="tooltip sidebar-heading" title="${vote_title}"> |
|
192 | 192 | <i class="icon-circle review-status-${c.commit_review_status}"></i> |
|
193 | 193 | ${_('Reviewers')} |
|
194 | 194 | </span> |
|
195 | 195 | </div> |
|
196 | 196 | |
|
197 | 197 | <div id="reviewers" class="right-sidebar-expanded-state pr-details-content reviewers"> |
|
198 | 198 | |
|
199 | 199 | <table id="review_members" class="group_members"> |
|
200 | 200 | ## This content is loaded via JS and ReviewersPanel |
|
201 | 201 | </table> |
|
202 | 202 | |
|
203 | 203 | </div> |
|
204 | 204 | |
|
205 | 205 | ## TODOs |
|
206 | 206 | <div class="sidebar-element clear-both"> |
|
207 | 207 | <div class="tooltip right-sidebar-collapsed-state" style="display: none" onclick="toggleSidebar(); return false" title="TODOs"> |
|
208 | 208 | <i class="icon-flag-filled"></i> |
|
209 | 209 | <span id="todos-count">${len(c.unresolved_comments)}</span> |
|
210 | 210 | </div> |
|
211 | 211 | |
|
212 | 212 | <div class="right-sidebar-expanded-state pr-details-title"> |
|
213 | 213 | ## Only show unresolved, that is only what matters |
|
214 | 214 | <span class="sidebar-heading noselect" onclick="refreshTODOs(); return false"> |
|
215 | 215 | <i class="icon-flag-filled"></i> |
|
216 | 216 | TODOs |
|
217 | 217 | </span> |
|
218 | 218 | |
|
219 | 219 | % if c.resolved_comments: |
|
220 | 220 | <span class="block-right action_button last-item noselect" onclick="$('.unresolved-todo-text').toggle(); return toggleElement(this, '.resolved-todo');" data-toggle-on="Show resolved" data-toggle-off="Hide resolved">Show resolved</span> |
|
221 | 221 | % else: |
|
222 | 222 | <span class="block-right last-item noselect">Show resolved</span> |
|
223 | 223 | % endif |
|
224 | 224 | |
|
225 | 225 | </div> |
|
226 | 226 | |
|
227 | 227 | <div class="right-sidebar-expanded-state pr-details-content"> |
|
228 | 228 | % if c.unresolved_comments + c.resolved_comments: |
|
229 | 229 | ${sidebar.comments_table(c.unresolved_comments + c.resolved_comments, len(c.unresolved_comments), todo_comments=True, is_pr=False)} |
|
230 | 230 | % else: |
|
231 | 231 | <table> |
|
232 | 232 | <tr> |
|
233 | 233 | <td> |
|
234 | 234 | ${_('No TODOs yet')} |
|
235 | 235 | </td> |
|
236 | 236 | </tr> |
|
237 | 237 | </table> |
|
238 | 238 | % endif |
|
239 | 239 | </div> |
|
240 | 240 | </div> |
|
241 | 241 | |
|
242 | 242 | ## COMMENTS |
|
243 | 243 | <div class="sidebar-element clear-both"> |
|
244 | 244 | <div class="tooltip right-sidebar-collapsed-state" style="display: none" onclick="toggleSidebar(); return false" title="${_('Comments')}"> |
|
245 | 245 | <i class="icon-comment" style="color: #949494"></i> |
|
246 | 246 | <span id="comments-count">${len(c.inline_comments_flat+c.comments)}</span> |
|
247 | 247 | <span class="display-none" id="general-comments-count">${len(c.comments)}</span> |
|
248 | 248 | <span class="display-none" id="inline-comments-count">${len(c.inline_comments_flat)}</span> |
|
249 | 249 | </div> |
|
250 | 250 | |
|
251 | 251 | <div class="right-sidebar-expanded-state pr-details-title"> |
|
252 | 252 | <span class="sidebar-heading noselect" onclick="refreshComments(); return false"> |
|
253 | 253 | <i class="icon-comment" style="color: #949494"></i> |
|
254 | 254 | ${_('Comments')} |
|
255 | 255 | </span> |
|
256 | 256 | |
|
257 | 257 | </div> |
|
258 | 258 | |
|
259 | 259 | <div class="right-sidebar-expanded-state pr-details-content"> |
|
260 | 260 | % if c.inline_comments_flat + c.comments: |
|
261 | 261 | ${sidebar.comments_table(c.inline_comments_flat + c.comments, len(c.inline_comments_flat+c.comments), is_pr=False)} |
|
262 | 262 | % else: |
|
263 | 263 | <table> |
|
264 | 264 | <tr> |
|
265 | 265 | <td> |
|
266 | 266 | ${_('No Comments yet')} |
|
267 | 267 | </td> |
|
268 | 268 | </tr> |
|
269 | 269 | </table> |
|
270 | 270 | % endif |
|
271 | 271 | </div> |
|
272 | 272 | |
|
273 | 273 | </div> |
|
274 | 274 | |
|
275 | 275 | </div> |
|
276 | 276 | |
|
277 | 277 | </div> |
|
278 | 278 | </aside> |
|
279 | 279 | |
|
280 | 280 | ## FORM FOR MAKING JS ACTION AS CHANGESET COMMENTS |
|
281 | 281 | <script type="text/javascript"> |
|
282 | 282 | window.setReviewersData = ${c.commit_set_reviewers_data_json | n}; |
|
283 | 283 | |
|
284 | 284 | $(document).ready(function () { |
|
285 | 285 | var boxmax = parseInt($('#trimmed_message_box').css('max-height'), 10); |
|
286 | 286 | |
|
287 | 287 | if ($('#trimmed_message_box').height() === boxmax) { |
|
288 | 288 | $('#message_expand').show(); |
|
289 | 289 | } |
|
290 | 290 | |
|
291 | 291 | $('#message_expand').on('click', function (e) { |
|
292 | 292 | $('#trimmed_message_box').css('max-height', 'none'); |
|
293 | 293 | $(this).hide(); |
|
294 | 294 | }); |
|
295 | 295 | |
|
296 | 296 | $('.show-inline-comments').on('click', function (e) { |
|
297 | 297 | var boxid = $(this).attr('data-comment-id'); |
|
298 | 298 | var button = $(this); |
|
299 | 299 | |
|
300 | 300 | if (button.hasClass("comments-visible")) { |
|
301 | 301 | $('#{0} .inline-comments'.format(boxid)).each(function (index) { |
|
302 | 302 | $(this).hide(); |
|
303 | 303 | }); |
|
304 | 304 | button.removeClass("comments-visible"); |
|
305 | 305 | } else { |
|
306 | 306 | $('#{0} .inline-comments'.format(boxid)).each(function (index) { |
|
307 | 307 | $(this).show(); |
|
308 | 308 | }); |
|
309 | 309 | button.addClass("comments-visible"); |
|
310 | 310 | } |
|
311 | 311 | }); |
|
312 | 312 | |
|
313 | 313 | // next links |
|
314 | 314 | $('#child_link').on('click', function (e) { |
|
315 | 315 | // fetch via ajax what is going to be the next link, if we have |
|
316 | 316 | // >1 links show them to user to choose |
|
317 | 317 | if (!$('#child_link').hasClass('disabled')) { |
|
318 | 318 | $.ajax({ |
|
319 | 319 | url: '${h.route_path('repo_commit_children',repo_name=c.repo_name, commit_id=c.commit.raw_id)}', |
|
320 | 320 | success: function (data) { |
|
321 | 321 | if (data.results.length === 0) { |
|
322 | 322 | $('#child_link').html("${_('No Child Commits')}").addClass('disabled'); |
|
323 | 323 | } |
|
324 | 324 | if (data.results.length === 1) { |
|
325 | 325 | var commit = data.results[0]; |
|
326 | 326 | window.location = pyroutes.url('repo_commit', { |
|
327 | 327 | 'repo_name': '${c.repo_name}', |
|
328 | 328 | 'commit_id': commit.raw_id |
|
329 | 329 | }); |
|
330 | 330 | } else if (data.results.length === 2) { |
|
331 | 331 | $('#child_link').addClass('disabled'); |
|
332 | 332 | $('#child_link').addClass('double'); |
|
333 | 333 | |
|
334 | 334 | var _html = ''; |
|
335 | 335 | _html += '<a title="__title__" href="__url__"><span class="tag branchtag"><i class="icon-code-fork"></i>__branch__</span> __rev__</a> ' |
|
336 | 336 | .replace('__branch__', data.results[0].branch) |
|
337 | 337 | .replace('__rev__', 'r{0}:{1}'.format(data.results[0].revision, data.results[0].raw_id.substr(0, 6))) |
|
338 | 338 | .replace('__title__', data.results[0].message) |
|
339 | 339 | .replace('__url__', pyroutes.url('repo_commit', { |
|
340 | 340 | 'repo_name': '${c.repo_name}', |
|
341 | 341 | 'commit_id': data.results[0].raw_id |
|
342 | 342 | })); |
|
343 | 343 | _html += ' | '; |
|
344 | 344 | _html += '<a title="__title__" href="__url__"><span class="tag branchtag"><i class="icon-code-fork"></i>__branch__</span> __rev__</a> ' |
|
345 | 345 | .replace('__branch__', data.results[1].branch) |
|
346 | 346 | .replace('__rev__', 'r{0}:{1}'.format(data.results[1].revision, data.results[1].raw_id.substr(0, 6))) |
|
347 | 347 | .replace('__title__', data.results[1].message) |
|
348 | 348 | .replace('__url__', pyroutes.url('repo_commit', { |
|
349 | 349 | 'repo_name': '${c.repo_name}', |
|
350 | 350 | 'commit_id': data.results[1].raw_id |
|
351 | 351 | })); |
|
352 | 352 | $('#child_link').html(_html); |
|
353 | 353 | } |
|
354 | 354 | } |
|
355 | 355 | }); |
|
356 | 356 | e.preventDefault(); |
|
357 | 357 | } |
|
358 | 358 | }); |
|
359 | 359 | |
|
360 | 360 | // prev links |
|
361 | 361 | $('#parent_link').on('click', function (e) { |
|
362 | 362 | // fetch via ajax what is going to be the next link, if we have |
|
363 | 363 | // >1 links show them to user to choose |
|
364 | 364 | if (!$('#parent_link').hasClass('disabled')) { |
|
365 | 365 | $.ajax({ |
|
366 | 366 | url: '${h.route_path("repo_commit_parents",repo_name=c.repo_name, commit_id=c.commit.raw_id)}', |
|
367 | 367 | success: function (data) { |
|
368 | 368 | if (data.results.length === 0) { |
|
369 | 369 | $('#parent_link').html('${_('No Parent Commits')}').addClass('disabled'); |
|
370 | 370 | } |
|
371 | 371 | if (data.results.length === 1) { |
|
372 | 372 | var commit = data.results[0]; |
|
373 | 373 | window.location = pyroutes.url('repo_commit', { |
|
374 | 374 | 'repo_name': '${c.repo_name}', |
|
375 | 375 | 'commit_id': commit.raw_id |
|
376 | 376 | }); |
|
377 | 377 | } else if (data.results.length === 2) { |
|
378 | 378 | $('#parent_link').addClass('disabled'); |
|
379 | 379 | $('#parent_link').addClass('double'); |
|
380 | 380 | |
|
381 | 381 | var _html = ''; |
|
382 | 382 | _html += '<a title="__title__" href="__url__"><span class="tag branchtag"><i class="icon-code-fork"></i>__branch__</span> __rev__</a>' |
|
383 | 383 | .replace('__branch__', data.results[0].branch) |
|
384 | 384 | .replace('__rev__', 'r{0}:{1}'.format(data.results[0].revision, data.results[0].raw_id.substr(0, 6))) |
|
385 | 385 | .replace('__title__', data.results[0].message) |
|
386 | 386 | .replace('__url__', pyroutes.url('repo_commit', { |
|
387 | 387 | 'repo_name': '${c.repo_name}', |
|
388 | 388 | 'commit_id': data.results[0].raw_id |
|
389 | 389 | })); |
|
390 | 390 | _html += ' | '; |
|
391 | 391 | _html += '<a title="__title__" href="__url__"><span class="tag branchtag"><i class="icon-code-fork"></i>__branch__</span> __rev__</a>' |
|
392 | 392 | .replace('__branch__', data.results[1].branch) |
|
393 | 393 | .replace('__rev__', 'r{0}:{1}'.format(data.results[1].revision, data.results[1].raw_id.substr(0, 6))) |
|
394 | 394 | .replace('__title__', data.results[1].message) |
|
395 | 395 | .replace('__url__', pyroutes.url('repo_commit', { |
|
396 | 396 | 'repo_name': '${c.repo_name}', |
|
397 | 397 | 'commit_id': data.results[1].raw_id |
|
398 | 398 | })); |
|
399 | 399 | $('#parent_link').html(_html); |
|
400 | 400 | } |
|
401 | 401 | } |
|
402 | 402 | }); |
|
403 | 403 | e.preventDefault(); |
|
404 | 404 | } |
|
405 | 405 | }); |
|
406 | 406 | |
|
407 | 407 | // browse tree @ revision |
|
408 | 408 | $('#files_link').on('click', function (e) { |
|
409 | 409 | window.location = '${h.route_path('repo_files:default_path',repo_name=c.repo_name, commit_id=c.commit.raw_id)}'; |
|
410 | 410 | e.preventDefault(); |
|
411 | 411 | }); |
|
412 | 412 | |
|
413 | 413 | reviewersController = new ReviewersController(); |
|
414 | 414 | ReviewersPanel.init(reviewersController, null, setReviewersData); |
|
415 | 415 | |
|
416 | 416 | var channel = '${c.commit_broadcast_channel}'; |
|
417 | 417 | new ReviewerPresenceController(channel) |
|
418 | 418 | |
|
419 | function breakLongCommitMessage() { | |
|
420 | const commitElements = document.querySelectorAll(".left-content-message .commit"); | |
|
421 | const maxAllowedWidth = window.innerWidth * 0.9; | |
|
422 | ||
|
423 | commitElements.forEach(commitElement => { | |
|
424 | const originalText = commitElement.textContent; | |
|
425 | const lines = originalText.split("\n"); | |
|
426 | const brokenLines = []; | |
|
427 | ||
|
428 | commitElement.style.whiteSpace = "nowrap"; | |
|
429 | ||
|
430 | for (let line of lines) { | |
|
431 | let brokenLine = ""; | |
|
432 | let words = line.split(" "); | |
|
433 | let currentLine = ""; | |
|
434 | ||
|
435 | words.forEach(word => { | |
|
436 | const testLine = currentLine.length > 0 ? currentLine + " " + word : word; | |
|
437 | ||
|
438 | commitElement.textContent = testLine; | |
|
439 | const testLineWidth = commitElement.offsetWidth; | |
|
440 | ||
|
441 | if (testLineWidth > maxAllowedWidth) { | |
|
442 | brokenLine += currentLine + "\n"; | |
|
443 | currentLine = word; | |
|
444 | } else { | |
|
445 | currentLine = testLine; | |
|
446 | } | |
|
447 | }); | |
|
448 | ||
|
449 | brokenLine += currentLine; | |
|
450 | brokenLines.push(brokenLine.trim()); | |
|
451 | } | |
|
452 | ||
|
453 | commitElement.textContent = brokenLines.join("\n"); | |
|
454 | ||
|
455 | commitElement.style.whiteSpace = "pre-wrap"; | |
|
456 | }); | |
|
457 | } | |
|
458 | ||
|
459 | window.addEventListener("load", function () { | |
|
460 | const button = document.getElementById("break-button"); | |
|
461 | button.addEventListener("click", breakLongCommitMessage); | |
|
462 | ||
|
463 | }); | |
|
419 | 464 | }) |
|
420 | 465 | </script> |
|
421 | 466 | |
|
422 | 467 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now