details.js 990 B

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * DO NOT EDIT THIS FILE.
  3. * See the following change record for more information,
  4. * https://www.drupal.org/node/2815083
  5. * @preserve
  6. **/
  7. (function ($, Modernizr, Drupal) {
  8. Drupal.behaviors.claroDetails = {
  9. attach: function attach(context) {
  10. $(context).once('claroDetails').on('click', function (event) {
  11. if (event.target.nodeName === 'SUMMARY') {
  12. $(event.target).trigger('focus');
  13. }
  14. });
  15. }
  16. };
  17. Drupal.behaviors.claroDetailsToggleShim = {
  18. attach: function attach(context) {
  19. if (Modernizr.details || !Drupal.CollapsibleDetails.instances.length) {
  20. return;
  21. }
  22. $(context).find('details .details-title').once('claroDetailsToggleShim').on('keypress', function (event) {
  23. var keyCode = event.keyCode || event.charCode;
  24. if (keyCode === 32) {
  25. $(event.target).closest('summary').trigger('click');
  26. event.preventDefault();
  27. }
  28. });
  29. }
  30. };
  31. })(jQuery, Modernizr, Drupal);