highlight, math, notes and zoom plugins now register via Reveal.registerPlugin
This commit is contained in:
		| @@ -402,7 +402,7 @@ Reveal.addEventListener( 'customevent', function() { | ||||
| 				dependencies: [ | ||||
| 					{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, | ||||
| 					{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, | ||||
| 					{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, | ||||
| 					{ src: 'plugin/highlight/highlight.js', async: true }, | ||||
| 					{ src: 'plugin/search/search.js', async: true }, | ||||
| 					{ src: 'plugin/zoom-js/zoom.js', async: true }, | ||||
| 					{ src: 'plugin/notes/notes.js', async: true } | ||||
|   | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -20,28 +20,6 @@ var RevealMath = window.RevealMath || (function(){ | ||||
| 		skipStartupTypeset: true | ||||
| 	}; | ||||
|  | ||||
| 	defaults( options, defaultOptions ); | ||||
| 	defaults( options.tex2jax, defaultOptions.tex2jax ); | ||||
| 	options.mathjax = options.config = null; | ||||
|  | ||||
| 	loadScript( url, function() { | ||||
|  | ||||
| 		MathJax.Hub.Config( options ); | ||||
|  | ||||
| 		// Typeset followed by an immediate reveal.js layout since | ||||
| 		// the typesetting process could affect slide height | ||||
| 		MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub ] ); | ||||
| 		MathJax.Hub.Queue( Reveal.layout ); | ||||
|  | ||||
| 		// Reprocess equations in slides when they turn visible | ||||
| 		Reveal.addEventListener( 'slidechanged', function( event ) { | ||||
|  | ||||
| 			MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, event.currentSlide ] ); | ||||
|  | ||||
| 		} ); | ||||
|  | ||||
| 	} ); | ||||
|  | ||||
| 	function defaults( options, defaultOptions ) { | ||||
|  | ||||
| 		for ( var i in defaultOptions ) { | ||||
| @@ -81,4 +59,37 @@ var RevealMath = window.RevealMath || (function(){ | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	return { | ||||
| 		init: function() { | ||||
|  | ||||
| 			defaults( options, defaultOptions ); | ||||
| 			defaults( options.tex2jax, defaultOptions.tex2jax ); | ||||
| 			options.mathjax = options.config = null; | ||||
|  | ||||
| 			loadScript( url, function() { | ||||
|  | ||||
| 				MathJax.Hub.Config( options ); | ||||
|  | ||||
| 				// Typeset followed by an immediate reveal.js layout since | ||||
| 				// the typesetting process could affect slide height | ||||
| 				MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub ] ); | ||||
| 				MathJax.Hub.Queue( Reveal.layout ); | ||||
|  | ||||
| 				// Reprocess equations in slides when they turn visible | ||||
| 				Reveal.addEventListener( 'slidechanged', function( event ) { | ||||
|  | ||||
| 					MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, event.currentSlide ] ); | ||||
|  | ||||
| 				} ); | ||||
|  | ||||
| 			} ); | ||||
|  | ||||
| 			// lofi xbrowser Promise.resolve() | ||||
| 			return { then: function( resolve ) { resolve(); }}; | ||||
|  | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| })(); | ||||
|  | ||||
| Reveal.registerPlugin( 'math', RevealMath ); | ||||
|   | ||||
| @@ -168,7 +168,8 @@ var RevealNotes = (function() { | ||||
|  | ||||
| 			} | ||||
|  | ||||
| 			return Promise.resolve(); | ||||
| 			// lofi xbrowser Promise.resolve() | ||||
| 			return { then: function( resolve ) { resolve(); }}; | ||||
|  | ||||
| 		}, | ||||
|  | ||||
|   | ||||
| @@ -1,29 +1,37 @@ | ||||
| // Custom reveal.js integration | ||||
| (function(){ | ||||
| 	var revealElement = document.querySelector( '.reveal' ); | ||||
| 	if( revealElement ) { | ||||
| var RevealZoom = (function(){ | ||||
|  | ||||
| 		revealElement.addEventListener( 'mousedown', function( event ) { | ||||
| 			var defaultModifier = /Linux/.test( window.navigator.platform ) ? 'ctrl' : 'alt'; | ||||
| 	return { | ||||
| 		init: function() { | ||||
|  | ||||
| 			var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : defaultModifier ) + 'Key'; | ||||
| 			var zoomLevel = ( Reveal.getConfig().zoomLevel ? Reveal.getConfig().zoomLevel : 2 ); | ||||
| 			Reveal.getRevealElement().addEventListener( 'mousedown', function( event ) { | ||||
| 				var defaultModifier = /Linux/.test( window.navigator.platform ) ? 'ctrl' : 'alt'; | ||||
|  | ||||
| 			if( event[ modifier ] && !Reveal.isOverview() ) { | ||||
| 				event.preventDefault(); | ||||
| 				var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : defaultModifier ) + 'Key'; | ||||
| 				var zoomLevel = ( Reveal.getConfig().zoomLevel ? Reveal.getConfig().zoomLevel : 2 ); | ||||
|  | ||||
| 				zoom.to({ | ||||
| 					x: event.clientX, | ||||
| 					y: event.clientY, | ||||
| 					scale: zoomLevel, | ||||
| 					pan: false | ||||
| 				}); | ||||
| 			} | ||||
| 		} ); | ||||
| 				if( event[ modifier ] && !Reveal.isOverview() ) { | ||||
| 					event.preventDefault(); | ||||
|  | ||||
| 					zoom.to({ | ||||
| 						x: event.clientX, | ||||
| 						y: event.clientY, | ||||
| 						scale: zoomLevel, | ||||
| 						pan: false | ||||
| 					}); | ||||
| 				} | ||||
| 			} ); | ||||
|  | ||||
| 			// lofi xbrowser Promise.resolve() | ||||
| 			return { then: function( resolve ) { resolve(); }}; | ||||
|  | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| })(); | ||||
|  | ||||
| Reveal.registerPlugin( 'zoom', RevealZoom ); | ||||
|  | ||||
| /*! | ||||
|  * zoom.js 0.3 (modified for use with reveal.js) | ||||
|  * http://lab.hakim.se/zoom-js | ||||
|   | ||||
		Reference in New Issue
	
	Block a user