<!---RevealJS--->
<script src="dependencies/revealjs/lib/js/head.min.js"></script>
<script src="dependencies/revealjs/js/reveal.js"></script>
<script>
  // Full list of configuration options available here:
  // https://github.com/hakimel/reveal.js#configuration
  Reveal.initialize({
    controls: false,
    progress: true,
    history: true,
    center: true,

    theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
    transition: Reveal.getQueryHash().transition || 'none', // default/cube/page/concave/zoom/linear/none
    backgroundTransition: 'none',

    // Optional libraries used to extend on reveal.js
    dependencies: [
      { src: 'dependencies/revealjs/lib/js/classList.js', condition: function() { return !document.body.classList; } },
      { src: 'dependencies/revealjs/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } },
      { src: 'dependencies/revealjs/plugin/zoom-js/zoom.js', condition: function() { return !!document.body.classList; } }
    ]
  });

  // SnapSVG
  // Run once at startup to inject all SVGs
  loadAllSvg();

  function loadAllSvg(){
    var els = document.getElementsByTagName("svg");

    for(var elCount = 0; elCount < els.length; elCount++){
        injectSvg(els[elCount]);
    }
  }

  function injectSvg(canvasTarget){
    if(canvasTarget){
      Snap.load(
        canvasTarget.getAttribute("data-path"),
        function (frag) {
          sCanvas = Snap("#" + canvasTarget.getAttribute("id"));
          fCanvas = Snap();
          sCanvas.clear();

          //Determine if grouped build-steps present
          var buildStepBase = frag.select("#base");
              buildStepGroups = frag.selectAll("[id^=step-]"),
              buildStepCount = buildStepGroups.length,
              buildStep = 0;

          //Setup the container canvas boundary sizing
          setCanvasBBox(frag, canvasTarget);

          // Show the first build step when available
          // Otherwise just show entire graphic
          if(buildStepCount > 0){
            // Include the non-fragment base layout/visuals
            fCanvas.append(buildStepBase);
            // fCanvas.append(buildStepGroups[buildStep]);

            for(; buildStep < buildStepCount; buildStep++){

              // Supports fragment in-out transitions by
              // wrapping in a group and applying a second
              // fragment class
              if(buildStepGroups[buildStep].node.id.match(/in-out/)){
                var tG = fCanvas.g(buildStepGroups[buildStep]);
                buildStepGroups[buildStep].attr("class", "fragment fade-out");
                tG.attr("class", "fragment");
                fCanvas.append(tG);
              }
              else{
                buildStepGroups[buildStep].attr("class", "fragment");
                fCanvas.append(buildStepGroups[buildStep]);
              }
            }
          } else{
            //No "steps" to build out, ensure boundary guide
            //is not rendered
            frag.select("#boundary").remove();
            fCanvas.append(frag);
          }

          sCanvas.append(fCanvas);
        }
      );
    }
  }

  function setCanvasBBox(canvas, target){
    var boundary,
        maxWidth,
        maxHeight;

    boundary = canvas.select("#boundary").select(":first-child").getBBox();
    maxWidth = Math.ceil(boundary.width);
    maxHeight = Math.ceil(boundary.height);

    target.setAttribute("height", (((maxHeight/maxWidth)*100)+"%"));
    target.setAttribute("viewBox", "0 0 " + maxWidth + " " + maxHeight);
    return canvas;
  }
</script>

<script src="dependencies/plugins/launcher/launcher.js"></script>
<script src="dependencies/plugins/help/help.js"></script>
