From 35e5545e157d755a4647c7033588d5ae35dda4cc Mon Sep 17 00:00:00 2001 From: shu zOMG chen Date: Thu, 9 Nov 2017 20:35:17 -0800 Subject: [PATCH] Add ability to specify custom link in modal footer --- README.md | 8 ++++++++ src/iframe/iframe.html | 2 +- src/iframe/js/script.js | 14 ++++++++++++++ src/widget.js | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e652d02..1e971ac 100755 --- a/README.md +++ b/README.md @@ -106,6 +106,14 @@ you can pass some properties in to customize the default behavior. * Prevents the widget iframe from loading Google Analytics. Defaults to false. */ disableGoogleAnalytics: false, // @type {boolean} + + /* + * To add a custom link to the modal footer. + */ + custom_disclaimer_link: { + text: 'Link text', // @type {string} link text + href: 'http://battleforthenet.com/' // @type {string} link href attribute + }, /* * Always show the widget. Useful for testing. diff --git a/src/iframe/iframe.html b/src/iframe/iframe.html index b1bac80..35f18ce 100755 --- a/src/iframe/iframe.html +++ b/src/iframe/iframe.html @@ -58,7 +58,7 @@

-
+

We will only use your phone number to connect this call. Privacy policy. Get the code. Not in the US? .

diff --git a/src/iframe/js/script.js b/src/iframe/js/script.js index f9b27fd..e0c135b 100755 --- a/src/iframe/js/script.js +++ b/src/iframe/js/script.js @@ -101,6 +101,17 @@ return themeObj; } + function addCustomDisclaimerLink(link) { + var p = document.createElement('p'); + var a = document.createElement('a'); + a.setAttribute('href', link.href); + a.setAttribute('target', '_blank'); + a.textContent = link.text; + p.appendChild(a); + + document.getElementById("disclaimer").appendChild(p); + } + function renderContent(theme) { document.body.classList.add(theme.className); @@ -192,6 +203,9 @@ } renderContent.call(this, getTheme(this.options.theme)); + if (this.options.custom_disclaimer_link) { + addCustomDisclaimerLink(this.options.custom_disclaimer_link); + } var org = getOrg(this.options.org); var donateLinks = document.querySelectorAll('a.donate'); diff --git a/src/widget.js b/src/widget.js index 68d369e..9d19fe2 100644 --- a/src/widget.js +++ b/src/widget.js @@ -5,6 +5,7 @@ if (typeof _bftn_options.delay == "undefined") _bftn_options.delay = 1000; if (typeof _bftn_options.debug == "undefined") _bftn_options.debug = false; if (typeof _bftn_options.date == "undefined") _bftn_options.date = new Date(2017, 10 /* Zero-based month */, 23); + if (typeof _bftn_options.custom_disclaimer_link == "undefined") _bftn_options.custom_disclaimer_link = null; if (typeof _bftn_options.viewCookieExpires == "undefined") _bftn_options.viewCookieExpires = 1; if (typeof _bftn_options.actionCookieExpires == "undefined") _bftn_options.actionCookieExpires = 7; if (typeof _bftn_options.always_show_widget == "undefined") _bftn_options.always_show_widget = false;