Show More
@@ -128,7 +128,7 b'' | |||||
128 |
|
128 | |||
129 | <div class="clear-fix"></div> |
|
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 | ${_('Show More')} |
|
132 | ${_('Show More')} | |
133 | </div> |
|
133 | </div> | |
134 |
|
134 | |||
@@ -416,6 +416,51 b'' | |||||
416 | var channel = '${c.commit_broadcast_channel}'; |
|
416 | var channel = '${c.commit_broadcast_channel}'; | |
417 | new ReviewerPresenceController(channel) |
|
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 | </script> |
|
465 | </script> | |
421 |
|
466 |
General Comments 0
You need to be logged in to leave comments.
Login now