Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/compact_forms/CHANGELOG.txt,v
retrieving revision 1.3
diff -u -p -r1.3 CHANGELOG.txt
--- CHANGELOG.txt	2 May 2009 00:39:31 -0000	1.3
+++ CHANGELOG.txt	3 May 2009 19:01:23 -0000
@@ -6,6 +6,8 @@ Compact Forms x.x-x.x, xxxx-xx-xx
 
 Compact Forms 6.x-1.x, xxxx-xx-xx
 ---------------------------------
+#404132 by sun: Fixed page requisites only need to be loaded on pages containing
+  configured forms.
 #404132 by sun: Changed order of functions.
 #243952 by sun: Ported to 6.x.
 #404132 by sun: Major rewrite:
Index: compact_forms.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/compact_forms/compact_forms.admin.inc,v
retrieving revision 1.1
diff -u -p -r1.1 compact_forms.admin.inc
--- compact_forms.admin.inc	1 May 2009 23:10:11 -0000	1.1
+++ compact_forms.admin.inc	3 May 2009 19:04:34 -0000
@@ -16,7 +16,7 @@ function compact_forms_admin_form() {
     '#rows' => 3,
     '#cols' => 40,
     '#default_value' => variable_get('compact_forms_ids', 'user-login-form'),
-    '#description' => 'Enter the CSS #id of the forms that you want to activate compact_forms for. One per line.',
+    '#description' => t('Enter the CSS #id of the forms that you want to activate compact_forms for. One per line.'),
   );
   $form['compact_forms_stars'] = array(
     '#title' => t('"Required field" - stars'),
Index: compact_forms.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/compact_forms/compact_forms.js,v
retrieving revision 1.2
diff -u -p -r1.2 compact_forms.js
--- compact_forms.js	1 May 2009 23:10:11 -0000	1.2
+++ compact_forms.js	3 May 2009 18:27:29 -0000
@@ -2,8 +2,6 @@
 
 (function ($) {
 
-Drupal.behaviors = Drupal.behaviors || {}; // D5 only.
-
 /**
  * Compact Forms jQuery plugin.
  */
@@ -64,9 +62,4 @@ Drupal.behaviors.compactForms = function
   });
 }
 
-// D5 only.
-$(document).ready(function () {
-  Drupal.behaviors.compactForms(this);
-});
-
 })(jQuery);
Index: compact_forms.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/compact_forms/compact_forms.module,v
retrieving revision 1.4
diff -u -p -r1.4 compact_forms.module
--- compact_forms.module	2 May 2009 00:39:31 -0000	1.4
+++ compact_forms.module	3 May 2009 18:58:24 -0000
@@ -39,37 +39,48 @@ function compact_forms_menu() {
 }
 
 /**
- * Implementation of hook_init().
- */
-function compact_forms_init() {
-  // Load our behavior.
-  _compact_forms_include_js();
-}
-
-/**
  * Implementation of hook_form_alter().
  */
 function compact_forms_form_alter(&$form, $form_state, $form_id) {
-  static $ids;
+  static $css_ids, $form_ids, $loaded, $field_size, $descriptions;
 
-  $field_size = variable_get('compact_forms_field_size', '');
-  $descriptions = variable_get('compact_forms_descriptions', 1);
-  // Nothing to do if no custom field size was configured and form element
-  // descriptions shall not be hidden.
-  if (empty($field_size) && !empty($descriptions)) {
-    return;
+  // Prepare CSS form ids.
+  if (!isset($css_ids)) {
+    $css_ids = explode("\n", variable_get('compact_forms_ids', 'user-login-form'));
+    $css_ids = array_filter(array_map('trim', $css_ids));
+  }
+  // Prepare Form API form ids.
+  if (!isset($form_ids) && !empty($css_ids)) {
+    $form_ids = array();
+    foreach ($css_ids as $id) {
+      $form_ids[] = strtr($id, array('-' => '_'));
+    }
   }
-
-  if (!isset($ids)) {
-    $ids = explode("\n", str_replace('-', '_', variable_get('compact_forms_ids', "user-login-form")));
+  // Prepare form alteration settings.
+  if (!isset($field_size)) {
+    $field_size = variable_get('compact_forms_field_size', '');
+    $descriptions = variable_get('compact_forms_descriptions', 1);
   }
-  if (in_array($form_id, $ids)) {
-    _compact_forms_resize_fields($form, $field_size, $descriptions);
+
+  if (in_array($form_id, $form_ids)) {
+    // Load our page requisites and JavaScript settings.
+    if (!isset($loaded)) {
+      _compact_forms_include_js($css_ids);
+      $loaded = TRUE;
+    }
+    // Only alter the form if a custom field size is configured or form element
+    // descriptions shall be hidden.
+    if (!empty($field_size) || !$descriptions) {
+      _compact_forms_resize_fields($form, $field_size, $descriptions);
+    }
   }
 }
 
 /**
- * Iterator.
+ * Helper function to recursively alter form elements.
+ *
+ * @todo Perform this in #after_build instead. - Or use hook_elements() to
+ *   append a #process function to all supported elements.
  */
 function _compact_forms_resize_fields(&$form, $field_size, $descriptions) {
   if (empty($form) || !is_array($form)) {
@@ -100,24 +111,22 @@ function _compact_forms_resize_fields(&$
 
 /**
  * Include JavaScript and CSS and attach behaviors to all selected forms.
+ *
+ * @param $css_ids
+ *   An array containing CSS form ids.
  */
-function _compact_forms_include_js() {
-  $ids = explode("\n", variable_get('compact_forms_ids', 'user-login-form'));
-  $ids = array_filter(array_map('trim', $ids));
-
-  if (!empty($ids)) {
-    $path = drupal_get_path('module', 'compact_forms');
-    drupal_add_js($path . '/compact_forms.js');
-    drupal_add_css($path . '/compact_forms.css');
-
-    $settings = array(
-      'compactForms' => array(
-        'forms' => $ids,
-        'stars' => (int) variable_get('compact_forms_stars', 2),
-        'colons' => (int) variable_get('compact_forms_colons', 0),
-      ),
-    );
-    drupal_add_js($settings, 'setting');
-  }
+function _compact_forms_include_js($css_ids) {
+  $path = drupal_get_path('module', 'compact_forms');
+  drupal_add_js($path . '/compact_forms.js');
+  drupal_add_css($path . '/compact_forms.css');
+
+  $settings = array(
+    'compactForms' => array(
+      'forms' => $css_ids,
+      'stars' => (int) variable_get('compact_forms_stars', 2),
+      'colons' => (int) variable_get('compact_forms_colons', 0),
+    ),
+  );
+  drupal_add_js($settings, 'setting');
 }
 
