Advertisement
RUSSEL86

Boostrap tab with iframe map/youtube problem solve

Apr 23rd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. <div class="container">
  2. <div class="row">
  3. <div class="col-md-12">
  4. <ul class="nav nav-tabs" id="myTabs">
  5. <li class="active"><a href="#home" data-toggle="tab">Home</a>
  6. </li>
  7. <li><a href="#mps" data-toggle="tab">Google Maps</a>
  8. </li>
  9. <li><a href="#ytb" data-toggle="tab">YouTube</a>
  10. </li>
  11. <li><a href="#rn" data-toggle="tab">Antwon</a>
  12. </li>
  13. </ul>
  14. <div class="tab-content">
  15.  
  16.  
  17.  
  18. <div class="tab-pane active" id="mps" data-src="https://maps.google.de/maps?f=q&amp;source=s_q&amp;hl=de&amp;geocode=&amp;q=moskow&amp;aq=&amp;sll=49.60804,10.807114&amp;sspn=0.40491,1.056747&amp;ie=UTF8&amp;hq=&amp;hnear=Moskau,+gorod+Moskva,+Russland&amp;ll=55.755826,37.6173&amp;spn=0.175821,0.528374&amp;t=m&amp;z=12&amp;output=embed"><br><small><a href="https://maps.google.de/maps?f=q&amp;source=embed&amp;hl=de&amp;geocode=&amp;q=moskow&amp;aq=&amp;sll=49.60804,10.807114&amp;sspn=0.40491,1.056747&amp;ie=UTF8&amp;hq=&amp;hnear=Moskau,+gorod+Moskva,+Russland&amp;ll=55.755826,37.6173&amp;spn=0.175821,0.528374&amp;t=m&amp;z=12" style="color:#0000FF;text-align:left">Größere Kartenansicht</a></small>"&gt;
  19. <iframe src="" width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>
  20. </div>
  21.  
  22. <div class="tab-pane" id="ytb" data-src="http://www.youtube.com/embed/dQBzT3XBwzU">
  23. <iframe src="" width="560" height="315" frameborder="0" allowfullscreen="allowFullScreen"></iframe>
  24. </div>
  25.  
  26.  
  27. <div class="tab-pane" id="rn" data-src="http://player.vimeo.com/video/37138051?badge=0">
  28. <iframe src="" width="500" height="203" frameborder="0" webkitallowfullscreen="webkitAllowFullScreen" mozallowfullscreen="mozallowfullscreen" allowfullscreen="allowFullScreen"></iframe>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34.  
  35.  
  36. $('#myTabs').click('show', function(e) {
  37. paneID = $(e.target).attr('href');
  38. src = $(paneID).attr('data-src');
  39. // if the iframe hasn't already been loaded once
  40. if($(paneID+" iframe").attr("src")=="")
  41. {
  42. $(paneID+" iframe").attr("src",src);
  43. }
  44. });
  45.  
  46. // dynamic by ACF repeater
  47. -------------------------------
  48. <ul class="nav nav-tabs" id="myTabs">
  49. <?php
  50. $main_field = get_field('map_area', 'option');
  51. $first_title = $main_field[0]['map_title'];
  52. $first_link = $main_field[0]['map_address_code'];
  53. //print_r($first_title);
  54.  
  55. if(get_field('map_area', 'option')): $st = 1;
  56. while(has_sub_field('map_area', 'option')):
  57. if ($st == 1){ ?>
  58. <li class="active"><a href="#home" data-toggle="tab"><?php echo $first_title?></a> </li>
  59. <?php }else {?>
  60. <li><a href="#tab<?php echo $st; ?>" data-toggle="tab"><?php the_sub_field('map_title'); ?></a> </li>
  61. <?php } $st++; endwhile; endif; ?>
  62.  
  63. </select>
  64. <div class="tab-content">
  65. <?php if(get_field('map_area', 'option')):
  66. $i = 1;
  67. while(has_sub_field('map_area', 'option')):
  68. //$class = $i == 1 ? ' active' : '';
  69. if ($i == 1){?>
  70.  
  71. <div class="tab-pane active" id="tab1" data-src="<?php echo $first_link;?>">
  72. <iframe class="googl_mapnachman" src="<?php echo $first_link;?>" width="100%" height="550" frameborder="0" allowfullscreen="allowFullScreen"></iframe>
  73. </div>
  74. <?php }else {?>
  75. <div class="tab-pane" id="tab<?php echo $i; ?>" data-src="<?php the_sub_field('map_address_code'); ?>">
  76. <iframe class="googl_mapnachman" src="" width="100%" height="550" frameborder="0" allowfullscreen="allowFullScreen"></iframe>
  77. </div>
  78. <?php } $i++;
  79.  
  80. endwhile; endif; ?>
  81.  
  82.  
  83. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement