fixed studio and compoplayer init process
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
var _settings = drupalSettings.edlp_studio;
|
var _settings = drupalSettings.edlp_studio;
|
||||||
var $composer;
|
var $composer;
|
||||||
|
|
||||||
// audio play is handled by edlp_theme
|
// audio play is handled by edlp_theme
|
||||||
|
|
||||||
function init(){
|
function init(){
|
||||||
console.log('Studio Init');
|
console.log('Studio Init');
|
||||||
@@ -14,14 +14,20 @@
|
|||||||
function initEvents(){
|
function initEvents(){
|
||||||
$('body')
|
$('body')
|
||||||
.on('new-audio-cartel-loaded', initAjaxChutierLinks)
|
.on('new-audio-cartel-loaded', initAjaxChutierLinks)
|
||||||
.on('new-content-ajax-loaded', initStudio);
|
.on('new-content-ajax-loaded', initStudio)
|
||||||
|
.on('all-modal-closed', initStudio);
|
||||||
};
|
};
|
||||||
|
|
||||||
function initStudio(){
|
function initStudio(){
|
||||||
$composer = $('.composition_ui .composer', '#studio-ui');
|
if($('#studio-ui').length){
|
||||||
initAjaxChutierLinks();
|
$composer = $('.composition_ui .composer', '#studio-ui');
|
||||||
initAjaxCompoLinks();
|
initAjaxChutierLinks();
|
||||||
initDragAndDropUI();
|
initAjaxCompoLinks();
|
||||||
|
initDragAndDropUI();
|
||||||
|
$('body').trigger({'type':'studio-initialized'});
|
||||||
|
}else{
|
||||||
|
$('body').trigger({'type':'studio-not-active'});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ___ _ _ _ _ _ _ _ _ _
|
// ___ _ _ _ _ _ _ _ _ _
|
||||||
|
|||||||
@@ -45,6 +45,12 @@
|
|||||||
function initEvents(){
|
function initEvents(){
|
||||||
$('body')
|
$('body')
|
||||||
.on('on-studio-chutier-updated', initAjaxLinks)
|
.on('on-studio-chutier-updated', initAjaxLinks)
|
||||||
|
.on('studio-initialized', function(e){
|
||||||
|
_compoPlayer.initControls();
|
||||||
|
})
|
||||||
|
.on('studio-not-active', function(e){
|
||||||
|
_compoPlayer.deactivate();
|
||||||
|
})
|
||||||
.on('on-studio-compo-updated', function(e){
|
.on('on-studio-compo-updated', function(e){
|
||||||
initAjaxLinks();
|
initAjaxLinks();
|
||||||
_compoPlayer.refresh();
|
_compoPlayer.refresh();
|
||||||
@@ -280,7 +286,6 @@
|
|||||||
_$body.attr('corpus-map', 'ready');
|
_$body.attr('corpus-map', 'ready');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _ _ _
|
// _ _ _
|
||||||
// /_\ _ _ __| (_)___
|
// /_\ _ _ __| (_)___
|
||||||
// / _ \ || / _` | / _ \
|
// / _ \ || / _` | / _ \
|
||||||
@@ -637,11 +642,14 @@
|
|||||||
// \___\___/_|_|_| .__/\___/_| |_\__,_|\_, \___|_|
|
// \___\___/_|_|_| .__/\___/_| |_\__,_|\_, \___|_|
|
||||||
// |_| |__/
|
// |_| |__/
|
||||||
function CompoPlayer(){
|
function CompoPlayer(){
|
||||||
|
this.active = false;
|
||||||
this.playing = false;
|
this.playing = false;
|
||||||
this.paused = false;
|
this.paused = false;
|
||||||
this.playlist = [];
|
this.playlist = [];
|
||||||
this.current_index = 0;
|
this.current_index = 0;
|
||||||
|
this.$composer = null;
|
||||||
this.$compo = null;
|
this.$compo = null;
|
||||||
|
this.$controls = null;
|
||||||
this.init();
|
this.init();
|
||||||
};
|
};
|
||||||
CompoPlayer.prototype = {
|
CompoPlayer.prototype = {
|
||||||
@@ -655,26 +663,30 @@
|
|||||||
.on('audio-ended', this.onAudioPlayerEnded.bind(this));
|
.on('audio-ended', this.onAudioPlayerEnded.bind(this));
|
||||||
// .on('audio-play-next', this.onAudioPlayNext.bind(this));
|
// .on('audio-play-next', this.onAudioPlayNext.bind(this));
|
||||||
|
|
||||||
|
// this.newCompo();
|
||||||
|
},
|
||||||
|
initControls(){
|
||||||
|
console.log('CompoPlayer initControls()');
|
||||||
|
this.$composer = $('.composition_ui .composer');
|
||||||
|
this.$controls = $('.composition_ui .composer .compo-player-controls');
|
||||||
|
|
||||||
|
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.active = true; // TODO: set active false
|
||||||
|
|
||||||
this.newCompo();
|
this.newCompo();
|
||||||
},
|
},
|
||||||
newCompo(){
|
newCompo(){
|
||||||
console.log('CompoPlayer newCompo()');
|
console.log('CompoPlayer newCompo()');
|
||||||
// $('.composition_ui .composer .composition .field--name-documents')
|
|
||||||
this.$composer = $('.composition_ui .composer');
|
|
||||||
this.$compo = $('.composition_ui .composer .composition');
|
this.$compo = $('.composition_ui .composer .composition');
|
||||||
this.$controls = $('.composition_ui .composer .compo-player-controls');
|
|
||||||
if(!this.$controls.is('.ready')){
|
|
||||||
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.refresh();
|
||||||
},
|
},
|
||||||
refresh(){
|
refresh(){
|
||||||
@@ -810,6 +822,10 @@
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
deactivate(){
|
||||||
|
this.stop();
|
||||||
|
this.active = false;
|
||||||
|
},
|
||||||
// _audioPlayer events
|
// _audioPlayer events
|
||||||
onAudioOpenDocument(args){
|
onAudioOpenDocument(args){
|
||||||
if(args.caller !== this){
|
if(args.caller !== this){
|
||||||
@@ -887,6 +903,7 @@
|
|||||||
// TODO: animate the remove
|
// TODO: animate the remove
|
||||||
_$row.html('');
|
_$row.html('');
|
||||||
_$ajaxLinks.removeClass('is-active');
|
_$ajaxLinks.removeClass('is-active');
|
||||||
|
_$body.trigger({'type':'all-modal-closed'});
|
||||||
};
|
};
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|||||||
@@ -45,6 +45,12 @@
|
|||||||
function initEvents(){
|
function initEvents(){
|
||||||
$('body')
|
$('body')
|
||||||
.on('on-studio-chutier-updated', initAjaxLinks)
|
.on('on-studio-chutier-updated', initAjaxLinks)
|
||||||
|
.on('studio-initialized', function(e){
|
||||||
|
_compoPlayer.initControls();
|
||||||
|
})
|
||||||
|
.on('studio-not-active', function(e){
|
||||||
|
_compoPlayer.deactivate();
|
||||||
|
})
|
||||||
.on('on-studio-compo-updated', function(e){
|
.on('on-studio-compo-updated', function(e){
|
||||||
initAjaxLinks();
|
initAjaxLinks();
|
||||||
_compoPlayer.refresh();
|
_compoPlayer.refresh();
|
||||||
@@ -280,7 +286,6 @@
|
|||||||
_$body.attr('corpus-map', 'ready');
|
_$body.attr('corpus-map', 'ready');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _ _ _
|
// _ _ _
|
||||||
// /_\ _ _ __| (_)___
|
// /_\ _ _ __| (_)___
|
||||||
// / _ \ || / _` | / _ \
|
// / _ \ || / _` | / _ \
|
||||||
@@ -637,11 +642,14 @@
|
|||||||
// \___\___/_|_|_| .__/\___/_| |_\__,_|\_, \___|_|
|
// \___\___/_|_|_| .__/\___/_| |_\__,_|\_, \___|_|
|
||||||
// |_| |__/
|
// |_| |__/
|
||||||
function CompoPlayer(){
|
function CompoPlayer(){
|
||||||
|
this.active = false;
|
||||||
this.playing = false;
|
this.playing = false;
|
||||||
this.paused = false;
|
this.paused = false;
|
||||||
this.playlist = [];
|
this.playlist = [];
|
||||||
this.current_index = 0;
|
this.current_index = 0;
|
||||||
|
this.$composer = null;
|
||||||
this.$compo = null;
|
this.$compo = null;
|
||||||
|
this.$controls = null;
|
||||||
this.init();
|
this.init();
|
||||||
};
|
};
|
||||||
CompoPlayer.prototype = {
|
CompoPlayer.prototype = {
|
||||||
@@ -655,26 +663,30 @@
|
|||||||
.on('audio-ended', this.onAudioPlayerEnded.bind(this));
|
.on('audio-ended', this.onAudioPlayerEnded.bind(this));
|
||||||
// .on('audio-play-next', this.onAudioPlayNext.bind(this));
|
// .on('audio-play-next', this.onAudioPlayNext.bind(this));
|
||||||
|
|
||||||
|
// this.newCompo();
|
||||||
|
},
|
||||||
|
initControls(){
|
||||||
|
console.log('CompoPlayer initControls()');
|
||||||
|
this.$composer = $('.composition_ui .composer');
|
||||||
|
this.$controls = $('.composition_ui .composer .compo-player-controls');
|
||||||
|
|
||||||
|
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.active = true; // TODO: set active false
|
||||||
|
|
||||||
this.newCompo();
|
this.newCompo();
|
||||||
},
|
},
|
||||||
newCompo(){
|
newCompo(){
|
||||||
console.log('CompoPlayer newCompo()');
|
console.log('CompoPlayer newCompo()');
|
||||||
// $('.composition_ui .composer .composition .field--name-documents')
|
|
||||||
this.$composer = $('.composition_ui .composer');
|
|
||||||
this.$compo = $('.composition_ui .composer .composition');
|
this.$compo = $('.composition_ui .composer .composition');
|
||||||
this.$controls = $('.composition_ui .composer .compo-player-controls');
|
|
||||||
if(!this.$controls.is('.ready')){
|
|
||||||
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.refresh();
|
||||||
},
|
},
|
||||||
refresh(){
|
refresh(){
|
||||||
@@ -810,6 +822,10 @@
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
deactivate(){
|
||||||
|
this.stop();
|
||||||
|
this.active = false;
|
||||||
|
},
|
||||||
// _audioPlayer events
|
// _audioPlayer events
|
||||||
onAudioOpenDocument(args){
|
onAudioOpenDocument(args){
|
||||||
if(args.caller !== this){
|
if(args.caller !== this){
|
||||||
@@ -887,6 +903,7 @@
|
|||||||
// TODO: animate the remove
|
// TODO: animate the remove
|
||||||
_$row.html('');
|
_$row.html('');
|
||||||
_$ajaxLinks.removeClass('is-active');
|
_$ajaxLinks.removeClass('is-active');
|
||||||
|
_$body.trigger({'type':'all-modal-closed'});
|
||||||
};
|
};
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|||||||
Reference in New Issue
Block a user