From 6d9648e88c822cde6c17d816182482241ab51cad Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 1 Aug 2018 15:34:57 +0200 Subject: [PATCH 1/4] =?UTF-8?q?[Fix=20#2214]=20Don=E2=80=99t=20suggest=20u?= =?UTF-8?q?sing=20the=20messagerie=20when=20it=20is=20not=20available?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification_mailer/send_draft_notification.html.haml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/views/notification_mailer/send_draft_notification.html.haml b/app/views/notification_mailer/send_draft_notification.html.haml index 8ac77d5e0..e8acfea87 100644 --- a/app/views/notification_mailer/send_draft_notification.html.haml +++ b/app/views/notification_mailer/send_draft_notification.html.haml @@ -12,9 +12,3 @@ %p L'équipe demarches-simplifiees.fr - -%p - — - -%p - Merci de ne pas répondre à cet email. Postez directement vos questions dans votre dossier sur la plateforme. From 9a963828d2e3c796c6485ff2430f2ef95b015943 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 1 Aug 2018 16:37:52 +0200 Subject: [PATCH 2/4] ci: retry when yarn fails because of a transcient error --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4a10d4256..f0538ae06 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,7 +38,7 @@ yarn_save_cache: &yarn_save_cache yarn_install: &yarn_install run: name: Install JS Dependencies - command: yarn install --non-interactive + command: yarn install --non-interactive || yarn install --non-interactive jobs: build: From 78a9365fe1e21375f8d03fb6c242cc70b0e6828b Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 25 Jul 2018 16:20:31 +0200 Subject: [PATCH 3/4] Package mailjet widget with webpack --- app/assets/javascripts/mailjet.js | 132 --------------- app/javascript/packs/mailjet.js | 159 ++++++++++++++++++ .../layouts/_mailjet_newsletter.html.haml | 2 +- config/application.rb | 2 +- 4 files changed, 161 insertions(+), 134 deletions(-) delete mode 100644 app/assets/javascripts/mailjet.js create mode 100644 app/javascript/packs/mailjet.js diff --git a/app/assets/javascripts/mailjet.js b/app/assets/javascripts/mailjet.js deleted file mode 100644 index 42ba7b513..000000000 --- a/app/assets/javascripts/mailjet.js +++ /dev/null @@ -1,132 +0,0 @@ -if (typeof wScriptAlreadyLoaded === "undefined") { - var wScriptAlreadyLoaded = true; - - // Array of popin translations - var i8nMessages = []; - i8nMessages['en_US'] = []; - i8nMessages['fr_FR'] = []; - i8nMessages['de_DE'] = []; - i8nMessages['es_ES'] = []; - i8nMessages['en_US']['iframe-error'] = 'Your browser does not support the IFrame element'; - i8nMessages['en_US']['close-popin'] = 'Close'; - i8nMessages['fr_FR']['iframe-error'] = 'Votre navigateur ne supporte pas l\'élément iframe'; - i8nMessages['fr_FR']['close-popin'] = 'Fermer'; - i8nMessages['de_DE']['iframe-error'] = 'Ihr navigator verträgt kein Element iframe'; - i8nMessages['de_DE']['close-popin'] = 'Schließen'; - i8nMessages['es_ES']['iframe-error'] = 'Su navegante no soporta el elemento iframe'; - i8nMessages['es_ES']['close-popin'] = 'Cerrarse'; - - window.onload = function() { - // Display popin when click event occure on widget button - Array.prototype.forEach.call(document.getElementsByClassName("mj-w-btn"), function(btnNode) { - btnNode.style.cursor = "pointer"; - btnNode.addEventListener("click", function(event) { - mjOpenPopin(event, this); - }); - }); - - mjOpenPopin = function(event, element) { - event.preventDefault(); - //event.stopPropagation(); - - //var token = str.substring(btnNode.id.lastIndexOf("-") + 1, btnNode.id.length - btnNode.id.lastIndexOf("-")); - var token = element.getAttribute("data-token"); - - //Register parameters - var widgetPopinData = document.querySelector(".mj-w-data[data-token='" + token + "']"); - if (widgetPopinData) { - var apiKey = widgetPopinData.getAttribute("data-apikey"); - var wId = widgetPopinData.getAttribute("data-w-id"); - var locale = widgetPopinData.getAttribute("data-lang"); - var base = widgetPopinData.getAttribute("data-base"); - var width = widgetPopinData.getAttribute("data-width"); - var height = widgetPopinData.getAttribute("data-height"); - var statics = widgetPopinData.getAttribute("data-statics"); - - // Call to Mailjet CSS file - var cssFile = document.createElement("link"); - cssFile.setAttribute("rel", "stylesheet"); - cssFile.setAttribute("type", "text/css"); - if (statics) { - base += "/" + statics; - } - cssFile.setAttribute("href", base + "/css/w-popin-less.css"); - document.getElementsByTagName("head")[0].appendChild(cssFile); - - var htmlCode = "
" + - "
" + - "
" + - "\""" + - "" + - "
" + - "
"; - - widgetPopinData.innerHTML = htmlCode; - - document.getElementById("mj-w-iframe").onload = function() { - - document.getElementById("mj-w-iframe").style.height= height + "px"; - document.getElementById('mj-w-close-img').style.display = "block"; - document.getElementById("mj-w-loader").style.display = "none"; - document.getElementById("mj-w-popin-block").style.border = "none"; - if (window.matchMedia("(max-width: 767px)").matches) { - document.getElementById("mj-w-iframe").style.width = '100%'; - document.getElementById("mj-w-popin-block").style.height = 'auto'; - document.getElementById("mj-w-popin-block").style.width = '90%'; - } - }; - - var closeImgNode = document.getElementById("mj-w-close-img"); - closeImgNode.addEventListener("click", function(event) { - closePopin(); - event.preventDefault(); - }); - - document.addEventListener("keydown", escapeEvent); - document.getElementById("mj-w-iframe").onclick=function(event){ - event.stopPropagation(); - }; - //document.addEventListener("click"); - - document.getElementById("mj-w-overlay").style.display = "block"; - document.getElementById("mj-w-overlay").addEventListener("click", function(event){ - closePopin(); - event.preventDefault(); - }); - } - } - - // Escape event : close popin - function escapeEvent(e) { - if (e.keyCode == 27) { // Escape key - closePopin(); - } - } - - // Close popin (remove popin HTML code) - function closePopin() { - var rootContainer = document.getElementById("mj-w-overlay"); - if(rootContainer) { - rootContainer.parentNode.removeChild(rootContainer); - } - document.removeEventListener("keypress", escapeEvent); - } - - window.onresize = function(event) { - if (window.matchMedia("(max-width: 767px)").matches) { - var popin = document.getElementById("mj-w-popin-block"); - var iframe = document.getElementById("mj-w-iframe"); - if (popin) { - popin.style.height = 'auto'; - popin.style.width = '90%'; - } - if (iframe) { - iframe.style.width = '100%'; - } - } - } - - }; -} diff --git a/app/javascript/packs/mailjet.js b/app/javascript/packs/mailjet.js new file mode 100644 index 000000000..30b85a446 --- /dev/null +++ b/app/javascript/packs/mailjet.js @@ -0,0 +1,159 @@ +// This file is copied from mailjet. We serve here a copy of it ourselves +// to avoid loading javascript files from other domains on the frontpage. + +// Array of popin translations +const i8nMessages = []; +i8nMessages['en_US'] = []; +i8nMessages['fr_FR'] = []; +i8nMessages['de_DE'] = []; +i8nMessages['es_ES'] = []; +i8nMessages['en_US']['iframe-error'] = + 'Your browser does not support the IFrame element'; +i8nMessages['en_US']['close-popin'] = 'Close'; +i8nMessages['fr_FR']['iframe-error'] = + "Votre navigateur ne supporte pas l'élément iframe"; +i8nMessages['fr_FR']['close-popin'] = 'Fermer'; +i8nMessages['de_DE']['iframe-error'] = + 'Ihr navigator verträgt kein Element iframe'; +i8nMessages['de_DE']['close-popin'] = 'Schließen'; +i8nMessages['es_ES']['iframe-error'] = + 'Su navegante no soporta el elemento iframe'; +i8nMessages['es_ES']['close-popin'] = 'Cerrarse'; + +function mjOpenPopin(event, element) { + event.preventDefault(); + //event.stopPropagation(); + + //var token = str.substring(btnNode.id.lastIndexOf("-") + 1, btnNode.id.length - btnNode.id.lastIndexOf("-")); + var token = element.getAttribute('data-token'); + + //Register parameters + var widgetPopinData = document.querySelector( + ".mj-w-data[data-token='" + token + "']" + ); + if (widgetPopinData) { + var apiKey = widgetPopinData.getAttribute('data-apikey'); + var wId = widgetPopinData.getAttribute('data-w-id'); + var locale = widgetPopinData.getAttribute('data-lang'); + var base = widgetPopinData.getAttribute('data-base'); + var width = widgetPopinData.getAttribute('data-width'); + var height = widgetPopinData.getAttribute('data-height'); + var statics = widgetPopinData.getAttribute('data-statics'); + + // Call to Mailjet CSS file + var cssFile = document.createElement('link'); + cssFile.setAttribute('rel', 'stylesheet'); + cssFile.setAttribute('type', 'text/css'); + if (statics) { + base += '/' + statics; + } + cssFile.setAttribute('href', base + '/css/w-popin-less.css'); + document.getElementsByTagName('head')[0].appendChild(cssFile); + + var htmlCode = + ''; + + widgetPopinData.innerHTML = htmlCode; + + document.getElementById('mj-w-iframe').onload = function() { + document.getElementById('mj-w-iframe').style.height = height + 'px'; + document.getElementById('mj-w-close-img').style.display = 'block'; + document.getElementById('mj-w-loader').style.display = 'none'; + document.getElementById('mj-w-popin-block').style.border = 'none'; + if (window.matchMedia('(max-width: 767px)').matches) { + document.getElementById('mj-w-iframe').style.width = '100%'; + document.getElementById('mj-w-popin-block').style.height = 'auto'; + document.getElementById('mj-w-popin-block').style.width = '90%'; + } + }; + + var closeImgNode = document.getElementById('mj-w-close-img'); + closeImgNode.addEventListener('click', function(event) { + closePopin(); + event.preventDefault(); + }); + + document.addEventListener('keydown', escapeEvent); + document.getElementById('mj-w-iframe').onclick = function(event) { + event.stopPropagation(); + }; + //document.addEventListener("click"); + + document.getElementById('mj-w-overlay').style.display = 'block'; + document + .getElementById('mj-w-overlay') + .addEventListener('click', function(event) { + closePopin(); + event.preventDefault(); + }); + } +} + +// Escape event : close popin +function escapeEvent(e) { + if (e.keyCode == 27) { + // Escape key + closePopin(); + } +} + +// Close popin (remove popin HTML code) +function closePopin() { + var rootContainer = document.getElementById('mj-w-overlay'); + if (rootContainer) { + rootContainer.parentNode.removeChild(rootContainer); + } + document.removeEventListener('keypress', escapeEvent); +} + +addEventListener('load', () => { + // Display popin when click event occure on widget button + for (let btnNode of document.getElementsByClassName('mj-w-btn')) { + btnNode.style.cursor = 'pointer'; + btnNode.addEventListener('click', function(event) { + mjOpenPopin(event, this); + }); + } +}); + +addEventListener('resize', () => { + if (window.matchMedia('(max-width: 767px)').matches) { + const popin = document.getElementById('mj-w-popin-block'); + const iframe = document.getElementById('mj-w-iframe'); + if (popin) { + popin.style.height = 'auto'; + popin.style.width = '90%'; + } + if (iframe) { + iframe.style.width = '100%'; + } + } +}); + +window.mjOpenPopin = mjOpenPopin; diff --git a/app/views/layouts/_mailjet_newsletter.html.haml b/app/views/layouts/_mailjet_newsletter.html.haml index e290caf30..58930a243 100644 --- a/app/views/layouts/_mailjet_newsletter.html.haml +++ b/app/views/layouts/_mailjet_newsletter.html.haml @@ -1,2 +1,2 @@ %data.mj-w-data{ "data-apikey" => "1v5T", "data-base" => "https://app.mailjet.com", "data-height" => "328", "data-lang" => "fr_FR", "data-statics" => "statics", "data-token" => "11c89e7ddb46fbcdcb7f8fe5fdfca818", "data-w-id" => "39b", "data-width" => "640", "value" => "mj" } -= javascript_include_tag 'mailjet', "data-turbolinks-eval": false += javascript_pack_tag 'mailjet', defer: true, 'data-turbolinks-eval': false diff --git a/config/application.rb b/config/application.rb index 6e5f62433..7d54fd628 100644 --- a/config/application.rb +++ b/config/application.rb @@ -25,7 +25,7 @@ module TPS config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/validators #{config.root}/app/facades) config.assets.paths << Rails.root.join('app', 'assets', 'javascript') config.assets.paths << Rails.root.join('app', 'assets', 'fonts') - config.assets.precompile += %w(.woff mailjet.js) + config.assets.precompile += %w(.woff) if Rails.env.production? URL = "https://www.demarches-simplifiees.fr/" From 3645c564163a71661d905301452aa26b49ddd943 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 1 Aug 2018 16:50:58 +0200 Subject: [PATCH 4/4] Use Chartkick with defer option --- config/initializers/chartkick.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/initializers/chartkick.rb b/config/initializers/chartkick.rb index c9269816f..213fa9164 100644 --- a/config/initializers/chartkick.rb +++ b/config/initializers/chartkick.rb @@ -1,4 +1,5 @@ Chartkick.options = { content_for: :charts_js, + defer: true, colors: ["rgba(61, 149, 236, 1)"] }