(function ($, Drupal) {

  Drupal.behaviors.usgs_transcript = {
    attach: function (context) {
      $(context).find('.d-media-transcript').once('.d-media-transcript').each(function() {
        var transcript = $(this);

        $(transcript).find('.d-media-transcript-toggle').on('click', function() {
          $(transcript).find('.d-media-transcript-box').slideToggle();
            if ($(transcript).find('span').text() === 'Show Transcript') {
              $(transcript).find('span').text('Hide Transcript');
            }
            else {
              $(transcript).find('span').text('Show Transcript');
            }
            $(transcript).find('i').toggleClass('fa-angle-down fa-angle-up');
        });
      });
    }
  };

})(jQuery, Drupal);



