Index: compact_forms.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/compact_forms/compact_forms.js,v
retrieving revision 1.6
diff -u -p -r1.6 compact_forms.js
--- compact_forms.js	6 Aug 2009 20:27:22 -0000	1.6
+++ compact_forms.js	5 Jan 2010 14:55:24 -0000
@@ -2,6 +2,8 @@
 
 (function ($) {
 
+Drupal.compactForms = {};
+
 /**
  * Compact Forms jQuery plugin.
  */
@@ -19,7 +21,8 @@ $.fn.compactForm = function (stars, colo
       }
 
       if ($field.val() != '') {
-        $label.fadeOut(1);
+        // Firefox doesn't like .hide() here for some reason.
+        $label.css('display', 'none');
       }
 
       $label.parent().addClass('compact-form-wrapper');
@@ -35,30 +38,66 @@ $.fn.compactForm = function (stars, colo
 
       if (colons === 0) {
         var lbl = $label.html();
-        lbl = lbl.replace(/:/,' ');
+        lbl = lbl.replace(/:/, ' ');
         $label.html(lbl);
       }
 
       $field.focus(function () {
-        if($(this).val() === '') {
+        if ($field.val() === '') {
           $label.fadeOut('fast');
         }
       });
 
       $field.blur(function () {
-        if($(this).val() === '') {
+        if ($field.val() === '') {
           $label.fadeIn('slow');
         }
       });
+
+      // Chrome adds passwords after page load, so we need to track changes.
+      $field.change(function () {
+        if ($field != document.activeElement) {
+          if ($field.val() === '') {
+            $label.fadeIn('fast');
+          }
+          else {
+            $label.css('display', 'none');
+          }
+        }
+      });
     });
   });
 };
 
+/**
+ * Attach compact forms behavior to all enabled forms upon page load.
+ */
 Drupal.behaviors.compactForms = function (context) {
   if (!Drupal.settings || !Drupal.settings.compactForms) {
     return;
   }
   $('#' + Drupal.settings.compactForms.forms.join(',#'), context).compactForm(Drupal.settings.compactForms.stars, Drupal.settings.compactForms.colons);
+
+  // Safari adds passwords without triggering any event after page load.
+  // We therefore need to wait a bit and then check for field values.
+  if ($.browser.safari) {
+    setTimeout(Drupal.compactForms.fixSafari, 200);
+  }
 };
 
+/**
+ * Checks for field values and hides the corresponding label if non-empty.
+ *
+ * @todo Convert $.fn.compactForm to always use a function like this.
+ */
+Drupal.compactForms.fixSafari = function () {
+  $('label.compact-form-label').each(function () {
+    var $label = $(this);
+    var context = this.form;
+    if ($('#' + $label.attr('for'), context).val() != '') {
+      $label.css('display', 'none');
+    }
+  });
+}
+
 })(jQuery);
