demarches-normaliennes/app/assets/javascripts/old_design/admin.js

53 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-03-30 17:00:35 +02:00
$(document).on('turbolinks:load', init_admin);
2016-07-20 11:38:19 +02:00
function init_admin(){
2017-04-04 16:15:33 +02:00
destroy_action();
on_change_type_de_champ_select();
2016-07-20 11:38:19 +02:00
}
2016-02-09 12:23:49 +01:00
function destroy_action(){
2017-04-04 16:15:33 +02:00
$(".delete").on('click', function(){
$(this).hide();
$(this).closest('td').find(".confirm").show();
});
$(".cancel").on('click', function(){
$(this).closest('td').find(".delete").show();
$(this).closest('td').find(".confirm").hide();
});
$("#liste-gestionnaire #libelle").on('click', function(){
2017-04-04 16:15:33 +02:00
setTimeout(destroy_action, 500);
});
2016-07-20 11:38:19 +02:00
}
function on_change_type_de_champ_select (){
$("select.form-control.type-champ").on('change', function(e){
2017-04-04 16:15:33 +02:00
parent = $(this).parent().parent();
parent.removeClass('header-section');
parent.children(".drop-down-list").removeClass('show-inline');
parent.children(".pj-template").removeClass('show-inline');
2017-04-04 16:15:33 +02:00
$('.mandatory', parent).show();
switch(this.value){
case 'header_section':
parent.addClass('header-section');
2017-04-04 16:15:33 +02:00
break;
case 'drop_down_list':
case 'multiple_drop_down_list':
2018-06-14 12:53:27 +02:00
case 'linked_drop_down_list':
parent.children(".drop-down-list").addClass('show-inline');
2017-04-04 16:15:33 +02:00
break;
case 'piece_justificative':
parent.children(".pj-template").addClass('show-inline');
break;
2017-04-04 16:15:33 +02:00
case 'explication':
$('.mandatory', parent).hide();
break;
}
});
}