prevent same theme from loading repeatedly
authorHakim El Hattab <hakim.elhattab@gmail.com>
Thu, 30 Aug 2012 05:13:25 +0000 (01:13 -0400)
committerHakim El Hattab <hakim.elhattab@gmail.com>
Thu, 30 Aug 2012 05:13:25 +0000 (01:13 -0400)
js/reveal.js
js/reveal.min.js

index 31b9bf1210b7a60b3484cc0dbceab206d5c36f43..593c32d6fe4eb9cfa411e24f0a0da91c379f821a 100644 (file)
@@ -226,8 +226,12 @@ var Reveal = (function(){
                        dom.progress.style.display = 'block';
                }
 
+               // Load the theme in the config, if it's not already loaded
                if( config.theme && dom.theme ) {
-                       dom.theme.setAttribute( 'href', 'css/theme/' + config.theme + '.css' );
+                       var themeURL = 'css/theme/' + config.theme + '.css';
+                       if( dom.theme.getAttribute( 'href' ) !== themeURL ) {
+                               dom.theme.setAttribute( 'href', themeURL );
+                       }
                }
 
                if( config.transition !== 'default' ) {
index cdc904a0ad59625b97294d485239673e75f7f2fa..a8161bf02dcb4dc4d5726d810d8bef912d7bd7af 100644 (file)
@@ -14,12 +14,13 @@ document.body.style.height="120%";window.addEventListener("load",X,false);window
 for(var af=0,ad=N.dependencies.length;af<ad;af++){var ag=N.dependencies[af];if(!ag.condition||ag.condition()){if(ag.async){ai.push(ag.src);}else{ae.push(ag.src);
 }if(typeof ag.callback==="function"){head.ready(ag.src.match(/([\w\d_-]*)\.?[^\\\/]*$/i)[0],ag.callback);}}}function ah(){head.js.apply(null,ai);F();}if(ae.length){head.ready(ah);
 head.js.apply(null,ae);}else{ah();}}function F(){C();I();H();K();}function I(){if(P===false){N.transition="linear";}if(N.controls&&d.controls){d.controls.style.display="block";
-}if(N.progress&&d.progress){d.progress.style.display="block";}if(N.theme&&d.theme){d.theme.setAttribute("href","css/theme/"+N.theme+".css");}if(N.transition!=="default"){d.wrapper.classList.add(N.transition);
-}if(N.mouseWheel){document.addEventListener("DOMMouseScroll",n,false);document.addEventListener("mousewheel",n,false);}if(N.rollingLinks){J();}}function C(){document.addEventListener("touchstart",y,false);
-document.addEventListener("touchmove",Z,false);document.addEventListener("touchend",S,false);window.addEventListener("hashchange",u,false);if(N.keyboard){document.addEventListener("keydown",aa,false);
-}if(N.controls&&d.controls){d.controlsLeft.addEventListener("click",o(z),false);d.controlsRight.addEventListener("click",o(i),false);d.controlsUp.addEventListener("click",o(s),false);
-d.controlsDown.addEventListener("click",o(D),false);}}function Q(){document.removeEventListener("keydown",aa,false);document.removeEventListener("touchstart",y,false);
-document.removeEventListener("touchmove",Z,false);document.removeEventListener("touchend",S,false);window.removeEventListener("hashchange",u,false);if(N.controls&&d.controls){d.controlsLeft.removeEventListener("click",o(z),false);
+}if(N.progress&&d.progress){d.progress.style.display="block";}if(N.theme&&d.theme){var ad="css/theme/"+N.theme+".css";if(d.theme.getAttribute("href")!==ad){d.theme.setAttribute("href",ad);
+}}if(N.transition!=="default"){d.wrapper.classList.add(N.transition);}if(N.mouseWheel){document.addEventListener("DOMMouseScroll",n,false);document.addEventListener("mousewheel",n,false);
+}if(N.rollingLinks){J();}}function C(){document.addEventListener("touchstart",y,false);document.addEventListener("touchmove",Z,false);document.addEventListener("touchend",S,false);
+window.addEventListener("hashchange",u,false);if(N.keyboard){document.addEventListener("keydown",aa,false);}if(N.controls&&d.controls){d.controlsLeft.addEventListener("click",o(z),false);
+d.controlsRight.addEventListener("click",o(i),false);d.controlsUp.addEventListener("click",o(s),false);d.controlsDown.addEventListener("click",o(D),false);
+}}function Q(){document.removeEventListener("keydown",aa,false);document.removeEventListener("touchstart",y,false);document.removeEventListener("touchmove",Z,false);
+document.removeEventListener("touchend",S,false);window.removeEventListener("hashchange",u,false);if(N.controls&&d.controls){d.controlsLeft.removeEventListener("click",o(z),false);
 d.controlsRight.removeEventListener("click",o(i),false);d.controlsUp.removeEventListener("click",o(s),false);d.controlsDown.removeEventListener("click",o(D),false);
 }}function r(ae,ad){for(var af in ad){ae[af]=ad[af];}}function O(af,ad){var ag=af.x-ad.x,ae=af.y-ad.y;return Math.sqrt(ag*ag+ae*ae);}function o(ad){return function(ae){ae.preventDefault();
 ad.call();};}function X(){setTimeout(function(){window.scrollTo(0,1);},0);}function aa(ae){if(ae.target.contentEditable!="inherit"||ae.shiftKey||ae.altKey||ae.ctrlKey||ae.metaKey){return;