4
0
Fork 0
PresentazioneEtherpadEtherc.../static/js/slides.js

165 lines
4.2 KiB
JavaScript
Raw Normal View History

2016-02-29 19:31:32 +01:00
function isPreview() {
2017-03-02 01:10:27 +01:00
return !!window.location.search.match(/preview/gi);
2016-02-29 19:31:32 +01:00
}
function initializeReveal() {
2017-03-02 01:10:27 +01:00
// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
2017-03-03 04:16:37 +01:00
2017-03-02 01:10:27 +01:00
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
transitionSpeed: isPreview() ? 'fast' : 'default',
embedded: isPreview() ? true : false,
// Optional reveal.js plugins
dependencies: [{
2018-03-06 02:23:12 +01:00
src: '/static/reveal.js/lib/js/classList.js',
condition: function () {
return !document.body.classList;
2017-03-02 01:10:27 +01:00
}
2018-03-06 02:23:12 +01:00
},
// Interpret Markdown in <section> elements
{
src: '/static/reveal.js/plugin/markdown/marked.js',
condition: function () {
return !!document.querySelector('[data-markdown]');
}
}, {
src: '/static/reveal.js/plugin/markdown/markdown.js',
condition: function () {
return !!document.querySelector('[data-markdown]');
}
},
// Syntax highlight for <code> elements
{
src: '/static/reveal.js/plugin/highlight/highlight.js',
async: true,
callback: function () {
hljs.initHighlightingOnLoad();
}
},
// Zoom in and out with Alt+click
{
src: '/static/reveal.js/plugin/zoom-js/zoom.js',
async: true
},
// Speaker notes
{
src: '/static/reveal.js/plugin/notes/notes.js',
async: true
},
// MathJax
{
src: '/static/reveal.js/plugin/math/math.js',
async: true
},
{
src: '/static/reveal.js/lib/js/classList.js',
condition: function () {
return !document.body.classList;
}
}
2017-03-02 01:10:27 +01:00
]
});
2017-03-03 04:16:37 +01:00
themesCtrl();
2016-02-29 19:31:32 +01:00
}
function highlightAnyCodeBlocks() {
2018-03-06 02:23:12 +01:00
$(document).ready(function () {
$('pre code').each(function (i, block) {
2017-03-02 01:10:27 +01:00
hljs.highlightBlock(block);
});
2016-02-29 19:31:32 +01:00
});
}
function insertMarkdownReference() {
2017-03-02 01:10:27 +01:00
var markdownReference = $('<section/>', {
'data-markdown': "/slides.md",
2018-02-18 01:07:30 +01:00
'data-separator': "^---\n",
'data-separator-vertical': "^--\n",
2017-03-02 01:10:27 +01:00
'data-separator-notes': "^Note:",
'data-charset': "utf-8"
});
$('.slides').html(markdownReference);
2016-02-29 19:31:32 +01:00
}
function scrollToCurrentSlide() {
2017-03-02 01:10:27 +01:00
var i = Reveal.getIndices();
Reveal.slide(i.h, i.v, i.f);
2016-02-29 19:31:32 +01:00
}
function reloadMarkdown() {
2017-03-02 01:10:27 +01:00
insertMarkdownReference();
RevealMarkdown.initialize();
highlightAnyCodeBlocks();
scrollToCurrentSlide();
2016-02-29 19:31:32 +01:00
}
function externalLinksInNewWindow() {
2018-03-06 02:23:12 +01:00
$(document.links).filter(function () {
2017-03-02 01:10:27 +01:00
return this.hostname != window.location.hostname;
}).attr('target', '_blank');
2016-02-29 19:31:32 +01:00
}
insertMarkdownReference();
initializeReveal();
2017-03-03 04:16:37 +01:00
function themesCtrl() {
var defaultTheme = "black.css",
currentTheme = localStorage.getItem('theme?') ||
2018-03-06 02:23:12 +01:00
defaultTheme;
2017-03-03 04:16:37 +01:00
function setTheme(theme) {
cssEl = $("#theme");
cssEl.attr("href", "/static/reveal.js/css/theme/" + theme);
localStorage.setItem('theme?', theme);
}
setTheme(currentTheme);
if (!isPreview()) {
return
}
var availableThemes = [
"black.css",
"beige.css",
"blood.css",
"league.css",
"moon.css",
"night.css",
"serif.css",
"simple.css",
"sky.css",
"solarized.css",
"white.css",
];
themeEl = $("#themes");
2018-03-06 02:23:12 +01:00
availableThemes.forEach(function (theme) {
2017-03-03 04:16:37 +01:00
elem = $("<option value=" + theme + ">" + theme + "</option>");
themeEl.append(elem);
})
themeEl.val(currentTheme);
2018-03-06 02:23:12 +01:00
themeEl.change(function () {
2017-03-03 04:16:37 +01:00
val = themeEl.val()
setTheme(val);
});
themeEl.attr("hidden", false);
}
2016-02-29 19:31:32 +01:00
// Monkey patch Reveal so we can reload markdown through an
// inter window message (using the reveal rpc api)
// (yes, reveal has an rpc api!)
// see save.js
Reveal.reloadMarkdown = reloadMarkdown;