hugo-toha/static/js/note.js
Emruz Hossain 67c49c7432
Fix note layout (#274)
* Re-structure note lists

Signed-off-by: hossainemruz <hossainemruz@gmail.com>

* Support note splitting

Signed-off-by: hossainemruz <hossainemruz@gmail.com>

* Update single page

Signed-off-by: hossainemruz <hossainemruz@gmail.com>

* Refactor separator logic in navbar

Signed-off-by: hossainemruz <hossainemruz@gmail.com>
2021-05-02 05:02:27 +06:00

32 lines
1.2 KiB
JavaScript

"use strict";
(function ($) {
jQuery(document).ready(function () {
function resizeGridItem(item) {
var grid = document.getElementsByClassName("note-card-holder")[0];
var rowHeight = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-auto-rows'));
var rowGap = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-row-gap'));
var rowSpan = Math.ceil((item.querySelector('.item').getBoundingClientRect().height + rowGap) / (rowHeight + rowGap));
item.style.gridRowEnd = "span " + rowSpan;
}
function resizeAllGridItems() {
var allItems = document.getElementsByClassName("note-card");
for (var x = 0; x < allItems.length; x++) {
resizeGridItem(allItems[x]);
}
}
function resizeInstance(instance) {
var item = instance.elements[0];
resizeGridItem(item);
}
// window.onload = resizeAllGridItems();
window.addEventListener("resize", resizeAllGridItems);
var allItems = document.getElementsByClassName("note-card");
for (var x = 0; x < allItems.length; x++) {
imagesLoaded(allItems[x], resizeInstance);
}
});
})(jQuery);