123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- export default class Notes {
- constructor( Reveal ) {
- this.Reveal = Reveal;
- }
- render() {
- this.element = document.createElement( 'div' );
- this.element.className = 'speaker-notes';
- this.element.setAttribute( 'data-prevent-swipe', '' );
- this.element.setAttribute( 'tabindex', '0' );
- this.Reveal.getRevealElement().appendChild( this.element );
- }
-
- configure( config, oldConfig ) {
- if( config.showNotes ) {
- this.element.setAttribute( 'data-layout', typeof config.showNotes === 'string' ? config.showNotes : 'inline' );
- }
- }
-
- update() {
- if( this.Reveal.getConfig().showNotes && this.element && this.Reveal.getCurrentSlide() && !this.Reveal.print.isPrintingPDF() ) {
- this.element.innerHTML = this.getSlideNotes() || '<span class="notes-placeholder">No notes on this slide.</span>';
- }
- }
-
- updateVisibility() {
- if( this.Reveal.getConfig().showNotes && this.hasNotes() && !this.Reveal.print.isPrintingPDF() ) {
- this.Reveal.getRevealElement().classList.add( 'show-notes' );
- }
- else {
- this.Reveal.getRevealElement().classList.remove( 'show-notes' );
- }
- }
-
- hasNotes() {
- return this.Reveal.getSlidesElement().querySelectorAll( '[data-notes], aside.notes' ).length > 0;
- }
-
- isSpeakerNotesWindow() {
- return !!window.location.search.match( /receiver/gi );
- }
-
- getSlideNotes( slide = this.Reveal.getCurrentSlide() ) {
-
- if( slide.hasAttribute( 'data-notes' ) ) {
- return slide.getAttribute( 'data-notes' );
- }
-
- let notesElement = slide.querySelector( 'aside.notes' );
- if( notesElement ) {
- return notesElement.innerHTML;
- }
- return null;
- }
- }
|