mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
collapsible.js: Minor performance improvements
This commit is contained in:
parent
17bd3ce14f
commit
917e68d68d
@ -154,7 +154,7 @@
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (typeof collapsible.dataset.noPersistence !== 'undefined') {
|
} else if (typeof collapsible.dataset.noPersistence !== 'undefined') {
|
||||||
if (collapsible.matches('.collapsed')) {
|
if (collapsible.classList.contains('collapsed')) {
|
||||||
_this.expand(collapsible);
|
_this.expand(collapsible);
|
||||||
} else {
|
} else {
|
||||||
_this.collapse(collapsible, _this.calculateCollapsedHeight(collapsible));
|
_this.collapse(collapsible, _this.calculateCollapsedHeight(collapsible));
|
||||||
@ -253,9 +253,9 @@
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collapsible.matches('table')) {
|
if (collapsible.tagName === 'TABLE') {
|
||||||
return '> tbody > tr';
|
return '> tbody > tr';
|
||||||
} else if (collapsible.matches('ul, ol')) {
|
} else if (collapsible.tagName === 'UL' || collapsible.tagName === 'OL') {
|
||||||
return '> li:not(.collapsible-control)';
|
return '> li:not(.collapsible-control)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,19 +279,23 @@
|
|||||||
var visibleRows = Number(collapsible.dataset.visibleRows);
|
var visibleRows = Number(collapsible.dataset.visibleRows);
|
||||||
if (isNaN(visibleRows)) {
|
if (isNaN(visibleRows)) {
|
||||||
visibleRows = this.defaultVisibleRows;
|
visibleRows = this.defaultVisibleRows;
|
||||||
|
} else if (visibleRows === 0) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $(rowSelector, collapsible).length > visibleRows * 2;
|
return $(rowSelector, collapsible).length > visibleRows * 2;
|
||||||
} else {
|
} else {
|
||||||
var actualHeight = collapsible.scrollHeight - parseFloat(
|
|
||||||
window.getComputedStyle(collapsible).getPropertyValue('padding-top')
|
|
||||||
);
|
|
||||||
|
|
||||||
var maxHeight = Number(collapsible.dataset.visibleHeight);
|
var maxHeight = Number(collapsible.dataset.visibleHeight);
|
||||||
if (isNaN(maxHeight)) {
|
if (isNaN(maxHeight)) {
|
||||||
maxHeight = this.defaultVisibleHeight;
|
maxHeight = this.defaultVisibleHeight;
|
||||||
|
} else if (maxHeight === 0) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var actualHeight = collapsible.scrollHeight - parseFloat(
|
||||||
|
window.getComputedStyle(collapsible).getPropertyValue('padding-top')
|
||||||
|
);
|
||||||
|
|
||||||
return actualHeight >= maxHeight * 2;
|
return actualHeight >= maxHeight * 2;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user