Revision 1289:7fa299909144 plugins

View differences:

plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb
9 9
    </p>
10 10

  
11 11
    <p style="margin-bottom: -2.5em; padding-bottom; 0"><label><%= l(:identify_author_question) %></label></p>
12

  
12 13
    <p class="author_identify">
13 14
      <label class='inline'><%= radio_button_tag(:identify_author, "yes", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_yes ), :onchange => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_yes) %> </label><br />
14 15

  
plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb
1 1
<%= raw @results.map {|result| {
2
      'label' => "#{result.name} (#{result.mail.partition('@')[2]})",
3
      'value' => result.name,
4
      'search_author_class' => result.class.name,
5
      'search_author_id' => result.id,
6
      'institution' => result.institution,
7
      'email' => result.mail,
8
      }
9
    }.to_json
10
%>
2
    'label' => "#{result.name} <em>#{result.mail.partition('@')[2]}</em>",
3
    'value' => result.name,
4
    'search_author_class' => result.class.name,
5
    'search_author_id' => result.id,
6
    'name' => result.name,
7
    'institution' => result.institution,
8
    'email' => result.mail,
9
    }
10
}.to_json %>
plugins/redmine_bibliography/assets/javascripts/authors.js
21 21
        source: '/publications/autocomplete_for_author',
22 22
        minLength: 2,
23 23
        focus: function(event, ui) {
24
            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.value);
24
            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.name);
25 25
            $this.closest('div').next().find("input[id$='institution']").val(ui.item.institution);
26 26
            $this.closest('div').next().find("input[id$='email']").val(ui.item.email);
27 27
            $this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class);
......
30 30
            return false;
31 31
        },
32 32
        select: function(event, ui){
33
            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.value);
33
            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.name);
34 34
            $this.closest('div').next().find("input[id$='institution']").val(ui.item.institution);
35 35
            $this.closest('div').next().find("input[id$='email']").val(ui.item.email);
36 36
            $this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class);
......
40 40
        .data( "autocomplete" )._renderItem = function( ul, item ) {
41 41
            return $( "<li></li>" )
42 42
                .data( "item.autocomplete", item )
43
                .append( "<a>" + item.institution + "</a>" )
43
                .append( "<a>" + item.label + "</a>" )
44 44
                .appendTo( ul );
45 45
            };
46 46
        });
47 47

  
48

  
49

  
50

  
51
function identify_author_status(status, object_id) {
52
    $('publication_authorships_attributes_' + object_id + '_edit_author_info').select('input').each(function(s) {
53

  
54
        if(status == "no"){
55
            s.value = "";
56
            s.readOnly = false;
57
        }
58

  
59
        if(status == "correct"){
60
            s.readOnly = false;
61
        }
62
        if(status == "yes"){
63
            s.readOnly = true;
64
        }
65
    });
66
}
67

  
68 48
function toggle_div(div_id){
69 49
    $("#" + div_id).toggle(0.3);
70 50
}
71 51

  
72
function toggle_input_field(field){
73
    if (field.classNames().inspect().include("readonly") === false){
74
			field.readOnly = true;
75
			field.addClassName('readonly');
76
    } else {
77
			field.readOnly = false;
78
			field.removeClassName('readonly');
79
    }
80
}
81

  
82
function toggle_edit_save_button(object_id){
83
    $button = $('publication_authorships_attributes_' + object_id + '_edit_save_button');
84
    if ($button.value == "Edit author"){
85
        $button.value = "Save author";
86
    } else {
87
        $button.value = "Edit author";
88
    }
89
}
90

  
91 52
function toggle_save_author(form_object_id, $this){
92 53
    $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('input').each(function(s) {
93 54
	toggle_input_field(s, $this);

Also available in: Unified diff