mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 02:59:24 +02:00
Admin UI for libraries and uploads
This commit is contained in:
parent
9aee135c2f
commit
a605bcbe76
27 changed files with 2140 additions and 361 deletions
|
@ -2,13 +2,24 @@ import Vue from 'vue'
|
|||
|
||||
import moment from 'moment'
|
||||
|
||||
export function truncate (str, max, ellipsis) {
|
||||
export function truncate (str, max, ellipsis, middle) {
|
||||
max = max || 100
|
||||
ellipsis = ellipsis || '…'
|
||||
if (str.length <= max) {
|
||||
return str
|
||||
}
|
||||
return str.slice(0, max) + ellipsis
|
||||
if (middle) {
|
||||
var sepLen = 1,
|
||||
charsToShow = max - sepLen,
|
||||
frontChars = Math.ceil(charsToShow/2),
|
||||
backChars = Math.floor(charsToShow/2);
|
||||
|
||||
return str.substr(0, frontChars) +
|
||||
ellipsis +
|
||||
str.substr(str.length - backChars);
|
||||
} else {
|
||||
return str.slice(0, max) + ellipsis
|
||||
}
|
||||
}
|
||||
|
||||
Vue.filter('truncate', truncate)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue