Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. $( document ).on('turbolinks:load', function() {
  2.  
  3. /*************************** centre *******************************************/
  4. /* copy loaded thumbnails into carousel */
  5. $('#gallery_centre .row .thumbnail').on('load', function() {
  6. }).each(function(i) {
  7. if(this.complete) {
  8. var item_centre = $('<div class="item item_centre"></div>');
  9. var itemDiv_centre = $(this).parents('div');
  10.  
  11. $(itemDiv_centre.html()).appendTo(item_centre);
  12. item_centre.appendTo('.carousel-inner_centre');
  13. if (i==0){ // set first item active
  14. item_centre.addClass('active');
  15. }
  16. }
  17. });
  18. /* activate the carousel */
  19. $('#modalCarouselCentre').carousel({interval:false});
  20. /* change modal title when slide changes */
  21. $('#modalCarouselCentre').on('slid.bs.carousel', function () {
  22. $('.modal-title').html($(this).find('.active').attr("title"));
  23. })
  24. /* when clicking a thumbnail */
  25. $('#gallery_centre .row .thumbnail').click(function(){
  26. var idx_centre = $(this).parents('div').index();
  27. var id_centre = parseInt(idx_centre);
  28. $('#myModalCentre').modal('show'); // show the modal
  29. $('#modalCarouselCentre').carousel(id_centre); // slide carousel to selected
  30. });
  31.  
  32. /***************************** Coeur *****************************************/
  33. /* copy loaded thumbnails into carousel */
  34. $('#gallery_coeur .row .thumbnail').on('load', function() {
  35. }).each(function(i) {
  36. if(this.complete) {
  37. var item_coeur = $('<div class="item item_coeur"></div>');
  38. var itemDiv_coeur = $(this).parents('div');
  39.  
  40. $(itemDiv_coeur.html()).appendTo(item_coeur);
  41. item_coeur.appendTo('.carousel-inner_coeur');
  42. if (i==0){ // set first item active
  43. item_coeur.addClass('active');
  44. }
  45. }
  46. });
  47. /* activate the carousel */
  48. $('#modalCarouselCoeur').carousel({interval:false});
  49. /* change modal title when slide changes */
  50. $('#modalCarouselCoeur').on('slid.bs.carousel', function () {
  51. $('.modal-title').html($(this).find('.active').attr("title"));
  52. })
  53. /* when clicking a thumbnail */
  54. $('#gallery_coeur .row .thumbnail').click(function(){
  55. var idx_coeur = $(this).parents('div').index();
  56. var id_coeur = parseInt(idx_coeur);
  57. $('#myModalCoeur').modal('show'); // show the modal
  58. $('#modalCarouselCoeur').carousel(id_coeur); // slide carousel to selected
  59. });
  60.  
  61. /*************************** Deloc *******************************************/
  62. /* copy loaded thumbnails into carousel */
  63. $('#gallery_deloc .row .thumbnail').on('load', function() {
  64. }).each(function(i) {
  65. if(this.complete) {
  66. var item_deloc = $('<div class="item item_deloc"></div>');
  67. var itemDiv_deloc = $(this).parents('div');
  68.  
  69. $(itemDiv_deloc.html()).appendTo(item_deloc);
  70. item_deloc.appendTo('.carousel-inner_deloc');
  71. if (i==0){ // set first item active
  72. item_deloc.addClass('active');
  73. }
  74. }
  75. });
  76. /* activate the carousel */
  77. $('#modalCarouselDeloc').carousel({interval:false});
  78. /* change modal title when slide changes */
  79. $('#modalCarouselDeloc').on('slid.bs.carousel', function () {
  80. $('.modal-title').html($(this).find('.active').attr("title"));
  81. })
  82. /* when clicking a thumbnail */
  83. $('#gallery_deloc .row .thumbnail').click(function(){
  84. var idx_deloc = $(this).parents('div').index();
  85. var id_deloc = parseInt(idx_deloc);
  86. $('#myModalDeloc').modal('show'); // show the modal
  87. $('#modalCarouselDeloc').carousel(id_deloc); // slide carousel to selected
  88. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement