From 5fccc7e4211c7b87afe82096038a7a58f75d23f5 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 6 Dec 2023 21:10:00 +0100 Subject: [PATCH] Remove inline js --- config/config.default.php | 5 ++++- resources/assets/js/design.js | 13 +++++++++++++ resources/assets/js/vendor.js | 1 + resources/views/pages/design.twig | 30 +++++++++++------------------- 4 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 resources/assets/js/design.js diff --git a/config/config.default.php b/config/config.default.php index 233175b8..89e424d9 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -423,7 +423,10 @@ return [ 'X-Content-Type-Options' => 'nosniff', 'X-Frame-Options' => 'sameorigin', 'Referrer-Policy' => 'strict-origin-when-cross-origin', - 'Content-Security-Policy' => 'default-src \'self\' \'unsafe-inline\' \'unsafe-eval\'; img-src \'self\' data:;', + 'Content-Security-Policy' => + 'default-src \'self\'; ' + . ' style-src \'self\' \'unsafe-inline\'; ' + . 'img-src \'self\' data:;', 'X-XSS-Protection' => '1; mode=block', 'Feature-Policy' => 'autoplay \'none\'', //'Strict-Transport-Security' => 'max-age=7776000', diff --git a/resources/assets/js/design.js b/resources/assets/js/design.js new file mode 100644 index 00000000..f6dc09a3 --- /dev/null +++ b/resources/assets/js/design.js @@ -0,0 +1,13 @@ +import { ready } from './ready'; + +ready(() => { + [...document.getElementsByClassName('prevent-default')].forEach((element) => { + let preventDefault = (e) => { + e.preventDefault(); + return false; + }; + + element.addEventListener('submit', preventDefault); + element.addEventListener('click', preventDefault); + }); +}); diff --git a/resources/assets/js/vendor.js b/resources/assets/js/vendor.js index 38ae6b4e..ef30ac17 100644 --- a/resources/assets/js/vendor.js +++ b/resources/assets/js/vendor.js @@ -3,3 +3,4 @@ window.bootstrap = require('bootstrap'); import './forms'; import './countdown'; import './dashboard'; +import './design'; diff --git a/resources/views/pages/design.twig b/resources/views/pages/design.twig index 62abd39d..b7bb816d 100644 --- a/resources/views/pages/design.twig +++ b/resources/views/pages/design.twig @@ -19,7 +19,7 @@ {% set types_buttons=['link']|merge(types) %} {% set shortsum='Lorem ipsum dolor…' %} {% set lipsum='Lorem ipsum dolor sit amet, consectetur adipisici elit…' %} -{% set linksum='Lorem ipsum! Dolor link amet, consectetur adipisici elit!' %} +{% set linksum='Lorem ipsum! Dolor link amet, consectetur adipisici elit!' %} {% block content %}
@@ -94,13 +94,13 @@

Navigation Tabs

@@ -108,13 +108,13 @@

Navigation Pills

@@ -250,7 +250,7 @@

{{ type|capitalize }}

{{ shortsum }}

-

Some link

+

Some link

@@ -594,12 +594,4 @@ Por scientie, musica, sport etc, litot Europa usa li sam vocabular. {{ bar_chart | raw }} - {% endblock %}