Skip to content
Snippets Groups Projects
Unverified Commit 917243a3 authored by Fredrik Jonsson's avatar Fredrik Jonsson Committed by GitHub
Browse files

Merge pull request #1900 from OpenTechFund/enhancement/add_user_input_form_copy_js

Add user input to the submission form copy javascript.
parents a60bb7de b375b87f
No related branches found
No related tags found
No related merge requests found
......@@ -15,12 +15,22 @@
$('.application-form').find('.form__group, .rich-text').each(function () {
var question_text = '';
var label_text = $(this).find('.form__question').html();
var input_text = $(this).find('input').val();
var rich_text = $(this).find('.tinymce4-editor').val();
if (label_text) {
// Get the label, i.e. question.
label_text = strip(label_text);
label_text = label_text.replace(/(\r\n|\n|\r)/gm, '');
label_text = label_text.replace(/[ ]+/g, ' ');
question_text = '### ' + label_text;
// Get the user input if any.
if (input_text) {
question_text = question_text + '\n\n' + strip(input_text);
}
else if (rich_text) {
question_text = question_text + '\n\n' + strip(rich_text);
}
}
else {
// Get the sub headers and help text.
......@@ -39,9 +49,10 @@
var $button = $('<button/>')
.text('Copy questions to clipboard')
.addClass('link link--button link--button--narrow js-clipboard-button')
.css({'display': 'block', 'margin-left': 'auto'})
.attr('title', 'Copies all the questions to the clipboard in plain text.');
$('.application-form').before($button);
.attr('title', 'Copies all the questions and user input to the clipboard in plain text.');
var $application_form = $('.application-form');
$button.clone().css({'display': 'block', 'margin-left': 'auto'}).insertBefore($application_form);
$button.insertAfter($application_form.find('.link--button-secondary').last());
$('.js-clipboard-button').on('click', function (e) {
e.preventDefault();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment