Revision 1425:cd304b50908c plugins/redmine_bibliography/assets

View differences:

plugins/redmine_bibliography/assets/javascripts/authors.js
3 3
    var regexp = new RegExp("new_" + association, "g");
4 4

  
5 5
    $(link).before(content.replace(regexp, new_id));
6

  
7
    if(action != "new"){
8
        toggle_save_author(new_id, $(link));
9
    }
10 6
}
11 7

  
12 8
function remove_fields(link) {
......
14 10
  $(link).closest(".fields").hide();
15 11
}
16 12

  
17
$(".author_search").live('keyup.autocomplete', function(){
18
     $this = $(this);
13
function authorship_autocomplete(url){
14
    $(".author_name_on_paper").live('keyup.autocomplete', function(){
15
         $this = $(this);
19 16

  
20
     $this.autocomplete({
21
        source: '/publications/autocomplete_for_author',
22
        minLength: 2,
23
        focus: function(event, ui) {
24
            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.name);
25
            $this.closest('div').next().find("input[id$='institution']").val(ui.item.institution);
26
            $this.closest('div').next().find("input[id$='email']").val(ui.item.email);
27
            $this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class);
28
            $this.closest('div').next().find("input[id$='search_author_id']").val(ui.item.search_author_id);
17
         $this.autocomplete({
18
            source: url,
19
            minLength: 2,
20
            focus: function(event, ui) {
21
                $this.val(ui.item.label);
22
                return false;
23
            },
24
            select: function(event, ui){
25
                $this.closest('div').find("input[id$='institution']").val(ui.item.institution);
26
                $this.closest('div').find("input[id$='email']").val(ui.item.email);
29 27

  
30
            return false;
31
        },
32
        select: function(event, ui){
33
            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.name);
34
            $this.closest('div').next().find("input[id$='institution']").val(ui.item.institution);
35
            $this.closest('div').next().find("input[id$='email']").val(ui.item.email);
36
            $this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class);
37
            $this.closest('div').next().find("input[id$='search_author_id']").val(ui.item.search_author_id);
38
        }
39
        })
40
        .data( "autocomplete" )._renderItem = function( ul, item ) {
41
            return $( "<li></li>" )
42
                .data( "item.autocomplete", item )
43
                .append( "<a>" + item.label + "</a>" )
44
                .appendTo( ul );
45
            };
46
        });
28
                $this.closest('div').find("input[id$='search_author_class']").val(ui.item.  search_author_class);
29
                $this.closest('div').find("input[id$='search_author_id']").val(ui.item. search_author_id);
47 30

  
31
                $this.closest('div').find("input[id$='search_author_tie']").attr('checked', '   checked');
32
                $this.closest('div').find("input[id$='search_author_tie']").next('span').   replaceWith(ui.item.authorship_link);
48 33

  
49
$("input[id$='identify_author_yes']").live("click", function() {
50
    console.log("aaaa");
51
});
52

  
53
$("input[id$='identify_author_no']").live("click", function() {
54
    $this.closest('div').next().find("input[id$='name_on_paper']").val('');
55
    $this.closest('div').next().find("input[id$='institution']").val('');
56
    $this.closest('div').next().find("input[id$='email']").val('');
57
    $this.closest('div').next().find("input[id$='search_author_class']").val('');
58
});
59

  
60
function toggle_div(div_id){
61
    $("#" + div_id).toggle(0.3);
34
                // triggers the save button
35
                $this.closest('div').next('div').find('.author_save_btn').click();
36
            }
37
            })
38
            .data( "autocomplete" )._renderItem = function( ul, item ) {
39
                return $( "<li>" )
40
                    .data("item.autocomplete", item )
41
                    .append( "<a>" + item.label + "<br><em>" + item.email + "</em><br>" + item. institution + "</a>" )
42
                    .appendTo(ul);
43
                };
44
            });
62 45
}
63

  
64
function toggle_save_author(form_object_id, $this){
65
    $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('input').each(function(s) {
66
	toggle_input_field(s, $this);
67
    });
68
    $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('p.description').each(function(s) {
69
	s.toggle();
70
    });
71
    toggle_edit_save_button(form_object_id);
72
    toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author");
73
}
plugins/redmine_bibliography/assets/javascripts/bibliography.js
2 2

  
3 3
function disable_fields(){
4 4
	$this = $(this);
5

  
5 6
	$author_info = $this.closest('div').prev();
6
	$author_info.children('.description').toggle();
7
//    $author_info.children('.description').toggle();
7 8
	$author_info.find('p :input').attr("readonly", true);
8 9
    $author_info.find('p :input').addClass('readonly');
9 10

  
11
    // Always hides on save
12
    $this.closest('div').prev().find('p.search_author_tie').hide();
13

  
10 14
    $this.siblings('.author_edit_btn').show();
11 15
    $this.hide();
12 16

  
......
15 19

  
16 20
function enable_fields(){
17 21
    $this = $(this);
22

  
18 23
    $author_info = $this.closest('div').prev();
19
    $author_info.children('.description').toggle();
24
//    $author_info.children('.description').toggle();
20 25
    $author_info.find('p :input').attr("readonly", false);
21 26
    $author_info.find('p :input').removeClass('readonly');
22 27

  
28
    // Always shows on edit
29
    $this.closest('div').prev().find('p.search_author_tie').show();
30

  
23 31
    $this.siblings('.author_save_btn').show();
24 32
    $this.hide();
25 33

  
26 34
    return false;
27 35
}
36

  
plugins/redmine_bibliography/assets/javascripts/edit_publication.js
1
// edit_publication.js
2

  
3
$(document).ready(function(){
4
    // shows the correct bibtex fields
5
    $('#publication_bibtex_entry_attributes_entry_type').trigger('change');
6

  
7
    // adds the events to the edit/save authorship button
8
    $('.author_save_btn').live('click', disable_fields);
9
    $('.author_edit_btn').live('click', enable_fields);
10

  
11
    // clicks all authorships
12
    $('.author_save_btn').trigger('click');
13
});
plugins/redmine_bibliography/assets/javascripts/new_publication.js
1
// edit_publication.js
2

  
3
$(document).ready(function(){
4
    // adds the events to the edit/save authorship button
5
    $('.author_save_btn').live('click', disable_fields);
6
    $('.author_edit_btn').live('click', enable_fields);
7

  
8

  
9
});
plugins/redmine_bibliography/assets/stylesheets/bibliography.css
20 20
}
21 21

  
22 22
.tabular .author_edit .description {
23
    padding-top: 0;
24 23
    font-style: italic;
24
    font-size: small;
25 25
}
26 26

  
27 27
.publication_project {
28 28
    margin-right: 18px;
29 29
}
30 30

  
31
#authors select {
32
    min-width: 150px;
33
}
34

  
35

  
36 31
div#bibliography dd { margin-bottom: 1em; font-size: 0.9em; }
37 32

  
38 33
div#bibliography dd .authors { font-style: italic; }
......
71 66
  background-image: url(../../../images/loading.gif);
72 67
}
73 68

  
74
.author_edit_btn {
75
  display:none;
69
.search_author_tie {
70
  display: none;
71
  float: left;
76 72
}
77 73

  
74
.author_edit_btn {
75
  display: none;
76
}

Also available in: Unified diff