cartel auto switch

This commit is contained in:
2018-09-13 11:15:45 +02:00
parent caaf23fbbd
commit a079425b7f
4 changed files with 37 additions and 6 deletions
@@ -854,6 +854,9 @@
this.$fav = $('<div>').addClass('favoris').appendTo(this.$container);
// cartel
this.$cartel = $('<div>').addClass('cartel').appendTo(this.$container);
this.scndCartel_visible = 0;
this.cartelSwitchIntervalMS = 7000;
this.cartelSwitchInterval = false;
// hiding
this.hideTimer = false;
@@ -971,6 +974,7 @@
},
launch(){
this.clearTimeOutToHide();
this.clearIntervalAutoCartelSwitch();
this.setSRC(this.historic[this.currentHistoricIndex].audio_url);
this.loadNode(this.historic[this.currentHistoricIndex].nid);
// emmit new playing doc (e.g.: corpus map nowing that audio played from RandomPlayer)
@@ -1139,8 +1143,12 @@
this.$cartel.html(data.rendered).removeClass('loading');
_$body.trigger({'type':'new-audio-cartel-loaded'});
initAjaxLinks();
// and call druapl behaviours
// init cartel auto switch
this.cartelSwitchInterval = setInterval(this.switchCartel.bind(this), this.cartelSwitchIntervalMS);
// call drupal behaviours (for addtoany)
Drupal.attachBehaviors(this.$cartel);
// open automaticly tha article if needed
if(this.auto_open_article){
this.$cartel.find('a.link-article').trigger('click');
this.auto_open_article = false;
@@ -1185,6 +1193,25 @@
this.hideTimer = false;
}
},
// cartel
switchCartel(){
// console.log("switchCartel", this.scndCartel_visible);
if (this.scndCartel_visible) {
// return to first cartel
this.$cartel.removeClass('second-visible');
this.scndCartel_visible = 0;
}else{
// switch to 2nd cartel
this.$cartel.addClass('second-visible');
this.scndCartel_visible = 1;
}
},
clearIntervalAutoCartelSwitch(){
if(this.cartelSwitchInterval){
clearInterval(this.cartelSwitchInterval);
this.cartelSwitchInterval = false;
}
},
hide(){
// console.log('AudioPlayer hide()');
this.$container_parent.removeClass('audio-player-visible');