Guest User

Untitled

a guest
Jun 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. // vypocty na tabulku a dopocitavani nakejch blblosti
  2. $bookOnLine = 4;
  3. $count = count($this->publikovaneTituly);
  4. $rows = ceil($count / $bookOnLine);
  5. $available = $rows * $bookOnLine - $count;
  6.  
  7. $data2Table = array();
  8. $i = 1;
  9. foreach ($this->publikovaneTituly as $r)
  10. {
  11. $data2Table[$i] = $r;
  12. $i++;
  13. }
  14.  
  15. unset($this->publikovaneTituly); // alokace pameti
  16.  
  17. //debug($data2Table);
  18.  
  19. echo '<table id="publikovane-tituly"><tr>';
  20. foreach ($data2Table as $index => $r)
  21. {
  22. $date = explode('-', $r->dateexp);
  23. $newDate = implode('.', array($date[2], $date[1], $date[0]) );
  24. ?>
  25. <td class="tac">
  26. <div><img src="/storage/images/100x/<?= $r->image ?>"></div>
  27. <strong><?= $r->name ?></strong> (publikováno: <?= $newDate ?>)
  28. </td>
  29. <?
  30. if ($index % $bookOnLine == 0)
  31. {
  32. echo "</tr><tr>";
  33. }
  34. }
  35.  
  36. // dopocitani prazdnych bunek
  37. if ($available > 0)
  38. {
  39. for ($i = 0; $i < $available; $i++)
  40. {
  41. ?>
  42. <td>&nbsp;</td>
  43. <?
  44. }
  45. echo '</tr>';
  46. }
  47.  
  48. echo '</table>';
  49.  
  50.  
  51. ?>
  52. <script>
  53. $(window).load(function(){
  54.  
  55. var maxHeight = 0;
  56. $("#publikovane-tituly tr").each(function(index){
  57.  
  58. $(this).find("td").each(function(index){
  59.  
  60. var imgHeight = $(this).find("img").height();
  61. if (imgHeight > maxHeight)
  62. maxHeight = imgHeight;
  63.  
  64. });
  65.  
  66. });
  67.  
  68. if (maxHeight)
  69. {
  70. $("#publikovane-tituly").find("img").parent("div").css("height", maxHeight + 10 + "px");
  71. }
  72.  
  73.  
  74. })
  75. </script>
Add Comment
Please, Sign In to add comment