Skip to content

Commit

Permalink
Break-words on build history
Browse files Browse the repository at this point in the history
Using zero-width spaces to break words over a configured len
  • Loading branch information
tfennelly committed Nov 18, 2014
1 parent c6eefe5 commit 122d12c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ THE SOFTWARE.
<tr class="build-row ${transitive}" buildTimeMillis="${build.timestamp.time.time}">
<td class="pane build-name">
<a class="build-status-link" href="${link}console"><l:icon alt="${build.iconColor.description} &gt; ${%Console Output}" class="${build.buildStatusIconClassName} icon-sm" tooltip="${build.iconColor.description} &gt; ${%Console Output}"/></a><st:nbsp/>
${build.displayName}
<span class="break-words" breakAfter="3">${build.displayName}</span>
</td>
<td class="pane build-details">
<a class="tip model-link inside" href="${link}">
Expand All @@ -43,7 +43,7 @@ THE SOFTWARE.
<t:buildProgressBar build="${build}"/>
</j:if>
<j:if test="${!empty build.description}">
<div class="desc">
<div class="desc break-words" breakAfter="15">
<j:out value="${app.markupFormatter.translate(build.truncatedDescription)}"/>
</div>
</j:if>
Expand Down
6 changes: 3 additions & 3 deletions war/src/main/webapp/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -961,13 +961,13 @@ table.parameters > tbody:hover {
}

#buildHistory .build-name {
width: 30%;
width: 25%;
}
#buildHistory .build-details {
width: 50%;
width: 45%;
}
#buildHistory .build-stop, #buildHistory .build-badge {
width: 10%;
width: 15%;
}

/* ========================= editable combobox style ========================= */
Expand Down
37 changes: 36 additions & 1 deletion war/src/main/webapp/scripts/hudson-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,40 @@ Form.findMatchingInput = function(base, name) {
return null; // not found
}

function breakWords(container) {
container.getElementsBySelector(".break-words").each(function(element) {
if (Element.hasClassName(element, 'words-broken')) {
// already done.
return;
}

var maxWordSize = element.getAttribute('breakAfter');
var words = element.textContent.split(/\s+/);
var newTextContent = '';

var splitRegex = new RegExp('.{1,' + maxWordSize + '}', 'g');
for (var i = 0; i < words.length; i++) {
var word = words[i];
var wordTokens = word.match(splitRegex);
if (wordTokens) {
for (var ii = 0; ii < wordTokens.length; ii++) {
if (newTextContent.length === 0) {
newTextContent += wordTokens[ii];
} else {
newTextContent += String.fromCharCode(8203) + wordTokens[ii];
}
}
} else {
newTextContent += word;
}
newTextContent += ' ';
}

element.textContent = newTextContent;
Element.addClassName(element, 'words-broken');
});
}

function updateBuildHistory(ajaxUrl,nBuild) {
if(isRunAsTest) return;

Expand Down Expand Up @@ -1654,7 +1688,7 @@ function updateBuildHistory(ajaxUrl,nBuild) {
}

insertDateSeparatorRows();

breakWords($(bh));

function updateBuilds() {
if(isPageVisible()){
Expand Down Expand Up @@ -1697,6 +1731,7 @@ function updateBuildHistory(ajaxUrl,nBuild) {
removeDateSeparatorRows();
updateBuildRows();
insertDateSeparatorRows();
breakWords($(bh));
}
});
} else {
Expand Down

0 comments on commit 122d12c

Please sign in to comment.