mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 16:48:12 +00:00
Merge pull request #365 from hugueslacroix/master
Follow up on issue #360 and pull request #362
This commit is contained in:
commit
5be7b122f3
@ -60,6 +60,12 @@ jsPsych.plugins['free-sort'] = (function() {
|
||||
default: 'above',
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
button_label: {
|
||||
type: [jsPsych.plugins.parameterType.STRING],
|
||||
default: 'Done',
|
||||
no_function: false,
|
||||
description: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,6 +79,7 @@ jsPsych.plugins['free-sort'] = (function() {
|
||||
trial.prompt_location = trial.prompt_location || "above";
|
||||
trial.sort_area_width = trial.sort_area_width || 800;
|
||||
trial.sort_area_height = trial.sort_area_height || 800;
|
||||
trial.button_label = typeof trial.button_label === 'undefined' ? 'Done' : trial.button_label;
|
||||
|
||||
// if any trial variables are functions
|
||||
// this evaluates the function and replaces
|
||||
@ -118,7 +125,7 @@ jsPsych.plugins['free-sort'] = (function() {
|
||||
});
|
||||
}
|
||||
|
||||
display_element.innerHTML += '<button id="jspsych-free-sort-done-btn" class="jspsych-btn">Done</button>';
|
||||
display_element.innerHTML += '<button id="jspsych-free-sort-done-btn" class="jspsych-btn">'+trial.button_label+'</button>';
|
||||
|
||||
var maxz = 1;
|
||||
|
||||
|
@ -53,6 +53,18 @@ jsPsych.plugins.instructions = (function() {
|
||||
default: false,
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
button_label_previous: {
|
||||
type: [jsPsych.plugins.parameterType.STRING],
|
||||
default: 'Previous',
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
button_label_next: {
|
||||
type: [jsPsych.plugins.parameterType.STRING],
|
||||
default: 'Next',
|
||||
no_function: false,
|
||||
description: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -64,6 +76,8 @@ jsPsych.plugins.instructions = (function() {
|
||||
trial.allow_backward = (typeof trial.allow_backward === 'undefined') ? true : trial.allow_backward;
|
||||
trial.allow_keys = (typeof trial.allow_keys === 'undefined') ? true : trial.allow_keys;
|
||||
trial.show_clickable_nav = (typeof trial.show_clickable_nav === 'undefined') ? false : trial.show_clickable_nav;
|
||||
trial.button_label_previous = (typeof trial.button_label_previous === 'undefined') ? 'Previous' : trial.button_label_previous;
|
||||
trial.button_label_next = (typeof trial.button_label_next === 'undefined') ? 'Next' : trial.button_label_next;
|
||||
|
||||
// if any trial variables are functions
|
||||
// this evaluates the function and replaces
|
||||
@ -95,9 +109,9 @@ jsPsych.plugins.instructions = (function() {
|
||||
|
||||
var nav_html = "<div class='jspsych-instructions-nav'>";
|
||||
if (current_page != 0 && trial.allow_backward) {
|
||||
nav_html += "<button id='jspsych-instructions-back' class='jspsych-btn'>< Previous</button>";
|
||||
nav_html += "<button id='jspsych-instructions-back' class='jspsych-btn'>< "+trial.button_label_previous+"</button>";
|
||||
}
|
||||
nav_html += "<button id='jspsych-instructions-next' class='jspsych-btn'>Next ></button></div>"
|
||||
nav_html += "<button id='jspsych-instructions-next' class='jspsych-btn'>"+trial.button_label_next+" ></button></div>"
|
||||
|
||||
display_element.innerHTML += nav_html;
|
||||
|
||||
|
@ -66,6 +66,12 @@ jsPsych.plugins.palmer = (function() {
|
||||
default: '',
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
button_label: {
|
||||
type: [jsPsych.plugins.parameterType.STRING],
|
||||
default: 'Done',
|
||||
no_function: false,
|
||||
description: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,6 +86,7 @@ jsPsych.plugins.palmer = (function() {
|
||||
trial.timing_item = trial.timing_item || 1000;
|
||||
trial.timing_feedback = trial.timing_feedback || 1000;
|
||||
trial.prompt = (typeof trial.prompt === 'undefined') ? "" : trial.prompt;
|
||||
trial.button_label = typeof trial.button_label === 'undefined' ? 'Submit Answers' : trial.button_label;
|
||||
|
||||
// if any trial variables are functions
|
||||
// this evaluates the function and replaces
|
||||
@ -246,7 +253,7 @@ jsPsych.plugins.palmer = (function() {
|
||||
// start recording the time
|
||||
var startTime = (new Date()).getTime();
|
||||
|
||||
display_element.innerHTML += '<p><button id="jspsych-palmer-submitButton" class="jspsych-btn" type="button">Submit Answer</button></p>';
|
||||
display_element.innerHTML += '<p><button id="jspsych-palmer-submitButton" class="jspsych-btn" type="button">'+trial.button_label+'</button></p>';
|
||||
display_element.querySelector('#jspsych-palmer-submitButton').addEventListener('click', function() {
|
||||
save_data();
|
||||
});
|
||||
|
@ -47,6 +47,12 @@ jsPsych.plugins['reconstruction'] = (function() {
|
||||
default: 'g',
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
button_label: {
|
||||
type: [jsPsych.plugins.parameterType.STRING],
|
||||
default: '',
|
||||
no_function: false,
|
||||
description: 'Submit Answers'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,6 +64,7 @@ jsPsych.plugins['reconstruction'] = (function() {
|
||||
trial.step_size = trial.step_size || 0.05;
|
||||
trial.key_increase = trial.key_increase || 'h';
|
||||
trial.key_decrease = trial.key_decrease || 'g';
|
||||
trial.button_label = typeof trial.button_label === 'undefined' ? 'Submit Answers' : trial.button_label;
|
||||
|
||||
// if any trial variables are functions
|
||||
// this evaluates the function and replaces
|
||||
@ -105,7 +112,7 @@ jsPsych.plugins['reconstruction'] = (function() {
|
||||
display_element.innerHTML = '<div id="jspsych-reconstruction-stim-container">'+trial.stim_function(param)+'</div>';
|
||||
|
||||
// add submit button
|
||||
display_element.innerHTML += '<button id="jspsych-reconstruction-next" class="jspsych-btn jspsych-reconstruction">Submit Answers</button>';
|
||||
display_element.innerHTML += '<button id="jspsych-reconstruction-next" class="jspsych-btn jspsych-reconstruction">'+trial.button_label+'</button>';
|
||||
|
||||
display_element.querySelector('#jspsych-reconstruction-next').addEventListener('click', endTrial);
|
||||
}
|
||||
|
@ -81,6 +81,12 @@ jsPsych.plugins.similarity = (function() {
|
||||
default: '',
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
button_label: {
|
||||
type: [jsPsych.plugins.parameterType.STRING],
|
||||
default: '',
|
||||
no_function: false,
|
||||
description: 'Submit Answers'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,6 +107,8 @@ jsPsych.plugins.similarity = (function() {
|
||||
trial.is_html = (typeof trial.is_html === 'undefined') ? false : trial.is_html;
|
||||
trial.prompt = (typeof trial.prompt === 'undefined') ? '' : trial.prompt;
|
||||
|
||||
trial.button_label = typeof trial.button_label === 'undefined' ? 'Submit Answers' : trial.button_label;
|
||||
|
||||
// if any trial variables are functions
|
||||
// this evaluates the function and replaces
|
||||
// it with the output of the function
|
||||
@ -231,7 +239,7 @@ jsPsych.plugins.similarity = (function() {
|
||||
display_element.append($('<button>', {
|
||||
'id': 'next',
|
||||
'class': 'sim',
|
||||
'html': 'Submit Answer'
|
||||
'html': trial.button_label
|
||||
}));
|
||||
|
||||
// if prompt is set, show prompt
|
||||
|
@ -29,6 +29,12 @@ jsPsych.plugins['survey-likert'] = (function() {
|
||||
default: undefined,
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
button_label: {
|
||||
type: [jsPsych.plugins.parameterType.STRING],
|
||||
default: 'Submit Answers',
|
||||
no_function: false,
|
||||
description: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,12 @@ jsPsych.plugins['survey-multi-choice'] = (function() {
|
||||
default: '',
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
button_label: {
|
||||
type: [jsPsych.plugins.parameterType.STRING],
|
||||
default: '',
|
||||
no_function: false,
|
||||
description: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -63,6 +69,8 @@ jsPsych.plugins['survey-multi-choice'] = (function() {
|
||||
trial.preamble = typeof trial.preamble == 'undefined' ? "" : trial.preamble;
|
||||
trial.required = typeof trial.required == 'undefined' ? null : trial.required;
|
||||
trial.horizontal = typeof trial.required == 'undefined' ? false : trial.horizontal;
|
||||
//If button_label is empty, the browser's language will be used to determine the button label.
|
||||
trial.button_label = typeof trial.button_label === 'undefined' ? '' : trial.button_label;
|
||||
|
||||
// if any trial variables are functions
|
||||
// this evaluates the function and replaces
|
||||
@ -113,16 +121,18 @@ jsPsych.plugins['survey-multi-choice'] = (function() {
|
||||
|
||||
// add label and question text
|
||||
var form = document.getElementById(option_id_name)
|
||||
var input_id_name = _join(plugin_id_name, 'response', i);
|
||||
var input_name = _join(plugin_id_name, 'response', i);
|
||||
var input_id = _join(plugin_id_name, 'response', i, j);
|
||||
var label = document.createElement('label');
|
||||
label.setAttribute('class', plugin_id_name+'-text');
|
||||
label.innerHTML = trial.options[i][j];
|
||||
label.setAttribute('for', input_id_name)
|
||||
label.setAttribute('for', input_id)
|
||||
|
||||
// create radio button
|
||||
var input = document.createElement('input');
|
||||
input.setAttribute('type', "radio");
|
||||
input.setAttribute('name', input_id_name);
|
||||
input.setAttribute('name', input_name);
|
||||
input.setAttribute('id', input_id);
|
||||
input.setAttribute('value', trial.options[i][j]);
|
||||
form.appendChild(label);
|
||||
form.insertBefore(input, label);
|
||||
@ -137,8 +147,7 @@ jsPsych.plugins['survey-multi-choice'] = (function() {
|
||||
}
|
||||
}
|
||||
// add submit button
|
||||
trial_form.innerHTML += '<input type="submit" id="'+plugin_id_name+'-next" class="'+plugin_id_name+' jspsych-btn"></input>';
|
||||
|
||||
trial_form.innerHTML += '<input type="submit" id="'+plugin_id_name+'-next" class="'+plugin_id_name+' jspsych-btn"' + (trial.button_label ? ' value="'+trial.button_label + '"': '') + '></input>';
|
||||
trial_form.addEventListener('submit', function(event) {
|
||||
event.preventDefault();
|
||||
var matches = display_element.querySelectorAll("div." + plugin_id_name + "-question");
|
||||
|
@ -46,6 +46,12 @@ jsPsych.plugins['survey-multi-select'] = (function() {
|
||||
default: '',
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
button_label: {
|
||||
type: [jsPsych.plugins.parameterType.STRING],
|
||||
default: '',
|
||||
no_function: false,
|
||||
description: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -62,6 +68,8 @@ jsPsych.plugins['survey-multi-select'] = (function() {
|
||||
trial.required = typeof trial.required == 'undefined' ? true : trial.required;
|
||||
trial.required_msg = trial.required_msg || '*please select at least one option!';
|
||||
trial.horizontal = typeof trial.horizontal == 'undefined' ? false : trial.horizontal;
|
||||
//If button_label is empty, the browser's language will be used to determine the button label.
|
||||
trial.button_label = typeof trial.button_label === 'undefined' ? '' : trial.button_label;
|
||||
|
||||
// if any trial variables are functions
|
||||
// this evaluates the function and replaces
|
||||
@ -112,16 +120,18 @@ jsPsych.plugins['survey-multi-select'] = (function() {
|
||||
|
||||
// add label and question text
|
||||
var form = document.getElementById(option_id_name)
|
||||
var input_id_name = _join(plugin_id_name, 'response', i);
|
||||
var input_name = _join(plugin_id_name, 'response', i);
|
||||
var input_id = _join(plugin_id_name, 'response', i, j);
|
||||
var label = document.createElement('label');
|
||||
label.setAttribute('class', plugin_id_name+'-text');
|
||||
label.innerHTML = trial.options[i][j];
|
||||
label.setAttribute('for', input_id_name)
|
||||
label.setAttribute('for', input_id)
|
||||
|
||||
// create checkboxes
|
||||
var input = document.createElement('input');
|
||||
input.setAttribute('type', "checkbox");
|
||||
input.setAttribute('name', input_id_name);
|
||||
input.setAttribute('name', input_name);
|
||||
input.setAttribute('id', input_id);
|
||||
input.setAttribute('value', trial.options[i][j])
|
||||
form.appendChild(label)
|
||||
form.insertBefore(input, label)
|
||||
@ -129,7 +139,7 @@ jsPsych.plugins['survey-multi-select'] = (function() {
|
||||
}
|
||||
// add submit button
|
||||
trial_form.innerHTML +='<div class="fail-message"></div>'
|
||||
trial_form.innerHTML += '<input type="submit" id="'+plugin_id_name+'-next" class="'+plugin_id_name+' jspsych-btn"></input>';
|
||||
trial_form.innerHTML += '<input type="submit" id="'+plugin_id_name+'-next" class="'+plugin_id_name+' jspsych-btn"' + (trial.button_label ? ' value="'+trial.button_label +'"': '') + '></input>';
|
||||
|
||||
trial_form.addEventListener('submit', function(event) {
|
||||
event.preventDefault();
|
||||
|
@ -24,7 +24,7 @@ jsPsych.plugins['survey-text'] = (function() {
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
premable: {
|
||||
preamble: {
|
||||
type: [jsPsych.plugins.parameterType.STRING],
|
||||
default: '',
|
||||
no_function: false,
|
||||
@ -43,6 +43,19 @@ jsPsych.plugins['survey-text'] = (function() {
|
||||
default: 40,
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
values: {
|
||||
type: [jsPsych.plugins.parameterType.STRING],
|
||||
array: true,
|
||||
default: '',
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
button_label: {
|
||||
type: [jsPsych.plugins.parameterType.STRING],
|
||||
default: '',
|
||||
no_function: false,
|
||||
description: 'Submit Answers'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user