Skip to content

Commit

Permalink
embed script
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienheureux committed Dec 11, 2024
1 parent 21d7165 commit 3b145a3
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 15 deletions.
3 changes: 2 additions & 1 deletion qfdmd/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from typing import Any

from django.conf import settings
from django.http import HttpResponse
from django.shortcuts import render
from django.views.generic import DetailView, ListView
Expand All @@ -14,7 +15,7 @@
def generate_iframe_script() -> str:
return (
'<script id="quefairedemesdechets" '
'src="https://quefairedemesdechets.ademe.fr/iframe.js" '
f'src="{settings.BASE_URL}/iframe.js">'
"</script>"
)

Expand Down
9 changes: 3 additions & 6 deletions static/to_compile/entrypoints/assistant/script-to-iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ import { iframeResize } from "iframe-resizer";
window.addEventListener("DOMContentLoaded", () => {
const script = document.getElementById("quefairedemesdechets");
const search = script?.dataset?.search;
const source = window.location.href.toString();

const src = `http://localhost:8000/dechet${
search || "?"
}&iframe=1&source=${source}`;

const origin = new URL(script?.getAttribute("src")).origin
const src = `${origin}/dechet/?iframe`;
const iframe = document.createElement("iframe");

const iframeAttributes = {
Expand All @@ -21,6 +17,7 @@ window.addEventListener("DOMContentLoaded", () => {
for (var key in iframeAttributes) {
iframe.setAttribute(key, iframeAttributes[key]);
}

iframeResize({}, iframe);

script.parentNode.insertBefore(iframe, script);
Expand Down
5 changes: 3 additions & 2 deletions templates/components/sidebar/action.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{% block modal_wrapper_for_id %}
<button
class=""
{# The rounded-full here need to match the one of the icon #}
class="qf-p-0 lg:qf-rounded-l-full"
data-fr-opened="false"
aria-controls="fr-modal-{{ id }}"
aria-labelled-by="sidebar-action-{{ id }}"
>
<span class="
lg:qf-rounded-l-full lg:qf-py-2w lg:qf-pl-2w
lg:qf-rounded-l-full lg:qf-py-2w lg:qf-pl-2w lg:qf-pr-1w
hover:!qf-bg-green-menthe-850-active qf-bg-green-menthe-850-hover
qf-flex qf-items-center qf-justify-center
max-lg:qf-aspect-square max-lg:qf-p-3v max-lg:qf-scale-75 max-lg:qf-rounded-full
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "../action.html" %}

{% block icon %}
{% include "./_icon.html" %}
{% include "./icon.html" %}
{% endblock icon %}

{% block button_text %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "../action.html" %}

{% block icon %}
{% include "./_icon.html" %}
{% include "./icon.html" %}
{% endblock icon %}

{% block button_text %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "../action.html" %}

{% block icon %}
{% include "./_icon.html" %}
{% include "./icon.html" %}
{% endblock icon %}

{% block button_text %}
Expand Down
6 changes: 3 additions & 3 deletions templates/components/sidebar/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
class="qf-flex lg:qf-flex-col qf-gap-3w
qf-flex-row max-lg:qf-justify-between"
>
{% include "./embed/_action.html" %}
{% include "./share/_action.html" %}
{% include "./email/_action.html" %}
{% include "./embed/action.html" %}
{% include "./share/action.html" %}
{% include "./email/action.html" %}
</nav>
</aside>

0 comments on commit 3b145a3

Please sign in to comment.