mediawiki-extensions-Popups/resources/ext.popups/index.js
Jon Robson 8f03303dc4 Restrict page previews to browsers that support multiple not selectors
Change-Id: Ia45c03d1fd6949bf83ebed6d40075e453e42cdd7
2023-05-12 13:43:18 -07:00

24 lines
894 B
JavaScript

var types = require( './types.json' );
// Load Popups when touch events are not available in the browser (e.g. not a mobile device).
var isTouchDevice = 'ontouchstart' in document.documentElement;
var supportNotQueries;
try {
supportNotQueries = document.body.matches( 'div:not(.foo,.bar)' );
supportNotQueries = true;
} catch ( e ) {
supportNotQueries = false;
}
if ( !isTouchDevice && supportNotQueries ) {
mw.loader.using( types.concat( [ 'ext.popups.main' ] ) ).then( function () {
// Load custom popup types
types.forEach( function ( moduleName ) {
var module = require( moduleName );
mw.popups.register( module );
} );
// For now this API is limited to extensions/skins as we have not had a chance to
// consider the implications of gadgets having access to this function and dealing with
// challenges such as selector overlap.
delete mw.popups.register;
} );
}