To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / vendor / plugins / redmine_bibliography / assets / javascripts / authors.js @ 1024:503ed68a4e0f

History | View | Annotate | Download (2.2 KB)

1
function remove_fields(link) {
2
    $(link).previous("input[type=hidden]").value = "1";
3
    $(link).up(".fields").hide();
4
}
5

    
6
function add_author_fields(link, association, content, action) {
7
        var new_id = new Date().getTime();
8
  var regexp = new RegExp("new_" + association, "g");
9
  $(link).insert({
10
                before: content.replace(regexp, new_id)
11
  });
12
        if(action != "new"){
13
                toggle_save_author(new_id, $(link));
14
        };
15
}
16

    
17
function identify_author_status(status, object_id) {
18
    $('publication_authorships_attributes_' + object_id + '_edit_author_info').select('input').each(function(s) {
19
        if(status == "no"){
20
            s.value = "";
21
            s.readOnly = false;
22
        };
23
        
24
        if(status == "correct"){s.readOnly = false;};
25
        if(status == "yes"){s.readOnly = true;};
26
    });
27
}
28

    
29
function toggle_div(div_id){        
30
    Effect.toggle(div_id, "appear", {duration:0.3});
31
}
32

    
33
function toggle_input_field(field){        
34
    if (field.classNames().inspect().include("readonly") == false){
35
                        field.readOnly = true;        
36
                        field.addClassName('readonly');
37
    } else {
38
                        field.readOnly = false;
39
                        field.removeClassName('readonly');
40
    };        
41
}
42

    
43
function toggle_edit_save_button(object_id){
44
    $button = $('publication_authorships_attributes_' + object_id + '_edit_save_button');
45
    if ($button.value == "Edit author"){
46
        $button.value = "Save author";
47
    } else {
48
        $button.value = "Edit author";
49
    };
50
}
51

    
52
function toggle_save_author(form_object_id, $this){
53
    $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('input').each(function(s) {
54
        toggle_input_field(s, $this);
55
    });
56
    $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('p.description').each(function(s) {
57
        s.toggle();
58
    });
59
    toggle_edit_save_button(form_object_id);
60
    toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author");
61
}
62

    
63
function hide_all_bibtex_required_fields(){$$('p.bibtex').each(function(s){s.hide()})}
64

    
65
// entrytype_fields is a jsno array with the fields requires by the selected bibtex entry 
66
function show_required_bibtex_fields(entrytype_fields) {
67
        $$('p.bibtex').each(function(s){
68
                if(entrytype_fields.indexOf(s.down('input').id.split('_').last()) != -1){
69
                        s.show();
70
                        }
71
                else {
72
                        s.hide();
73
                        }
74
        })
75
}
76