- Timestamp:
- 11/26/2019 06:19:54 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentytwenty/assets/js/index.js
r46701 r46786 72 72 // Add a class to the body for when touch is enabled for browsers that don't support media queries 73 73 // for interaction media features. Adapted from <https://codepen.io/Ferie/pen/vQOMmO> 74 ( function() { 75 var matchMedia = function() { 76 // Include the 'heartz' as a way to have a non matching MQ to help terminate the join. See <https://git.io/vznFH>. 77 var prefixes = [ '-webkit-', '-moz-', '-o-', '-ms-' ]; 78 var query = [ '(', prefixes.join( 'touch-enabled),(' ), 'heartz', ')' ].join( '' ); 79 return window.matchMedia && window.matchMedia( query ).matches; 80 }; 81 82 if ( ( 'ontouchstart' in window ) || ( window.DocumentTouch && document instanceof window.DocumentTouch ) || matchMedia() ) { 83 document.body.classList.add( 'touch-enabled' ); 84 } 85 }() ); 74 twentytwenty.touchEnabled = { 75 76 init: function() { 77 var matchMedia = function() { 78 // Include the 'heartz' as a way to have a non matching MQ to help terminate the join. See <https://git.io/vznFH>. 79 var prefixes = [ '-webkit-', '-moz-', '-o-', '-ms-' ]; 80 var query = [ '(', prefixes.join( 'touch-enabled),(' ), 'heartz', ')' ].join( '' ); 81 return window.matchMedia && window.matchMedia( query ).matches; 82 }; 83 84 if ( ( 'ontouchstart' in window ) || ( window.DocumentTouch && document instanceof window.DocumentTouch ) || matchMedia() ) { 85 document.body.classList.add( 'touch-enabled' ); 86 } 87 } 88 }; // twentytwenty.touchEnabled 86 89 87 90 /* ----------------------------------------------------------------------------------------------- … … 746 749 twentytwenty.modalMenu.init(); // Modal Menu 747 750 twentytwenty.primaryMenu.init(); // Primary Menu 751 twentytwenty.touchEnabled.init(); // Add class to body if device is touch-enabled 748 752 } ); 749 753
Note: See TracChangeset
for help on using the changeset viewer.