diff --git a/app/assets/javascripts/old_design/admin.js b/app/assets/javascripts/old_design/admin.js index 981032ec3..5b7af468e 100644 --- a/app/assets/javascripts/old_design/admin.js +++ b/app/assets/javascripts/old_design/admin.js @@ -1,52 +1,47 @@ -$(document).on('turbolinks:load', init_admin); +$(document).on('click', '.delete', function() { + $(this).hide(); + $(this) + .closest('td') + .find('.confirm') + .show(); +}); -function init_admin(){ - destroy_action(); - on_change_type_de_champ_select(); -} +$(document).on('click', '.cancel', function() { + $(this) + .closest('td') + .find('.delete') + .show(); + $(this) + .closest('td') + .find('.confirm') + .hide(); +}); -function destroy_action(){ - $(".delete").on('click', function(){ - $(this).hide(); - $(this).closest('td').find(".confirm").show(); - }); +$(document).on('change', 'select.form-control.type-champ', function() { + var parent = $(this) + .parent() + .parent(); - $(".cancel").on('click', function(){ - $(this).closest('td').find(".delete").show(); - $(this).closest('td').find(".confirm").hide(); - }); + parent.removeClass('header-section'); + parent.children('.drop-down-list').removeClass('show-inline'); + parent.children('.pj-template').removeClass('show-inline'); - $("#liste-gestionnaire #libelle").on('click', function(){ - setTimeout(destroy_action, 500); - }); -} + $('.mandatory', parent).show(); -function on_change_type_de_champ_select (){ - $("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'); - parent.children(".pj-template").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': - case 'linked_drop_down_list': - parent.children(".drop-down-list").addClass('show-inline'); - break; - case 'piece_justificative': - parent.children(".pj-template").addClass('show-inline'); - break; - case 'explication': - $('.mandatory', parent).hide(); - break; - } - }); -} + switch (this.value) { + case 'header_section': + parent.addClass('header-section'); + break; + case 'drop_down_list': + case 'multiple_drop_down_list': + case 'linked_drop_down_list': + parent.children('.drop-down-list').addClass('show-inline'); + break; + case 'piece_justificative': + parent.children('.pj-template').addClass('show-inline'); + break; + case 'explication': + $('.mandatory', parent).hide(); + break; + } +}); diff --git a/app/assets/javascripts/old_design/dossiers_list_link.js b/app/assets/javascripts/old_design/dossiers_list_link.js index 18b167ace..70425251a 100644 --- a/app/assets/javascripts/old_design/dossiers_list_link.js +++ b/app/assets/javascripts/old_design/dossiers_list_link.js @@ -1,10 +1,6 @@ -$(document).on('turbolinks:load', link_init); - -function link_init() { - $('#dossiers-list tr').on('click', function(event) { - var href = $(this).data('href'); - if (href && event.target.tagName !== 'A') { - location.href = href; - } - }); -} +$(document).on('click', '#dossiers-list tr', function(event) { + var href = $(this).data('href'); + if (href && event.target.tagName !== 'A') { + location.href = href; + } +}); diff --git a/app/views/admin/procedures/index.js.erb b/app/views/admin/procedures/index.js.erb index 232965d99..b2e0bdc6a 100644 --- a/app/views/admin/procedures/index.js.erb +++ b/app/views/admin/procedures/index.js.erb @@ -1,2 +1 @@ <%= smart_listing_update :procedures %> -link_init(); \ No newline at end of file diff --git a/app/views/admin/types_de_champ/show.js.erb b/app/views/admin/types_de_champ/show.js.erb index b0001f62f..5c22f8080 100644 --- a/app/views/admin/types_de_champ/show.js.erb +++ b/app/views/admin/types_de_champ/show.js.erb @@ -1,3 +1,2 @@ <%= render_flash(timeout: 3000, sticky: true) %> <%= render_to_element('#liste-champ', partial: 'admin/types_de_champ/form', locals: { procedure: @procedure, types_de_champ: @types_de_champ }) %> -on_change_type_de_champ_select();