personal-journal/app/assets/javascripts/personal_journal/author.js.erb

24 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2014-06-12 10:27:26 +00:00
$(document).ready(function() {
$('.main-forms .add-on').tooltip();
$(document).on('click', '#add_author', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_authors", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn-box').prev('.add-target-box').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
2015-03-12 10:24:38 +00:00
$(this).parent().siblings('.add-target-box').append(("<%= escape_javascript(add_attribute 'form_author', f, :journal_paper_authors) rescue "" %>").replace(old_id, new_id));
2014-06-12 10:27:26 +00:00
$(this).parent('.add-btn-box').prev('.add-target-box').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
formTip();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
});