list.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. var isMobile = false, isTablet = false, isLaptop = false;
  3. (function ($) {
  4. jQuery(document).ready(function () {
  5. function detectDevice() {
  6. if (window.innerWidth <= 425) {
  7. isMobile = true;
  8. isTablet = false;
  9. isLaptop = false;
  10. } else if (window.innerWidth <= 768) {
  11. isMobile = false;
  12. isTablet = true;
  13. isLaptop = false;
  14. } else {
  15. isMobile = false;
  16. isTablet = false;
  17. isLaptop = true;
  18. }
  19. }
  20. detectDevice();
  21. // ======= Adjust height of the post cards =============
  22. function adjustPostCardsHeight() {
  23. if (!isMobile) { // no need to adjust height for mobile devices
  24. let postCardHolder = document.getElementById("post-card-holder");
  25. if (postCardHolder == null ){
  26. return
  27. }
  28. let el = postCardHolder.children;
  29. let maxHeight = 0;
  30. for (let i = 0; i < el.length; i++) {
  31. if (el[i].children[1].clientHeight > maxHeight) {
  32. maxHeight = el[i].children[1].clientHeight;
  33. }
  34. }
  35. for (let i = 0; i < el.length; i++) {
  36. el[i].children[1].setAttribute("style", "min-height: " + maxHeight + "px;")
  37. }
  38. }
  39. }
  40. adjustPostCardsHeight();
  41. });
  42. })(jQuery);