diff --git a/Gruntfile.js b/Gruntfile.js index 87630d5..96a4f52 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,7 +1,9 @@ /* global module:false */ module.exports = function(grunt) { var port = grunt.option('port') || 8000; - var base = grunt.option('base') || '.'; + var root = grunt.option('root') || '.'; + + if (!Array.isArray(root)) root = [root]; // Project configuration grunt.initConfig({ @@ -69,6 +71,7 @@ module.exports = function(grunt) { curly: false, eqeqeq: true, immed: true, + esnext: true, latedef: true, newcap: true, noarg: true, @@ -93,11 +96,12 @@ module.exports = function(grunt) { server: { options: { port: port, - base: base, + base: root, livereload: true, open: true } - } + }, + }, zip: { @@ -126,14 +130,20 @@ module.exports = function(grunt) { tasks: 'css-core' }, html: { - files: [ '*.html'] + files: root.map(path => path + '/*.html') }, markdown: { - files: [ '*.md' ] + files: root.map(path => path + '/*.md') }, options: { livereload: true } + }, + + retire: { + js: ['js/reveal.js', 'lib/js/*.js', 'plugin/**/*.js'], + node: ['.'], + options: {} } }); @@ -148,6 +158,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks( 'grunt-contrib-connect' ); grunt.loadNpmTasks( 'grunt-autoprefixer' ); grunt.loadNpmTasks( 'grunt-zip' ); + grunt.loadNpmTasks( 'grunt-retire' ); // Default task grunt.registerTask( 'default', [ 'css', 'js' ] ); diff --git a/LICENSE b/LICENSE index faadd00..924cd89 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (C) 2016 Hakim El Hattab, http://hakim.se +Copyright (C) 2016 Hakim El Hattab, http://hakim.se, and reveal.js contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 32824e3..dd38a99 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ The presentation markup hierarchy needs to be `.reveal > .slides > section` wher ### Markdown -It's possible to write your slides using Markdown. To enable Markdown, add the ```data-markdown``` attribute to your ```
``` elements and wrap the contents in a ``` @@ -182,11 +281,20 @@ currentState, currentSlide, upcomingSlide, + layoutLabel, + layoutDropdown, connected = false; var socket = io.connect( window.location.origin ), socketId = '{{socketId}}'; + var SPEAKER_LAYOUTS = { + 'default': 'Default', + 'wide': 'Wide', + 'tall': 'Tall', + 'notes-only': 'Notes only' + }; + socket.on( 'statechanged', function( data ) { // ignore data from sockets that aren't ours @@ -205,6 +313,8 @@ } ); + setupLayout(); + // Load our presentation iframes setupIframes(); @@ -362,6 +472,74 @@ } + /** + * Sets up the speaker view layout and layout selector. + */ + function setupLayout() { + + layoutDropdown = document.querySelector( '.speaker-layout-dropdown' ); + layoutLabel = document.querySelector( '.speaker-layout-label' ); + + // Render the list of available layouts + for( var id in SPEAKER_LAYOUTS ) { + var option = document.createElement( 'option' ); + option.setAttribute( 'value', id ); + option.textContent = SPEAKER_LAYOUTS[ id ]; + layoutDropdown.appendChild( option ); + } + + // Monitor the dropdown for changes + layoutDropdown.addEventListener( 'change', function( event ) { + + setLayout( layoutDropdown.value ); + + }, false ); + + // Restore any currently persisted layout + setLayout( getLayout() ); + + } + + /** + * Sets a new speaker view layout. The layout is persisted + * in local storage. + */ + function setLayout( value ) { + + var title = SPEAKER_LAYOUTS[ value ]; + + layoutLabel.innerHTML = 'Layout' + ( title ? ( ': ' + title ) : '' ); + layoutDropdown.value = value; + + document.body.setAttribute( 'data-speaker-layout', value ); + + // Persist locally + if( window.localStorage ) { + window.localStorage.setItem( 'reveal-speaker-layout', value ); + } + + } + + /** + * Returns the ID of the most recently set speaker layout + * or our default layout if none has been set. + */ + function getLayout() { + + if( window.localStorage ) { + var layout = window.localStorage.getItem( 'reveal-speaker-layout' ); + if( layout ) { + return layout; + } + } + + // Default to the first record in the layouts hash + for( var id in SPEAKER_LAYOUTS ) { + return id; + } + + } + function zeroPadInteger( num ) { var str = '00' + parseInt( num ); diff --git a/plugin/notes/notes.html b/plugin/notes/notes.html index c80e77f..4fda869 100644 --- a/plugin/notes/notes.html +++ b/plugin/notes/notes.html @@ -8,6 +8,7 @@