Revision 1432:ebda59ca84db plugins/redmine_bibliography/assets/javascripts

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("<span>" + ui.item.authorship_link + "</span>");
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
1
// bibliography.js
1 2

  
2
$("#publication_bibtex_entry_attributes_entry_type").live("change", function() {
3
function disable_fields(){
4
	$this = $(this);
5

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

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

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

  
17
    return false;
18
}
19

  
20
function enable_fields(){
3 21
    $this = $(this);
4 22

  
5
    $.ajax({
6
        type: "get",
7
        url: "/publications/show_bibtex_fields",
8
        data: {
9
            value: $this.val()
10
        },
11
        dataType: "script"
12
    });
23
    $author_info = $this.closest('div').prev();
24
//    $author_info.children('.description').toggle();
25
    $author_info.find('p :input').attr("readonly", false);
26
    $author_info.find('p :input').removeClass('readonly');
27

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

  
31
    $this.siblings('.author_save_btn').show();
32
    $this.hide();
13 33

  
14 34
    return false;
15
});
16
$(document).ready(function() {
17
    $("#publication_bibtex_entry_attributes_entry_type").trigger('change');
18
});
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/javascripts/order_authorships.js
1
$(document).ready(function(){
2

  
3
   $('#authorships').sortable({
4
       axis: 'y',
5
       dropOnEmpty: false,
6
       handle: '.handle',
7
       cursor: 'crosshair',
8
       items: 'li',
9
       opacity: 0.4,
10
       scroll: true,
11
       update: function(){
12
          $.ajax({
13
              type: 'post',
14
              data: $('#authorships').sortable('serialize'),
15
              dataType: 'script',
16
              complete: function(request){
17
                 $('#authorship').effect('highlight');
18
              },
19
                 url: '/authorships/sort'});
20
              }
21
          });
22
     });
23

  
24

  
25

  
26

  
27

  
28

  

Also available in: Unified diff