Index: filefield.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/filefield/filefield.module,v
retrieving revision 1.164
diff -u -r1.164 filefield.module
--- filefield.module	6 Feb 2009 10:56:30 -0000	1.164
+++ filefield.module	1 Mar 2009 03:27:31 -0000
@@ -85,6 +85,10 @@
       'arguments' => array('element' => NULL),
       'file' => 'filefield_widget.inc',
     ),
+    'filefield_widget_file' => array(
+      'arguments' => array('element' => NULL),
+      'file' => 'filefield_widget.inc',
+    ),
 
 
     'filefield_formatter_default' => array(
Index: filefield.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/filefield/filefield.css,v
retrieving revision 1.16
diff -u -r1.16 filefield.css
--- filefield.css	28 Feb 2009 22:50:19 -0000	1.16
+++ filefield.css	1 Mar 2009 03:27:30 -0000
@@ -19,52 +19,40 @@
 /**
  * General widget form styles (applicable to all widgets).
  */
-
-.filefield-element input.form-submit {
-  float: left; /* RTF */
-  margin: 0 .5em 0 0; /* RTF */
-}
-
-.filefield-row {
-}
-
-.filefield-row .filefield-info {
-  float: left;
-  padding-right: 1em;
+.filefield-element {
+  margin: 1em 0;
+  white-space: normal;
 }
 
-.filefield-row .filefield-edit {
+.filefield-element .filefield-preview {
   float: left;
-  width: 70%;
+  width: 180px;
+  overflow: hidden;
+  margin-right: 10px;
 }
 
-.filefield-row .filefield-description {
-  width: 70%;
+.filefield-element .filefield-edit .form-item {
+  margin: 0 0 1em 0;
 }
 
-.filefield-row .filefield-list {
-  float: right;
+.filefield-element input.form-submit,
+.filefield-element input.form-file {
+  margin: 0;
 }
 
-.filefield-file-edit-widget {
- float: left;
+.filefield-element input.progress-disabled {
+  float: none;
+  display: inline;
 }
 
-/* Only applies to single-value fields, for which we provide our own table. */
-.filefield-file-container-table {
-  width: 90%;
-  margin-top: 3px;
-  margin-bottom: 2px;
+.filefield-element div.ahah-progress,
+.filefield-element div.throbber {
+  display: inline;
+  float: none;
+  padding: 1px 13px 2px 3px;
 }
 
-.filefield-file-upload {
-  margin-bottom: 5px;
-}
 
-.filefield-js-error {
-  /* For some reason, the JS error message doesn't wrap by default. */
-  white-space: normal;
-}
 
 /* End general widget form styles. */
 
Index: filefield_widget.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/filefield/filefield_widget.inc,v
retrieving revision 1.54
diff -u -r1.54 filefield_widget.inc
--- filefield_widget.inc	28 Feb 2009 22:50:18 -0000	1.54
+++ filefield_widget.inc	1 Mar 2009 03:27:31 -0000
@@ -183,10 +183,16 @@
   $item = $element['#value'];
   $field_name = $element['#field_name'];
   $delta = $element['#delta'];
+  $element['#theme'] = 'filefield_widget_item';
 
   $field = content_fields($element['#field_name'], $element['#type_name']);
 
-  // check remove buttons...
+  // Title is not necessary for each individual field.
+  if ($field['multiple'] > 0) {
+    unset($element['#title']);
+  }
+
+  // Check if a remove button was clicked.
   $remove_name = $element['#field_name'] .'_'. $element['#delta'] .'_remove_btn';
   if (isset($form_state['clicked_button']) && $form_state['clicked_button']['#name'] == $remove_name) {
     $item = array('fid' => 0, 'list' => $field['list_default'], 'data' => array('description' => ''));
@@ -208,6 +214,7 @@
       '#type' => 'textfield',
       '#title' => t('Description'),
       '#value' => isset($item['data']['description']) ? $item['data']['description'] : '',
+      '#access' => !empty($item['fid']),
     );
   }
 
@@ -223,11 +230,10 @@
       '#title' => t('List'),
       '#value' => isset($item['list']) ? $item['list'] : $field['list_default'],
       '#attributes' => array('class' => 'filefield-list'),
+      '#access' => !empty($item['fid']),
     );
   }
 
-
-
   foreach ($element['#upload_validators'] as $callback => $arguments) {
     $help_func = $callback .'_help';
     if (function_exists($help_func)) {
@@ -237,27 +243,15 @@
   $element['upload'] = array(
     '#name' => 'files['. $element['#field_name'] .'_'. $element['#delta'] .']',
     '#type' => 'file',
-    '#title' => t('New Upload'),
     '#description' => implode('<br />', $desc),
+    '#size' => 22,
     '#attributes' => array(
       'accept' => implode(',', array_filter(explode(' ', $field['widget']['file_extensions']))),
-    )
+    ),
+    '#access' => empty($item['fid']),
   );
 
-
-  if ($item['fid'] != 0) {
-    $element['upload']['#title'] = t('Replace');
-  }
-
-  if (isset($element['#attributes']['class']) && strlen($element['#attributes']['class'])) {
-    $element['#attributes']['class'] .= 'filefield-element clear-block';
-  }
-  else {
-    $element['#attributes']['class'] = 'filefield-element clear-block';
-  }
-
   $element['#attributes']['id'] = $element['#id'] .'-ahah-wrapper';
-  $element['#attributes']['class'] = $element['#attributes']['class'];
   $element['#prefix'] = '<div '. drupal_attributes($element['#attributes']) .'>';
   $element['#suffix'] = '</div>';
   $element['upload_btn'] = array(
@@ -275,25 +269,25 @@
     '#delta' => $element['#delta'],
     '#type_name' => $element['#type_name'],
     '#upload_validators' => $element['#upload_validators'],
+    '#access' => empty($item['fid']),
   );
-  if ($item['fid'] != 0) {
-    $element['remove_btn'] = array(
-      '#name' => $element['#field_name'] .'_'. $element['#delta'] .'_remove_btn',
-      '#type' => 'submit',
-      '#value' => t('Remove'),
-      '#process' => array('filefield_widget_process_remove_btn', 'form_expand_ahah'),
-      '#submit' => array('node_form_submit_build_node'),
-      '#ahah' => array( // with JavaScript
-        'path' => 'filefield/ahah/'.   $element['#type_name'] .'/'. $element['#field_name'] .'/'. $element['#delta'],
-        'wrapper' => $element['#id'] .'-ahah-wrapper',
-        'method' => 'replace',
-        'effect' => 'fade',
-      ),
-      '#field_name' => $element['#field_name'],
-      '#delta' => $element['#delta'],
-    );
-  }
 
+  $element['remove_btn'] = array(
+    '#name' => $element['#field_name'] .'_'. $element['#delta'] .'_remove_btn',
+    '#type' => 'submit',
+    '#value' => t('Remove'),
+    '#process' => array('filefield_widget_process_remove_btn', 'form_expand_ahah'),
+    '#submit' => array('node_form_submit_build_node'),
+    '#ahah' => array( // with JavaScript
+      'path' => 'filefield/ahah/'.   $element['#type_name'] .'/'. $element['#field_name'] .'/'. $element['#delta'],
+      'wrapper' => $element['#id'] .'-ahah-wrapper',
+      'method' => 'replace',
+      'effect' => 'fade',
+    ),
+    '#field_name' => $element['#field_name'],
+    '#delta' => $element['#delta'],
+    '#access' => !empty($item['fid']),
+  );
 
   return $element;
 }
@@ -314,22 +308,55 @@
 }
 
 function theme_filefield_widget_preview($item) {
-  return '<div class="filefield-preview clear-block">'.
-           '<div class="filename">'. theme('filefield_file', $item) .'</div>'.
-           '<div class="filesize">'. format_size($item['filesize']) .'</div>'.
-           '<div class="filemime">'. $item['filemime'] .'</div>'.
-         '</div>';
+  return '<div class="filename">'. theme('filefield_file', $item) .'</div>'.
+         '<div class="filesize">'. format_size($item['filesize']) .'</div>'.
+         '<div class="filemime">'. $item['filemime'] .'</div>';
 }
 
 function theme_filefield_widget_item($element) {
-  return '<div class="filefield-row clear-block">'.
-              '<div class="filefield-filename clear-block">'. drupal_render($element['preview']) . '</div>'.
-              '<div class="fllefield-edit clear-block">'.
-                '<div class="filefield-list">'. drupal_render($element['list']) . '</div>' .
-                '<div class="filefield-description">'. drupal_render($element['description']) . '</div>' .
-                '<div class="filefield-stuff">'. drupal_render($element) .'</div>'.
-              '</div>'.
-         '</div>';
+  // Put the upload button directly after the upload field.
+  $element['upload']['#field_suffix'] = drupal_render($element['upload_btn']);
+  $element['upload']['#theme'] = 'filefield_widget_file';
+
+  $output = '';
+  $output .= '<div class="filefield-element clear-block">';
+
+  if ($element['fid']['#value'] != 0) {
+    $output .= '<div class="filefield-preview">';
+    $output .= drupal_render($element['preview']);
+    $output .= '</div>';
+  }
+
+  $output .= '<div class="filefield-edit">';
+  $output .=  drupal_render($element);
+  $output .= '</div>';
+  $output .= '</div>';
+
+  return $output;
+}
+
+/**
+ * Render the #field_suffix for file elements.
+ */
+function theme_filefield_widget_file($element) {
+  $output = '';
+
+  $output .= '<div class="filefield-upload clear-block">';
+
+  if (isset($element['#field_prefix'])) {
+    $output .= $element['#field_prefix'];
+  }
+
+  _form_set_class($element, array('form-file'));
+  $output .= '<input type="file" name="'. $element['#name'] .'"'. ($element['#attributes'] ? ' '. drupal_attributes($element['#attributes']) : '') .' id="'. $element['#id'] .'" size="'. $element['#size'] ."\" />\n";
+
+  if (isset($element['#field_suffix'])) {
+    $output .= $element['#field_suffix'];
+  }
+
+  $output .= '</div>';
+
+  return theme('form_element', $element, $output);
 }
 
 /**
