bespokejs / bespoke

DIY Presentation Micro-Framework

Home Page:http://markdalgleish.com/projects/bespoke.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add control over which children become slides

mojavelinux opened this issue · comments

Currently, any direct child of the parent element becomes a slide. This is not always the desired behavior. Certain plugins or situations may want to allow child elements to be inserted for auxiliary purposes, or to allow slides to be excluded (an abbreviated presentation). For these reasons, it would be nice if the from method allowed both the parent and the child selectors to be specified.

I propose that we allow the argument to be an array. The second item in the array is assumed to be the child selector or collection of nodes.

bespoke.from(['article', 'article > section'], [(plugins)]);

I'd also be open to using a Hash if the Array argument seems to cryptic:

bespoke.from({ container: 'article', slides: 'article > section' }, [(plugins)]);

or

bespoke.from({ parent: 'article', slides: 'article > section' }, [(plugins)]);

If we want to shorten it slightly, we could automatically prepend the container/parent selector the the slides selector so it can be written as:

bespoke.from({ parent: 'article', slides: '> section' }, [(plugins)]);

This would also ensure that they are descendant elements.

Actually, we can just use querySelectorAll from the parent element to limit the scope.

Let me know if you want the key for the parent to be parent or container. I'll update the PR accordingly.

...or whether you'd like to use an array.