# HG changeset patch # User luisf # Date 1368191966 -3600 # Node ID f8bb7ccc6facb9b3e894989c2d336493684590bc # Parent 99fe7b784587f1f1d7d8d7abd2a6b1e07654ee10 fixed javascript and helper to add author fields. Removed unused code. diff -r 99fe7b784587 -r f8bb7ccc6fac plugins/redmine_bibliography/app/helpers/publications_helper.rb --- a/plugins/redmine_bibliography/app/helpers/publications_helper.rb Fri May 10 11:53:01 2013 +0100 +++ b/plugins/redmine_bibliography/app/helpers/publications_helper.rb Fri May 10 14:19:26 2013 +0100 @@ -52,7 +52,7 @@ fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render(association.to_s.singularize + "_fields", :f => builder) end - link_to_function(name, h("add_author_fields(this, '#{association}', '#{escape_javascript(fields)}', '#{action}')"), { :class => 'icon icon-add', :id => "add_another_author" }) + link_to_function(name, "add_author_fields(this, '#{association}', '#{escape_javascript(fields)}', '#{action}')", { :class => 'icon icon-add', :id => "add_another_author" }) end def sanitized_object_name(object_name) diff -r 99fe7b784587 -r f8bb7ccc6fac plugins/redmine_bibliography/assets/javascripts/authors.js --- a/plugins/redmine_bibliography/assets/javascripts/authors.js Fri May 10 11:53:01 2013 +0100 +++ b/plugins/redmine_bibliography/assets/javascripts/authors.js Fri May 10 14:19:26 2013 +0100 @@ -1,17 +1,17 @@ -function remove_fields(link) { - $(link).previous("input[type=hidden]").value = "1"; - $(link).up(".fields").hide(); +function add_author_fields(link, association, content, action) { + var new_id = new Date().getTime(); + var regexp = new RegExp("new_" + association, "g"); + + $(link).before(content.replace(regexp, new_id)); + + if(action != "new"){ + toggle_save_author(new_id, $(link)); + } } -function add_author_fields(link, association, content, action) { - var new_id = new Date().getTime(); - var regexp = new RegExp("new_" + association, "g"); - $(link).insert({ - before: content.replace(regexp, new_id) - }); - if(action != "new"){ - toggle_save_author(new_id, $(link)); - }; +function remove_fields(link) { + $(link).prev("input[type=hidden]").val("1"); + $(link).closest(".fields").hide(); } function identify_author_status(status, object_id) {