added titles attributes to studio, random, search links

This commit is contained in:
2018-10-23 19:36:55 +02:00
parent 34405c3db8
commit d339fdd732
5 changed files with 11 additions and 3 deletions
@@ -238,10 +238,12 @@ function edlp_corpus_page_attachments(array &$attachments) {
$url = Url::fromRoute('edlp_corpus.corpusjson');
$attachments['#attached']['drupalSettings']['edlp_corpus']['load_corpus_ajax_url'] = $url->getInternalPath();
// load corpus
$url = Url::fromRoute('edlp_corpus.articlesindex');
$attachments['#attached']['drupalSettings']['edlp_corpus']['articlesindex_url'] = $url->getInternalPath();
// random btn link title
$attachments['#attached']['drupalSettings']['edlp_corpus']['random_link_title'] = t('Shuffle the selection');
}
@@ -29,6 +29,7 @@ class EdlpSearchLinkBlock extends BlockBase {
'attributes' => array(
'data-drupal-link-system-path' => $url->getInternalPath(),
'class' => array('ajax-link'),
'title' => t('Search sounds by title, speaker, language, genre or entry'),
)
)
);
@@ -60,6 +60,7 @@ class StudioLinkBlock extends BlockBase implements ContainerFactoryPluginInterf
'attributes' => array(
'data-drupal-link-system-path' => $url->getInternalPath(),
'class' => array('ajax-link'),
'title' => t('The studio displays your bookmarked sounds. You can save them and create your own playlists'),
)
)
);
@@ -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);}
@@ -1316,7 +1316,11 @@
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.$btn = $('<a>')
.html('Shuffle')
.attr('href',this.path)
.attr('title', drupalSettings.edlp_corpus.random_link_title)
.addClass('random-player-btn');
this.init();
};
RandomPlayer.prototype = {