Skip to content

Commit

Permalink
Commit 56
Browse files Browse the repository at this point in the history
  • Loading branch information
madmurphy committed Oct 7, 2022
1 parent ab9b04c commit ec1c278
Show file tree
Hide file tree
Showing 19 changed files with 495 additions and 56 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Change Log


## 3.1.5 (2022-10-07)

Changes:

* Documentation


## 3.1.4 (2022-08-06)

Changes:
Expand Down
1 change: 1 addition & 0 deletions dev/js-add-ons
2 changes: 1 addition & 1 deletion dev/takefive-dev.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
|*|
|*| https://github.com/madmurphy/takefive.css/
|*|
|*| Version 3.1.4
|*| Version 3.1.5
|*|
|*| (c) [email protected]
|*|
Expand Down
17 changes: 17 additions & 0 deletions dist/js-add-ons/takefive-clean-empty-hash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
window.addEventListener("DOMContentLoaded", function () {

var aEmptyHashLinks = document.querySelectorAll("a[href$=\"#\"]");

for (var nIdx = 0; nIdx < aEmptyHashLinks.length; nIdx++) {

aEmptyHashLinks[nIdx].addEventListener("click", function (oEvt) {

location.hash = "";
history.replaceState(null, "", this.href.split('#')[0]);
oEvt.preventDefault();

});

}

}, false);
57 changes: 57 additions & 0 deletions dist/js-add-ons/takefive-clean-history.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
(function () {

var bOpenedWithSlide = false, nHistCount = -1;

function newSlideClicked () {

nHistCount--;

}

function exitClicked (oEvt) {

if (bOpenedWithSlide) {

/* The page was loaded with a slide open */
bOpenedWithSlide = false;

} else {

history.go(nHistCount);
oEvt.preventDefault();

}

nHistCount = -1;

}

addEventListener("DOMContentLoaded", function () {

var
elIter,
aLinks = document.querySelectorAll("article.slide a"),
elTest = document.createElement("a");

bOpenedWithSlide = Boolean(document.querySelector("article.slide:target"));
elTest.href = location.href;

for (var nLen = aLinks.length, nIdx = 0; nIdx < nLen; nIdx++) {

elIter = aLinks[nIdx];
elTest.hash = elIter.hash || "#";

if (elTest.href === elIter.href) {
elIter.addEventListener("click",
elIter.hash && document.querySelector("article.slide" + elIter.hash) ?
newSlideClicked
:
exitClicked
);
}

}

}, false);

})();
23 changes: 23 additions & 0 deletions dist/js-add-ons/takefive-keyboard-events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* close the slide currently open or do nothing */
function closeCurrentSlide () {

var oSlide = document.querySelector("article.slide:target");

if (oSlide) {

var oExitLink = oSlide.querySelector("nav:first-of-type a[rel~=\"parent\"]");
location.assign(oExitLink ? oExitLink.href : "#");

}

}

window.addEventListener("keyup", function (oEvt) {

if (oEvt.key === "Escape") {

closeCurrentSlide();

}

}, false);
55 changes: 55 additions & 0 deletions dist/js-add-ons/takefive-touch-events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
(function () {

var nDownX = null, nDownY = null;

function handleTouchStart (oEvt) {

const oFirstTouch = oEvt.touches[0];

nDownX = oFirstTouch.clientX;
nDownY = oFirstTouch.clientY;

};

function handleTouchMove (oEvt) {

if (!nDownX || !nDownY) {

return;

}

var
oLink, sRel = null,
nDiffX = nDownX - oEvt.touches[0].clientX,
nDiffY = nDownY - oEvt.touches[0].clientY;

switch (Math.abs(nDiffX) > Math.abs(nDiffY) ? nDiffX > 0 ? 3 : 2 : nDiffY > 0 ? 1 : 0) {

/* Cases: `0` -> down swipe, `1` -> up swipe, `2` -> right swipe, `3` -> left swipe */
case 2: sRel = "prev"; break; /* Right swipe */
case 3: sRel = "next"; break; /* Left swipe */

}

nDownX = null;
nDownY = null;

sRel && (oLink = this.querySelector("nav:first-of-type a[href][rel~=\"" + sRel + "\"]")) && location.assign(oLink.href);

};

window.addEventListener("DOMContentLoaded", function () {

const aSlides = document.querySelectorAll("article.slide");

for (var nIdx = 0, nLen = aSlides.length; nIdx < nLen; nIdx++) {

aSlides[nIdx].addEventListener('touchstart', handleTouchStart, false);
aSlides[nIdx].addEventListener('touchmove', handleTouchMove, false);

}

}, false);

})();
2 changes: 1 addition & 1 deletion dist/takefive.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
|*|
|*| https://github.com/madmurphy/takefive.css/
|*|
|*| Version 3.1.4
|*| Version 3.1.5
|*|
|*| (c) [email protected]
|*|
Expand Down
4 changes: 2 additions & 2 deletions dist/takefive.min.css

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions docs/css/docs-classes.css
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ table.definition th:first-child {
padding-left: 1em;
}

