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'
},
globals: {
'$': true,
'process': true
},
plugins: ['prettier'],

View file

@ -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);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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;

View file

@ -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);
};
});

View file

@ -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