|
@@ -77,11 +77,36 @@
|
|
function initAjaxCompoLinks(){
|
|
function initAjaxCompoLinks(){
|
|
console.log('studio initAjaxCompoLinks');
|
|
console.log('studio initAjaxCompoLinks');
|
|
$('.new-composition-link:not(.ajax-enabled)')
|
|
$('.new-composition-link:not(.ajax-enabled)')
|
|
|
|
+ .addClass('ajax-enabled')
|
|
|
|
+ .on('click', onClickNewCompoLink);
|
|
|
|
+ $('.composition-link:not(.ajax-enabled)')
|
|
.addClass('ajax-enabled')
|
|
.addClass('ajax-enabled')
|
|
.on('click', onClickCompoLink);
|
|
.on('click', onClickCompoLink);
|
|
|
|
+ $('.delete-composition-link:not(.ajax-enabled)')
|
|
|
|
+ .addClass('ajax-enabled')
|
|
|
|
+ .on('click', onClickDeleteCompoLink);
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // ___ ___
|
|
|
|
+ // / _ \ _ __ ___ _ _ / __|___ _ __ _ __ ___
|
|
|
|
+ // | (_) | '_ \/ -_) ' \ | (__/ _ \ ' \| '_ \/ _ \
|
|
|
|
+ // \___/| .__/\___|_||_| \___\___/_|_|_| .__/\___/
|
|
|
|
+ // |_| |_|
|
|
function onClickCompoLink(e){
|
|
function onClickCompoLink(e){
|
|
|
|
+ e.preventDefault();
|
|
|
|
+ console.log('onClickCompoLink');
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // _ _ _____ __ __ __ ___ _ __ _ __ ___
|
|
|
|
+ // | ' \/ -_) V V / / _/ _ \ ' \| '_ \/ _ \
|
|
|
|
+ // |_||_\___|\_/\_/ \__\___/_|_|_| .__/\___/
|
|
|
|
+ // |_|
|
|
|
|
+
|
|
|
|
+ function onClickNewCompoLink(e){
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
setInputForNewCompoName($(this));
|
|
setInputForNewCompoName($(this));
|
|
return false;
|
|
return false;
|
|
@@ -141,6 +166,43 @@
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
+ // ___ _ _
|
|
|
|
+ // | \ ___| |___| |_ ___ __ ___ _ __ _ __ ___
|
|
|
|
+ // | |) / -_) / -_) _/ -_) / _/ _ \ ' \| '_ \/ _ \
|
|
|
|
+ // |___/\___|_\___|\__\___| \__\___/_|_|_| .__/\___/
|
|
|
|
+ // |_|
|
|
|
|
+ function onClickDeleteCompoLink(e){
|
|
|
|
+ e.preventDefault();
|
|
|
|
+ // TODO: confirm
|
|
|
|
+ deleteCompo($(this));
|
|
|
|
+ return false;
|
|
|
|
+ };
|
|
|
|
+ function deleteCompo($link){
|
|
|
|
+ var ajax_path = $link.attr('data-drupal-link-system-path');
|
|
|
|
+ var path = window.location.origin + Drupal.url(ajax_path);
|
|
|
|
+ $link.parents('li').addClass('ajax-loading');
|
|
|
|
+ $.getJSON(path, {})
|
|
|
|
+ .done(function(data){
|
|
|
|
+ onDeleteCompoDone(data, $link);
|
|
|
|
+ })
|
|
|
|
+ .fail(function(jqxhr, textStatus, error){
|
|
|
|
+ onErrorDeleteCompo(jqxhr, textStatus, error, $link);
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+ function onDeleteCompoDone(data, $link, $form){
|
|
|
|
+ console.log('onDeleteCompoDone',data);
|
|
|
|
+ if(data.status == "ok"){
|
|
|
|
+ $link.parents('li').remove();
|
|
|
|
+ }else{
|
|
|
|
+ console.warn(data.message);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ function onErrorDeleteCompo(jqxhr, textStatus, error, $link){
|
|
|
|
+ $link.parents('li').removeClass('ajax-loading');
|
|
|
|
+ console.warn('delete compo load failed : '+error, jqxhr.responseText);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+
|
|
// ___ _ _ _ _
|
|
// ___ _ _ _ _
|
|
// / __| |_ _ _ __| (_)___ ___ _ _(_)
|
|
// / __| |_ _ _ __| (_)___ ___ _ _(_)
|
|
// \__ \ _| || / _` | / _ \___| || | |
|
|
// \__ \ _| || / _` | / _ \___| || | |
|