@proca/widget
Version:
Proca is an open-source campaign toolkit designed to empower activists and organisations in their digital advocacy efforts. It provides a flexible and customisable platform for creating and managing online petitions, email campaigns, and other forms of di
303 lines (268 loc) • 13.9 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="alternate" type="application/json+oembed" href="https://widget.proca.foundation/d/demo/petition/oembed.json" title="Embed JSON">
<meta property="og:image" content="https://placekitten.com/540/284" />
<title><%= campaign %> widget for <%= organisation %></title>
<meta name="twitter:title" content="Demo of <%= campaign %>" />
<meta name="description" content="Sign the initiative with <%= organisation %>!" />
<meta name="twitter:description" content="Sign the initiative with <%= organisation %>" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@eucampaign" />
<meta name="twitter:image" content="%PUBLIC_URL%/logo.png" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<style>
pre {background:#e3e3e3;margin-top:15px;padding:15px;}
aa.dark {background: #343a40}
aa.light {background: "transparent"}
html {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
nope.font-family: "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace;
}
</style>
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
-->
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<minimal-style style="display:none">
.proca-widget, #signature-form {max-width:600px;min-width:300px}
.row{
display: flex;
flex-direction: row;
flex-wrap: wrap;
width:100%;
}
.col{
display: flex;
flex-direction: column;
flex-basis: 100%;
padding:0 10px;
flex:1;
}
pre {background:#dede; padding: 10px}
</minimal-style>
<style>
body {padding-top:5rem;}
</style>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Demo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="dropdown02" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Design of your page</a>
<div class="dropdown-menu columns" aria-labelledby="dropdown02">
<a class="dropdown-item" data-class="col-md" href="#">two equal columns</a>
<a class="dropdown-item" data-class="col-md-4" href="#">large content column</a>
<a class="dropdown-item" disabled>Floating action</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Layout</a>
<div class="dropdown-menu " aria-labelledby="dropdown01">
<a class="dropdown-item theme" data-theme="dark" href="#">Toggle dark/light</a>
<div class="dropdown-divider"></div>
<div class="color">
<a class="dropdown-item" data-color="#2196f3" href="#">Blue</a>
<a class="dropdown-item" data-color="#9c27b0" href="#">Purple</a>
<a class="dropdown-item" data-color="#4caf50">Green</a>
</div>
<div class="dropdown-divider"></div>
<div class="variant">
<a class="dropdown-item" data-variant="filled" href="#">Filled</a>
<a class="dropdown-item" data-variant="outlined" href="#">Outlined</a>
<a class="dropdown-item" data-variant="standard">Standard</a>
</div>
</li>
</ul>
<div class="form-inline my-2 my-lg-0">
<button class="proca-next btn btn-primary" data-toggle="modal" data-target="#code">Widget code</button>
<button class="proca-next btn btn-secondary" onClick="proca.go()">Next</button>
</div>
</div>
</nav>
<noscript
>You need to enable JavaScript to participate to this campaign.</noscript
>
<div id="root" class="container">
<h2>Campaign <%= campaign %></h2>
<div class="proca-widget" id="signature-form" nodata-dialog-title="Want to be informed on our next actions?" nodata-twitter-text="Do the test">
<div class="alert alert-info" role="alert">
<h3> This is an example, but your can test signing </h3>
For a real one, the signature form will be directly embedded into your website, with your design and url.
<br>
<p class="proca-description">
This is the text of the campaign, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
<p class="proca-description">
Lorem ipsum dolor <span class="proca-counter"></span> sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
<div class="row">
<div class="col">
<p class="proca-text [disable]consent_intro">I want to receive the newsletter from {{name}}</p>
<p class="proca-text [disable]sign-now">Do it now!</p>
<p class="proca-text share">I signed <%= campaign %>, you should sign too!</p>
<p class="proca-text share-twitter">I signed #<%=campaign %>, you should too!</p>
<p class="proca-text twitter_actionText">I signed #<%=campaign %>, you should too!</p>
<p class="proca-text email_subject">I signed #<%=campaign %>, you should too!</p>
<p class="proca-text email_body">I signed #<%=campaign %>, you should too!</p>
<p class="proca-text [remove]-share-whatsapp">Hi, sign that!</p>
<p class="proca-text [disable]ddd-consent-into"></p>
<h2>How to embed this into your website?</h2>
<p>
You simply need to copy paste in your website editor, for instance wordpress. The specific instructions depends of your website, check with your webmaster or search how to add "raw html" + your CMS.
</p>
<div class="row">
<div class="col">
<h4>Just the action tool</h4>
This is the most flexible solution, you can have a full width form, or manage your layout exactly the way your want.
<pre class="dynamic">
<script id="proca" src="https://%widget_path%"></script>
<div class="proca-widget">
</div>
<p class="proca-text share">I signed <%= campaign %>, you should sign too!</p>
<p class="proca-text share-twitter">I signed #<%=campaign %>, you should too!</p>
<p class="proca-text twitter_actionText">I signed #<%=campaign %>, you should too!</p>
<p class="proca-text email_subject">I signed #<%=campaign %>, you should too!</p>
<p class="proca-text email_body">I signed #<%=campaign %>, you should too!</p>
</pre>
</div>
<div class="col">
<h4>Action tool and campaign text (two columns)</h4>
If you want a little help and have something in two columns (like the example above), it's almost the same, but you put the text you want on the left hand column as the content of the widget
<pre class="dynamic">
<script id="proca" src="https://%widget_path%"></script>
<div class="proca-widget">
<div class="proca-description"></div>
Put here the title and text of the campaign
</div>
</pre>
</div>
</div>
<p><i>You can put the first line wherever you want, the other lines has to be where you want the form to be displayed</i></p>
<div>
◦<p>
Please do <b>NOT</b> test the widget on a live page – we don’t want people trying to sign before we go live!
<br>
you can see an example of the widget and the steps above.
</div>
</div>
</div>
</div>
</div>
<div class="modal" id="code" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">How to add the widget on your site?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<h4>Any page (Javascript)</h4>
<pre class="dynamic">
<script id="proca" src="https://%widget_path%"></script>
<div class="proca-widget"></div>
</pre>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">Save changes</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script>
var params = {};
function loader () {
proca.hook("twitter","load", function(list){
list[0].description ="bozo";
console.log(list);
});
proca.set("geolocate",true);
console.log("loaded");
proca.go(); // continue to the next step
}
function display() {
var variants = ["standard", "filled", "outlined"];
var urlParams = new URLSearchParams(window.location.search);
var widget_path = window.location.hostname + window.location.pathname.replace("/index.html","");
var widget_shortcode = window.location.pathname.replace("/index.html","").replace("/d/","");
for (let d of document.getElementsByClassName("dynamic")) {
d.innerHTML = d.innerHTML.replace("%widget_path%",widget_path);
d.innerHTML = d.innerHTML.replace("%widget_shortcode%",widget_shortcode);
}
// if (urlParams.get("variant")) {
// params.variant = urlParams.get("variant");
// }
if (urlParams.get("actionPage"))
params.actionPage= urlParams.get("actionPage");
// params.loader = urlParams.get("proca_loader");
proca.Widget(params);
}
if (typeof proca === "object") {
//not used on dev
display();
} else {
console.log("DEV MODE");
window.addEventListener("DOMContentLoaded", function() {
display();
});
}
</script>
<script>
function procaReady () {
console.log("ready");
}
jQuery(function($) {
$('.columns a').click(function() {
$('#action_column').removeClass().addClass($(this).data('class'));
window.dispatchEvent(new Event('resize'));
});
$('.color a').click(function() {
proca.set("layout","primaryColor",$(this).data('color')); });
$('.variant a').click(function() {
proca.set("layout","variant",$(this).data('variant'));
});
$('a.theme').click(function() {
var theme=$(this).data('theme');
$("#signature-form").removeClass().addClass("bg-"+theme);
proca.set("layout","theme",theme);
$(this).data('theme', theme === "light"? "dark":"light");
});
});
</script>
</body>
</html>