Skip to content
Browse files

Improve Enter key behavior in Opera

  • Loading branch information...
1 parent 6109113 commit 541097e13a251c4d652010fd3842c75886eae980 @mathiasbynens committed Mar 15, 2012
Showing with 4 additions and 4 deletions.
  1. +2 −2 jquery.details.js
  2. +2 −2 jquery.details.min.js
View
4 jquery.details.js
@@ -1,4 +1,4 @@
-/*! http://mths.be/details v0.0.5 by @mathias | includes http://mths.be/noselect v1.0.3 */
+/*! http://mths.be/details v0.0.6 by @mathias | includes http://mths.be/noselect v1.0.3 */
;(function(document, $) {
var proto = $.fn,
@@ -131,7 +131,7 @@
// Toggle the `open` and `aria-expanded` attributes and the `open` property of the `details` element and display the additional info
toggleOpen($details, $detailsSummary, $detailsNotSummary, true);
}).keyup(function(event) {
- if (32 == event.keyCode && !isOpera || 13 == event.keyCode) {
+ if (32 == event.keyCode || (13 == event.keyCode && !isOpera)) {
// Space or Enter is pressed — trigger the `click` event on the `summary` element
// Opera already seems to trigger the `click` event when Enter is pressed
event.preventDefault();
View
4 jquery.details.min.js
@@ -1,2 +1,2 @@
-/*! http://mths.be/details v0.0.5 by @mathias | includes http://mths.be/noselect v1.0.3 */
-;(function(a,$){var e=$.fn,d,c=Object.prototype.toString.call(window.opera)=='[object Opera]',f=(function(k){var i=k.createElement('details'),h,g,j;if(!('open' in i)){return false}g=k.body||(function(){var l=k.documentElement;h=true;return l.insertBefore(k.createElement('body'),l.firstElementChild||l.firstChild)}());i.innerHTML='<summary>a</summary>b';i.style.display='block';g.appendChild(i);j=i.offsetHeight;i.open=true;j=j!=i.offsetHeight;g.removeChild(i);if(h){g.parentNode.removeChild(g)}return j}(a)),b=function(h,k,j,g){var i=typeof h.attr('open')=='string',l=i&&g||!i&&!g;if(l){h.removeClass('open').prop('open',false).triggerHandler('close.details');k.attr('aria-expanded',false);j.hide()}else{h.addClass('open').prop('open',true).triggerHandler('open.details');k.attr('aria-expanded',true);j.show()}};e.noSelect=function(){var g='none';return this.bind('selectstart dragstart mousedown',function(){return false}).css({MozUserSelect:g,msUserSelect:g,webkitUserSelect:g,userSelect:g})};if(f){d=e.details=function(){return this.each(function(){var h=$(this),g=$('summary',h).first();g.attr({role:'button','aria-expanded':h.prop('open')}).on('click',function(){var i=h.prop('open');g.attr('aria-expanded',!i);h.triggerHandler((i?'close':'open')+'.details')})})};d.support=f}else{d=e.details=function(){return this.each(function(){var g=$(this),i=$('summary',g).first(),h=g.children(':not(summary)'),j=g.contents(':not(summary)');if(!i.length){i=$('<summary>').text('Details').prependTo(g)}if(h.length!=j.length){j.filter(function(){return this.nodeType==3&&/[^ \t\n\f\r]/.test(this.data)}).wrap('<span>');h=g.children(':not(summary)')}b(g,i,h);i.attr('role','button').noSelect().prop('tabIndex',0).on('click',function(){i.focus();b(g,i,h,true)}).keyup(function(k){if(32==k.keyCode&&!c||13==k.keyCode){k.preventDefault();i.click()}})})};d.support=f}}(document,jQuery));
+/*! http://mths.be/details v0.0.6 by @mathias | includes http://mths.be/noselect v1.0.3 */
+;(function(a,$){var e=$.fn,d,c=Object.prototype.toString.call(window.opera)=='[object Opera]',f=(function(k){var i=k.createElement('details'),h,g,j;if(!('open' in i)){return false}g=k.body||(function(){var l=k.documentElement;h=true;return l.insertBefore(k.createElement('body'),l.firstElementChild||l.firstChild)}());i.innerHTML='<summary>a</summary>b';i.style.display='block';g.appendChild(i);j=i.offsetHeight;i.open=true;j=j!=i.offsetHeight;g.removeChild(i);if(h){g.parentNode.removeChild(g)}return j}(a)),b=function(h,k,j,g){var i=typeof h.attr('open')=='string',l=i&&g||!i&&!g;if(l){h.removeClass('open').prop('open',false).triggerHandler('close.details');k.attr('aria-expanded',false);j.hide()}else{h.addClass('open').prop('open',true).triggerHandler('open.details');k.attr('aria-expanded',true);j.show()}};e.noSelect=function(){var g='none';return this.bind('selectstart dragstart mousedown',function(){return false}).css({MozUserSelect:g,msUserSelect:g,webkitUserSelect:g,userSelect:g})};if(f){d=e.details=function(){return this.each(function(){var h=$(this),g=$('summary',h).first();g.attr({role:'button','aria-expanded':h.prop('open')}).on('click',function(){var i=h.prop('open');g.attr('aria-expanded',!i);h.triggerHandler((i?'close':'open')+'.details')})})};d.support=f}else{d=e.details=function(){return this.each(function(){var g=$(this),i=$('summary',g).first(),h=g.children(':not(summary)'),j=g.contents(':not(summary)');if(!i.length){i=$('<summary>').text('Details').prependTo(g)}if(h.length!=j.length){j.filter(function(){return this.nodeType==3&&/[^ \t\n\f\r]/.test(this.data)}).wrap('<span>');h=g.children(':not(summary)')}b(g,i,h);i.attr('role','button').noSelect().prop('tabIndex',0).on('click',function(){i.focus();b(g,i,h,true)}).keyup(function(k){if(32==k.keyCode||(13==k.keyCode&&!c)){k.preventDefault();i.click()}})})};d.support=f}}(document,jQuery));

0 comments on commit 541097e

Please sign in to comment.
Something went wrong with that request. Please try again.