<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,7 +1,9 @@
 &lt;%= javascript_include_merged :base %&gt;       
 
 &lt;% javascript_tag do %&gt;
-	var attachmentOnChange = function(element) {
+	var attachmentOnChange = function(element) {   
+		warn('element = ' + element);
+		warn('element value = ' + element.value);
 	  attachment_uuid = '&lt;%= current_object.attachment_uuid %&gt;'; 
 		with(window.parent) { 
 		  window.eval('attachmentOnChangeUpdateParent(&quot;' + attachment_uuid + '&quot;,&quot;' + escape(element.value) + '&quot;)'); </diff>
      <filename>app/views/attachments/new.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -525,18 +525,23 @@ var findSubmit = function(form_element_or_id) {
 }  
   
 var attachmentOnChangeUpdateParent = function(attachment_uuid, filename) {
-  filename = unescape(filename);
-	if (short_name = filename.match(/([^\/\\]+)\.\w+$/)[1]) {
-	  filename = short_name;
-  }
   preview_slot = document.getElementById(attachment_uuid + '-preview');
   // TODO: report prototype bug: preview_slot.update should work but fails in IE
-  Element.update(preview_slot, '&lt;img src=&quot;/images/wait_lg.gif&quot;&gt;  Uploading...');  
+  Element.update(preview_slot, '&lt;img src=&quot;/images/wait_lg.gif&quot;&gt;  Uploading...');   
+  
+  // Set the card name from filename if we can find the name field and it's blank.
 	if (name_field = preview_slot.up('form').down('.card-name-field')) {
   	if (!name_field.value || name_field.value.blank()) { 
+      filename = unescape(filename);
+      // chop off directories etc.
+    	if (match_bits = filename.match(/([^\/\\]+)\.\w+$/)) {
+    	  filename = match_bits[1];
+      }
       name_field.value = filename; 
     }
-  }
+  }                               
+  
+  // for now, don't let users submit while the image is in process of uploading.
 	deactivateSubmit(attachment_uuid);  
 }
 </diff>
      <filename>public/javascripts/application.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d990424a8b95a4581b3c2110e483b0984331473f</id>
    </parent>
  </parents>
  <author>
    <name>Lewis Hoffman</name>
    <email>lewis@grasscommons.org</email>
  </author>
  <url>http://github.com/wagn/wagn/commit/624bb5c20c6f102628be04660512d27e13ead4d5</url>
  <id>624bb5c20c6f102628be04660512d27e13ead4d5</id>
  <committed-date>2009-06-16T14:50:12-07:00</committed-date>
  <authored-date>2009-06-16T14:50:12-07:00</authored-date>
  <message>fix image update bug

existing code depended on regex matching, so it was failing for files with no
filesystem path prepended. the presense of this was somewhat browser dependent.</message>
  <tree>25f036665727946ec1956b24137bf5b99a57c689</tree>
  <committer>
    <name>Lewis Hoffman</name>
    <email>lewis@grasscommons.org</email>
  </committer>
</commit>
