Index: compact_forms.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/compact_forms/compact_forms.css,v
retrieving revision 1.1
diff -u -r1.1 compact_forms.css
--- compact_forms.css	29 Jul 2007 17:20:58 -0000	1.1
+++ compact_forms.css	13 Aug 2007 07:39:37 -0000
@@ -1,4 +1,5 @@
-/* $Id: compact_forms.css,v 1.1 2007/07/29 17:20:58 tomsun Exp $ */
+/* $Id: compact_forms.css,v 1.1 2007/07/29 17:20:58 tomsun Exp $ */
+
 
 .compact-form-wrapper {
   position: relative;
@@ -11,3 +12,6 @@
   z-index:1;
   font-size: .9em;
 }
+.compact-form-hint {
+  color: #999999 !important;
+}
Index: compact_forms.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/compact_forms/compact_forms.js,v
retrieving revision 1.1
diff -u -r1.1 compact_forms.js
--- compact_forms.js	29 Jul 2007 17:20:58 -0000	1.1
+++ compact_forms.js	13 Aug 2007 07:39:38 -0000
@@ -1,4 +1,5 @@
-/* $Id: compact_forms.js,v 1.1 2007/07/29 17:20:58 tomsun Exp $
+/* $Id: compact_forms.js,v 1.1 2007/07/29 17:20:58 tomsun Exp $
+
 
     Compact Forms jQuery plugin
     Copyright 2007 Tom Sundstršm
@@ -19,7 +20,8 @@
 
 
 (function($){
-  $.fn.compactForm = function(stars, colons) {
+  $.fn.compactForm = function(behavior, stars, colons) {
+    var behavior = behavior || 0;
     var stars = stars || 0;
     var colons = colons || 0;
     this.each(function(index) {
@@ -29,15 +31,7 @@
         if (field.attr("type") != "text" && field.attr("type") != "password") {
           return;
         }
-
-        if($(field).val() != "") {
-            $(label).fadeOut(1);
-        }
-
-        $(label).parent().addClass("compact-form-wrapper");
-        label.addClass("compact-form-label");
-        field.addClass("compact-form-field");
-
+       
         if (stars === 0) {
           $(label).find(".form-required").hide();
         } else if (stars === 2) {
@@ -50,12 +44,59 @@
           $(label).html(lbl);
         }
 
+        if (behavior === 0) {
+          if($(field).val() != "") {
+              $(label).fadeOut(1);
+          }
+          $(label).parent().addClass("compact-form-wrapper");
+          label.addClass("compact-form-label");
+          field.addClass("compact-form-field");
+        } else {
+          $(label).hide();
+          if($(field).val() === "") {
+            $(field).addClass("compact-form-hint");
+            $(field).val($(label).text());
+          }
+        }
+
         $(field).focus(function() {
-          if($(this).val() === "") {
            $(label).fadeOut("fast");
          }
        });
+          if (behavior === 0) {
+            if($(this).val() === "") {
+              $(label).fadeOut("fast");
+            }
+          } else {
+            if($(this).val() === $(label).text()) {
+              $(this).val('');
+              $(this).removeClass("compact-form-hint");
+            }
+          }
+        });
 
         $(field).blur(function() {
-          if($(this).val() === "") {
            $(label).fadeIn("slow");
          }
        });
+          if (behavior === 0) {
+            if($(this).val() === "") {
+              $(label).fadeIn("slow");
+            }
+          } else {
+            if($(this).val() === "") {
+              $(this).addClass("compact-form-hint");
+              $(this).val($(label).text());
+            }
+          }
+        });
       });
+      if (behavior === 1) {
+        $(this).find("input").each(function() {
+          var field = $(this);
+          if (field.attr("type") != "submit") {
+            return;
+          }
+          
+          $(field).click(function() {
+            $("input.compact-form-hint").val("");
+          });
+        });
+      }
     });
   }
 })(jQuery);
Index: compact_forms.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/compact_forms/compact_forms.module,v
retrieving revision 1.1
diff -u -r1.1 compact_forms.module
--- compact_forms.module	29 Jul 2007 17:20:58 -0000	1.1
+++ compact_forms.module	13 Aug 2007 07:39:38 -0000
@@ -1,199 +1,210 @@
-<?php // $Id: compact_forms.module,v 1.1 2007/07/29 17:20:58 tomsun Exp $
-/*
-    Compact Forms Drupal module
-    Copyright 2007 Tom SundstrÃ¶m
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as
-    published by the Free Software Foundation.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public
-    License along with this program; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-
-/**
- * Implementation of hook_help().
- */
-function compact_forms_help($section) {
-  switch ($section) {
-    case 'admin/help#help':
-      // TODO: expand
-      $output = '<p>'. t('Makes form fields compact by overlaying the field label on top the field itself using jQuery.') . '</p>';
-      return $output;
-  }
-}
-
-
-/**
- * Implementation of hook_perm().
- */
-function compact_forms_perm() {
-  return array(
-    'administer Compact Forms',
-  );
-}
-
-
-/**
- * Implementation of hook_form_alter().
- */
-function compact_forms_form_alter($form_id, &$form) {
-  $field_size = variable_get('compact_forms_field_size', '');
-  $descriptions = variable_get('compact_forms_descriptions', 1);
-  if (empty($field_size) && !empty($descriptions)) {
-    // Nothing to alter.
-    return;
-  }
-
-  static $ids = NULL;
-  if ($ids === NULL) {
-    $ids = explode("\n", str_replace('-', '_', variable_get('compact_forms_ids', "user-login-form")));
-  }
-  if (in_array($form_id, $ids)) {
-    _compact_forms_resize_fields($form, $field_size, $descriptions);
-  }
-}
-
-
-/**
- * Iterator.
- */
-function _compact_forms_resize_fields(&$subform, $field_size, $descriptions) {
-  if (is_array($subform) && !empty($subform)) {
-    foreach($subform as $key => $field) {
-      switch($field['#type']) {
-
-        case 'fieldset':
-          _compact_forms_resize_fields($subform[$key], $field_size);
-          break;
-        
-        case 'textfield':
-        case 'password':
-        case 'password_confirm':
-          if (!empty($field_size)) {
-            $subform[$key]['#size'] = $field_size; 
-          }
-          if (empty($descriptions)) {
-            unset($subform[$key]['#description']);
-          }
-          break;
-      }
-    }  
-  }
-}
-
-/**
- * Implementation of hook_menu().
- */
-function compact_forms_menu($may_cache) {
-  global $user;
-  $items = array();
-
-  if (!$may_cache) {
-    
-    _compact_forms_include_js();
-
-    $items[] = array(
-      'title' => t('Compact Forms'),
-      'path' => 'admin/settings/compact_forms',
-      'description' => t('Makes form fields compact by overlaying the field label on top the field itself using jQuery.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => 'compact_forms_admin_form',
-      'access' => user_access('administer Compact Forms'),
-    );
-  }
-
-  return $items;
-}
-
-
-/**
- * Compact Forms admin settings.
- */
-function compact_forms_admin_form() {
-
-  $form['compact_forms_ids'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Form ID:s'),
-    '#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.',
-  );
-  
-  $form['compact_forms_stars'] = array(
-    '#title' => t('"Required field" - stars'),
-    '#type' => 'radios',
-    '#options' => array(
-      0 => t('Remove "required" stars'),
-      1 => t('Leave "required" stars attached to label'),
-      2 => t('Insert "required" stars after the field'),
-    ),
-    '#default_value' => variable_get('compact_forms_stars', 2),
-    '#description' => t('How to deal with the stars added by Drupal to indicate required fields.'),
-  );
-  
-  $form['compact_forms_colons'] = array(
-    '#title' => t('Trailing colons in labels'),
-    '#type' => 'radios',
-     '#options' => array(
-      0 => t('Remove trailing colons from the label'),
-      1 => t('Keep trailing colons'),
-    ),
-    '#default_value' => variable_get('compact_forms_colons', 0),
-  );
-
-  $form['compact_forms_field_size'] = array(
-    '#title' => t('Textfield size'),
-    '#type' => 'textfield',
-    '#size' => 3,
-    '#default_value' => variable_get('compact_forms_field_size', ''),
-    '#description' => t('Optionally override the width of all text fields in the selected forms'),
-  );
-  $form['compact_forms_descriptions'] = array(
-    '#title' => t('Textfield descriptions'),
-    '#type' => 'radios',
-    '#options' => array(
-      0 => t('Hide descriptions'),
-      1 => t('Show descriptions'),
-    ),
-    '#default_value' => variable_get('compact_forms_descriptions', 1),
-    '#description' => t('Optionally hide descriptions of all textfields (in general not recommended).'),
-  );
-  
-  return system_settings_form($form);
-}
-
-
-/**
- * Include JavaScript and CSS and attach behaviours to all selected forms.
- */
-function _compact_forms_include_js() {
-    $ids = explode("\n", variable_get('compact_forms_ids', "user-login-form"));
-    $inline_js = '';
-    
-    if (is_array($ids) && !empty($ids)) {
-      $stars = variable_get('compact_forms_stars', 2);
-      $colons = variable_get('compact_forms_colons', 0);
-      
-      foreach ($ids as $id) {
-        $id = trim($id);
-        if (!empty($id)) {
-         
-          $inline_js .= '$("#' . $id. '").compactForm(' . $stars . ', ' . $colons . ');';
-        }
-      }
-    }
-    if (!empty($inline_js)) {
-      drupal_add_js(drupal_get_path('module', 'compact_forms') . '/compact_forms.js');
-      drupal_add_css(drupal_get_path('module', 'compact_forms') . '/compact_forms.css');
-      drupal_add_js('$(document).ready(function() {'. $inline_js . '});', 'inline');      
-    }
-}
+<?php // $Id: compact_forms.module,v 1.1 2007/07/29 17:20:58 tomsun Exp $
+/*
+    Compact Forms Drupal module
+    Copyright 2007 Tom SundstrÃ¶m
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License version 2 as
+    published by the Free Software Foundation.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public
+    License along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+
+/**
+ * Implementation of hook_help().
+ */
+function compact_forms_help($section) {
+  switch ($section) {
+    case 'admin/help#help':
+      // TODO: expand
+      $output = '<p>'. t('Makes form fields compact by overlaying the field label on top the field itself using jQuery.') . '</p>';
+      return $output;
+  }
+}
+
+
+/**
+ * Implementation of hook_perm().
+ */
+function compact_forms_perm() {
+  return array(
+    'administer Compact Forms',
+  );
+}
+
+
+/**
+ * Implementation of hook_form_alter().
+ */
+function compact_forms_form_alter($form_id, &$form) {
+  $field_size = variable_get('compact_forms_field_size', '');
+  $descriptions = variable_get('compact_forms_descriptions', 1);
+  if (empty($field_size) && !empty($descriptions)) {
+    // Nothing to alter.
+    return;
+  }
+
+  static $ids = NULL;
+  if ($ids === NULL) {
+    $ids = explode("\n", str_replace('-', '_', variable_get('compact_forms_ids', "user-login-form")));
+  }
+  if (in_array($form_id, $ids)) {
+    _compact_forms_resize_fields($form, $field_size, $descriptions);
+  }
+}
+
+
+/**
+ * Iterator.
+ */
+function _compact_forms_resize_fields(&$subform, $field_size, $descriptions) {
+  if (is_array($subform) && !empty($subform)) {
+    foreach($subform as $key => $field) {
+      switch($field['#type']) {
+
+        case 'fieldset':
+          _compact_forms_resize_fields($subform[$key], $field_size);
+          break;
+        
+        case 'textfield':
+        case 'password':
+        case 'password_confirm':
+          if (!empty($field_size)) {
+            $subform[$key]['#size'] = $field_size; 
+          }
+          if (empty($descriptions)) {
+            unset($subform[$key]['#description']);
+          }
+          break;
+      }
+    }  
+  }
+}
+
+/**
+ * Implementation of hook_menu().
+ */
+function compact_forms_menu($may_cache) {
+  global $user;
+  $items = array();
+
+  if (!$may_cache) {
+    
+    _compact_forms_include_js();
+
+    $items[] = array(
+      'title' => t('Compact Forms'),
+      'path' => 'admin/settings/compact_forms',
+      'description' => t('Makes form fields compact by overlaying the field label on top the field itself using jQuery.'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => 'compact_forms_admin_form',
+      'access' => user_access('administer Compact Forms'),
+    );
+  }
+
+  return $items;
+}
+
+
+/**
+ * Compact Forms admin settings.
+ */
+function compact_forms_admin_form() {
+
+  $form['compact_forms_ids'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Form ID:s'),
+    '#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.',
+  );
+
+  $form['compact_forms_label_behavior'] = array(
+    '#title' => t('How should the label be modified'),
+    '#type' => 'radios',
+     '#options' => array(
+      0 => t('Move the label as a css overlay, over the form field'),
+      1 => t('Insert the label as the form field value'),
+    ),
+    '#default_value' => variable_get('compact_forms_label_behavior', 0),
+  );
+  
+  $form['compact_forms_stars'] = array(
+    '#title' => t('"Required field" - stars'),
+    '#type' => 'radios',
+    '#options' => array(
+      0 => t('Remove "required" stars'),
+      1 => t('Leave "required" stars attached to label'),
+      2 => t('Insert "required" stars after the field'),
+    ),
+    '#default_value' => variable_get('compact_forms_stars', 2),
+    '#description' => t('How to deal with the stars added by Drupal to indicate required fields.'),
+  );
+  
+  $form['compact_forms_colons'] = array(
+    '#title' => t('Trailing colons in labels'),
+    '#type' => 'radios',
+     '#options' => array(
+      0 => t('Remove trailing colons from the label'),
+      1 => t('Keep trailing colons'),
+    ),
+    '#default_value' => variable_get('compact_forms_colons', 0),
+  );
+
+  $form['compact_forms_field_size'] = array(
+    '#title' => t('Textfield size'),
+    '#type' => 'textfield',
+    '#size' => 3,
+    '#default_value' => variable_get('compact_forms_field_size', ''),
+    '#description' => t('Optionally override the width of all text fields in the selected forms'),
+  );
+  $form['compact_forms_descriptions'] = array(
+    '#title' => t('Textfield descriptions'),
+    '#type' => 'radios',
+    '#options' => array(
+      0 => t('Hide descriptions'),
+      1 => t('Show descriptions'),
+    ),
+    '#default_value' => variable_get('compact_forms_descriptions', 1),
+    '#description' => t('Optionally hide descriptions of all textfields (in general not recommended).'),
+  );
+  
+  return system_settings_form($form);
+}
+
+
+/**
+ * Include JavaScript and CSS and attach behaviours to all selected forms.
+ */
+function _compact_forms_include_js() {
+    $ids = explode("\n", variable_get('compact_forms_ids', "user-login-form"));
+    $inline_js = '';
+    
+    if (is_array($ids) && !empty($ids)) {
+      $behavior = variable_get('compact_forms_label_behavior', 0);
+      $stars = variable_get('compact_forms_stars', 2);
+      $colons = variable_get('compact_forms_colons', 0);
+      
+      foreach ($ids as $id) {
+        $id = trim($id);
+        if (!empty($id)) {
+         
+          $inline_js .= '$("#' . $id. '").compactForm(' . $behavior . ', ' . $stars . ', ' . $colons . ');';
+        }
+      }
+    }
+    if (!empty($inline_js)) {
+      drupal_add_js(drupal_get_path('module', 'compact_forms') . '/compact_forms.js');
+      drupal_add_css(drupal_get_path('module', 'compact_forms') . '/compact_forms.css');
+      drupal_add_js('$(document).ready(function() {'. $inline_js . '});', 'inline');      
+    }
+}