diff options
Diffstat (limited to 'plugins/jetpack/modules/shortcodes/js/brightcove.js')
-rw-r--r-- | plugins/jetpack/modules/shortcodes/js/brightcove.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/plugins/jetpack/modules/shortcodes/js/brightcove.js b/plugins/jetpack/modules/shortcodes/js/brightcove.js new file mode 100644 index 00000000..c4f8ba50 --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/js/brightcove.js @@ -0,0 +1,29 @@ +/* global brightcove, brightcoveData */ +(function($){ + var script = document.createElement('script'), + tld = 'co.jp' === brightcoveData.tld ? 'co.jp' : 'com', + timer = false; + + // Load Brightcove script + script.src = 'https://sadmin.brightcove.' + tld + '/js/BrightcoveExperiences.js'; + script.type = 'text/javascript'; + script.language = 'JavaScript'; + document.head.appendChild( script ); + + // Start detection for Brightcove script loading in its object + try_brightcove(); + + // Detect if Brightcove script has loaded and bind some events once loaded + function try_brightcove() { + clearTimeout( timer ); + + if ( 'object' === typeof brightcove ) { + $( document ).ready( brightcove.createExperiences ); + $( 'body' ).on( 'post-load', brightcove.createExperiences ); + + brightcove.createExperiences(); + } else { + timer = setTimeout( try_brightcove, 100 ); + } + } +})(jQuery);
\ No newline at end of file |