+
+ function areReqsSatisfied( name ) {
+ var i, ext, skin, node;
+ if ( !extDependencyMap[ name ] ) {
+ return true;
+ }
+
+ if ( extDependencyMap[ name ].extensions ) {
+ for ( i in extDependencyMap[ name ].extensions ) {
+ ext = extDependencyMap[ name ].extensions[ i ];
+ node = document.getElementById( 'config_ext-' + ext );
+ if ( !node || !node.checked ) {
+ return false;
+ }
+ }
+ }
+ if ( extDependencyMap[ name ].skins ) {
+ for ( i in extDependencyMap[ name ].skins ) {
+ skin = extDependencyMap[ name ].skins[ i ];
+ node = document.getElementById( 'config_skin-' + skin );
+ if ( !node || !node.checked ) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ // Disable checkboxes if the extension has dependencies
+ $( '.mw-ext-with-dependencies input' ).prop( 'disabled', true );
+ $( '.config-ext-input[data-name]' ).on( 'change', function () {
+ $( '.mw-ext-with-dependencies input' ).each( function () {
+ var name = this.getAttribute( 'data-name' );
+ if ( areReqsSatisfied( name ) ) {
+ // Re-enable it!
+ this.disabled = false;
+ } else {
+ // Uncheck and disable the checkbox
+ this.checked = false;
+ this.disabled = true;
+ }
+ } );
+ } );