table.definition.longterms th:first-child {
width: 13em;
}

table.definition th,
table.definition thead th:first-child {
font-weight: bold;
Expand Down Expand Up @@ -881,6 +885,11 @@ mark, .bg0 {
background-color: #87e4ff;
}

.bg2 {
background-color: rgba(255, 93, 0, .1);
}


.resultbox {
box-sizing: border-box;
border: 2px inset;
Expand Down
2 changes: 1 addition & 1 deletion docs/css/docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ mark {
}

figure img, figure object {
box-shadow: 0 8px 8px #000;
box-shadow: 0 3px 3px 0 rgba(0, 0, 0, .6);
}

}
Expand Down
4 changes: 2 additions & 2 deletions docs/css/takefive.min.css

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions docs/js-add-ons.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="css/print.min.css" />
<link rel="stylesheet" type="text/css" href="css/docs.css" />
<link rel="stylesheet" type="text/css" href="css/docs-classes.css" />
<link rel="stylesheet" type="text/css" href="css/takefive.min.css" />
<script type="text/javascript" src="js/takefive-clean-history.js"></script>
<script type="text/javascript" src="js/takefive-keyboard-events.js"></script>
<script type="text/javascript" src="js/takefive-touch-events.js"></script>
<title>Take Five! &ndash; JavaScript Add-Ons</title>
</head>

<body>

<header>
<h1><em>Take Five!</em> &ndash; JavaScript Add-Ons</h1>
</header>
<p>This page includes a few scripts that allow to</p>
<ul>
<li>Clean the browser's history after leaving a presentation (<a href="js/takefive-clean-history.js" target="_blank"><code>js-add-ons/takefive-clean-history.js</code></a>)</li>
<li>Leave a presentation by pressing <code>Esc</code> on the keyboard (<a href="js/takefive-keyboard-events.js" target="_blank"><code>js-add-ons/takefive-keyboard-events.js</code></a>)</li>
<li>Swipe left and right via touch events (<a href="js/takefive-touch-events.js" target="_blank"><code>js-add-ons/takefive-touch-events.js</code></a>)</li>
</ul>
<p>A further script that allows to use an empty hash (<code>#</code>) as the exit link and leave no traces in the address bar is available (<a href="js/takefive-clean-empty-hash.js" target="_blank"><code>js-add-ons/takefive-clean-empty-hash.js</code></a>), however this is alternative to <a href="js/takefive-clean-history.js" target="_blank"><code>takefive-clean-history.js</code></a> and can be used only when the latter is not used.</p>
<p style="text-align: center; font-size: 2em;"><a href="#example-slide-1">Try them live</a></p>
<article class="slide" id="example-slide-1">
<header>
<h3>Slide 1</h3>
</header>
<figure>
<img src="media/10.jpg" />
<figcaption>Silhouette of tree near body of water during golden hour</figcaption>
</figure>
<nav>
<a href="#" rel="parent">Manual</a>
<a href="#example-slide-2" rel="next">Close up of leaf</a>
<a href="#example-slide-4" rel="last">Gray asphalt road surrounded by tall trees</a>
<a href="media/10.jpg" download rel="attachment" target="_blank">Download this picture</a>
</nav>
</article>
<article class="slide" id="example-slide-2">
<header>
<h3>Slide 2</h3>
</header>
<figure>
<img src="media/11.jpg" />
<figcaption>Close up of leaf</figcaption>
</figure>
<nav>
<a href="#" rel="parent">Manual</a>
<a href="#example-slide-1" rel="prev first">Silhouette of tree near body of water during golden hour</a>
<a href="#example-slide-3" rel="next">Green hill near body of water</a>
<a href="#example-slide-4" rel="last">Gray asphalt road surrounded by tall trees</a>
<a href="media/11.jpg" download rel="attachment" target="_blank">Download this picture</a>
</nav>
</article>
<article class="slide" id="example-slide-3">
<header>
<h3>Slide 3</h3>
</header>
<figure>
<img src="media/12.jpg" />
<figcaption>Green hill near body of water</figcaption>
</figure>
<nav>
<a href="#" rel="parent">Manual</a>
<a href="#example-slide-2" rel="prev">Close up of leaf</a>
<a href="#example-slide-4" rel="next last">Gray asphalt road surrounded by tall trees</a>
<a href="#example-slide-1" rel="first">Silhouette of tree near body of water during golden hour</a>
<a href="media/12.jpg" download rel="attachment" target="_blank">Download this picture</a>
</nav>
</article>
<article class="slide" id="example-slide-4">
<header>
<h3>Slide 4</h3>
</header>
<figure>
<img src="media/13.jpg" />
<figcaption>Gray asphalt road surrounded by tall trees</figcaption>
</figure>
<nav>
<a href="#" rel="parent">Manual</a>
<a href="#example-slide-3" rel="prev">Green hill near body of water</a>
<a href="#example-slide-1" rel="first">Silhouette of tree near body of water during golden hour</a>
<a href="media/13.jpg" download rel="attachment" target="_blank">Download this picture</a>
</nav>
</article>
<footer>
<h2>Free software</h2>
<p><strong>Take Five!</strong> is free software. You can redistribute it and/or modify it under the terms of the <a href="https://www.gnu.org/licenses/gpl-3.0-standalone.html" target="_blank" rel="noopener">GPL license</a>, version 3 or any later version. The code is <a href="https://github.com/madmurphy/takefive.css/" target="_blank" rel="noopener">available on GitHub</a>.</p>
</footer>

</body>
</html>
17 changes: 17 additions & 0 deletions docs/js/takefive-clean-empty-hash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
window.addEventListener("DOMContentLoaded", function () {

var aEmptyHashLinks = document.querySelectorAll("a[href$=\"#\"]");

for (var nIdx = 0; nIdx < aEmptyHashLinks.length; nIdx++) {

aEmptyHashLinks[nIdx].addEventListener("click", function (oEvt) {

location.hash = "";
history.replaceState(null, "", this.href.split('#')[0]);
oEvt.preventDefault();

});

}

}, false);
57 changes: 57 additions & 0 deletions docs/js/takefive-clean-history.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
(function () {

var bOpenedWithSlide = false, nHistCount = -1;

function newSlideClicked () {

nHistCount--;

}

function exitClicked (oEvt) {

if (bOpenedWithSlide) {

/* The page was loaded with a slide open */
bOpenedWithSlide = false;

} else {

history.go(nHistCount);
oEvt.preventDefault();

}

nHistCount = -1;

}

addEventListener("DOMContentLoaded", function () {

var
elIter,
aLinks = document.querySelectorAll("article.slide a"),
elTest = document.createElement("a");

bOpenedWithSlide = Boolean(document.querySelector("article.slide:target"));
elTest.href = location.href;

for (var nLen = aLinks.length, nIdx = 0; nIdx < nLen; nIdx++) {

elIter = aLinks[nIdx];
elTest.hash = elIter.hash || "#";

if (elTest.href === elIter.href) {
elIter.addEventListener("click",
elIter.hash && document.querySelector("article.slide" + elIter.hash) ?
newSlideClicked
:
exitClicked
);
}

}

}, false);

})();
Loading

0 comments on commit ec1c278

Please sign in to comment.