// jshint devel:true

function get_file (data) {
	var url = $(data.into).find('#pfile').val();
	console.log(url);
	var form = $('.modal-body form');
	var html =  '<div class="wpcf7-response-output wpcf7-mail-sent-ok">'+
				'<p>Thank you for your interest. You may proceed to download the file by clicking the "Download" button below.</p>'+
				'<p><a class="btn btn-success" href="'+url+'" download>Download</a></p>'+
				'</div>';

	form.css({
		'height': 0,
		'opacity':0,
	})

	$('.modal-body').append(html);

}

$(function(){

	$('#myModal').on('show.bs.modal', function (event) {
  	  var button = $(event.relatedTarget) // Button that triggered the modal
	  var file = button.data('file') // Extract info from data-* attributes
	  $('#pfile').val(file);
	  $('.wpcf7-response-output').remove();

	  var form = $('.modal-body form');
	  form.css({
			'height': 'auto',
			'opacity':1,
	 })
	})

	$('.dropdown').on('show.bs.dropdown', function(e){
        $(this).find('.dropdown-menu').first().stop(true, true).slideDown('fast');
    });

    $('.dropdown').on('hide.bs.dropdown', function(e){
        e.preventDefault();
        $(this).find('.dropdown-menu').first().stop(true, true).slideUp('fast', function(){
            $('.dropdown').removeClass('open');
            $('.dropdown').find('.dropdown-toggle').attr('aria-expanded','false');
        });
    });
	
	$(".dropdown-menu").on( "click.bs.collapse.data-api", function(e) {
        e.stopPropagation();
    });

})