diff vendor/plugins/redmine_bibliography/assets/javascripts/authors.js @ 605:8fc59e8ddd63 feature_36

Edit/Save Author Button working correctly.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 18 Aug 2011 16:32:39 +0100
parents 48c027b30576
children 63f92a52a4eb
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js	Thu Aug 18 15:05:16 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js	Thu Aug 18 16:32:39 2011 +0100
@@ -27,16 +27,31 @@
 	Effect.toggle(div_id, "appear", {duration:0.3});
 }
 
-function toggle_input_field(field_id){
-	field_id.addClassName('readonly').next('em').hide();
-	field_id.readOnly = true;
+function toggle_input_field(field){	
+	if(field.readOnly == false){
+		field.readOnly = true;	
+		field.addClassName('readonly').next('em').hide();
+	} else{
+		field.readOnly = false;
+		field.removeClassName('readonly').next('em').show();		
+	};	
 }
 
-function toggle_save_author(form_object_id){
+function toggle_edit_save_button(object_id){
+	$button = $('publication_authorships_attributes_' + object_id + '_edit_save_button');
+	if($button.value == "Save Author"){
+		$button.value = "Edit Author";	
+	} else {
+		$button.value = "Save Author";
+	};
+}
+
+function toggle_save_author(form_object_id, $this){
 	$('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('input').each(function(s) {
-	  toggle_input_field(s);
+	  toggle_input_field(s, $this);
 	});
 	
+	toggle_edit_save_button(form_object_id);
 	toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author");
 }