-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Github Action
committed
Feb 23, 2024
1 parent
975b109
commit e86e172
Showing
5 changed files
with
206 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Open: time (via embed code)</title> | ||
<link rel="stylesheet" href="//embed.typeform.com/next/css/sidetab.css" /> | ||
</head> | ||
<body> | ||
<h1> | ||
This sidetab opens in <span id="seconds">5</span> seconds (via embed code) | ||
</h1> | ||
<p>The sidetab is opened automatically after the given time has passed.</p> | ||
<p> | ||
If the user closes the sidetab and then refreshes, it will not reopen the | ||
Typeform. | ||
</p> | ||
|
||
<a | ||
id="sidetab" | ||
class="typeform-share" | ||
data-tf-sidetab="HLjqXS5W" | ||
data-tf-medium="unit-test" | ||
data-tf-open="time" | ||
data-tf-open-value="5000" | ||
data-tf-prevent-reopen-on-close | ||
> | ||
</a> | ||
|
||
<p> | ||
<button id="reset-cookie"> | ||
Reset cookie to reopen Typeform automatically | ||
</button> | ||
</p> | ||
|
||
<p> | ||
<button id="refresh">Refresh page</button> | ||
</p> | ||
|
||
<h2>Customize the time</h2> | ||
<p>This can be set on "Share" page as well.</p> | ||
<form action="" method="get"> | ||
<label for="time">Milliseconds</label> | ||
<input | ||
id="time" | ||
name="ms" | ||
type="number" | ||
value="5000" | ||
step="1000" | ||
min="1000" | ||
/> | ||
<button type="submit">Set</button> | ||
</form> | ||
|
||
<script> | ||
const ms = parseInt( | ||
new URL(window.location.href).searchParams.get('ms'), | ||
10 | ||
) | ||
if (ms) { | ||
document.getElementById('sidetab').dataset.tfOpenValue = ms | ||
document.getElementById('time').value = ms | ||
document.getElementById('seconds').innerHTML = Math.round(ms / 1000) | ||
} | ||
|
||
document.getElementById('reset-cookie').addEventListener('click', () => { | ||
document.cookie = 'tf-HLjqXS5W-closed=false;Path=/' | ||
window.location.reload() | ||
}) | ||
|
||
document.getElementById('refresh').addEventListener('click', () => { | ||
window.location.reload() | ||
}) | ||
</script> | ||
|
||
<script src="//embed.typeform.com/next/embed.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "prevent-reopen-on-close-html", | ||
"license": "MIT", | ||
"description": "Embed SDK Demo - prevent-reopen-on-close-html", | ||
"version": "1.0.0", | ||
"main": "index.html", | ||
"scripts": { | ||
"start": "parcel index.html --open", | ||
"build": "parcel build index.html" | ||
}, | ||
"dependencies": { | ||
"parcel-bundler": "^1.6.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.2.0" | ||
}, | ||
"resolutions": { | ||
"@babel/preset-env": "7.13.8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Open: time (via API)</title> | ||
<link rel="stylesheet" href="//embed.typeform.com/next/css/sidetab.css" /> | ||
</head> | ||
<body> | ||
<h1>This sidetab opens in <span id="seconds">5</span> seconds (via API)</h1> | ||
<p>The sidetab is opened automatically after the given time has passed.</p> | ||
<p> | ||
If the user closes the sidetab and then refreshes, it will not reopen the | ||
Typeform. | ||
</p> | ||
|
||
<p> | ||
<button id="reset-cookie"> | ||
Reset cookie to reopen Typeform automatically | ||
</button> | ||
</p> | ||
|
||
<p> | ||
<button id="refresh">Refresh page</button> | ||
</p> | ||
|
||
<h2>Customize the time</h2> | ||
<p>This can be set on "Share" page as well.</p> | ||
<form action="" method="get"> | ||
<label for="time">Milliseconds</label> | ||
<input | ||
id="time" | ||
name="ms" | ||
type="number" | ||
value="5000" | ||
step="1000" | ||
min="1000" | ||
/> | ||
<button type="submit">Set</button> | ||
</form> | ||
|
||
<script src="//embed.typeform.com/next/embed.js"></script> | ||
<script> | ||
const ms = | ||
parseInt(new URL(window.location.href).searchParams.get('ms'), 10) || | ||
document.getElementById('time').value | ||
|
||
if (ms) { | ||
document.getElementById('time').value = ms | ||
document.getElementById('seconds').innerHTML = Math.round(ms / 1000) | ||
document.getElementById('seconds').innerHTML = Math.round(ms / 1000) | ||
} | ||
window.tf.createSidetab('HLjqXS5W', { | ||
open: 'time', | ||
openValue: ms, | ||
preventReopenOnClose: true, | ||
}) | ||
|
||
document.getElementById('reset-cookie').addEventListener('click', () => { | ||
document.cookie = 'tf-HLjqXS5W-closed=false;Path=/' | ||
window.location.reload() | ||
}) | ||
|
||
document.getElementById('refresh').addEventListener('click', () => { | ||
window.location.reload() | ||
}) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "prevent-reopen-on-close-js", | ||
"license": "MIT", | ||
"description": "Embed SDK Demo - prevent-reopen-on-close-js", | ||
"version": "1.0.0", | ||
"main": "index.html", | ||
"scripts": { | ||
"start": "parcel index.html --open", | ||
"build": "parcel build index.html" | ||
}, | ||
"dependencies": { | ||
"parcel-bundler": "^1.6.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.2.0" | ||
}, | ||
"resolutions": { | ||
"@babel/preset-env": "7.13.8" | ||
} | ||
} |