Autoformat

This commit is contained in:
Alex Myasoedov 2017-03-01 19:10:27 -05:00
parent e7921d0503
commit 57d3df15ca

View file

@ -1,66 +1,113 @@
function isPreview() { function isPreview() {
return !!window.location.search.match(/preview/gi); return !!window.location.search.match(/preview/gi);
} }
function initializeReveal() { function initializeReveal() {
// Full list of configuration options available at: // Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration // https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({ Reveal.initialize({
controls: true, controls: true,
progress: true, progress: true,
history: true, history: true,
center: true, center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom transition: 'slide', // none/fade/slide/convex/concave/zoom
transitionSpeed: isPreview() ? 'fast' : 'default', transitionSpeed: isPreview() ? 'fast' : 'default',
embedded: isPreview() ? true : false, embedded: isPreview() ? true : false,
// Optional reveal.js plugins // Optional reveal.js plugins
dependencies: [ dependencies: [{
{ src: '/static/revealjs/lib/js/classList.js', condition: function() { return !document.body.classList; } }, src: '/static/reveal.js/lib/js/classList.js',
{ src: '/static/revealjs/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, condition: function() {
{ src: '/static/revealjs/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); }, callback: function() { externalLinksInNewWindow(); } }, return !document.body.classList;
{ src: '/static/revealjs/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, }
{ src: '/static/revealjs/plugin/zoom-js/zoom.js', async: true }, },
{ src: '/static/revealjs/plugin/notes/notes.js', async: true }
] // 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/static/revealjs/lib/js/classList.js',
condition: function() {
return !document.body.classList;
}
}
d
]
});
} }
function highlightAnyCodeBlocks() { function highlightAnyCodeBlocks() {
$(document).ready(function() { $(document).ready(function() {
$('pre code').each(function(i, block) { $('pre code').each(function(i, block) {
hljs.highlightBlock(block); hljs.highlightBlock(block);
});
}); });
});
} }
function insertMarkdownReference() { function insertMarkdownReference() {
var markdownReference = $('<section/>', { var markdownReference = $('<section/>', {
'data-markdown': "/slides.md", 'data-markdown': "/slides.md",
'data-separator': "^-( *)-( *)-( *-*)*", 'data-separator': "^-( *)-( *)-( *-*)*",
'data-separator-notes': "^Note:", 'data-separator-notes': "^Note:",
'data-charset': "utf-8" 'data-charset': "utf-8"
}); });
$('.slides').html(markdownReference); $('.slides').html(markdownReference);
} }
function scrollToCurrentSlide() { function scrollToCurrentSlide() {
var i = Reveal.getIndices(); var i = Reveal.getIndices();
Reveal.slide(i.h, i.v, i.f); Reveal.slide(i.h, i.v, i.f);
} }
function reloadMarkdown() { function reloadMarkdown() {
insertMarkdownReference(); insertMarkdownReference();
RevealMarkdown.initialize(); RevealMarkdown.initialize();
highlightAnyCodeBlocks(); highlightAnyCodeBlocks();
scrollToCurrentSlide(); scrollToCurrentSlide();
} }
function externalLinksInNewWindow() { function externalLinksInNewWindow() {
$(document.links).filter(function() { $(document.links).filter(function() {
return this.hostname != window.location.hostname; return this.hostname != window.location.hostname;
}).attr('target', '_blank'); }).attr('target', '_blank');
} }
insertMarkdownReference(); insertMarkdownReference();