From f3a2f21fb302e6af52f6f613ff68404c8aa16a80 Mon Sep 17 00:00:00 2001 From: Fred Chasen Date: Wed, 30 Aug 2017 08:47:20 -0400 Subject: [PATCH] Updated hypothes.is examples --- examples/hypothesis-spreads.html | 42 +++++++++++++++++++++++++------- examples/hypothesis.html | 2 +- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/examples/hypothesis-spreads.html b/examples/hypothesis-spreads.html index 67c9376..4286eaf 100644 --- a/examples/hypothesis-spreads.html +++ b/examples/hypothesis-spreads.html @@ -31,6 +31,7 @@ }; }; + @@ -193,6 +194,22 @@ cursor: pointer; } + #viewer.spreads { + width: 84vw; + height: 80vh; + box-shadow: 0 0 4px #ccc; + border-radius: 5px; + padding: 0; + position: relative; + margin: 10vh auto; + background: white; + top: 0; + } + + #hiddenTitle { + display: none; + } + @@ -201,6 +218,7 @@ menu
+ @@ -223,11 +241,11 @@ var url = params && params.get("url") && decodeURIComponent(params.get("url")); // Load the opf - var book = ePub(url || window.location.protocol + "//s3.amazonaws.com/epubjs/books/alice/OPS/package.opf"); + var book = ePub(url || window.location.protocol + "//s3.amazonaws.com/epubjs.org/books/moby-dick-hypothesis-demo.epub"); var rendition = book.renderTo("viewer", { ignoreClass: "annotator-hl", width: "100%", - height: 600 + height: "100%" }); // var hash = window.location.hash.slice(2); @@ -237,13 +255,7 @@ var hash = decodeURIComponent(href); } - rendition.display(hash || undefined) - .then(function() { - var H_EMBED_URL = 'https://hypothes.is/embed.js'; - var script = document.createElement('script'); - script.setAttribute('src', H_EMBED_URL); - document.head.appendChild(script); - }); + rendition.display(hash || undefined); var next = document.getElementById("next"); @@ -269,8 +281,20 @@ nav.classList.remove("open"); }, false); + // Hidden + var hiddenTitle = document.getElementById("hiddenTitle"); rendition.on("rendered", function(section){ + var current = book.navigation && book.navigation.get(section.href); + + if (current) { + document.title = current.label; + + // TODO: this is needed to trigger the hypothesis client + // to inject into the iframe + hiddenTitle.textContent = current.label; + } + var old = document.querySelectorAll('.active'); Array.prototype.slice.call(old, 0).forEach(function (link) { link.classList.remove("active"); diff --git a/examples/hypothesis.html b/examples/hypothesis.html index 562db28..573dfab 100644 --- a/examples/hypothesis.html +++ b/examples/hypothesis.html @@ -196,7 +196,7 @@ var url = params && params.get("url") && decodeURIComponent(params.get("url")); // Load the opf - var book = ePub(url || window.location.protocol + "//s3.amazonaws.com/epubjs/books/alice/OPS/package.opf"); + var book = ePub(url || window.location.protocol + "//s3.amazonaws.com/epubjs.org/books/moby-dick-hypothesis-demo.epub"); var rendition = book.renderTo("viewer", { flow: "scrolled-doc", ignoreClass: "annotator-hl"