Created
December 5, 2014 16:23
-
-
Save olivierphi/a5859e4af8e5aef18f03 to your computer and use it in GitHub Desktop.
Repeat an element for each page on Reveal.js printed PDF
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
if (window.location.search.match( /print-pdf/gi )) { | |
(function () { | |
// Conditionally Load jQuery (javascript) | |
// Source: https://gist.github.com/gists/902090/ | |
var init, maybeLoadJq; | |
init = function() { | |
console && console.log && console.log('jQuery loaded !'); | |
// Begin copyright addition for every section | |
var $sections = $('.reveal section'); | |
console && console.log && console.log($sections.length + ' sections detected.'); | |
var toRepeatForEachPageHtmlStr = ''+ | |
'<div class="copyright-notice">' + | |
'© 2013 <a href="http://www.linkedin.com/in/olivierphilippon" target="_blank">Olivier Philippon</a> - Tous droits réservés.' + | |
'</div>'; | |
console && console.log && console.log('Let\'s add this to each one :', toRepeatForEachPageHtmlStr); | |
$sections.after(toRepeatForEachPageHtmlStr); | |
// End copyright addition for every section | |
}; | |
maybeLoadJq = function() { | |
var jQ; | |
if (!(typeof jQuery !== "undefined" && jQuery !== null)) { | |
jQ = document.createElement('script'); | |
jQ.type = 'text/javascript'; | |
jQ.onload = jQ.onreadystatechange = init; | |
jQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'; | |
return document.body.appendChild(jQ); | |
} else { | |
return init(); | |
} | |
}; | |
if (window.addEventListener) { | |
window.addEventListener('load', maybeLoadJq, false); | |
} else if (window.attachEvent) { | |
window.attachEvent('onload', maybeLoadJq); | |
} | |
})(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment