diff --git a/assets/app.js b/assets/app.js index 7c5a082..55eff4e 100644 --- a/assets/app.js +++ b/assets/app.js @@ -8,7 +8,6 @@ // any CSS you import will output into a single css file (app.css in this case) import './styles/app.scss'; -const $ = require('jquery'); // start the Stimulus application require('bootstrap'); @@ -18,27 +17,32 @@ import '@fortawesome/fontawesome-free/js/solid' import '@fortawesome/fontawesome-free/js/regular' import '@fortawesome/fontawesome-free/js/brands' -// Friendly captcha -import { WidgetInstance } from 'friendly-challenge'; - -function doneCallback(solution) { - $('#registration_form_captcha_solution').val(solution); -} - -const element = document.querySelector('#captcha'); -const options = { - doneCallback: doneCallback, - sitekey: 'FCMVL79DP1G5K1K0', -} -const widget = new WidgetInstance(element, options); -widget.start() - -// Dsiplay Filename when uploading -document.querySelector('.custom-file-input').addEventListener('change', function (e) { - var fileName = document.getElementById('offer_form_photo').files[0].name; - var nextSibling = e.target.nextElementSibling - nextSibling.innerText = fileName -}) - // Cookie-consent -import 'cookie-notice/dist/cookie.notice.min.js' \ No newline at end of file +import 'cookie-notice/dist/cookie.notice.min'; + +new cookieNoticeJS({ + // Position for the cookie-notifier (default=bottom) + 'cookieNoticePosition': 'bottom', + + // The message will be shown again in X days + 'expiresIn': 365, + + // Specify a custom font family and size in pixels + 'fontFamily': 'inherit', + 'fontSize': '.9rem', + + // Dismiss button background color + 'buttonBgColor': '#343a40', + + // Dismiss button text color + 'buttonTextColor': '#fff', + + // Notice background color + 'noticeBgColor': '#000', + + // Notice text color + 'noticeTextColor': '#fff', + + // Print debug output to the console (default=false) + 'debug': false +}); \ No newline at end of file diff --git a/assets/captcha.js b/assets/captcha.js new file mode 100644 index 0000000..9725baa --- /dev/null +++ b/assets/captcha.js @@ -0,0 +1,15 @@ +// Friendly captcha +import { WidgetInstance } from 'friendly-challenge'; +const $ = require('jquery'); + +function doneCallback(solution) { + $('#registration_form_captcha_solution').val(solution); +} + +const element = document.querySelector('#captcha'); +const options = { + doneCallback: doneCallback, + sitekey: 'FCMVL79DP1G5K1K0', +} +const widget = new WidgetInstance(element, options); +widget.start() \ No newline at end of file diff --git a/assets/fileUpload.js b/assets/fileUpload.js new file mode 100644 index 0000000..d489d65 --- /dev/null +++ b/assets/fileUpload.js @@ -0,0 +1,5 @@ +const $ = require('jquery'); + +$( ".custom-file-input" ).change(function() { + $(".custom-file-label").html(($(".custom-file-input").prop("files")[0]["name"])); +}); diff --git a/templates/app/new_offer.html.twig b/templates/app/new_offer.html.twig index d4b6096..a1cc1e0 100644 --- a/templates/app/new_offer.html.twig +++ b/templates/app/new_offer.html.twig @@ -1,6 +1,10 @@ {% extends 'base.html.twig' %} -{% block title %}New Offer{% endblock %} +{% block title %}New Offer{% endblock %} + +{% block javascripts %} + {{ encore_entry_script_tags('fileUpload') }} +{% endblock %} {% block body %} {% for message in app.flashes('error') %} diff --git a/templates/registration/register.html.twig b/templates/registration/register.html.twig index 41676ce..1380747 100644 --- a/templates/registration/register.html.twig +++ b/templates/registration/register.html.twig @@ -7,6 +7,10 @@ {% endblock %} +{% block javascripts %} + {{ encore_entry_script_tags('captcha') }} +{% endblock %} + {% block body %} {% for flashError in app.flashes('verify_email_error') %} diff --git a/webpack.config.js b/webpack.config.js index 24bc396..4b9a143 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -21,6 +21,8 @@ Encore * and one CSS file (e.g. app.css) if your JavaScript imports CSS. */ .addEntry('app', './assets/app.js') + .addEntry('captcha', './assets/captcha.js') + .addEntry('fileUpload', './assets/fileUpload.js') // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js) .enableStimulusBridge('./assets/controllers.json')