Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. <ul id="thumbnails">
  2. <li>
  3. <a href="#slide1">
  4. <img src="img/image-1.jpg" alt="This is caption 1">
  5. </a>
  6. </li>
  7. <li>
  8. <a href="#slide2">
  9. <img src="img/image-2.jpg" alt="This is caption 2">
  10. </a>
  11. </li>
  12. <li>
  13. <a href="#slide3">
  14. <img src="img/image-4.jpg" alt="And this is some very long caption for slide 4.">
  15. </a>
  16. </li>
  17.  
  18. // Create thumb-wrapping-elements
  19. $('.demo_wrapper').append('<div class="thumb-box"></div>');
  20. $('.thumb-box').append('<ul class="thumbs"></ul>');
  21.  
  22. // How many thumbs? Check how many slides there is.
  23. var count = $("#thumbnails li").length;
  24.  
  25. // Loop through and create li-elements and links
  26. for (var thumbcounter = 0; thumbcounter < count; thumbcounter++) {
  27.  
  28. // Whats the width of each thumb?
  29. if (count == 1) {var thumbwidth = "100%"}
  30. if (count == 2) {var thumbwidth = "50%"}
  31. if (count == 3) {var thumbwidth = "33.33%"}
  32. if (count == 4) {var thumbwidth = "25%"}
  33. if (count == 5) {var thumbwidth = "20%"}
  34. if (count == 6) {var thumbwidth = "16.66%"}
  35. if (count == 7) {var thumbwidth = "14.28%"}
  36. if (count == 8) {var thumbwidth = "12,5%"}
  37. if (count == 9) {var thumbwidth = "11.11%"}
  38. if (count == 10) {var thumbwidth = "10%"}
  39.  
  40. thumburl = thumbcounter + 1;
  41. $('.thumbs').append('<li><a href="#' + thumburl + '" data-slide="' + thumburl + '" style="width:' + thumbwidth + ';">
  42.  
  43. </a></li>');
  44.  
  45. <div class="thumb-box">
  46. <ul class="thumbs">
  47. <li>
  48. <a href="#1" data-slide="1">
  49. <img src="img/image-1.jpg" alt="This is caption 1 <a href='#link'>Even with links!</a>">
  50. </a>
  51. </li>
  52. <li>
  53. <a href="#2" data-slide="2">
  54. <img src="img/image-2.jpg" alt="This is caption 2">
  55. </a>
  56. </li>
  57. <li>
  58. <a href="#4" data-slide="3">
  59. <img src="img/image-4.jpg" alt="And this is some very long caption for slide 4.">
  60. </a>
  61. </li>
  62. </ul>
  63. </div>
  64.  
  65. // exported and edited the thumbwidth var for efficiency
  66. var thumbwidth = (100/count) + '%';
  67.  
  68. // Loop through and create li-elements and links
  69. for (var thumbcounter = 0; thumbcounter < count; thumbcounter++) {
  70.  
  71.  
  72. var thumburl = $('.thumbnails').find('img').eq(thumbcounter).attr('src');
  73. $('.thumbs').append('<li><a href="#' + thumburl + '" data-slide="' + thumburl + '" style="width:' + thumbwidth + ';"></a></li>');
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement