Explicitly import jQuery

This commit is contained in:
Paul Chavard 2018-08-09 11:53:59 +02:00
parent 980d89dcac
commit 008d84f107
18 changed files with 28 additions and 12 deletions

View file

@ -5,7 +5,6 @@ module.exports = {
sourceType: 'module' sourceType: 'module'
}, },
globals: { globals: {
'$': true,
'process': true 'process': true
}, },
plugins: ['prettier'], plugins: ['prettier'],

View file

@ -1,6 +1,5 @@
// Administrate injects its own copy of jQuery, and it is the one // Administrate injects its own copy of jQuery
// configured by rails to send csrf-token /* globals $ */
const $ = window.$;
$(document).on('change', '#features input[type=checkbox]', ({ target }) => { $(document).on('change', '#features input[type=checkbox]', ({ target }) => {
target = $(target); target = $(target);

View file

@ -1,3 +1,5 @@
import $ from 'jquery';
export function toggleCondidentielExplanation() { export function toggleCondidentielExplanation() {
$('.confidentiel-explanation').toggle(); $('.confidentiel-explanation').toggle();
} }

View file

@ -1,3 +1,5 @@
import $ from 'jquery';
$(document).on('click', 'body', () => { $(document).on('click', 'body', () => {
$('.button.dropdown').removeClass('open'); $('.button.dropdown').removeClass('open');
}); });

View file

@ -1,3 +1,4 @@
import $ from 'jquery';
import L from 'leaflet'; import L from 'leaflet';
import { getData } from '../shared/data'; import { getData } from '../shared/data';

View file

@ -1,3 +1,4 @@
import $ from 'jquery';
import Bloodhound from 'bloodhound-js'; import Bloodhound from 'bloodhound-js';
const display = 'label'; const display = 'label';

View file

@ -1,3 +1,5 @@
import $ from 'jquery';
function showNotFound() { function showNotFound() {
$('.dossier-link .text-info').hide(); $('.dossier-link .text-info').hide();
$('.dossier-link .text-warning').show(); $('.dossier-link .text-warning').show();

View file

@ -1,3 +1,5 @@
import $ from 'jquery';
addEventListener('turbolinks:load', () => { addEventListener('turbolinks:load', () => {
$('select.select2').select2({ $('select.select2').select2({
language: 'fr', language: 'fr',

View file

@ -1,3 +1,5 @@
import $ from 'jquery';
addEventListener('turbolinks:load', () => { addEventListener('turbolinks:load', () => {
$('[data-siret]').on('input', evt => { $('[data-siret]').on('input', evt => {
const input = $(evt.target); const input = $(evt.target);

View file

@ -1,3 +1,5 @@
import $ from 'jquery';
$(document).on('click', 'body', () => { $(document).on('click', 'body', () => {
$('.print-menu').removeClass('open fade-in-down'); $('.print-menu').removeClass('open fade-in-down');
}); });

View file

@ -1,3 +1,5 @@
import $ from 'jquery';
$(document).on('blur keydown', 'input, textarea', () => { $(document).on('blur keydown', 'input, textarea', () => {
$(this).addClass('touched'); $(this).addClass('touched');
}); });

View file

@ -1,3 +1,5 @@
import $ from 'jquery';
$(document).on('click', 'body', () => { $(document).on('click', 'body', () => {
$('.header-menu').removeClass('open fade-in-down'); $('.header-menu').removeClass('open fade-in-down');
}); });

View file

@ -1,3 +1,5 @@
import $ from 'jquery';
export function scrollMessagerie() { export function scrollMessagerie() {
const $ul = $('.messagerie ul').first(); const $ul = $('.messagerie ul').first();

View file

@ -1,3 +1,5 @@
import $ from 'jquery';
export function showMotivation(state) { export function showMotivation(state) {
$(`.motivation.${state}`).show(); $(`.motivation.${state}`).show();
$('.dropdown-items').hide(); $('.dropdown-items').hide();

View file

@ -1,3 +1,4 @@
import $ from 'jquery';
import Chartkick from 'chartkick'; import Chartkick from 'chartkick';
export function toggleChart(event, chartClass) { export function toggleChart(event, chartClass) {

View file

@ -31,5 +31,6 @@ if (process.env['RAILS_ENV'] === 'test') {
window.Bloodhound = Bloodhound; window.Bloodhound = Bloodhound;
window.Chartkick = Chartkick; window.Chartkick = Chartkick;
// Export jQuery globally for legacy Javascript files used in the old design // Export jQuery globally for legacy Javascript files used in the old design
jQuery.rails = Rails;
window.$ = jQuery; window.$ = jQuery;
window.jQuery = jQuery; window.jQuery = jQuery;

View file

@ -19,8 +19,8 @@ Rails.delegate(document, '[data-remote]', 'ajax:send', ({ target }) => {
// jQuery-less version of rails-ujs it breaks. // jQuery-less version of rails-ujs it breaks.
// https://github.com/Sology/smart_listing/blob/master/app/assets/javascripts/smart_listing.coffee.erb#L9 // https://github.com/Sology/smart_listing/blob/master/app/assets/javascripts/smart_listing.coffee.erb#L9
addEventListener('load', () => { addEventListener('load', () => {
const { href } = $.rails; const { href } = Rails;
$.rails.href = function(element) { Rails.href = function(element) {
return element.href || href(element); return element.href || href(element);
}; };
}); });

View file

@ -1,9 +1,3 @@
const { environment } = require('@rails/webpacker') const { environment } = require('@rails/webpacker')
const webpack = require('webpack');
environment.plugins.append('Provide', new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}));
module.exports = environment module.exports = environment