Skip to content
Snippets Groups Projects
Commit b375b87f authored by Fredrik Jonsson's avatar Fredrik Jonsson
Browse files

Add user input to the submission form copy javascript.

parent 932fe82c
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