| 1 |
|
/** |
| 2 |
|
* Implemetation of Drupal Behavior |
| 3 |
|
*/ |
| 4 |
|
Drupal.behaviors.mp3players = function(context) { |
| 5 |
|
// Render MP3Players |
| 6 |
|
$('.mp3player:not(.mp3player-processed)').each(function() { |
| 7 |
|
var $thisPlayer = $(this); |
| 8 |
|
var playerID = $thisPlayer.attr('id'); |
| 9 |
|
$thisPlayer.addClass('mp3player-processed'); |
| 10 |
|
|
| 11 |
|
// Check variables so we dont get JS errors |
| 12 |
|
if (Drupal.settings.mp3player != undefined && AudioPlayer != undefined && Drupal.settings.mp3player[playerID] != undefined) { |
| 13 |
|
var playerValue = Drupal.settings.mp3player[playerID] |
| 14 |
|
var soundFileValue = playerValue.audio_url; |
| 15 |
|
|
| 16 |
|
// Check for extras |
| 17 |
|
if (playerValue.extras != null) { |
| 18 |
|
soundFileValue = soundFileValue + playerValue.extras; |
| 19 |
|
} |
| 20 |
|
|
| 21 |
|
// Create new player and add code |
| 22 |
|
var newPlayer = AudioPlayer.embed(playerID, { soundFile: soundFileValue }); |
| 23 |
|
} |
| 24 |
|
}); |
| 25 |
|
} |