Skip to content

Instantly share code, notes, and snippets.

@olivierphi
Created December 5, 2014 16:23
Show Gist options
  • Save olivierphi/a5859e4af8e5aef18f03 to your computer and use it in GitHub Desktop.
Save olivierphi/a5859e4af8e5aef18f03 to your computer and use it in GitHub Desktop.
Repeat an element for each page on Reveal.js printed PDF
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">' +
'&copy; 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