// ===== Extensions to bootstrap theme // ===== 2017-2019 enbiz Gerd Stammwitz //console.log('Loaded bootstrap_addons'); jQuery('document').ready(function(e) { // --- Close all (sic!) sections jQuery('.panel-group').on('show.bs.collapse','.collapse', function (e) { //console.log('Fired: Close all'); jQuery('.collapse.in').collapse('hide'); }); // --- Scroll panel to top of browser area when opened // Based on http://stackoverflow.com/questions/14646231/bootstrap-collapse-go-to-top-of-the-open-item jQuery('.panel-group').on('shown.bs.collapse', function (e) { //console.log('Fired: Move to top'); var panelhead = jQuery(this).find('.panel > .collapse.in').closest('.panel').find('.panel-heading'); jQuery('html, body').animate({scrollTop: panelhead.offset().top + -50}, 500); }); /* jQuery('.panel-group').bind('shown', function() { var active=jQuery("#accordion_univlist .in").attr('id'); scrollhere('#'+active); jQuery('.closebutton-right').hide(); }); jQuery('.accordion-heading').click(function () { // Do something if you want to do on click else ignore this handler. }); function scrollhere(destination){ var stop = jQuery(destination).offset().top - 80; var delay = 1000; jQuery('body,html').animate({scrollTop: stop}, delay); return false; } */ // ===== Extend Bootstrap's Modal // ===== Stop all videos when a modal is closed // ===== 20190926 enbiz Gerd Stammwitz jQuery('document').ready(function(e) { function stopAllVideos() { jQuery('.video-js').each(function(){ videojs(this.id).ready(function(){ this.pause(); }); }); } jQuery('.modal').on('hide.bs.modal',function(e) { //console.log('Hide modal'); stopAllVideos(); }); // --- Autoplay video in popup // Default to first video jQuery('.modal.autoplay').on('shown.bs.modal',function(e) { var firstVideoID=jQuery(this).find('video').first().attr('id'); //console.log('BT Autoplay Hook '+firstVideoID); // Silently ignore missing if (typeof firstVideoID != 'undefined') { var vid=document.getElementById(firstVideoID); vid.play(); } //stopAllVideos(); ; }); }); });