Browse Source

highlight, math, notes and zoom plugins now register via Reveal.registerPlugin

Hakim El Hattab 5 years ago
parent
commit
c40e9819a2
5 changed files with 62 additions and 41 deletions
  1. 1 1
      demo.html
  2. 1 0
      plugin/highlight/highlight.js
  3. 33 22
      plugin/math/math.js
  4. 2 1
      plugin/notes/notes.js
  5. 25 17
      plugin/zoom-js/zoom.js

+ 1 - 1
demo.html

@@ -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 it is too large
+ 1 - 0
plugin/highlight/highlight.js


+ 33 - 22
plugin/math/math.js

@@ -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 );

+ 2 - 1
plugin/notes/notes.js

@@ -168,7 +168,8 @@ var RevealNotes = (function() {
 
 			}
 
-			return Promise.resolve();
+			// lofi xbrowser Promise.resolve()
+			return { then: function( resolve ) { resolve(); }};
 
 		},
 

+ 25 - 17
plugin/zoom-js/zoom.js

@@ -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

Some files were not shown because too many files changed in this diff