From 95eb9070903b0b54b63d81744e94bb66ed5c9d8e Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 6 Oct 2020 17:10:34 +0200 Subject: [PATCH] remove unused javascript --- app/javascript/new_design/messagerie.js | 2 +- app/javascript/packs/application.js | 8 ++++---- app/javascript/shared/rails-ujs-fix.js | 21 --------------------- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/app/javascript/new_design/messagerie.js b/app/javascript/new_design/messagerie.js index d2e056feb..d849996f8 100644 --- a/app/javascript/new_design/messagerie.js +++ b/app/javascript/new_design/messagerie.js @@ -1,6 +1,6 @@ import { scrollTo, scrollToBottom } from '@utils'; -export function scrollMessagerie() { +function scrollMessagerie() { const ul = document.querySelector('.messagerie ul'); if (ul) { diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 3183dcf79..bce040af7 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -29,14 +29,15 @@ import '../new_design/champs/carte'; import '../new_design/champs/linked-drop-down-list'; import '../new_design/champs/repetition'; -import { toggleCondidentielExplanation } from '../new_design/avis'; -import { scrollMessagerie } from '../new_design/messagerie'; +import { + toggleCondidentielExplanation, + replaceSemicolonByComma +} from '../new_design/avis'; import { showMotivation, motivationCancel, showImportJustificatif } from '../new_design/state-button'; -import { replaceSemicolonByComma } from '../new_design/avis'; import { acceptEmailSuggestion, discardEmailSuggestionBox @@ -46,7 +47,6 @@ import { const DS = { fire: (eventName, data) => Rails.fire(document, eventName, data), toggleCondidentielExplanation, - scrollMessagerie, showMotivation, motivationCancel, showImportJustificatif, diff --git a/app/javascript/shared/rails-ujs-fix.js b/app/javascript/shared/rails-ujs-fix.js index 4c12c029b..b9031ce63 100644 --- a/app/javascript/shared/rails-ujs-fix.js +++ b/app/javascript/shared/rails-ujs-fix.js @@ -1,26 +1,5 @@ -import Rails from '@rails/ujs'; import jQuery from 'jquery'; -// `smart_listing` gem is overriding `$.rails.href` method. When using newer -// 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, handleRemote } = Rails; - Rails.href = function (element) { - return element.href || href(element); - }; - Rails.handleRemote = function (e) { - if (this instanceof HTMLElement) { - handleRemote.call(this, e); - } else { - let element = e.find('[data-remote]')[0]; - let event = new CustomEvent('click'); - Object.defineProperty(event, 'target', { value: element }); - return handleRemote.call(element, event); - } - }; -}); - // rails-ujs installs CSRFProtection for its own ajax implementation. We might need // CSRFProtection for jQuery initiated requests. This code is from jquery-ujs. jQuery.ajaxPrefilter((options, originalOptions, xhr) => {