|
@@ -47,7 +47,7 @@ Drupal.attachBehaviors(this.$cartel);this.setAutoOpenArticle();if(this.auto_open
|
|
|
this.event_handlers[event_name].push(handler);return this;},emmit(event_name,args){void 0;var handler;var args=args||{};for(var i=this.event_handlers[event_name].length-1;i>=0;i--){handler=this.event_handlers[event_name][i];(function(handler,args){setTimeout(function(){handler(args);},0);}(handler,args));}
|
|
|
return this;},}
|
|
|
function RandomPlayer(playlist){this.active=false;this.playlist=playlist;this.path=drupalSettings.path.baseUrl+drupalSettings.path.pathPrefix+'#random'
|
|
|
-this.$btn=$('<a>').html('Shuffle').attr('href',this.path).addClass('random-player-btn');this.init();};RandomPlayer.prototype={init(){$('<div>').addClass('block random-player').append(this.$btn).prependTo('.region-footer-right');this.$btn.on('click',this.toggleActive.bind(this));_audioPlayer.on('audio-play-next',this.onAudioPlayNext.bind(this)).on('audio-ended',this.onAudioPlayerEnded.bind(this)).on('stop-shuffle',this.stop.bind(this));_$corpus_canvas.on('update-random-playlist',this.updatePlaylist.bind(this));if(window.location.hash=='#random'){this.start();}},updatePlaylist(e){this.playlist=e.playlist;this.shuffle();},shuffle(){var tempPLaylist=[];for(var i=this.playlist.length-1;i>=0;i--){tempPLaylist.push(this.playlist[i]);}
|
|
|
+this.$btn=$('<a>').html('Shuffle').attr('href',this.path).attr('title',drupalSettings.edlp_corpus.random_link_title).addClass('random-player-btn');this.init();};RandomPlayer.prototype={init(){$('<div>').addClass('block random-player').append(this.$btn).prependTo('.region-footer-right');this.$btn.on('click',this.toggleActive.bind(this));_audioPlayer.on('audio-play-next',this.onAudioPlayNext.bind(this)).on('audio-ended',this.onAudioPlayerEnded.bind(this)).on('stop-shuffle',this.stop.bind(this));_$corpus_canvas.on('update-random-playlist',this.updatePlaylist.bind(this));if(window.location.hash=='#random'){this.start();}},updatePlaylist(e){this.playlist=e.playlist;this.shuffle();},shuffle(){var tempPLaylist=[];for(var i=this.playlist.length-1;i>=0;i--){tempPLaylist.push(this.playlist[i]);}
|
|
|
this.shuffledPlaylist=[];while(tempPLaylist.length>0){var r=Math.floor(Math.random()*tempPLaylist.length);this.shuffledPlaylist.push(tempPLaylist.splice(r,1)[0]);}},toggleActive(e){e.preventDefault();if(this.active){this.stop();}else{this.start();}
|
|
|
return false;},start(){this.active=_audioPlayer.shuffle_is_active=true;this.$btn.addClass('is-active');this.shuffle();this.next();if(typeof _paq!=='undefined'){_paq.push(['trackEvent','RandomPlayer','start']);}},stop(){this.active=false;this.$btn.removeClass('is-active');history.replaceState(history.state,null,window.location.pathname);_audioPlayer.deActivateRandom();if(typeof _paq!=='undefined'){_paq.push(['trackEvent','RandomPlayer','stop']);}},next(){void 0;if(this.active&&this.shuffledPlaylist.length>0)
|
|
|
_audioPlayer.openDocument(this.shuffledPlaylist.splice(0,1)[0],'random');},onAudioPlayNext(){void 0;if(this.active){this.next();}},onAudioPlayerEnded(){void 0;if(this.active){this.next();}}};function CompoPlayer(){this.active=false;this.playing=false;this.paused=false;this.playlist=[];this.current_index=0;this.$composer=null;this.$compo=null;this.$controls=null;this.init();};CompoPlayer.prototype={init(){_audioPlayer.on('audio-open-document',this.onAudioOpenDocument.bind(this)).on('audio-play',this.onAudioPlayerPlay.bind(this)).on('audio-pause',this.onAudioPlayerPause.bind(this)).on('audio-ended',this.onAudioPlayerEnded.bind(this));},newCompo(){this.initControls();},initControls(){this.$composer=$('.composition_ui .composer');this.$compo=$('.composition_ui .composer .composition');this.$controls=$('.composition_ui .composer .compo-player-controls');if(!this.$controls.is('.ready')&&this.$compo){this.$previous=$('<div>').addClass('previous').on('click',this.prev.bind(this)).appendTo(this.$controls);this.$playpause=$('<div>').addClass('play-pause').on('click',this.togglePlayPause.bind(this)).appendTo(this.$controls);this.$next=$('<div>').addClass('next').on('click',this.next.bind(this)).appendTo(this.$controls);this.$controls.addClass('ready');this.refresh();this.active=true;}},refresh(){this.stop();this.playlist=[];var that=this;$('.field--name-documents .field__item',this.$compo).each(function(i,el){var $link=$('a.audio-link',this);that.playlist.push({item:$(this),audio_url:$link.attr("audio_url"),nid:$link.attr("nid"),});});this.showHideControls();},togglePlayPause(){if(this.playing&&!this.paused){this.pause();}else{if(this.playing&&this.paused){this.play();}else{this.start();}}},start(){this.playing=true;this.play();},play(){if(this.paused){this.paused=false;_audioPlayer.play();}else{_audioPlayer.emmit('stop-shuffle').openDocument(this.playlist[this.current_index],this);}
|