Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions extensions/goto/deck.goto.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ the deck container.
var $document = $(document);
var rootCounter;

var maybeAddSnippet = function() {
var options = $.deck('getOptions');
if (options.snippets.goto) {
if ($(options.selectors.gotoForm).size() > 0 && options.alert.goto) {
alert("'options.snippets.goto' is true but a "+options.selectors.gotoForm+" has been found."
+"\nThis might cause interaction glitches."
+"\n"
+"\nSuggestion: remove your html snippet or pass the {snippets: {goto: false}} option."
);
}
$('<form/>').addClass('goto-form').attr('action', '.').attr('method', 'get')
.append($('<label/>').attr('for', 'goto-slide').text('Go to slide:'))
.append($('<input/>').attr('type', 'text').attr('id', 'goto-slide').attr('name', 'slidenum').attr('list', 'goto-datalist'))
.append($('<datalist/>').attr('id', 'goto-datalist'))
.append($('<input/>').attr('type', 'submit').attr('value', 'Go'))
.appendTo($.deck('getContainer'));
}
};

var bindKeyEvents = function() {
$document.unbind('keydown.deckgoto');
$document.bind('keydown.deckgoto', function(event) {
Expand Down Expand Up @@ -136,6 +155,14 @@ the deck container.
gotoInput: '#goto-slide'
},

snippets: {
goto: true
},

alert: {
goto: true
},

keys: {
goto: 71 // g
},
Expand Down Expand Up @@ -181,6 +208,7 @@ the deck container.
});

$document.bind('deck.init', function() {
maybeAddSnippet();
bindKeyEvents();
populateDatalist();
markRootSlides();
Expand Down