diff --git a/.eslintrc.js b/.eslintrc.js index 48dcefa38..6e3ee44b1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,7 +5,6 @@ module.exports = { sourceType: 'module' }, globals: { - '$': true, 'process': true }, plugins: ['prettier'], diff --git a/app/javascript/manager/fields/features.js b/app/javascript/manager/fields/features.js index d7e34c65e..98b40bf94 100644 --- a/app/javascript/manager/fields/features.js +++ b/app/javascript/manager/fields/features.js @@ -1,6 +1,5 @@ -// Administrate injects its own copy of jQuery, and it is the one -// configured by rails to send csrf-token -const $ = window.$; +// Administrate injects its own copy of jQuery +/* globals $ */ $(document).on('change', '#features input[type=checkbox]', ({ target }) => { target = $(target); diff --git a/app/javascript/new_design/avis.js b/app/javascript/new_design/avis.js index 09c84320b..c35fdc6eb 100644 --- a/app/javascript/new_design/avis.js +++ b/app/javascript/new_design/avis.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + export function toggleCondidentielExplanation() { $('.confidentiel-explanation').toggle(); } diff --git a/app/javascript/new_design/buttons.js b/app/javascript/new_design/buttons.js index 22c584abb..321ea62fe 100644 --- a/app/javascript/new_design/buttons.js +++ b/app/javascript/new_design/buttons.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + $(document).on('click', 'body', () => { $('.button.dropdown').removeClass('open'); }); diff --git a/app/javascript/new_design/carto.js b/app/javascript/new_design/carto.js index 699d09f3d..7a5331b7b 100644 --- a/app/javascript/new_design/carto.js +++ b/app/javascript/new_design/carto.js @@ -1,3 +1,4 @@ +import $ from 'jquery'; import L from 'leaflet'; import { getData } from '../shared/data'; diff --git a/app/javascript/new_design/champs/address.js b/app/javascript/new_design/champs/address.js index 4dda67eea..c368c6321 100644 --- a/app/javascript/new_design/champs/address.js +++ b/app/javascript/new_design/champs/address.js @@ -1,3 +1,4 @@ +import $ from 'jquery'; import Bloodhound from 'bloodhound-js'; const display = 'label'; diff --git a/app/javascript/new_design/champs/dossier-link.js b/app/javascript/new_design/champs/dossier-link.js index 87485c721..0a86d53c9 100644 --- a/app/javascript/new_design/champs/dossier-link.js +++ b/app/javascript/new_design/champs/dossier-link.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + function showNotFound() { $('.dossier-link .text-info').hide(); $('.dossier-link .text-warning').show(); diff --git a/app/javascript/new_design/champs/multiple-drop-down-list.js b/app/javascript/new_design/champs/multiple-drop-down-list.js index 27a4e92c8..5b5cefe71 100644 --- a/app/javascript/new_design/champs/multiple-drop-down-list.js +++ b/app/javascript/new_design/champs/multiple-drop-down-list.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + addEventListener('turbolinks:load', () => { $('select.select2').select2({ language: 'fr', diff --git a/app/javascript/new_design/champs/siret.js b/app/javascript/new_design/champs/siret.js index c391edfee..22e814851 100644 --- a/app/javascript/new_design/champs/siret.js +++ b/app/javascript/new_design/champs/siret.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + addEventListener('turbolinks:load', () => { $('[data-siret]').on('input', evt => { const input = $(evt.target); diff --git a/app/javascript/new_design/dossier.js b/app/javascript/new_design/dossier.js index 72ad041b9..e7bbf68b9 100644 --- a/app/javascript/new_design/dossier.js +++ b/app/javascript/new_design/dossier.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + $(document).on('click', 'body', () => { $('.print-menu').removeClass('open fade-in-down'); }); diff --git a/app/javascript/new_design/form-validation.js b/app/javascript/new_design/form-validation.js index 3acba9558..06b9c161c 100644 --- a/app/javascript/new_design/form-validation.js +++ b/app/javascript/new_design/form-validation.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + $(document).on('blur keydown', 'input, textarea', () => { $(this).addClass('touched'); }); diff --git a/app/javascript/new_design/header.js b/app/javascript/new_design/header.js index c18d3b2a2..b7f048ec7 100644 --- a/app/javascript/new_design/header.js +++ b/app/javascript/new_design/header.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + $(document).on('click', 'body', () => { $('.header-menu').removeClass('open fade-in-down'); }); diff --git a/app/javascript/new_design/messagerie.js b/app/javascript/new_design/messagerie.js index 7056a9111..a7dd2bc39 100644 --- a/app/javascript/new_design/messagerie.js +++ b/app/javascript/new_design/messagerie.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + export function scrollMessagerie() { const $ul = $('.messagerie ul').first(); diff --git a/app/javascript/new_design/state-button.js b/app/javascript/new_design/state-button.js index 3316f9b68..71b8e8d55 100644 --- a/app/javascript/new_design/state-button.js +++ b/app/javascript/new_design/state-button.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + export function showMotivation(state) { $(`.motivation.${state}`).show(); $('.dropdown-items').hide(); diff --git a/app/javascript/new_design/toggle-chart.js b/app/javascript/new_design/toggle-chart.js index 510389266..b51622402 100644 --- a/app/javascript/new_design/toggle-chart.js +++ b/app/javascript/new_design/toggle-chart.js @@ -1,3 +1,4 @@ +import $ from 'jquery'; import Chartkick from 'chartkick'; export function toggleChart(event, chartClass) { diff --git a/app/javascript/packs/application-old.js b/app/javascript/packs/application-old.js index 2af95caeb..32ecd1f03 100644 --- a/app/javascript/packs/application-old.js +++ b/app/javascript/packs/application-old.js @@ -31,5 +31,6 @@ if (process.env['RAILS_ENV'] === 'test') { window.Bloodhound = Bloodhound; window.Chartkick = Chartkick; // Export jQuery globally for legacy Javascript files used in the old design +jQuery.rails = Rails; window.$ = jQuery; window.jQuery = jQuery; diff --git a/app/javascript/shared/rails-ujs-fix.js b/app/javascript/shared/rails-ujs-fix.js index 8af3592f8..19aac8054 100644 --- a/app/javascript/shared/rails-ujs-fix.js +++ b/app/javascript/shared/rails-ujs-fix.js @@ -19,8 +19,8 @@ Rails.delegate(document, '[data-remote]', 'ajax:send', ({ target }) => { // jQuery-less version of rails-ujs it breaks. // https://github.com/Sology/smart_listing/blob/master/app/assets/javascripts/smart_listing.coffee.erb#L9 addEventListener('load', () => { - const { href } = $.rails; - $.rails.href = function(element) { + const { href } = Rails; + Rails.href = function(element) { return element.href || href(element); }; }); diff --git a/config/webpack/environment.js b/config/webpack/environment.js index a57480bbf..d16d9af74 100644 --- a/config/webpack/environment.js +++ b/config/webpack/environment.js @@ -1,9 +1,3 @@ const { environment } = require('@rails/webpacker') -const webpack = require('webpack'); -environment.plugins.append('Provide', new webpack.ProvidePlugin({ - $: 'jquery', - jQuery: 'jquery' -})); - module.exports = environment