Skip to content

Instantly share code, notes, and snippets.

@ghankerson
Created May 8, 2014 13:58
Show Gist options
  • Select an option

  • Save ghankerson/797ff066d29ef3f2c664 to your computer and use it in GitHub Desktop.

Select an option

Save ghankerson/797ff066d29ef3f2c664 to your computer and use it in GitHub Desktop.
(function($){
Drupal.behaviors.popupplayer = {
attach: function(context, settings) {
$(".views-field-title span").click( function(e){
// Get track info from the views row
var identifier = $(this).parents('.views-row').find('.views-field-field-file-podcast .field-content').text();
var description = $(this).parents('.views-row').find('.views-field-field-lede .field-content').html();
var title = $(this).parents('.views-row').find('.views-field-title .field-content a').text();
var link = $(this).parents('.views-row').find('.views-field-title .field-content a').attr('href');
var image_sm = $(this).parents('.views-row').find('.views-field-field-image .field-content').html();
var program = $(this).parents('.views-row').find('.views-field-field-ref-show .field-content').html();
var playable = APMPlayerFactory.getPlayable({
type: 'audio',
identifier: apmg_audio_cleanup_uri(identifier),
title: title,
image_sm: image_sm,
program: program,
description: description,
url: link
});
var id = $('#apm_playlist li').attr('id');
//console.log(playable);
// Update the player
$('#apm_playlist li').fadeOut().remove();
$('#apm_media_player').apmplayer_ui('addPlayable', playable);
$('#apm_media_player').apmplayer_ui('gotoPlaylistItem', playable.identifier);
apmplayer_ui.playlist.remove(id);
// Build and update the download link.
var download_link = playable.http_file_path.replace('ondemand-http.stream.publicradio.org', 'download.publicradio.org/podcast');
$('#apm_share_download a').attr('href', download_link);
e.preventDefault();
});
}
};
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment