},
// Transform JSON sound object to HTML container for playlist.
_htmlifyJsonSound: function(sound) {
- var container = $('<li>');
+ var container = $('<li>').attr('data-origin',sound.id);
var audio = $('<audio>',this.options.html5audioOptions).hide();
$.each(sound.source,function(k,v){
var source = $('<source>',{src:v,type:k});
audio.append(source);
});
audio.attr('title',sound.title)
- .attr('data-origin',sound.id)
+
.on('play',function(){
thePlaylist.setFocus(container);
container.addClass('playing');
},
// Create a public method.
registerAudio: function(audio,success) {
- var htmlAudio = this._htmlifyJsonSound(this.jsonifyAudio(audio));
+ var audioObj = this.jsonifyAudio(audio);
+ var htmlAudio = this._htmlifyJsonSound(audioObj);
this.playlistContainer.append(htmlAudio);
this.isLastAdd = htmlAudio;
if(!this.isActive){this.setFocus(this.isLastAdd);}
this._update();
},
// Play next sound
+ bindControl: function(control,audio,element,options) {
+ element.addClass('loading');
+ audioID = audio.attr('id');
+ //TODO for controls in page content
+ },
+ // Play next sound
registerControl: function(name,options) {
this.controlButtons[name] = $('<button>',options);
this.controlContainer.append(this.controlButtons[name]);
this.isActive.next().find('audio').trigger('beforePlay').trigger('play');
return true;
},
+ // Play next sound
+ playLast: function() {
+ this.playlistContainer.find('audio').last().trigger('beforePlay').trigger('play');
+ return true;
+ },
// Pause all sounds.
pauseSounds: function(selector) {
this.playlistContainer.find('audio').each(function(){$(this).trigger('pause');});
self.registerControl('showList',{class:"icon-list",click: function(){
self.playlistContainer.toggleClass('deploy');
}});
+ self.controlButtons['showList'].appendTo($('#localList .label'));
},
onPlay:function(self){
$('#DirectStreamPanik')[0].pause();
}
});
-/****************************************************/
-/**** AUDIOPLAYER ****/
-/****************************************************/
+ /****************************************************/
+ /**** AUDIOPLAYER ****/
+ /****************************************************/
if($('#player-container').offset()){
var topPosition = 0;
topPosition = $('#player-container').offset().top;
}
});
}
-/****************************************************/
-/**** AJAX REQUESTS ****/
-/****************************************************/
+ /****************************************************/
+ /**** AJAX REQUESTS ****/
+ /****************************************************/
String.prototype.decodeHTML = function() {
return $("<div>", {html: "" + this}).html();
};
loadPage_request = $.get(href, null, afterLoad);
};
init = function() {
- $("#All a, #All area, #All form").removeClass('loading');
+ $("#All a, #All area").removeClass('loading');
$("#All a, #All area").unbind('click').on('click',function() {
$(this).addClass('loading');
var href = $(this).attr("href");
* part points to the same domain */
if (!href) {
doLog('No href attributes, unable to load content','error');
- $("#All a, #All area, #All form").removeClass('loading');
+ $("#All a, #All area").removeClass('loading');
return false;
- }else if (href.indexOf(document.domain) > -1 ||
- href.indexOf(':') === -1 || href.indexOf(':') > 5) {
+ }else if (!$(this).attr('target') && (
+ href.indexOf(document.domain) > -1 ||href.indexOf(':') === -1 || href.indexOf(':') > 5
+ )) {
loadPage(href);
return false;
}else{
$(this).attr('target','_blanck');
- $("#All a, #All area, #All form").removeClass('loading');
+ $("#All a, #All area").removeClass('loading');
return true;
}
});
});
activeTab.trigger('load');
});
- $('[data-player-audio]').on('click',function(){
- var audio = $($(this).attr('data-player-audio'));
- $localList.playlist("registerAudio",audio,doLog(audio.attr('title')+' has been added to your playlist.','ok'));
+ $('[data-player-action]').on('click',function(){
+ var audio = $('#'+$(this).attr('data-player-audio'));
+ if($(this).attr('data-player-action') == "registerAudio"){
+ $localList.playlist("registerAudio",audio,doLog(audio.attr('title')+' has been added to your playlist.','ok'));
+ }else if($(this).attr('data-player-action') == "playAudio"){
+ $localList.playlist("registerAudio",audio,doLog(audio.attr('title')+' has been added to your playlist.','ok'));
+ $localList.playlist("playLast");
+ }else{
+ $localList.playlist($(this).attr('data-player-action'));
+ }
+ });
+ $('[data-player-control]').each(function(){
+ var audio = $('#'+$(this).attr('data-player-audio'));
+ $localList.playlist("bindControl",$(this).attr('data-player-control'),audio,$(this));
});
+
$('[data-highlight]').on('check',function(){
$($(this).attr('data-about')).find($(this).attr('data-highlight')).addClass('highlighted').removeClass('normal');
}).on('uncheck',function(){
$('[data-toggle].icon-check-empty').each(function(){
$(this).trigger('uncheck');
});
- /*
- $('[data-highlight].icon-check').each(function(){
- $(this).trigger('check');
- });
- */
- /*
- $("[data-audio-control]").each(function() {
- var audio = $('#'+$(this).attr('data-audio-control'));
- var audioElement = audio[0];
- if(audioElement){
- var addToPlaylist = $(this).find('.add');
- addToPlaylist.on('click',function(e){
- audio.clone().appendTo('#Playlist');
- $('#Playlist').parent().show();
- });
- var playPauseButton = $(this).find('.playpause');
- //alert($(this).attr('data-audio'));
- playPauseButton.on('click',function(e){
- if (audioElement.paused == false) {
- audioElement.pause();
- } else {
- audioElement.play();
- }
- });
- //alert($(this).attr('data-audio'));
- playPauseButton.on('click',function(e){
- if (audioElement.paused == false) {
- audioElement.pause();
- } else {
- audioElement.play();
- }
- });
- // Bind back event in case of direct control
- audio.on('play',function(){
- playPauseButton.addClass('icon-pause').removeClass('icon-play');
- }).on('pause',function(){
- playPauseButton.addClass('icon-play').removeClass('icon-pause');
- });
- }
- });
- */
}
init();
});