refactored notes.js, search.js, single.js into application.js

This commit is contained in:
Aaron Qian 2022-11-11 01:15:50 -08:00 committed by Aaron Qian
parent dd344a0262
commit 97d60b44d9
No known key found for this signature in database
GPG key ID: BF1A987C395B5B0E
40 changed files with 275 additions and 270 deletions

View file

@ -0,0 +1,32 @@
import $ from 'jquery';
import imagesLoaded from 'imagesloaded';
$(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);
}
});