mirror of
https://github.com/ail-project/ail-framework.git
synced 2025-02-14 13:26:24 +00:00
chg: [show tracker] add btn to hide/show long rule
This commit is contained in:
parent
05bcfaa7d1
commit
63be1f3d0f
1 changed files with 21 additions and 19 deletions
|
@ -220,7 +220,10 @@
|
|||
{% if rule_content %}
|
||||
<h5 class="mb-0">Yara Rule:</h5>
|
||||
<p class="my-0">
|
||||
<pre class="text-collapse border bg-light">{{ rule_content }}</pre>
|
||||
<pre class="text-collapse border bg-light mb-0">
|
||||
{{ rule_content }}
|
||||
</pre>
|
||||
<button class="btn btn-info btn-sm" id="btn_read_more">Show more</button>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
|
@ -380,7 +383,6 @@
|
|||
$('#div_edit_tags').hide();
|
||||
$('#div_edit_description').hide();
|
||||
$("#page-Tracker").addClass("active");
|
||||
text_collapse();
|
||||
|
||||
$('#date-range-from').dateRangePicker({
|
||||
separator: ' to ',
|
||||
|
@ -439,26 +441,26 @@
|
|||
}
|
||||
}
|
||||
|
||||
function text_collapse() {
|
||||
const textElements = document.querySelectorAll(".text-collapse");
|
||||
// Hover effect
|
||||
var btn_read_more = $('#btn_read_more')
|
||||
var textElement = document.querySelectorAll(".text-collapse")[0];
|
||||
const lineHeight = parseFloat(window.getComputedStyle(textElement).lineHeight);
|
||||
var maxLines = 30;
|
||||
const maxHeight = lineHeight * maxLines;
|
||||
|
||||
textElements.forEach((textElement) => {
|
||||
console.log(textElements)
|
||||
const lineHeight = parseFloat(window.getComputedStyle(textElement).lineHeight);
|
||||
const maxLines = 30;
|
||||
const maxHeight = lineHeight * maxLines;
|
||||
|
||||
// Apply initial truncation
|
||||
textElement.style.maxHeight = maxHeight + 'px';
|
||||
|
||||
// Hover effect
|
||||
textElement.addEventListener("mouseenter", () => {
|
||||
// Apply initial truncation
|
||||
textElement.style.maxHeight = maxHeight + 'px';
|
||||
if (textElement.getBoundingClientRect().height < maxHeight) {
|
||||
btn_read_more.hide();
|
||||
} else {
|
||||
btn_read_more.on("click", function() {
|
||||
if (btn_read_more.text() === "Show more") {
|
||||
textElement.style.maxHeight = 'none';
|
||||
});
|
||||
|
||||
textElement.addEventListener("mouseleave", () => {
|
||||
btn_read_more.text("Show less");
|
||||
} else {
|
||||
textElement.style.maxHeight = maxHeight + 'px';
|
||||
});
|
||||
btn_read_more.text("Show more");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue