expo interface using own subdomain, fix #544

This commit is contained in:
2019-12-11 10:52:49 +01:00
parent 3b6f9cbd98
commit 180b98274b
29 changed files with 283 additions and 102 deletions
@@ -23,6 +23,7 @@
var _$log_form;
var _user_tokens;
var _states_history = [];
var _is_expo = $('body').hasClass('domain-expo-encyclopediedelaparole-org');
// ___ _ _
// |_ _|_ _ (_) |_
@@ -1040,7 +1041,11 @@
.openDocument(e.target_node);
});
_randomPlayer = new RandomPlayer(e.playlist);
_randomPlayer = new RandomPlayer(e.playlist);
if (_is_expo) {
_randomPlayer.start();
}
// mainly for articles link
initAjaxLinks();
@@ -1167,7 +1172,11 @@
};
AudioPlayer.prototype = {
init(){
this.$container_parent = $('header[role="banner"] .region-header');
if(!_is_expo){
this.$container_parent = $('header[role="banner"] .region-header');
}else{
this.$container_parent = $('main[role="main"]');
}
// append ui to document
this.$container.appendTo(this.$container_parent);
// record timeline width
@@ -1343,6 +1352,11 @@
this.clearTimeOutToHide();
// this.audio.play();
// making sound shorter for debuging purpose
// if(_is_expo){
// setTimeout(this.seekToEnd.bind(this), 20000);
// }
// Not really needed has we trigger play right after setting the source https://stackoverflow.com/questions/47431439/mp4-video-safari-showing-unhandled-promise-rejection-object-domerror-in-c
var promise = this.audio.play();
// console.log('promise', promise);
@@ -1397,6 +1411,12 @@
console.log("Audio seeking : seek", seek);
this.audio.currentTime = seek;
},
seekToEnd(){
if (this.audio.duration > 40) {
console.log("seekToEnd", this.audio.duration);
this.audio.currentTime = this.audio.duration - 20;
}
},
// audio events
onPlaying(){
this.$btns.addClass('is-playing');
@@ -1448,14 +1468,16 @@
// cartel autoswitch
this.scndCartel_visible = 0;
this.$cartel.removeClass('second-visible');
// if second cartel has special info ?
if (this.$cartel.find('.second-cartel .col-left').children().length > 1
|| this.$cartel.find('.second-cartel').children('.col-right').length){
// init cartel auto switch
this.cartelSwitchInterval = setInterval(this.switchCartel.bind(this), this.cartelSwitchIntervalMS);
if(!_is_expo){
// if second cartel has special info ?
if (this.$cartel.find('.second-cartel .col-left').children().length > 1
|| this.$cartel.find('.second-cartel').children('.col-right').length){
// init cartel auto switch
this.cartelSwitchInterval = setInterval(this.switchCartel.bind(this), this.cartelSwitchIntervalMS);
}
// call drupal behaviours (for addtoany)
Drupal.attachBehaviors(this.$cartel);
}
// call drupal behaviours (for addtoany)
Drupal.attachBehaviors(this.$cartel);
// open automaticly tha article if needed
this.setAutoOpenArticle();
if(this.auto_open_article){
@@ -1599,25 +1621,21 @@
_audioPlayer
.on('audio-play-next', this.onAudioPlayNext.bind(this))
.on('audio-ended', this.onAudioPlayerEnded.bind(this))
// .on('audio-ended', function(e){
// console.log('RandomPlayer, audio-ended', e);
// })
.on('stop-shuffle', this.stop.bind(this));
_$corpus_canvas
.on('update-random-playlist', this.updatePlaylist.bind(this));
// provide a link to auto start random player
if(window.location.hash == '#random'){
this.start();
// window.location.hash = '';
}
},
updatePlaylist(e){
// debugger;
this.playlist = e.playlist;
this.shuffle();
if (!_is_expo) {
this.playlist = e.playlist;
this.shuffle();
}
},
shuffle(){
var tempPLaylist = [];
@@ -1667,8 +1685,12 @@
},
next(){
console.log('RandomPlayer next', this.active, this.shuffledPlaylist.length);
if(this.active && this.shuffledPlaylist.length > 0)
if(this.active){
if (this.shuffledPlaylist.length == 0) {
this.shuffle();
}
_audioPlayer.openDocument(this.shuffledPlaylist.splice(0,1)[0], 'random');
}
},
onAudioPlayNext(){
console.log('RandomPlayer : onAudioPlayNext()');
@@ -1680,6 +1702,9 @@
console.log('RandomPlayer : onAudioPlayerEnded()');
if(this.active){
this.next();
if(_is_expo){
_$corpus_canvas.trigger({'type':'scramble-collection'}); //shuffle-collection scramble-collection
}
}
}
};