1
Fork 0

Move JS from a tag into a file

This commit is contained in:
Jake Howard 2020-04-25 15:40:08 +01:00
parent 2e39767860
commit 48cfaf8025
Signed by: jake
GPG key ID: 57AFB45680EDD477
7 changed files with 7630 additions and 464 deletions

11
.eslintrc Normal file
View file

@ -0,0 +1,11 @@
{
"extends": [
"dabapps/commonjs",
"dabapps/browser",
"dabapps/es",
"plugin:prettier/recommended"
],
"globals": {
"M": true
}
}

8025
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -11,6 +11,10 @@
"dependencies": {
"@fortawesome/fontawesome-free": "5.13.0",
"materialize-css": "1.0.0",
"node-sass": "4.14.0"
"parcel-bundler": "1.12.4",
"sass": "1.26.5"
},
"devDependencies": {
"eslint-config-dabapps": "6.0.4"
}
}

View file

@ -8,7 +8,10 @@ rm -rf static/build
mkdir -p static/build/css static/build/js
node-sass --include-path node_modules/ -q static/src/scss/index.scss static/build/css/index.css
parcel build --no-autoinstall --no-source-maps -d static/build/js static/src/js/index.js
# Separate step because parcel process images itself, and breaks them
sass -I node_modules/ -s compressed --no-source-map static/src/scss/index.scss static/build/css/index.css
# Install materialize CSS
cp node_modules/materialize-css/dist/js/materialize.min.js static/build/js/materialize.min.js

View file

@ -2,7 +2,7 @@
set -e
export PATH=env/bin:${PATH}
export PATH=env/bin:node_modules/.bin:${PATH}
coverage run --source=website manage.py test $@
@ -20,3 +20,7 @@ isort -rc -c website/
echo "> Running type checker..."
mypy website/
echo "> Running eslint..."
eslint static/src/js

3
static/src/js/index.js Normal file
View file

@ -0,0 +1,3 @@
document.addEventListener("DOMContentLoaded", function() {
M.Sidenav.init(document.querySelectorAll(".sidenav"), {});
});

View file

@ -51,13 +51,7 @@
</footer>
<script type="text/javascript" src="{% static 'js/materialize.min.js' %}"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.sidenav');
var instances = M.Sidenav.init(elems, {});
});
</script>
<script type="text/javascript" src="{% static 'js/index.js' %}"></script>
{% block extrascripts %}{% endblock %}
</body>