1var PdfExport = ( function( _Reveal ){ 2 3 var Reveal = _Reveal; 4 var setStylesheet = null; 5 var installAltKeyBindings = null; 6 7 function getRevealJsPath(){ 8 var regex = /\b[^/]+\/reveal.css$/i; 9 var script = Array.from( document.querySelectorAll( 'link' ) ).find( function( e ){ 10 return e.attributes.href && e.attributes.href.value.search( regex ) >= 0; 11 }); 12 if( !script ){ 13 console.error( 'reveal.css could not be found in included <link> elements. Did you rename this file?' ); 14 return ''; 15 } 16 return script.attributes.href.value.replace( regex, '' ); 17 } 18 19 function setStylesheet3( pdfExport ){ 20 var link = document.querySelector( '#print' ); 21 if( !link ){ 22 link = document.createElement( 'link' ); 23 link.rel = 'stylesheet'; 24 link.id = 'print'; 25 document.querySelector( 'head' ).appendChild( link ); 26 } 27 var style = 'paper'; 28 if( pdfExport ){ 29 style = 'pdf'; 30 } 31 link.href = getRevealJsPath() + 'css/print/' + style + '.css'; 32 } 33 34 function setStylesheet4( pdfExport ){ 35 } 36 37 function installAltKeyBindings3(){ 38 } 39 40 function installAltKeyBindings4(){ 41 if( isPrintingPDF() ){ 42 var config = Reveal.getConfig(); 43 var shortcut = config.pdfExportShortcut || 'E'; 44 window.addEventListener( 'keydown', function( e ){ 45 if( e.target.nodeName.toUpperCase() == 'BODY' 46 && ( e.key.toUpperCase() == shortcut.toUpperCase() || e.keyCode == shortcut.toUpperCase().charCodeAt( 0 ) ) ){ 47 e.preventDefault(); 48 togglePdfExport(); 49 return false; 50 } 51 }, true ); 52 } 53 } 54 55 function isPrintingPDF(){ 56 return ( /print-pdf/gi ).test( window.location.search ); 57 } 58 59 function togglePdfExport(){ 60 var url_doc = new URL( document.URL ); 61 var query_doc = new URLSearchParams( url_doc.searchParams ); 62 if( isPrintingPDF() ){ 63 query_doc.delete( 'print-pdf' ); 64 }else{ 65 query_doc.set( 'print-pdf', '' ); 66 } 67 url_doc.search = ( query_doc.toString() ? '?' + query_doc.toString() : '' ); 68 window.location.href = url_doc.toString(); 69 } 70 71 function installKeyBindings(){ 72 var config = Reveal.getConfig(); 73 var shortcut = config.pdfExportShortcut || 'E'; 74 Reveal.addKeyBinding({ 75 keyCode: shortcut.toUpperCase().charCodeAt( 0 ), 76 key: shortcut.toUpperCase(), 77 description: 'PDF export mode' 78 }, togglePdfExport ); 79 installAltKeyBindings(); 80 } 81 82 function install(){ 83 installKeyBindings(); 84 setStylesheet( isPrintingPDF() ); 85 } 86 87 var Plugin = { 88 } 89 90 if( Reveal && Reveal.VERSION && Reveal.VERSION.length && Reveal.VERSION[ 0 ] == '3' ){ 91 // reveal 3.x 92 setStylesheet = setStylesheet3; 93 installAltKeyBindings = installAltKeyBindings3; 94 install(); 95 }else{ 96 // must be reveal 4.x 97 setStylesheet = setStylesheet4; 98 installAltKeyBindings = installAltKeyBindings4; 99 Plugin.id = 'pdf-export'; 100 Plugin.init = function( _Reveal ){ 101 Reveal = _Reveal; 102 install(); 103 }; 104 Plugin.togglePdfExport = function () { 105 togglePdfExport(); 106 }; 107 } 108 109 return Plugin; 110 111})( Reveal );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.