? system.js
Index: system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.435
diff -u -r1.435 system.module
--- system.module	2 Jan 2007 05:05:38 -0000	1.435
+++ system.module	5 Jan 2007 08:29:19 -0000
@@ -1249,6 +1249,10 @@
 
   // Array for disabling checkboxes in callback system_module_disable.
   $disabled = array();
+  // Array of dependencies for passing to js.
+  $dependencies_js = array();
+  // Array of dependents for passing to js.
+  $dependents_js = array();
   // Traverse the files retrieved and build the form.
   foreach ($files as $filename => $file) {
     $form['name'][$filename] = array('#value' => $file->info['name']);
@@ -1265,6 +1269,7 @@
     $dependencies = array();
     // Check for missing dependencies.
     if (is_array($file->info['dependencies'])) {
+      $dependencies_js[$file->name] = $file->info['dependencies'];
       foreach ($file->info['dependencies'] as $dependency) {
         if (!isset($files[$dependency]) || !$files[$dependency]->status) {
           if (isset($files[$dependency])) {
@@ -1294,6 +1299,7 @@
     // Mark dependents disabled so user can not remove modules being depended on.
     $dependents = array();
     if (is_array($file->info['dependents'])) {
+      $dependents_js[$file->name] = $file->info['dependents'];
       foreach ($file->info['dependents'] as $dependent) {
         if ($files[$dependent]->status == 1) {
           $dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-enabled">enabled</span>)');
@@ -1316,6 +1322,10 @@
     }
   }
 
+  // Pass dependency data to the browser.
+  drupal_add_js(array('moduleDependencies' => array('dependencies' => $dependencies_js, 'dependents' => $dependents_js)), 'setting');
+  drupal_add_js(drupal_get_path('module', 'system') .'/system.js');
+
   // Merge in required modules.
   $modules_required = array('block', 'filter', 'node', 'system', 'user', 'watchdog');
   foreach ($modules_required as $required) {
--- modules/system/system.js
+++ modules/system/system.js
@@ -0,0 +1,46 @@
+/* $Id: $ */++Drupal.systemAutoAttach = function () {+  $('#system-modules input[@type=checkbox]')+    .click(function () {+      Drupal.moduleDependencies(this);+    });+}++Drupal.moduleDependencies = function (elt) {+  var dependencies = Drupal.settings.moduleDependencies['dependencies'][elt.value];+  if (dependencies && dependencies.length) {+    for (i in dependencies) {+      $('#edit-status-' + dependencies[i]).each(function () {+        if (elt.checked) {+          $(this)+            .attr('checked', 'checked')+            .attr('disabled', 'disabled');+        }+        else {+          if ($(this).attr('disabled')) {+            var disabled = false;+            var dependents = Drupal.settings.moduleDependencies['dependents'][dependencies[i]];+            if (dependents && dependents.length) {+              for (j in dependents) {+                if ($('#edit-status-' + dependents[j]).attr('checked')) {+                  disabled = true;+                  break;+                }+              }+              if (disabled == false) {+                $('#edit-status-' + dependencies[i]).attr('disabled', false);+              }+            }+          }+        }+        Drupal.moduleDependencies(this);+      });+    }+  }+}++// Global killswitch.+if (Drupal.jsEnabled) {+  $(document).ready(Drupal.systemAutoAttach);+}