| @@ -1,0 +1,29 @@ | ||
| 1 | +/* global brightcove, brightcoveData */ | |
| 2 | +( function ( $ ) { | |
| 3 | + var script = document.createElement( 'script' ), | |
| 4 | + tld = 'co.jp' === brightcoveData.tld ? 'co.jp' : 'com', | |
| 5 | + timer = false; | |
| 6 | + | |
| 7 | + // Load Brightcove script | |
| 8 | + script.src = 'https://sadmin.brightcove.' + tld + '/js/BrightcoveExperiences.js'; | |
| 9 | + script.type = 'text/javascript'; | |
| 10 | + script.language = 'JavaScript'; | |
| 11 | + document.head.appendChild( script ); | |
| 12 | + | |
| 13 | + // Start detection for Brightcove script loading in its object | |
| 14 | + try_brightcove(); | |
| 15 | + | |
| 16 | + // Detect if Brightcove script has loaded and bind some events once loaded | |
| 17 | + function try_brightcove() { | |
| 18 | + clearTimeout( timer ); | |
| 19 | + | |
| 20 | + if ( 'object' === typeof brightcove ) { | |
| 21 | + $( document ).ready( brightcove.createExperiences ); | |
| 22 | + $( 'body' ).on( 'post-load', brightcove.createExperiences ); | |
| 23 | + | |
| 24 | + brightcove.createExperiences(); | |
| 25 | + } else { | |
| 26 | + timer = setTimeout( try_brightcove, 100 ); | |
| 27 | + } | |
| 28 | + } | |
| 29 | +} )( jQuery ); | |