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

47 lines
1.2 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(){
setTimeout(destroy_action, 500);
});
2016-07-20 11:38:19 +02:00
}
function on_change_type_de_champ_select (){
2017-04-04 16:15:33 +02:00
$("select.form-control.type_champ").on('change', function(e){
parent = $(this).parent().parent();
parent.removeClass('header_section');
parent.children(".drop_down_list").removeClass('show_inline');
$('.mandatory', parent).show();
switch(this.value){
case 'header_section':
parent.addClass('header_section');
break;
case 'drop_down_list':
case 'multiple_drop_down_list':
parent.children(".drop_down_list").addClass('show_inline');
break;
case 'explication':
$('.mandatory', parent).hide();
break;
}
});
}