diff options
-rw-r--r-- | index.html | 4 | ||||
-rw-r--r-- | js/reveal.js | 28 | ||||
-rw-r--r-- | js/reveal.min.js | 80 | ||||
-rw-r--r-- | plugin/notes/notes.html | 45 | ||||
-rw-r--r-- | plugin/notes/notes.js | 100 |
5 files changed, 177 insertions, 80 deletions
@@ -261,6 +261,10 @@ function linkify( selector ) { <li class="fragment"><em>of view</em></li> <li class="fragment"><strong>fragments</strong></li> </ol> + + <aside class="notes"> + This slide has fragments which are also stepped through in the notes window. + </aside> </section> <section> <h2>Fragment Styles</h2> diff --git a/js/reveal.js b/js/reveal.js index 749e71d..425b617 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -1,5 +1,5 @@ /*! - * reveal.js 2.1 r35 + * reveal.js 2.1 r36 * http://lab.hakim.se/reveal-js * MIT licensed * @@ -268,12 +268,15 @@ var Reveal = (function(){ // Start auto-sliding if it's enabled cueAutoSlide(); - // Notify listeners that the presentation is ready - dispatchEvent( 'ready', { - 'indexh': indexh, - 'indexv': indexv, - 'currentSlide': currentSlide - } ); + // Notify listeners that the presentation is ready but use a 1ms + // timeout to ensure it's not fired synchronously after #initialize() + setTimeout( function() { + dispatchEvent( 'ready', { + 'indexh': indexh, + 'indexv': indexv, + 'currentSlide': currentSlide + } ); + }, 1 ); } /** @@ -1088,9 +1091,14 @@ var Reveal = (function(){ * @param {Object} event */ function onDocumentKeyDown( event ) { - // Disregard the event if the target is editable or a - // modifier is present - if ( document.querySelector( ':focus' ) !== null || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return; + // Check if there's a focused element that could be using + // the keyboard + var activeElement = document.activeElement; + var hasFocus = !!( document.activeElement && ( document.activeElement.type || document.activeElement.href || document.activeElement.contentEditable !== 'inherit' ) ); + + // Disregard the event if there's a focused element or a + // keyboard modifier key is present + if ( hasFocus || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return; var triggered = true; diff --git a/js/reveal.min.js b/js/reveal.min.js index 41e0fc0..e389070 100644 --- a/js/reveal.min.js +++ b/js/reveal.min.js @@ -1,7 +1,83 @@ /*! - * reveal.js 2.1 r35 + * reveal.js 2.1 r36 * http://lab.hakim.se/reveal-js * MIT licensed * * Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se - */var Reveal=function(){function m(e){if(!c&&!l){document.body.setAttribute("class","no-transforms");return}T(n,e);y();b()}function g(){f.theme=document.querySelector("#theme");f.wrapper=document.querySelector(".reveal");if(!f.wrapper.querySelector(".progress")&&n.progress){var e=document.createElement("div");e.classList.add("progress");e.innerHTML="<span></span>";f.wrapper.appendChild(e)}if(!f.wrapper.querySelector(".controls")&&n.controls){var t=document.createElement("aside");t.classList.add("controls");t.innerHTML='<div class="left"></div><div class="right"></div><div class="up"></div><div class="down"></div>';f.wrapper.appendChild(t)}if(!f.wrapper.querySelector(".state-background")){var r=document.createElement("div");r.classList.add("state-background");f.wrapper.appendChild(r)}if(!f.wrapper.querySelector(".pause-overlay")){var i=document.createElement("div");i.classList.add("pause-overlay");f.wrapper.appendChild(i)}f.progress=document.querySelector(".reveal .progress");f.progressbar=document.querySelector(".reveal .progress span");if(n.controls){f.controls=document.querySelector(".reveal .controls");f.controlsLeft=document.querySelector(".reveal .controls .left");f.controlsRight=document.querySelector(".reveal .controls .right");f.controlsUp=document.querySelector(".reveal .controls .up");f.controlsDown=document.querySelector(".reveal .controls .down")}}function y(){if(navigator.userAgent.match(/(iphone|ipod|android)/i)){document.documentElement.style.overflow="scroll";document.body.style.height="120%";window.addEventListener("load",k,!1);window.addEventListener("orientationchange",k,!1)}}function b(){function o(){head.js.apply(null,t);w()}var e=[],t=[];for(var r=0,i=n.dependencies.length;r<i;r++){var s=n.dependencies[r];if(!s.condition||s.condition()){s.async?t.push(s.src):e.push(s.src);typeof s.callback=="function"&&head.ready(s.src.match(/([\w\d_\-]*)\.?[^\\\/]*$/i)[0],s.callback)}}if(e.length){head.ready(o);head.js.apply(null,e)}else o()}function w(){g();S();E();z();J();L("ready",{indexh:i,indexv:s,currentSlide:u})}function E(){l===!1&&(n.transition="linear");n.controls&&f.controls&&(f.controls.style.display="block");n.progress&&f.progress&&(f.progress.style.display="block");n.transition!=="default"&&f.wrapper.classList.add(n.transition);if(n.mouseWheel){document.addEventListener("DOMMouseScroll",st,!1);document.addEventListener("mousewheel",st,!1)}n.rollingLinks&&A();if(n.theme&&f.theme){var e=f.theme.getAttribute("href"),t=/[^\/]*?(?=\.css)/,r=e.match(t)[0];if(n.theme!==r){e=e.replace(t,n.theme);f.theme.setAttribute("href",e)}}}function S(){document.addEventListener("touchstart",nt,!1);document.addEventListener("touchmove",rt,!1);document.addEventListener("touchend",it,!1);window.addEventListener("hashchange",ut,!1);n.keyboard&&document.addEventListener("keydown",tt,!1);n.progress&&f.progress&&f.progress.addEventListener("click",C(ot),!1);if(n.controls&&f.controls){f.controlsLeft.addEventListener("click",C(K),!1);f.controlsRight.addEventListener("click",C(Q),!1);f.controlsUp.addEventListener("click",C(G),!1);f.controlsDown.addEventListener("click",C(Y),!1)}}function x(){document.removeEventListener("keydown",tt,!1);document.removeEventListener("touchstart",nt,!1);document.removeEventListener("touchmove",rt,!1);document.removeEventListener("touchend",it,!1);window.removeEventListener("hashchange",ut,!1);n.progress&&f.progress&&f.progress.removeEventListener("click",C(ot),!1);if(n.controls&&f.controls){f.controlsLeft.removeEventListener("click",C(K),!1);f.controlsRight.removeEventListener("click",C(Q),!1);f.controlsUp.removeEventListener("click",C(G),!1);f.controlsDown.removeEventListener("click",C(Y),!1)}}function T(e,t){for(var n in t)e[n]=t[n]}function N(e,t){var n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}function C(e){return function(t){t.preventDefault();e.call(null,t)}}function k(){setTimeout(function(){window.scrollTo(0,1)},0)}function L(e,t){var n=document.createEvent("HTMLEvents",1,2);n.initEvent(e,!0,!0);T(n,t);f.wrapper.dispatchEvent(n)}function A(){if(l&&!("msPerspective"in document.body.style)){var e=document.querySelectorAll(".reveal .slides section a:not(.image)");for(var t=0,n=e.length;t<n;t++){var r=e[t];if(r.textContent&&!r.querySelector("img")&&(!r.className||!r.classList.contains(r,"roll"))){r.classList.add("roll");r.innerHTML='<span data-title="'+r.text+'">'+r.innerHTML+"</span>"}}}}function O(){if(n.overview){f.wrapper.classList.add("overview");var t=document.querySelectorAll(e);for(var r=0,o=t.length;r<o;r++){var u=t[r],a="translateZ(-2500px) translate("+(r-i)*105+"%, 0%)";u.setAttribute("data-index-h",r);u.style.display="block";u.style.WebkitTransform=a;u.style.MozTransform=a;u.style.msTransform=a;u.style.OTransform=a;u.style.transform=a;u.classList.contains("stack")||u.addEventListener("click",at,!0);var l=u.querySelectorAll("section");for(var c=0,h=l.length;c<h;c++){var p=l[c],d="translate(0%, "+(c-(r===i?s:0))*105+"%)";p.setAttribute("data-index-h",r);p.setAttribute("data-index-v",c);p.style.display="block";p.style.WebkitTransform=d;p.style.MozTransform=d;p.style.msTransform=d;p.style.OTransform=d;p.style.transform=d;p.addEventListener("click",at,!0)}}}}function M(){if(n.overview){f.wrapper.classList.remove("overview");var e=Array.prototype.slice.call(document.querySelectorAll(".reveal .slides section"));for(var t=0,r=e.length;t<r;t++){var i=e[t];i.style.WebkitTransform="";i.style.MozTransform="";i.style.msTransform="";i.style.OTransform="";i.style.transform="";i.removeEventListener("click",at)}I()}}function _(e){typeof e=="boolean"?e?O():M():D()?M():O()}function D(){return f.wrapper.classList.contains("overview")}function P(){var e=document.body,t=e.requestFullScreen||e.webkitRequestFullScreen||e.mozRequestFullScreen||e.msRequestFullScreen;t&&t.apply(e)}function H(){f.wrapper.classList.add("paused")}function B(){f.wrapper.classList.remove("paused")}function j(){F()?B():H()}function F(){return f.wrapper.classList.contains("paused")}function I(r,l){o=u;var c=a.concat();a.length=0;var h=i,p=s;i=q(e,r===undefined?i:r);s=q(t,l===undefined?s:l);e:for(var v=0,m=a.length;v<m;v++){for(var g=0;g<c.length;g++)if(c[g]===a[v]){c.splice(g,1);continue e}document.documentElement.classList.add(a[v]);L(a[v])}while(c.length)document.documentElement.classList.remove(c.pop());n.progress&&f.progress&&(f.progressbar.style.width=i/(document.querySelectorAll(e).length-1)*window.innerWidth+"px");D()&&O();R();clearTimeout(d);d=setTimeout(W,1500);var y=document.querySelectorAll(e),b=y[i],w=b.querySelectorAll("section");u=w[s]||b;i!==h||s!==p?L("slidechanged",{indexh:i,indexv:s,previousSlide:o,currentSlide:u}):o=null;o&&o.classList.remove("present")}function q(e,t){var i=Array.prototype.slice.call(document.querySelectorAll(e)),s=i.length;if(s){if(n.loop){t%=s;t<0&&(t=s+t)}t=Math.max(Math.min(t,s-1),0);for(var o=0;o<s;o++){var u=i[o];if(D()===!1){var f=Math.abs((t-o)%(s-3))||0;u.style.display=f>3?"none":"block"}i[o].classList.remove("past");i[o].classList.remove("present");i[o].classList.remove("future");o<t?i[o].classList.add("past"):o>t&&i[o].classList.add("future");u.querySelector("section")&&i[o].classList.add("stack")}i[t].classList.add("present");var l=i[t].getAttribute("data-state");l&&(a=a.concat(l.split(" ")));var c=i[t].getAttribute("data-autoslide");c?r=parseInt(c):r=n.autoSlide}else t=0;return t}function R(){if(n.controls&&f.controls){var e=U();[f.controlsLeft,f.controlsRight,f.controlsUp,f.controlsDown].forEach(function(e){e.classList.remove("enabled")});e.left&&f.controlsLeft.classList.add("enabled");e.right&&f.controlsRight.classList.add("enabled");e.up&&f.controlsUp.classList.add("enabled");e.down&&f.controlsDown.classList.add("enabled")}}function U(){var n=document.querySelectorAll(e),r=document.querySelectorAll(t);return{left:i>0,right:i<n.length-1,up:s>0,down:s<r.length-1}}function z(){var e=window.location.hash,t=e.slice(2).split("/"),n=e.replace(/#|\//gi,"");if(isNaN(parseInt(t[0],10))&&n.length){var r=document.querySelector("#"+n);if(r){var o=Reveal.getIndices(r);I(o.h,o.v)}else I(i,s)}else{var u=parseInt(t[0],10)||0,a=parseInt(t[1],10)||0;I(u,a)}}function W(){if(n.history){var e="/";if(i>0||s>0)e+=i;s>0&&(e+="/"+s);window.location.hash=e}}function X(t){var n=i,r=s;if(t){var o=!!t.parentNode.nodeName.match(/section/gi),u=o?t.parentNode:t,a=Array.prototype.slice.call(document.querySelectorAll(e));n=Math.max(a.indexOf(u),0);o&&(r=Math.max(Array.prototype.slice.call(t.parentNode.children).indexOf(t),0))}return{h:n,v:r}}function V(){if(document.querySelector(t+".present")){var n=document.querySelectorAll(t+".present .fragment:not(.visible)");if(n.length){n[0].classList.add("visible");L("fragmentshown",{fragment:n[0]});return!0}}else{var r=document.querySelectorAll(e+".present .fragment:not(.visible)");if(r.length){r[0].classList.add("visible");L("fragmentshown",{fragment:r[0]});return!0}}return!1}function $(){if(document.querySelector(t+".present")){var n=document.querySelectorAll(t+".present .fragment.visible");if(n.length){n[n.length-1].classList.remove("visible");L("fragmenthidden",{fragment:n[n.length-1]});return!0}}else{var r=document.querySelectorAll(e+".present .fragment.visible");if(r.length){r[r.length-1].classList.remove("visible");L("fragmenthidden",{fragment:r[r.length-1]});return!0}}return!1}function J(){clearTimeout(p);r&&(p=setTimeout(et,r))}function K(){(D()||$()===!1)&&I(i-1,0)}function Q(){(D()||V()===!1)&&I(i+1,0)}function G(){(D()||$()===!1)&&I(i,s-1)}function Y(){(D()||V()===!1)&&I(i,s+1)}function Z(){if($()===!1)if(U().up)G();else{var e=document.querySelector(".reveal .slides>section.past:nth-child("+i+")");if(e){s=e.querySelectorAll("section").length+1||0;i--;I()}}}function et(){V()===!1&&(U().down?Y():Q());J()}function tt(e){if(document.querySelector(":focus")!==null||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey)return;var t=!0;switch(e.keyCode){case 80:case 33:Z();break;case 78:case 34:et();break;case 72:case 37:K();break;case 76:case 39:Q();break;case 75:case 38:G();break;case 74:case 40:Y();break;case 36:I(0);break;case 35:I(Number.MAX_VALUE);break;case 32:D()?M():et();break;case 13:D()?M():t=!1;break;case 66:case 190:j();break;case 70:P();break;default:t=!1}if(t)e.preventDefault();else if(e.keyCode===27&&l){_();e.preventDefault()}J()}function nt(e){v.startX=e.touches[0].clientX;v.startY=e.touches[0].clientY;v.startCount=e.touches.length;e.touches.length===2&&n.overview&&(v.startSpan=N({x:e.touches[1].clientX,y:e.touches[1].clientY},{x:v.startX,y:v.startY}))}function rt(e){if(!v.handled){var t=e.touches[0].clientX,r=e.touches[0].clientY;if(e.touches.length===2&&v.startCount===2&&n.overview){var i=N({x:e.touches[1].clientX,y:e.touches[1].clientY},{x:v.startX,y:v.startY});if(Math.abs(v.startSpan-i)>v.threshold){v.handled=!0;i<v.startSpan?O():M()}e.preventDefault()}else if(e.touches.length===1&&v.startCount!==2){var s=t-v.startX,o=r-v.startY;if(s>v.threshold&&Math.abs(s)>Math.abs(o)){v.handled=!0;K()}else if(s<-v.threshold&&Math.abs(s)>Math.abs(o)){v.handled=!0;Q()}else if(o>v.threshold){v.handled=!0;G()}else if(o<-v.threshold){v.handled=!0;Y()}e.preventDefault()}}else navigator.userAgent.match(/android/gi)&&e.preventDefault()}function it(e){v.handled=!1}function st(e){clearTimeout(h);h=setTimeout(function(){var t=e.detail||-e.wheelDelta;t>0?et():Z()},100)}function ot(t){var n=Array.prototype.slice.call(document.querySelectorAll(e)).length,r=Math.floor(t.clientX/f.wrapper.offsetWidth*n);I(r)}function ut(e){z()}function at(e){if(D()){e.preventDefault();M();i=this.getAttribute("data-index-h");s=this.getAttribute("data-index-v");I()}}var e=".reveal .slides>section",t=".reveal .slides>section.present>section",n={controls:!0,progress:!0,history:!1,keyboard:!0,overview:!0,loop:!1,autoSlide:0,mouseWheel:!0,rollingLinks:!0,theme:null,transition:"default",dependencies:[]},r=n.autoSlide,i=0,s=0,o,u,a=[],f={},l="WebkitPerspective"in document.body.style||"MozPerspective"in document.body.style||"msPerspective"in document.body.style||"OPerspective"in document.body.style||"perspective"in document.body.style,c="WebkitTransform"in document.body.style||"MozTransform"in document.body.style||"msTransform"in document.body.style||"OTransform"in document.body.style||"transform"in document.body.style,h=0,p=0,d=0,v={startX:0,startY:0,startSpan:0,startCount:0,handled:!1,threshold:80};return{initialize:m,slide:I,left:K,right:Q,up:G,down:Y,prev:Z,next:et,prevFragment:$,nextFragment:V,navigateTo:I,navigateLeft:K,navigateRight:Q,navigateUp:G,navigateDown:Y,navigatePrev:Z,navigateNext:et,toggleOverview:_,addEventListeners:S,removeEventListeners:x,getIndices:X,getPreviousSlide:function(){return o},getCurrentSlide:function(){return u},getQueryHash:function(){var e={};location.search.replace(/[A-Z0-9]+?=(\w*)/gi,function(t){e[t.split("=").shift()]=t.split("=").pop()});return e},addEventListener:function(e,t,n){"addEventListener"in window&&(f.wrapper||document.querySelector(".reveal")).addEventListener(e,t,n)},removeEventListener:function(e,t,n){"addEventListener"in window&&(f.wrapper||document.querySelector(".reveal")).removeEventListener(e,t,n)}}}(); + */ +var Reveal=(function(){var l=".reveal .slides>section",b=".reveal .slides>section.present>section",R={controls:true,progress:true,history:false,keyboard:true,overview:true,loop:false,autoSlide:0,mouseWheel:true,rollingLinks:true,theme:null,transition:"default",dependencies:[]},Y=R.autoSlide,m=0,e=0,y,G,ak=[],f={},T="WebkitPerspective" in document.body.style||"MozPerspective" in document.body.style||"msPerspective" in document.body.style||"OPerspective" in document.body.style||"perspective" in document.body.style,n="WebkitTransform" in document.body.style||"MozTransform" in document.body.style||"msTransform" in document.body.style||"OTransform" in document.body.style||"transform" in document.body.style,z=0,k=0,D=0,ac={startX:0,startY:0,startSpan:0,startCount:0,handled:false,threshold:80}; +function i(al){if((!n&&!T)){document.body.setAttribute("class","no-transforms");return;}t(R,al);d();V();}function P(){f.theme=document.querySelector("#theme"); +f.wrapper=document.querySelector(".reveal");if(!f.wrapper.querySelector(".progress")&&R.progress){var ao=document.createElement("div");ao.classList.add("progress"); +ao.innerHTML="<span></span>";f.wrapper.appendChild(ao);}if(!f.wrapper.querySelector(".controls")&&R.controls){var an=document.createElement("aside");an.classList.add("controls"); +an.innerHTML='<div class="left"></div><div class="right"></div><div class="up"></div><div class="down"></div>';f.wrapper.appendChild(an);}if(!f.wrapper.querySelector(".state-background")){var am=document.createElement("div"); +am.classList.add("state-background");f.wrapper.appendChild(am);}if(!f.wrapper.querySelector(".pause-overlay")){var al=document.createElement("div");al.classList.add("pause-overlay"); +f.wrapper.appendChild(al);}f.progress=document.querySelector(".reveal .progress");f.progressbar=document.querySelector(".reveal .progress span");if(R.controls){f.controls=document.querySelector(".reveal .controls"); +f.controlsLeft=document.querySelector(".reveal .controls .left");f.controlsRight=document.querySelector(".reveal .controls .right");f.controlsUp=document.querySelector(".reveal .controls .up"); +f.controlsDown=document.querySelector(".reveal .controls .down");}}function d(){if(navigator.userAgent.match(/(iphone|ipod|android)/i)){document.documentElement.style.overflow="scroll"; +document.body.style.height="120%";window.addEventListener("load",ad,false);window.addEventListener("orientationchange",ad,false);}}function V(){var am=[],aq=[]; +for(var an=0,al=R.dependencies.length;an<al;an++){var ao=R.dependencies[an];if(!ao.condition||ao.condition()){if(ao.async){aq.push(ao.src);}else{am.push(ao.src); +}if(typeof ao.callback==="function"){head.ready(ao.src.match(/([\w\d_\-]*)\.?[^\\\/]*$/i)[0],ao.callback);}}}function ap(){head.js.apply(null,aq);H();}if(am.length){head.ready(ap); +head.js.apply(null,am);}else{ap();}}function H(){P();E();K();J();O();setTimeout(function(){r("ready",{indexh:m,indexv:e,currentSlide:G});},1);}function K(){if(T===false){R.transition="linear"; +}if(R.controls&&f.controls){f.controls.style.display="block";}if(R.progress&&f.progress){f.progress.style.display="block";}if(R.transition!=="default"){f.wrapper.classList.add(R.transition); +}if(R.mouseWheel){document.addEventListener("DOMMouseScroll",o,false);document.addEventListener("mousewheel",o,false);}if(R.rollingLinks){N();}if(R.theme&&f.theme){var an=f.theme.getAttribute("href"); +var al=/[^\/]*?(?=\.css)/;var am=an.match(al)[0];if(R.theme!==am){an=an.replace(al,R.theme);f.theme.setAttribute("href",an);}}}function E(){document.addEventListener("touchstart",A,false); +document.addEventListener("touchmove",af,false);document.addEventListener("touchend",W,false);window.addEventListener("hashchange",w,false);if(R.keyboard){document.addEventListener("keydown",ah,false); +}if(R.progress&&f.progress){f.progress.addEventListener("click",q(ai),false);}if(R.controls&&f.controls){f.controlsLeft.addEventListener("click",q(B),false); +f.controlsRight.addEventListener("click",q(j),false);f.controlsUp.addEventListener("click",q(u),false);f.controlsDown.addEventListener("click",q(F),false); +}}function U(){document.removeEventListener("keydown",ah,false);document.removeEventListener("touchstart",A,false);document.removeEventListener("touchmove",af,false); +document.removeEventListener("touchend",W,false);window.removeEventListener("hashchange",w,false);if(R.progress&&f.progress){f.progress.removeEventListener("click",q(ai),false); +}if(R.controls&&f.controls){f.controlsLeft.removeEventListener("click",q(B),false);f.controlsRight.removeEventListener("click",q(j),false);f.controlsUp.removeEventListener("click",q(u),false); +f.controlsDown.removeEventListener("click",q(F),false);}}function t(am,al){for(var an in al){am[an]=al[an];}}function S(an,al){var ao=an.x-al.x,am=an.y-al.y; +return Math.sqrt(ao*ao+am*am);}function q(al){return function(am){am.preventDefault();al.call(null,am);};}function ad(){setTimeout(function(){window.scrollTo(0,1); +},0);}function r(am,al){var an=document.createEvent("HTMLEvents",1,2);an.initEvent(am,true,true);t(an,al);f.wrapper.dispatchEvent(an);}function N(){if(T&&!("msPerspective" in document.body.style)){var am=document.querySelectorAll(".reveal .slides section a:not(.image)"); +for(var an=0,al=am.length;an<al;an++){var ao=am[an];if(ao.textContent&&!ao.querySelector("img")&&(!ao.className||!ao.classList.contains(ao,"roll"))){ao.classList.add("roll"); +ao.innerHTML='<span data-title="'+ao.text+'">'+ao.innerHTML+"</span>";}}}}function I(){if(R.overview){f.wrapper.classList.add("overview");var al=document.querySelectorAll(l); +for(var aq=0,ao=al.length;aq<ao;aq++){var an=al[aq],av="translateZ(-2500px) translate("+((aq-m)*105)+"%, 0%)";an.setAttribute("data-index-h",aq);an.style.display="block"; +an.style.WebkitTransform=av;an.style.MozTransform=av;an.style.msTransform=av;an.style.OTransform=av;an.style.transform=av;if(!an.classList.contains("stack")){an.addEventListener("click",C,true); +}var au=an.querySelectorAll("section");for(var ap=0,am=au.length;ap<am;ap++){var at=au[ap],ar="translate(0%, "+((ap-(aq===m?e:0))*105)+"%)";at.setAttribute("data-index-h",aq); +at.setAttribute("data-index-v",ap);at.style.display="block";at.style.WebkitTransform=ar;at.style.MozTransform=ar;at.style.msTransform=ar;at.style.OTransform=ar; +at.style.transform=ar;at.addEventListener("click",C,true);}}}}function ae(){if(R.overview){f.wrapper.classList.remove("overview");var ao=Array.prototype.slice.call(document.querySelectorAll(".reveal .slides section")); +for(var an=0,al=ao.length;an<al;an++){var am=ao[an];am.style.WebkitTransform="";am.style.MozTransform="";am.style.msTransform="";am.style.OTransform=""; +am.style.transform="";am.removeEventListener("click",C);}a();}}function X(al){if(typeof al==="boolean"){al?I():ae();}else{L()?ae():I();}}function L(){return f.wrapper.classList.contains("overview"); +}function ab(){var al=document.body;var am=al.requestFullScreen||al.webkitRequestFullScreen||al.mozRequestFullScreen||al.msRequestFullScreen;if(am){am.apply(al); +}}function c(){f.wrapper.classList.add("paused");}function p(){f.wrapper.classList.remove("paused");}function aa(){if(ag()){p();}else{c();}}function ag(){return f.wrapper.classList.contains("paused"); +}function a(ar,aw){y=G;var ao=ak.concat();ak.length=0;var av=m,am=e;m=aj(l,ar===undefined?m:ar);e=aj(b,aw===undefined?e:aw);stateLoop:for(var ap=0,at=ak.length; +ap<at;ap++){for(var an=0;an<ao.length;an++){if(ao[an]===ak[ap]){ao.splice(an,1);continue stateLoop;}}document.documentElement.classList.add(ak[ap]);r(ak[ap]); +}while(ao.length){document.documentElement.classList.remove(ao.pop());}if(R.progress&&f.progress){f.progressbar.style.width=(m/(document.querySelectorAll(l).length-1))*window.innerWidth+"px"; +}if(L()){I();}s();clearTimeout(D);D=setTimeout(h,1500);var al=document.querySelectorAll(l);var au=al[m],aq=au.querySelectorAll("section");G=aq[e]||au;if(m!==av||e!==am){r("slidechanged",{indexh:m,indexv:e,previousSlide:y,currentSlide:G}); +}else{y=null;}if(y){y.classList.remove("present");}}function aj(ao,au){var am=Array.prototype.slice.call(document.querySelectorAll(ao)),at=am.length;if(at){if(R.loop){au%=at; +if(au<0){au=at+au;}}au=Math.max(Math.min(au,at-1),0);for(var aq=0;aq<at;aq++){var ar=am[aq];if(L()===false){var al=Math.abs((au-aq)%(at-3))||0;ar.style.display=al>3?"none":"block"; +}am[aq].classList.remove("past");am[aq].classList.remove("present");am[aq].classList.remove("future");if(aq<au){am[aq].classList.add("past");}else{if(aq>au){am[aq].classList.add("future"); +}}if(ar.querySelector("section")){am[aq].classList.add("stack");}}am[au].classList.add("present");var an=am[au].getAttribute("data-state");if(an){ak=ak.concat(an.split(" ")); +}var ap=am[au].getAttribute("data-autoslide");if(ap){Y=parseInt(ap);}else{Y=R.autoSlide;}}else{au=0;}return au;}function s(){if(R.controls&&f.controls){var al=g(); +[f.controlsLeft,f.controlsRight,f.controlsUp,f.controlsDown].forEach(function(am){am.classList.remove("enabled");});if(al.left){f.controlsLeft.classList.add("enabled"); +}if(al.right){f.controlsRight.classList.add("enabled");}if(al.up){f.controlsUp.classList.add("enabled");}if(al.down){f.controlsDown.classList.add("enabled"); +}}}function g(){var al=document.querySelectorAll(l),am=document.querySelectorAll(b);return{left:m>0,right:m<al.length-1,up:e>0,down:e<am.length-1};}function J(){var aq=window.location.hash; +var ap=aq.slice(2).split("/"),am=aq.replace(/#|\//gi,"");if(isNaN(parseInt(ap[0],10))&&am.length){var an=document.querySelector("#"+am);if(an){var ar=Reveal.getIndices(an); +a(ar.h,ar.v);}else{a(m,e);}}else{var ao=parseInt(ap[0],10)||0,al=parseInt(ap[1],10)||0;a(ao,al);}}function h(){if(R.history){var al="/";if(m>0||e>0){al+=m; +}if(e>0){al+="/"+e;}window.location.hash=al;}}function M(al){var ap=m,an=e;if(al){var aq=!!al.parentNode.nodeName.match(/section/gi);var ao=aq?al.parentNode:al; +var am=Array.prototype.slice.call(document.querySelectorAll(l));ap=Math.max(am.indexOf(ao),0);if(aq){an=Math.max(Array.prototype.slice.call(al.parentNode.children).indexOf(al),0); +}}return{h:ap,v:an};}function v(){if(document.querySelector(b+".present")){var am=document.querySelectorAll(b+".present .fragment:not(.visible)");if(am.length){am[0].classList.add("visible"); +r("fragmentshown",{fragment:am[0]});return true;}}else{var al=document.querySelectorAll(l+".present .fragment:not(.visible)");if(al.length){al[0].classList.add("visible"); +r("fragmentshown",{fragment:al[0]});return true;}}return false;}function Q(){if(document.querySelector(b+".present")){var am=document.querySelectorAll(b+".present .fragment.visible"); +if(am.length){am[am.length-1].classList.remove("visible");r("fragmenthidden",{fragment:am[am.length-1]});return true;}}else{var al=document.querySelectorAll(l+".present .fragment.visible"); +if(al.length){al[al.length-1].classList.remove("visible");r("fragmenthidden",{fragment:al[al.length-1]});return true;}}return false;}function O(){clearTimeout(k); +if(Y){k=setTimeout(x,Y);}}function B(){if(L()||Q()===false){a(m-1,0);}}function j(){if(L()||v()===false){a(m+1,0);}}function u(){if(L()||Q()===false){a(m,e-1); +}}function F(){if(L()||v()===false){a(m,e+1);}}function Z(){if(Q()===false){if(g().up){u();}else{var al=document.querySelector(".reveal .slides>section.past:nth-child("+m+")"); +if(al){e=(al.querySelectorAll("section").length+1)||0;m--;a();}}}}function x(){if(v()===false){g().down?F():j();}O();}function ah(an){var am=document.activeElement; +var ao=!!(document.activeElement&&(document.activeElement.type||document.activeElement.href||document.activeElement.contentEditable!=="inherit"));if(ao||an.shiftKey||an.altKey||an.ctrlKey||an.metaKey){return; +}var al=true;switch(an.keyCode){case 80:case 33:Z();break;case 78:case 34:x();break;case 72:case 37:B();break;case 76:case 39:j();break;case 75:case 38:u(); +break;case 74:case 40:F();break;case 36:a(0);break;case 35:a(Number.MAX_VALUE);break;case 32:L()?ae():x();break;case 13:L()?ae():al=false;break;case 66:case 190:aa(); +break;case 70:ab();break;default:al=false;}if(al){an.preventDefault();}else{if(an.keyCode===27&&T){X();an.preventDefault();}}O();}function A(al){ac.startX=al.touches[0].clientX; +ac.startY=al.touches[0].clientY;ac.startCount=al.touches.length;if(al.touches.length===2&&R.overview){ac.startSpan=S({x:al.touches[1].clientX,y:al.touches[1].clientY},{x:ac.startX,y:ac.startY}); +}}function af(aq){if(!ac.handled){var ao=aq.touches[0].clientX;var an=aq.touches[0].clientY;if(aq.touches.length===2&&ac.startCount===2&&R.overview){var ap=S({x:aq.touches[1].clientX,y:aq.touches[1].clientY},{x:ac.startX,y:ac.startY}); +if(Math.abs(ac.startSpan-ap)>ac.threshold){ac.handled=true;if(ap<ac.startSpan){I();}else{ae();}}aq.preventDefault();}else{if(aq.touches.length===1&&ac.startCount!==2){var am=ao-ac.startX,al=an-ac.startY; +if(am>ac.threshold&&Math.abs(am)>Math.abs(al)){ac.handled=true;B();}else{if(am<-ac.threshold&&Math.abs(am)>Math.abs(al)){ac.handled=true;j();}else{if(al>ac.threshold){ac.handled=true; +u();}else{if(al<-ac.threshold){ac.handled=true;F();}}}}aq.preventDefault();}}}else{if(navigator.userAgent.match(/android/gi)){aq.preventDefault();}}}function W(al){ac.handled=false; +}function o(al){clearTimeout(z);z=setTimeout(function(){var am=al.detail||-al.wheelDelta;if(am>0){x();}else{Z();}},100);}function ai(am){var al=Array.prototype.slice.call(document.querySelectorAll(l)).length; +var an=Math.floor((am.clientX/f.wrapper.offsetWidth)*al);a(an);}function w(al){J();}function C(al){if(L()){al.preventDefault();ae();m=this.getAttribute("data-index-h"); +e=this.getAttribute("data-index-v");a();}}return{initialize:i,slide:a,left:B,right:j,up:u,down:F,prev:Z,next:x,prevFragment:Q,nextFragment:v,navigateTo:a,navigateLeft:B,navigateRight:j,navigateUp:u,navigateDown:F,navigatePrev:Z,navigateNext:x,toggleOverview:X,addEventListeners:E,removeEventListeners:U,getIndices:M,getPreviousSlide:function(){return y; +},getCurrentSlide:function(){return G;},getQueryHash:function(){var al={};location.search.replace(/[A-Z0-9]+?=(\w*)/gi,function(am){al[am.split("=").shift()]=am.split("=").pop(); +});return al;},addEventListener:function(am,an,al){if("addEventListener" in window){(f.wrapper||document.querySelector(".reveal")).addEventListener(am,an,al); +}},removeEventListener:function(am,an,al){if("addEventListener" in window){(f.wrapper||document.querySelector(".reveal")).removeEventListener(am,an,al); +}}};})();
\ No newline at end of file diff --git a/plugin/notes/notes.html b/plugin/notes/notes.html index 485edec..013a18b 100644 --- a/plugin/notes/notes.html +++ b/plugin/notes/notes.html @@ -109,45 +109,30 @@ window.addEventListener( 'message', function( event ) { var data = JSON.parse( event.data ); - - if( data.markdown ) { - notes.innerHTML = (new Showdown.converter()).makeHtml( data.notes ); - } - else { - notes.innerHTML = data.notes; + // No need for updating the notes in case of fragment changes + if ( data.notes !== undefined) { + if( data.markdown ) { + notes.innerHTML = (new Showdown.converter()).makeHtml( data.notes ); + } + else { + notes.innerHTML = data.notes; + } } - // Kill the slide listeners while responding to the event - removeSlideListeners(); - // Update the note slides currentSlide.contentWindow.Reveal.slide( data.indexh, data.indexv ); nextSlide.contentWindow.Reveal.slide( data.nextindexh, data.nextindexv ); - // Resume listening on the next cycle - setTimeout( addSlideListeners, 1 ); + // Showing and hiding fragments + if( data.fragment === 'next' ) { + currentSlide.contentWindow.Reveal.nextFragment(); + } + else if( data.fragment === 'prev' ) { + currentSlide.contentWindow.Reveal.prevFragment(); + } }, false ); - function addSlideListeners() { - currentSlide.contentWindow.Reveal.addEventListener( 'slidechanged', onNotesSlideChange, false ); - nextSlide.contentWindow.Reveal.addEventListener( 'slidechanged', onNotesSlideChange, false ); - } - - function removeSlideListeners() { - currentSlide.contentWindow.Reveal.removeEventListener( 'slidechanged', onNotesSlideChange, false ); - nextSlide.contentWindow.Reveal.removeEventListener( 'slidechanged', onNotesSlideChange, false ); - } - - function onNotesSlideChange( event ) { - window.opener.postMessage( JSON.stringify({ - indexh : event.indexh, - indexv : event.indexv - }), '*' ); - } - - addSlideListeners(); - })( window ); }, false ); diff --git a/plugin/notes/notes.js b/plugin/notes/notes.js index 729dad3..7c83366 100644 --- a/plugin/notes/notes.js +++ b/plugin/notes/notes.js @@ -7,54 +7,78 @@ var RevealNotes = (function() { function openNotes() { var notesPopup = window.open( 'plugin/notes/notes.html', 'reveal.js - Notes', 'width=1120,height=850' ); - Reveal.addEventListener( 'slidechanged', post ); + // Fires when slide is changed + Reveal.addEventListener( 'slidechanged', function( event ) { + post('slidechanged'); + } ); - // Posts the current slide data to the notes window - function post() { - var slideElement = Reveal.getCurrentSlide(), - indexh = Reveal.getIndices().h, - indexv = Reveal.getIndices().v, - nextindexh, - nextindexv; + // Fires when a fragment is shown + Reveal.addEventListener( 'fragmentshown', function( event ) { + post('fragmentshown'); + } ); - if( slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION' ) { - nextindexh = indexh; - nextindexv = indexv + 1; - } else { - nextindexh = indexh + 1; - nextindexv = 0; - } + // Fires when a fragment is hidden + Reveal.addEventListener( 'fragmenthidden', function( event ) { + post('fragmenthidden'); + } ); - var notes = slideElement.querySelector( 'aside.notes' ); + /** + * Posts the current slide data to the notes window + * + * @param {String} eventType Expecting 'slidechanged', 'fragmentshown' + * or 'fragmenthidden' set in the events above to define the needed + * slideDate. + */ + function post( eventType ) { + var slideElement = Reveal.getCurrentSlide(), + messageData; - var slideData = { - notes : notes ? notes.innerHTML : '', - indexh : indexh, - indexv : indexv, - nextindexh : nextindexh, - nextindexv : nextindexv, - markdown : notes ? typeof notes.getAttribute( 'data-markdown' ) === 'string' : false - }; + if( eventType === 'slidechanged' ) { + var notes = slideElement.querySelector( 'aside.notes' ), + indexh = Reveal.getIndices().h, + indexv = Reveal.getIndices().v, + nextindexh, + nextindexv; - notesPopup.postMessage( JSON.stringify( slideData ), '*' ); - } + if( slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION' ) { + nextindexh = indexh; + nextindexv = indexv + 1; + } else { + nextindexh = indexh + 1; + nextindexv = 0; + } - // The main presentation is kept in sync when navigating the - // note slides so that the popup may be used as a remote - window.addEventListener( 'message', function( event ) { - var data = JSON.parse( event.data ); - - if( data && typeof data.indexh === 'number' && typeof data.indexv === 'number' ) { - Reveal.slide( data.indexh, data.indexv ); + messageData = { + notes : notes ? notes.innerHTML : '', + indexh : indexh, + indexv : indexv, + nextindexh : nextindexh, + nextindexv : nextindexv, + markdown : notes ? typeof notes.getAttribute( 'data-markdown' ) === 'string' : false + }; } - } ); + else if( eventType === 'fragmentshown' ) { + messageData = { + fragment : 'next' + }; + } + else if( eventType === 'fragmenthidden' ) { + messageData = { + fragment : 'prev' + }; + } + + notesPopup.postMessage( JSON.stringify( messageData ), '*' ); + } // Navigate to the current slide when the notes are loaded - notesPopup.addEventListener( 'load', post, false ); + notesPopup.addEventListener( 'load', function( event ) { + post('slidechanged'); + }, false ); } // If the there's a 'notes' query set, open directly - if( window.location.search.match(/(\?|\&)notes/gi ) !== null ) { + if( window.location.search.match( /(\?|\&)notes/gi ) !== null ) { openNotes(); } @@ -70,5 +94,5 @@ var RevealNotes = (function() { } }, false ); - return { open: openNotes } -})();
\ No newline at end of file + return { open: openNotes }; +})(); |