From e94e0d6ed8137d4b43f205d48a2d7ddde243c9c6 Mon Sep 17 00:00:00 2001 From: pabois <pierreandre.boissinot@noesya.coop> Date: Mon, 24 Oct 2022 17:24:45 +0200 Subject: [PATCH] correct js on devise layout --- app/assets/javascripts/admin/plugins/notyf.js | 61 ++++++++++--------- app/assets/javascripts/devise.js | 13 ++++ app/views/extranet/layouts/devise.html.erb | 2 +- app/views/layouts/devise.html.erb | 2 +- 4 files changed, 47 insertions(+), 31 deletions(-) create mode 100644 app/assets/javascripts/devise.js diff --git a/app/assets/javascripts/admin/plugins/notyf.js b/app/assets/javascripts/admin/plugins/notyf.js index 68499577b..894daa6de 100644 --- a/app/assets/javascripts/admin/plugins/notyf.js +++ b/app/assets/javascripts/admin/plugins/notyf.js @@ -1,31 +1,34 @@ /*global Notyf */ -var notyfAlerts = document.getElementsByClassName('js-notyf-alert'), - notyfNotices = document.getElementsByClassName('js-notyf-notice'), - notyf = new Notyf(); +window.addEventListener('DOMContentLoaded', function () { + 'use strict'; + var notyfAlerts = document.getElementsByClassName('js-notyf-alert'), + notyfNotices = document.getElementsByClassName('js-notyf-notice'), + notyf = new Notyf(); -if (notyfAlerts.length > 0) { - notyf.open({ - type: 'error', - position: { - x: 'center', - y: 'bottom' - }, - message: notyfAlerts[0].innerText, - duration: 9000, - ripple: true, - dismissible: true - }); -} -if (notyfNotices.length > 0) { - notyf.open({ - type: 'success', - position: { - x: 'center', - y: 'bottom' - }, - message: notyfNotices[0].innerText, - duration: 9000, - ripple: true, - dismissible: true - }); -} + if (notyfAlerts.length > 0) { + notyf.open({ + type: 'error', + position: { + x: 'center', + y: 'bottom' + }, + message: notyfAlerts[0].innerText, + duration: 9000, + ripple: true, + dismissible: true + }); + } + if (notyfNotices.length > 0) { + notyf.open({ + type: 'success', + position: { + x: 'center', + y: 'bottom' + }, + message: notyfNotices[0].innerText, + duration: 9000, + ripple: true, + dismissible: true + }); + } +}); diff --git a/app/assets/javascripts/devise.js b/app/assets/javascripts/devise.js new file mode 100644 index 000000000..039f2a362 --- /dev/null +++ b/app/assets/javascripts/devise.js @@ -0,0 +1,13 @@ +//= require activestorage +//= require jquery3 +//= require jquery_ujs +//= require notyf/notyf.min +//= require simple_form_password_with_hints +//= require simple_form_bs5_file_input +//= require cropperjs/dist/cropper +//= require jquery-cropper/dist/jquery-cropper +//= require gdpr/cookie_consent +//= require_self +//= require_tree ./admin/plugins + +window.osuny = {}; diff --git a/app/views/extranet/layouts/devise.html.erb b/app/views/extranet/layouts/devise.html.erb index 993387982..dc9c6b8ab 100644 --- a/app/views/extranet/layouts/devise.html.erb +++ b/app/views/extranet/layouts/devise.html.erb @@ -7,7 +7,7 @@ <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= stylesheet_link_tag 'admin', media: 'all' %> - <%= javascript_include_tag 'admin' %> + <%= javascript_include_tag 'devise' %> <%= favicon_link_tag 'favicon.png' %> </head> <body class="<%= body_classes %>"> diff --git a/app/views/layouts/devise.html.erb b/app/views/layouts/devise.html.erb index 1d4c61feb..ad40226ca 100644 --- a/app/views/layouts/devise.html.erb +++ b/app/views/layouts/devise.html.erb @@ -7,7 +7,7 @@ <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= stylesheet_link_tag 'admin', media: 'all' %> - <%= javascript_include_tag 'admin' %> + <%= javascript_include_tag 'devise' %> <%= favicon_link_tag 'favicon.png' %> </head> <body class="<%= body_classes %>"> -- GitLab