Format old javascript with prettier
This commit is contained in:
parent
af63ad5802
commit
7898a33469
13 changed files with 133 additions and 83 deletions
|
@ -17,23 +17,28 @@
|
|||
//= require bootstrap-wysihtml5
|
||||
//= require bootstrap-wysihtml5/locales/fr-FR
|
||||
|
||||
/* globals $ */
|
||||
|
||||
$(document).on('turbolinks:load', application_init);
|
||||
|
||||
function application_init(){
|
||||
function application_init() {
|
||||
tooltip_init();
|
||||
scroll_to();
|
||||
}
|
||||
|
||||
function tooltip_init() {
|
||||
$('.action_button[data-toggle="tooltip"]').tooltip({delay: { "show": 100, "hide": 100 }});
|
||||
$('[data-toggle="tooltip"]').tooltip({delay: { "show": 800, "hide": 100 }});
|
||||
$('.action_button[data-toggle="tooltip"]').tooltip({
|
||||
delay: { show: 100, hide: 100 }
|
||||
});
|
||||
$('[data-toggle="tooltip"]').tooltip({ delay: { show: 800, hide: 100 } });
|
||||
}
|
||||
|
||||
function scroll_to() {
|
||||
$('.js-scrollTo').on('click', function () { // Au clic sur un élément
|
||||
$('.js-scrollTo').on('click', function() {
|
||||
// Au clic sur un élément
|
||||
var page = $(this).attr('cible'); // Page cible
|
||||
var speed = 600; // Durée de l'animation (en ms)
|
||||
$('html, body').animate({scrollTop: $(page).offset().top - 200}, speed); // Go
|
||||
$('html, body').animate({ scrollTop: $(page).offset().top - 200 }, speed); // Go
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* globals $ */
|
||||
|
||||
$(document).on('click', '.delete', function() {
|
||||
$(this).hide();
|
||||
$(this)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* globals $ */
|
||||
|
||||
$(document).on('turbolinks:load', init_path_modal);
|
||||
|
||||
var PROCEDURE_PATH_SELECTOR = 'input[data-autocomplete=path]';
|
||||
|
@ -10,23 +12,22 @@ function init_path_modal() {
|
|||
}
|
||||
|
||||
function path_modal_action() {
|
||||
$('#publish-modal').on('show.bs.modal', function (event) {
|
||||
$("#publish-modal .modal-body .table .tr-content").hide();
|
||||
$('#publish-modal').on('show.bs.modal', function(event) {
|
||||
$('#publish-modal .modal-body .table .tr-content').hide();
|
||||
|
||||
var button = $(event.relatedTarget) // Button that triggered the modal
|
||||
var button = $(event.relatedTarget); // Button that triggered the modal
|
||||
var modal_title = button.data('modal_title'); // Extract info from data-* attributes
|
||||
var modal_index = button.data('modal_index'); // Extract info from data-* attributes
|
||||
|
||||
var modal = $(this)
|
||||
var modal = $(this);
|
||||
modal.find('#publish-modal-title').html(modal_title);
|
||||
$("#publish-modal .modal-body .table #"+modal_index).show();
|
||||
})
|
||||
$('#publish-modal .modal-body .table #' + modal_index).show();
|
||||
});
|
||||
}
|
||||
|
||||
function path_validation_action() {
|
||||
$(PROCEDURE_PATH_SELECTOR).keyup(function (key) {
|
||||
if (key.keyCode != 13)
|
||||
path_validation(this);
|
||||
$(PROCEDURE_PATH_SELECTOR).keyup(function(key) {
|
||||
if (key.keyCode != 13) path_validation(this);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -42,9 +43,8 @@ function togglePathMessage(valid, mine) {
|
|||
}
|
||||
|
||||
if ((valid && mine === null) || mine === true)
|
||||
$('#publish-modal #publish').removeAttr('disabled')
|
||||
else
|
||||
$('#publish-modal #publish').attr('disabled', 'disabled')
|
||||
$('#publish-modal #publish').removeAttr('disabled');
|
||||
else $('#publish-modal #publish').attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
function path_validation(el) {
|
||||
|
@ -53,13 +53,21 @@ function path_validation(el) {
|
|||
togglePathMessage(valid, null);
|
||||
}
|
||||
|
||||
function toggleErrorClass(node, boolean) {
|
||||
if (boolean) $(node).removeClass('input-error');
|
||||
else $(node).addClass('input-error');
|
||||
}
|
||||
|
||||
function validatePath(path) {
|
||||
var re = /^[a-z0-9_\-]{3,50}$/;
|
||||
var re = /^[a-z0-9_-]{3,50}$/;
|
||||
return re.test(path);
|
||||
}
|
||||
|
||||
function path_type_init() {
|
||||
$(PROCEDURE_PATH_SELECTOR).bind('autocomplete:select', function(ev, suggestion) {
|
||||
$(PROCEDURE_PATH_SELECTOR).bind('autocomplete:select', function(
|
||||
ev,
|
||||
suggestion
|
||||
) {
|
||||
togglePathMessage(true, suggestion['mine']);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* globals $ */
|
||||
|
||||
$(document).on('click', 'button#archive-procedure', function() {
|
||||
$('button#archive-procedure').hide();
|
||||
$('#confirm').show();
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/* globals $ */
|
||||
|
||||
$(document).on('turbolinks:load', wysihtml5_active);
|
||||
|
||||
function wysihtml5_active (){
|
||||
function wysihtml5_active() {
|
||||
$('.wysihtml5').each(function(i, elem) {
|
||||
$(elem).wysihtml5({
|
||||
toolbar: {
|
||||
"fa": true,
|
||||
"link": false,
|
||||
"color": false
|
||||
fa: true,
|
||||
link: false,
|
||||
color: false
|
||||
},
|
||||
parserRules: {
|
||||
tags: {
|
||||
|
@ -31,7 +33,7 @@ function wysihtml5_active (){
|
|||
}
|
||||
}
|
||||
},
|
||||
"locale": "fr-FR"
|
||||
locale: 'fr-FR'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* globals $ */
|
||||
|
||||
$(document).on('turbolinks:load', init_default_data_block);
|
||||
|
||||
function init_default_data_block() {
|
||||
|
@ -5,12 +7,15 @@ function init_default_data_block() {
|
|||
$('.default-data-block #dossier .carret-right').toggle();
|
||||
$('.default-data-block #dossier .carret-down').toggle();
|
||||
|
||||
$('.default-data-block .title').click(function () {
|
||||
$('.default-data-block .title').click(function() {
|
||||
toggle_default_data_bloc(this, 400);
|
||||
});
|
||||
|
||||
$('.new-action').click(function () {
|
||||
var messages_block = $(this).parents().closest('.default-data-block').find('.title')
|
||||
$('.new-action').click(function() {
|
||||
var messages_block = $(this)
|
||||
.parents()
|
||||
.closest('.default-data-block')
|
||||
.find('.title');
|
||||
toggle_default_data_bloc(messages_block, 400);
|
||||
});
|
||||
|
||||
|
@ -22,7 +27,7 @@ function init_default_data_block() {
|
|||
var block = $(element).parents('.show-block');
|
||||
if (block.attr('id') == 'messages') {
|
||||
block.children('.last-commentaire').toggle();
|
||||
$(".commentaires").animate({ scrollTop: $(this).height() }, "slow");
|
||||
$('.commentaires').animate({ scrollTop: $(this).height() }, 'slow');
|
||||
}
|
||||
|
||||
block.children('.body').slideToggle(duration);
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
/* globals $ */
|
||||
|
||||
$(document).on('turbolinks:load', init_modal_commentaire);
|
||||
|
||||
function init_modal_commentaire() {
|
||||
var modal = $("#modalCommentairesDossierParChamp");
|
||||
var body = modal.find(".modal-body");
|
||||
var modal = $('#modalCommentairesDossierParChamp');
|
||||
var body = modal.find('.modal-body');
|
||||
var originalBody = body.html();
|
||||
|
||||
modal.on("show.bs.modal", function (e) {
|
||||
body.load(e.relatedTarget.getAttribute("data-href"));
|
||||
modal.on('show.bs.modal', function(e) {
|
||||
body.load(e.relatedTarget.getAttribute('data-href'));
|
||||
});
|
||||
|
||||
$("#modalCommentairesDossierParChamp").on("hidden.bs.modal", function (e) {
|
||||
$('#modalCommentairesDossierParChamp').on('hidden.bs.modal', function() {
|
||||
body.html(originalBody);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,28 +1,40 @@
|
|||
/* eslint no-unused-vars:0 */
|
||||
/* globals $ */
|
||||
|
||||
$(document).on('turbolinks:load', handle_siret_form_errors);
|
||||
|
||||
function error_form_siret(invalid_siret) {
|
||||
setTimeout(function () {
|
||||
$("input[type='submit']").val('Erreur SIRET');
|
||||
setTimeout(function() {
|
||||
$("input[type='submit']").val('Erreur SIRET');
|
||||
}, 10);
|
||||
|
||||
$("input[type='submit']").removeClass('btn-success').addClass('btn-danger');
|
||||
|
||||
$("#dossier-siret").addClass('input-error').val(invalid_siret).on('input', reset_form_siret);
|
||||
$("input[type='submit']")
|
||||
.removeClass('btn-success')
|
||||
.addClass('btn-danger');
|
||||
|
||||
$('#dossier-siret')
|
||||
.addClass('input-error')
|
||||
.val(invalid_siret)
|
||||
.on('input', reset_form_siret);
|
||||
}
|
||||
|
||||
function reset_form_siret() {
|
||||
$("input[type='submit']").removeClass('btn-danger').addClass('btn-success').val('Valider');
|
||||
$("#dossier-siret").removeClass('input-error');
|
||||
$("input[type='submit']")
|
||||
.removeClass('btn-danger')
|
||||
.addClass('btn-success')
|
||||
.val('Valider');
|
||||
$('#dossier-siret').removeClass('input-error');
|
||||
}
|
||||
|
||||
function toggle_etape_1() {
|
||||
$('.row.etape.etape_1 .etapes-menu #logos').toggle(100);
|
||||
$('.row.etape.etape_1 .etapes-informations #description_procedure').toggle(100);
|
||||
$('.row.etape.etape_1 .etapes-informations #description_procedure').toggle(
|
||||
100
|
||||
);
|
||||
}
|
||||
|
||||
function handle_siret_form_errors() {
|
||||
$(".form-inline[data-remote]").on("ajax:error", function(event) {
|
||||
$('.form-inline[data-remote]').on('ajax:error', function(event) {
|
||||
var input = $('#dossier-siret', event.target);
|
||||
if (input.length) {
|
||||
var invalid_siret = input.val();
|
||||
|
|
|
@ -1,44 +1,53 @@
|
|||
/* globals $ */
|
||||
|
||||
$(document).on('turbolinks:load', filters_init);
|
||||
|
||||
function filters_init() {
|
||||
$('html').click(function(event) {
|
||||
var visible_filter = $('.filter_framed:visible')
|
||||
if(visible_filter.length) {
|
||||
if (!$(event.target).closest('.filter_framed').is(":visible")) {
|
||||
var visible_filter = $('.filter_framed:visible');
|
||||
if (visible_filter.length) {
|
||||
if (
|
||||
!$(event.target)
|
||||
.closest('.filter_framed')
|
||||
.is(':visible')
|
||||
) {
|
||||
visible_filter.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(".filter").on('click', function (event) {
|
||||
$('.filter').on('click', function(event) {
|
||||
filter_framed_show(event);
|
||||
filter_framed_close_all_excepted(framed_id(event));
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
$(".erase-filter").on('click', function (event) {
|
||||
$(this).parent().find(".filter_input").val("");
|
||||
$('.erase-filter').on('click', function() {
|
||||
$(this)
|
||||
.parent()
|
||||
.find('.filter_input')
|
||||
.val('');
|
||||
});
|
||||
}
|
||||
|
||||
function filter_framed_close_all_excepted(id) {
|
||||
$(".filter_framed:not("+id+")").hide();
|
||||
$('.filter_framed:not(' + id + ')').hide();
|
||||
|
||||
$(id).toggle();
|
||||
}
|
||||
|
||||
function framed_id(event) {
|
||||
return "#framed_" + event.target.id
|
||||
return '#framed_' + event.target.id;
|
||||
}
|
||||
|
||||
function filter_framed_show(event) {
|
||||
dom_object = $(framed_id(event));
|
||||
var dom_object = $(framed_id(event));
|
||||
|
||||
var offset = $('#main-container').offset();
|
||||
|
||||
var y = event.pageY - offset.top;
|
||||
var x = event.pageX - offset.left;
|
||||
|
||||
dom_object.css('top', (y + 7) + 'px');
|
||||
dom_object.css('left', (x + 7) + 'px');
|
||||
dom_object.css('top', y + 7 + 'px');
|
||||
dom_object.css('left', x + 7 + 'px');
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* globals $ */
|
||||
|
||||
$(document).on('click', '#dossiers-list tr', function(event) {
|
||||
var href = $(this).data('href');
|
||||
if (href && event.target.tagName !== 'A') {
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
/* globals $ */
|
||||
|
||||
$(document).on('turbolinks:load', modal_action);
|
||||
|
||||
function modal_action() {
|
||||
$('#pj-modal').on('show.bs.modal', function (event) {
|
||||
$("#pj-modal .modal-body .table .tr-content").hide();
|
||||
$('#pj-modal').on('show.bs.modal', function(event) {
|
||||
$('#pj-modal .modal-body .table .tr-content').hide();
|
||||
|
||||
var button = $(event.relatedTarget) // Button that triggered the modal
|
||||
var button = $(event.relatedTarget); // Button that triggered the modal
|
||||
var modal_title = button.data('modal_title'); // Extract info from data-* attributes
|
||||
var modal_index = button.data('modal_index'); // Extract info from data-* attributes
|
||||
|
||||
var modal = $(this)
|
||||
var modal = $(this);
|
||||
modal.find('#pj-modal-title').html(modal_title);
|
||||
$("#pj-modal .modal-body .table #"+modal_index).show();
|
||||
})
|
||||
$('#pj-modal .modal-body .table #' + modal_index).show();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
/* globals $ */
|
||||
|
||||
$(document).on('turbolinks:load', action_type_de_champs);
|
||||
|
||||
|
||||
function action_type_de_champs() {
|
||||
$("input[type='email']").on('change', function () {
|
||||
$("input[type='email']").on('change', function() {
|
||||
toggleErrorClass(this, validateEmail($(this).val()));
|
||||
});
|
||||
|
||||
$("input[type='number']").on('change', function () {
|
||||
$("input[type='number']").on('change', function() {
|
||||
toggleErrorClass(this, validateNumber($(this).val()));
|
||||
});
|
||||
|
||||
$("input[type='phone']").on('change', function () {
|
||||
val = $(this).val();
|
||||
$("input[type='phone']").on('change', function() {
|
||||
var val = $(this).val();
|
||||
val = val.replace(/[ ]/g, '');
|
||||
|
||||
toggleErrorClass(this, validatePhone(val));
|
||||
|
@ -19,25 +20,23 @@ function action_type_de_champs() {
|
|||
}
|
||||
|
||||
function toggleErrorClass(node, boolean) {
|
||||
if (boolean)
|
||||
$(node).removeClass('input-error');
|
||||
else
|
||||
$(node).addClass('input-error');
|
||||
if (boolean) $(node).removeClass('input-error');
|
||||
else $(node).addClass('input-error');
|
||||
}
|
||||
|
||||
function validatePhone(phone) {
|
||||
var re = /^(0|(\+[1-9]{2})|(00[1-9]{2}))[1-9][0-9]{8}$/;
|
||||
return validateInput(phone, re)
|
||||
return validateInput(phone, re);
|
||||
}
|
||||
|
||||
function validateEmail(email) {
|
||||
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
return validateInput(email, re)
|
||||
var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
return validateInput(email, re);
|
||||
}
|
||||
|
||||
function validateNumber(number) {
|
||||
var re = /^[0-9]+$/;
|
||||
return validateInput(number, re)
|
||||
return validateInput(number, re);
|
||||
}
|
||||
|
||||
function validateInput(input, regex) {
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
/* globals $ */
|
||||
|
||||
$(document).on('turbolinks:load', button_edit_procedure_init);
|
||||
|
||||
function button_edit_procedure_init(){
|
||||
function button_edit_procedure_init() {
|
||||
buttons_api_carto();
|
||||
button_individual();
|
||||
}
|
||||
|
||||
function buttons_api_carto () {
|
||||
|
||||
$("#procedure-module-api-carto-use-api-carto").on('change', function() {
|
||||
$("#modules-api-carto").toggle()
|
||||
function buttons_api_carto() {
|
||||
$('#procedure-module-api-carto-use-api-carto').on('change', function() {
|
||||
$('#modules-api-carto').toggle();
|
||||
});
|
||||
|
||||
if ($('#procedure-module-api-carto-use-api-carto').is(':checked'))
|
||||
$("#modules-api-carto").show();
|
||||
$('#modules-api-carto').show();
|
||||
}
|
||||
|
||||
function button_individual () {
|
||||
|
||||
$("#procedure_for_individual").on('change', function() {
|
||||
$("#individual-with-siret").toggle()
|
||||
function button_individual() {
|
||||
$('#procedure_for_individual').on('change', function() {
|
||||
$('#individual-with-siret').toggle();
|
||||
});
|
||||
|
||||
if ($('#procedure_for_individual').is(':checked'))
|
||||
$("#individual-with-siret").show();
|
||||
$('#individual-with-siret').show();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue