Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate filename in the middle on filepicker #14912

Merged
merged 1 commit into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions core/css/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,16 @@ code {
padding-left: 51px;
background-position: 7px 7px;
cursor: pointer;
// avoid taking full width
max-width: 0;
.filename-parts {
display: flex;
&__first {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
}
.filesize, .date {
width: 80px;
Expand Down Expand Up @@ -917,6 +927,9 @@ code {
background-size: contain;
line-height: $name-height;
max-width: none;
.filename-parts {
justify-content: center;
}
}
&.filesize {
line-height: $name-height / 3;
Expand Down
15 changes: 15 additions & 0 deletions core/js/oc-dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1060,10 +1060,25 @@ var OCdialogs = {
simpleSize = t('files', 'Pending');
sizeColor = 80;
}

// split the filename in half if the size is bigger than 20 char
// for ellipsis
if (entry.name.length >= 10) {
// leave maximum 10 letters
var split = Math.min(Math.floor(entry.name.length / 2), 10)
var filename1 = entry.name.substr(0, entry.name.length - split)
var filename2 = entry.name.substr(entry.name.length - split)
} else {
var filename1 = entry.name
var filename2 = ''
}

var $row = self.$listTmpl.octemplate({
type: entry.type,
dir: dir,
filename: entry.name,
filename1: filename1,
filename2: filename2,
date: OC.Util.relativeModifiedDate(entry.mtime),
size: simpleSize,
sizeColor: sizeColor,
Expand Down
6 changes: 5 additions & 1 deletion core/templates/filepicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ <h2>{emptytext}</h2>
<tbody>
<tr data-entryname="{filename}" data-type="{type}">
<td class="filename"
style="background-image:url({icon})">{filename}
style="background-image:url({icon})">
<span class="filename-parts">
<span class="filename-parts__first">{filename1}</span>
<span class="filename-parts__last">{filename2}</span>
</div>
</td>
<td class="filesize"
style="color:rgb({sizeColor}, {sizeColor}, {sizeColor})">
Expand Down