bespokejs / bespoke

DIY Presentation Micro-Framework
http://markdalgleish.com/projects/bespoke.js/
MIT License
4.68k stars 443 forks source link

Add control over which children become slides #61

Closed mojavelinux closed 9 years ago

mojavelinux commented 9 years ago

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.

mojavelinux commented 9 years ago

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

mojavelinux commented 9 years ago

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.