Skip to content

Commit

Permalink
Prevent key capture within ALL editable elements, not just those with…
Browse files Browse the repository at this point in the history
…in slides
  • Loading branch information
imakewebthings committed Jul 13, 2012
1 parent 3e327bd commit f13357d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions core/deck.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ that use the API provided by core.
methods.prev();
e.preventDefault();
}
});
})
/* Stop propagation of key events within editable elements */
.undelegate('input, textarea, select, button, meter, progress, [contentEditable]', 'keydown', esp)
.delegate('input, textarea, select, button, meter, progress, [contentEditable]', 'keydown', esp);

/* Bind touch events for swiping between slides on touch devices */
$container.unbind('touchstart.deck').bind('touchstart.deck', function(e) {
Expand Down Expand Up @@ -212,10 +215,7 @@ that use the API provided by core.
}
});
})
.scrollLeft(0).scrollTop(0)
/* Stop propagation of key events within editable elements of slides */
.undelegate('input, textarea, select, button, meter, progress, [contentEditable]', 'keydown', esp)
.delegate('input, textarea, select, button, meter, progress, [contentEditable]', 'keydown', esp);
.scrollLeft(0).scrollTop(0);

/*
Kick iframe videos, which dont like to redraw w/ transforms.
Expand Down
4 changes: 3 additions & 1 deletion test/spec.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,12 @@ describe('Deck JS', function() {
});

it('should not trigger events that originate within editable elements', function() {
var $outside = $('<input type="text" />').appendTo('body');
e = jQuery.Event('keydown');
e.which = 87;
$('.alt-slide1 input').trigger(e);
$outside.trigger(e);
expect($.deck('getSlide')).toHaveClass('alt-slide1');
$outside.remove();
});
});
});
Expand Down

0 comments on commit f13357d

Please sign in to comment.