Skip to content
This repository was archived by the owner on Oct 18, 2022. It is now read-only.

Commit 35e5545

Browse files
committed
Add ability to specify custom link in modal footer
1 parent 7fc3aeb commit 35e5545

4 files changed

Lines changed: 24 additions & 1 deletion

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ you can pass some properties in to customize the default behavior.
106106
* Prevents the widget iframe from loading Google Analytics. Defaults to false.
107107
*/
108108
disableGoogleAnalytics: false, // @type {boolean}
109+
110+
/*
111+
* To add a custom link to the modal footer.
112+
*/
113+
custom_disclaimer_link: {
114+
text: 'Link text', // @type {string} link text
115+
href: 'http://battleforthenet.com/' // @type {string} link href attribute
116+
},
109117
110118
/*
111119
* Always show the widget. Useful for testing.

src/iframe/iframe.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ <h1 id="headline"></h1>
5858
</button>
5959
</form>
6060

61-
<div class="disclaimer">
61+
<div id="disclaimer" class="disclaimer">
6262
<p>We will only use your phone number to connect this call. <a href="https://www.battleforthenet.com/privacy/" target="_blank">Privacy policy</a>. <a href="https://github.com/fightforthefuture/battleforthenet-widget#how-to-install-the-widget" target="_blank">Get the code</a>. Not in the US? <a class="donate" href="https://donate.fightforthefuture.org/" target="_blank">Donate</a>.</p>
6363
</div>
6464
</section>

src/iframe/js/script.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@
101101
return themeObj;
102102
}
103103

104+
function addCustomDisclaimerLink(link) {
105+
var p = document.createElement('p');
106+
var a = document.createElement('a');
107+
a.setAttribute('href', link.href);
108+
a.setAttribute('target', '_blank');
109+
a.textContent = link.text;
110+
p.appendChild(a);
111+
112+
document.getElementById("disclaimer").appendChild(p);
113+
}
114+
104115
function renderContent(theme) {
105116
document.body.classList.add(theme.className);
106117

@@ -192,6 +203,9 @@
192203
}
193204

194205
renderContent.call(this, getTheme(this.options.theme));
206+
if (this.options.custom_disclaimer_link) {
207+
addCustomDisclaimerLink(this.options.custom_disclaimer_link);
208+
}
195209

196210
var org = getOrg(this.options.org);
197211
var donateLinks = document.querySelectorAll('a.donate');

src/widget.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
if (typeof _bftn_options.delay == "undefined") _bftn_options.delay = 1000;
66
if (typeof _bftn_options.debug == "undefined") _bftn_options.debug = false;
77
if (typeof _bftn_options.date == "undefined") _bftn_options.date = new Date(2017, 10 /* Zero-based month */, 23);
8+
if (typeof _bftn_options.custom_disclaimer_link == "undefined") _bftn_options.custom_disclaimer_link = null;
89
if (typeof _bftn_options.viewCookieExpires == "undefined") _bftn_options.viewCookieExpires = 1;
910
if (typeof _bftn_options.actionCookieExpires == "undefined") _bftn_options.actionCookieExpires = 7;
1011
if (typeof _bftn_options.always_show_widget == "undefined") _bftn_options.always_show_widget = false;

0 commit comments

Comments
 (0)