Jump to content

PrivacyWire - Cookie Management & async external asset loading


joshua

Recommended Posts

I put the styles for it in the head section of my html/_main.php manual in a <style>-tag. For example:

<style>
	/* Cookie Banner */
	.show-banner>.privacywire-page-wrapper,
	.show-options>.privacywire-page-wrapper,
	.show-message>.privacywire-page-wrapper {
		position: fixed;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.6);
		backdrop-filter: blur(5px);
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.privacywire {
		display: none;
	}

	.show-banner .privacywire.privacywire-banner,
	.show-options .privacywire.privacywire-options,
	.show-message .privacywire.privacywire-message {
		display: block;
		position: relative;
		left: auto;
		right: auto;
		bottom: auto;
		max-width: 850px;
		padding: 2rem;
		color: #000;
		background-color: #fff;
	}

	.privacywire-page-wrapper input {
		margin-right: 0.5rem;
	}

	.privacywire-page-links {
		margin-top: 1rem;
	}

	.privacywire-buttons button,
	.privacywire-page-links a {
		margin: 0.5rem 0.5rem 0.5rem 0;
	}

	@media screen and (min-width: 992px) {

		.privacywire-buttons button,
		.privacywire-page-links a {
			margin: 0.5rem;
		}

		/* Don't give the first button margin-left */
		.privacywire-buttons button:first-child,
		.privacywire-page-links a:first-child {
			margin-left: 0;
		}
	}
</style>

So it loaded as first. That resolved it for my sites. (Also with fixed/relative notation)

  • Like 4
Link to comment
Share on other sites

  • 3 weeks later...

Hi @joshua,

I am getting the following error while trying to implement cookie consent for a Youtube iFrame:

Uncaught TypeError: "text/javascript".poster is undefined

What am I doing wrong? I tried both Ryan's TextFormatterVideoEmbed and manually adding all the attributes. All works fine but the src of the iframe is never resolved which I guess is due to the error above.

Any help is appreciated

thanks

 

Edit:
I am pretty sure this is caused by an error/missing semicolon in the PrivacyWire JS. Not sure how this works for anyone??

 

Link to comment
Share on other sites

  On 3/20/2025 at 8:11 AM, thomas said:

Hi @joshua,

I am getting the following error while trying to implement cookie consent for a Youtube iFrame:

Uncaught TypeError: "text/javascript".poster is undefined

Edit:
I am pretty sure this is caused by an error/missing semicolon in the PrivacyWire JS. Not sure how this works for anyone??

 

Expand  

@thomas had the same error. AI told me to change this:
 

updateAllowedElementOther(e) {
    const {
        dataset: t
    } = e;
    (e.type =
        t.type ??
        "text/javascript".poster.forEach((s) => {
            void 0 !== t[s] && (e[s] = t[s]);
        })),
    this.removeUnusedAttributesFromElement(e);
}

to this

updateAllowedElementOther(e) {
    const {
        dataset: t
    } = e;
    e.type = t.type ?? "text/javascript";
    ["src", "async", "defer"].forEach((s) => {
        if (t[s] !== undefined) e[s] = t[s];
    });
    this.removeUnusedAttributesFromElement(e);
}

It's working now. But I'm sure it's not the correct way and @joshua knows how deal with this problem and will update the code!

Link to comment
Share on other sites

  On 3/25/2025 at 11:41 AM, ngrmm said:

It's working now. But I'm sure it's not the correct way and @joshua knows how deal with this problem and will update the code!

Expand  

Thanks! I changed it to this and added the Javascript src to my package. Works fine but isn't really the proper way to use a ProcessWire Module I suppose. Let's hope @joshua fixes this 🙂

	updateAllowedElementOther(el) {
		const { dataset } = el;
		el.type = dataset.type ?? "text/javascript";
		["src", "srcset", "srcdoc", "poster"].forEach((k) => {
			if (dataset[k] !== undefined) {
				el[k] = dataset[k];
			}
		});
		this.removeUnusedAttributesFromElement(el);
	}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...