Guest User

Untitled

a guest
Dec 9th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
  2. <script type="text/javascript">
  3. $(document).ready(function () {
  4. // Update this value to the number of links you want to show per row
  5. var numberOfLinksPerRow = 4;
  6.  
  7. // local variables
  8. var pre = "<tr><td><div class='ms-promlink-body' id='promlink_row_";
  9. var post = "'></div></td></tr>";
  10. var numberOfLinksInCurrentRow = numberOfLinksPerRow;
  11. var currentRow = 1
  12. // find the number of promoted links we're displaying
  13. var numberOfPromotedLinks = $('.ms-promlink-body > .ms-tileview-tile-root').length;
  14. // if we have more links then we want in a row, let's continue
  15. if (numberOfPromotedLinks > numberOfLinksPerRow) {
  16. // we don't need the header anymore, no cycling through links
  17. $('.ms-promlink-root > .ms-promlink-header').empty();
  18. // let's iterate through all the links after the maximum displayed link
  19. for (i = numberOfLinksPerRow + 1; i <= numberOfPromotedLinks; i++) {
  20. // if we're reached the maximum number of links to show per row, add a new row
  21. // this happens the first time, with the values set initially
  22. if (numberOfLinksInCurrentRow == numberOfLinksPerRow) {
  23. // i just want the 2nd row to
  24. currentRow++;
  25. // create a new row of links
  26. $('.ms-promlink-root > table > tbody:last').append(pre + currentRow + post);
  27. // reset the number of links for the current row
  28. numberOfLinksInCurrentRow = 0;
  29. }
  30. // move the Nth (numberOfLinksPerRow + 1) div to the current table row
  31. $('#promlink_row_' + currentRow).append($('.ms-promlink-body > .ms-tileview-tile-root:eq(' + (numberOfLinksPerRow) + ')'));
  32. // increment the number of links in the current row
  33. numberOfLinksInCurrentRow++;
  34. }
  35. }
  36. });
  37. </script>
Add Comment
Please, Sign In to add comment