From d027a17fc6c324171a525e7c30eda5732f9b3243 Mon Sep 17 00:00:00 2001 From: imakewebthings Date: Mon, 9 Jan 2012 13:18:32 -0800 Subject: [PATCH] Add countNested option to deck.goto for #58 --- extensions/goto/deck.goto.js | 47 +++++++++++++++++++++++++++++++----- test/fixtures/nesteds.html | 2 +- test/spec.goto.js | 14 +++++++++++ 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/extensions/goto/deck.goto.js b/extensions/goto/deck.goto.js index 21ec43c..ad79f82 100644 --- a/extensions/goto/deck.goto.js +++ b/extensions/goto/deck.goto.js @@ -39,6 +39,10 @@ the deck container. options.keys.goto The numeric keycode used to show the Go To Slide form. + + options.countNested + If false, only top level slides will be counted when entering a + slide number. */ $.extend(true, $[deck].defaults, { classes: { @@ -53,7 +57,9 @@ the deck container. keys: { goto: 71 // g - } + }, + + countNested: true }); /* @@ -89,7 +95,17 @@ the deck container. $d.bind('deck.init', function() { var opts = $[deck]('getOptions'), - $datalist = $(opts.selectors.gotoDatalist); + $datalist = $(opts.selectors.gotoDatalist), + slideTest = $.map([ + opts.classes.before, + opts.classes.previous, + opts.classes.current, + opts.classes.next, + opts.classes.after + ], function(el, i) { + return '.' + el; + }).join(', '), + rootCounter = 1; // Bind key events $d.unbind('keydown.deckgoto').bind('keydown.deckgoto', function(e) { @@ -101,13 +117,22 @@ the deck container. } }); - /* Populate datalist */ + /* Populate datalist and work out countNested*/ $.each($[deck]('getSlides'), function(i, $slide) { - var id = $slide.attr('id'); + var id = $slide.attr('id'), + $parentSlides = $slide.parentsUntil(opts.selectors.container, slideTest); if (id) { $datalist.append('