Mercurial > hg > soundsoftware-site
changeset 1278:f8bb7ccc6fac redmine-2.2-integration
fixed javascript and helper to add author fields. Removed unused code.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Fri, 10 May 2013 14:19:26 +0100 |
parents | 99fe7b784587 |
children | a0488ec6979e |
files | plugins/redmine_bibliography/app/helpers/publications_helper.rb plugins/redmine_bibliography/assets/javascripts/authors.js |
diffstat | 2 files changed, 13 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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) {