Fixes #28: Stop propagation of key events from editable elements within slides

This commit is contained in:
imakewebthings 2011-09-14 23:38:52 +08:00
parent cfcc3dea76
commit 57c92b2af3
3 changed files with 16 additions and 3 deletions

View file

@ -135,7 +135,10 @@ that use the API provided by core.
init: function(elements, opts) {
var startTouch,
$c,
tolerance;
tolerance,
esp = function(e) {
e.stopPropagation();
};
options = $.extend(true, {}, $[deck].defaults, opts);
slides = [];
@ -199,7 +202,10 @@ that use the API provided by core.
}
});
})
.scrollLeft(0).scrollTop(0);
.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);
/*
Kick iframe videos, which dont like to redraw w/ transforms.

View file

@ -29,7 +29,7 @@
</div>
<div class="alt-container">
<div class="alt-slide alt-slide1"></div>
<div class="alt-slide alt-slide1"><input></div>
<div class="alt-slide alt-slide2"></div>

View file

@ -224,6 +224,13 @@ describe('Deck JS', function() {
$d.trigger(e);
expect($.deck('getSlide')).toHaveClass('alt-slide1');
});
it('should not trigger events that originate within editable elements', function() {
e = jQuery.Event('keydown');
e.which = 87;
$('.alt-slide1 input').trigger(e);
expect($.deck('getSlide')).toHaveClass('alt-slide1');
});
});
});