studio improvement, fixe #537
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
var _settings = drupalSettings.edlp_studio;
|
||||
var $composer;
|
||||
var _$composer;
|
||||
|
||||
// audio play is handled by edlp_theme
|
||||
|
||||
@@ -21,10 +21,11 @@
|
||||
|
||||
function initStudio(){
|
||||
if($('#studio-ui').length){
|
||||
$composer = $('.composition_ui .composer', '#studio-ui');
|
||||
_$composer = $('.composition_ui .composer', '#studio-ui');
|
||||
initAjaxChutierLinks();
|
||||
initAjaxCompoLinks();
|
||||
initDragAndDropUI();
|
||||
initUsedChutierInCompo();
|
||||
$('body').trigger({'type':'studio-initialized'});
|
||||
}else{
|
||||
$('body').trigger({'type':'studio-not-active'});
|
||||
@@ -95,6 +96,19 @@
|
||||
.addClass('ajax-enabled');
|
||||
};
|
||||
|
||||
function initUsedChutierInCompo(){
|
||||
console.log('initUsedChutierInCompo');
|
||||
$('.chutier-link.on-compo', '#studio-ui .chutier_ui').removeClass('on-compo');
|
||||
var nid;
|
||||
$('.audio-link', _$composer).each(function(index, el) {
|
||||
nid = $(el).attr('nid');
|
||||
console.log('compo item', nid);
|
||||
$('.chutier-link[target_id="'+nid+'"]', '#studio-ui .chutier_ui').addClass('on-compo');
|
||||
});
|
||||
|
||||
//audio-link
|
||||
};
|
||||
|
||||
// ___ ___
|
||||
// / _ \ _ __ ___ _ _ / __|___ _ __ _ __ ___
|
||||
// | (_) | '_ \/ -_) ' \ | (__/ _ \ ' \| '_ \/ _ \
|
||||
@@ -111,7 +125,7 @@
|
||||
var ajax_path = _settings.open_compo_ajax_url+'/'+cid;
|
||||
var path = window.location.origin + Drupal.url(ajax_path);
|
||||
$link.addClass('ajax-loading');
|
||||
$composer.addClass('ajax-loading');
|
||||
_$composer.addClass('ajax-loading');
|
||||
$.getJSON(path, {})
|
||||
.done(function(data){
|
||||
onOpenCompoDone(data, $link);
|
||||
@@ -121,16 +135,17 @@
|
||||
});
|
||||
};
|
||||
function onOpenCompoDone(data, $link){
|
||||
//console.log('onActionToCompoDone',data);
|
||||
console.log('onOpenCompoDone',data);
|
||||
$('.composition-link').removeClass('is-active');
|
||||
$link.removeClass('ajax-loading').addClass('is-active');
|
||||
if($('.composition', $composer).length){
|
||||
$('.composition', $composer).replaceWith(data.compo);
|
||||
if($('.composition', _$composer).length){
|
||||
$('.composition', _$composer).replaceWith(data.compo);
|
||||
}else{
|
||||
$('header', $composer).after(data.compo);
|
||||
$('header', _$composer).after(data.compo);
|
||||
}
|
||||
$composer.removeClass('ajax-loading');
|
||||
_$composer.removeClass('ajax-loading');
|
||||
initDragAndDropUI();
|
||||
initUsedChutierInCompo();
|
||||
$('body').trigger({
|
||||
'type':'on-studio-compo-opened'
|
||||
});
|
||||
@@ -233,7 +248,7 @@
|
||||
if($('.composition-link').length){
|
||||
openCompo($('.composition-link').eq(0));
|
||||
}else{
|
||||
$('.composition', $composer).html();
|
||||
$('.composition', _$composer).html();
|
||||
}
|
||||
}else{
|
||||
console.warn(data.message);
|
||||
@@ -342,7 +357,7 @@
|
||||
containment:$('#studio-ui'),
|
||||
scroll:false,
|
||||
helper:function(e){
|
||||
// we reproduce here the irem structure of destination sortable elements
|
||||
// we reproduce here the item structure of destination sortable elements
|
||||
// var $audio_link = $('.audio-link',this);
|
||||
return $('<div>').addClass('field__item')
|
||||
.append(
|
||||
@@ -374,6 +389,7 @@
|
||||
documents[i] = $(this).attr('nid');
|
||||
});
|
||||
// console.log(documents);
|
||||
initUsedChutierInCompo();
|
||||
recordCompoList(cid, documents);
|
||||
};
|
||||
function recordCompoList(cid, docs){
|
||||
|
||||
Reference in New Issue
Block a user