barraq / deck.ext.js

Provide extensions, themes and use cases for deck.js
17 stars 7 forks source link

deck.toc.js not reading h3 correctly #3

Open vaughany opened 12 years ago

vaughany commented 12 years ago

I've just installed deck.toc.js into the default example/index.html file, and noticed that while it works well, it's not reading all the

tags on the #how-to-overview slide.

I should see:

  • How to Make a Deck
    • Write Slides
    • Choose Themes
    • Include Extensions
  • The Markup
  • ...

...but all I am seeing in the ToC pop-up is:

  • How to make a Deck
    • Write Slides
  • The Markup
  • ...

barraq commented 12 years ago

Hi, I'm not sure to understand you well, which example/index.html are you talking about? can you copy and past it here so that I can see the problem. Best, Rémi

vaughany commented 12 years ago

Hi Rémi.

Sorry for the confusion. I meant "introduction", not "example". The file I am referring to is part of the deck.js distribution which I added deck.ext.js to:

https://github.com/imakewebthings/deck.js/blob/master/introduction/index.html

barraq commented 12 years ago

Ok, well the deck.toc.js extension currently only supports one <h*> per slide, therefore in the following only the h2 will be displayed...

  <section class="slide" id="how-to-overview">
    <h2>How to Make a Deck</h2>
    <ol>
        <li>
            <h3>Write Slides</h3>
            <p>Slide content is simple&nbsp;HTML.</p>
        </li>
        <li>
            <h3>Choose Themes</h3>
            <p>One for slide styles and one for deck&nbsp;transitions.</p>
        </li>
        <li>
            <h3>Include Extensions</h3>
            <p>Add extra functionality to your deck, or leave it stripped&nbsp;down.</p>
        </li>
    </ol>
  </section>
twitwi commented 12 years ago

Hi Rémi :), I think I experimented with the toc with only h2 and it was not working. I have a custom experimental branch where I had this fix to make it work:

@@ -217,7 +217,12 @@ This module provides a support for TOC to the deck.
             /* insert it at the right place */
             var $target = this.root;
             if( depth > 1) {
-                $target = ($target.find("li#toc-"+($c.slice(0,$c.length-1).join('-')))).children("ul");
+                $target = $target.find("li#toc-"+($c.slice(0,$c.length-1).join('-')));
+                if( $target.length > 0 ) {
+                    $target = $target.children("ul");
+                } else {
+                    $target = this.root;
+                }
             }
             $tocElm.appendTo($target);
         };

I did not really dig more but I remember it kind of fixes the problem.

Rémi @twitwi