You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
904 B
27 lines
904 B
function parentId(name) {
|
|
return "parent-" + name;
|
|
}
|
|
|
|
function isEllipsed(name) {
|
|
const child = document.getElementById(name);
|
|
const parent = document.getElementById(parentId(name));
|
|
const emptyData = parent.getAttribute("data-content") === "";
|
|
const hasOverflow = child.clientWidth < child.scrollWidth;
|
|
|
|
if (hasOverflow) {
|
|
if (emptyData) {
|
|
parent.setAttribute("data-content", name);
|
|
}
|
|
} else {
|
|
if (!emptyData) {
|
|
parent.setAttribute("data-content", "");
|
|
}
|
|
}
|
|
}
|
|
|
|
function ellipsedLabel ({ name, parentClass = "", childClass = "" }) {
|
|
const child = "<span onmouseover='isEllipsed(\"" + name + "\")' id='" + name + "' class='ellipsed-name " + childClass + "'>" + name + "</span>";
|
|
|
|
return "<span class='" + parentClass + "' id='" + parentId(name) + "' data-toggle='popover' data-placement='right' data-container='body' data-content=''>" + child + "</span>";
|
|
}
|