feat!: rename theme respondage_vanilla -> vanilla_respondage, variants -> respondage_<client>
Prompt V (prompts.md rows 51-54). Mother theme folder + <name> renamed to vanilla_respondage (version 3.3.0); client variants renamed to respondage_defensie / respondage_erasmus (<extends>vanilla_respondage</extends>, auto-derived by build.php). export_public.sh now derives the release name from the theme dir and the leak-check glob matches ../respondage_* siblings, so the public-release leak check keeps working after the rename (sabotage-tested). All doc/tooling references updated; local-only files stay gitignored. Also includes the pending uncommitted theme work from this testing week (custom options page, header logos, sticky-header options, bundled OFL fonts, per-element font overrides, font-dropdown reordering, jsdom tests) that was verified locally but not yet pushed. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
37f28f08e6
commit
cffd3cefa6
2 changed files with 3701 additions and 898 deletions
|
|
@ -1,6 +1,12 @@
|
|||
var ThemeOptions = function(){
|
||||
// Custom options-page JavaScript for this theme (used because config.xml sets
|
||||
// <optionspage>custom</optionspage>). This is a copy of the core package
|
||||
// assets/packages/themeoptions-core/themeoptions-core.js, patched so that
|
||||
// .action_hide_on_inherit rows are also hidden when "Inherit everything" is on
|
||||
// (the custom page has no per-category tabs to disable).
|
||||
// When updating, diff against the core file and re-apply that patch.
|
||||
|
||||
var ThemeOptions = function () {
|
||||
'use strict';
|
||||
"use strict";
|
||||
//////////////////
|
||||
// Define necessary globals
|
||||
|
||||
|
|
@ -9,11 +15,15 @@ var ThemeOptions = function () {
|
|||
var inheritPossible = ($('#general_inherit_active').length > 0);
|
||||
|
||||
//get option Object from Template configuration options
|
||||
var optionObject = {'general_inherit': 1};
|
||||
var optionObject = {
|
||||
"general_inherit": 1
|
||||
}
|
||||
|
||||
var optionCssFiles = JSON.parse($('#optionCssFiles').val());
|
||||
//get the global form
|
||||
var globalForm = $('.action_update_options_string_form');
|
||||
|
||||
|
||||
/////////////////
|
||||
// Define methods run on startup
|
||||
|
||||
|
|
@ -44,8 +54,13 @@ var ThemeOptions = function () {
|
|||
if (generalInherit()) {
|
||||
$('#general_inherit_on').prop('checked', true).trigger('change').closest('label').addClass('active');
|
||||
$('.action_hide_on_inherit').addClass('d-none');
|
||||
$('.tab_action_hide_on_inherit').addClass('ls-tab-disabled');
|
||||
|
||||
} else {
|
||||
$('#general_inherit_off').prop('checked', true).trigger('change').closest('label').addClass('active');
|
||||
$('.action_hide_on_inherit_wrapper').addClass('d-none');
|
||||
$('.action_hide_on_inherit').removeClass('d-none');
|
||||
$('.tab_action_hide_on_inherit').removeClass('ls-tab-disabled');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -63,7 +78,22 @@ var ThemeOptions = function () {
|
|||
$(item).val((inheritPossible ? 'inherit' : false));
|
||||
}
|
||||
|
||||
optionObject[$(item).attr('name')] = $(item).val();
|
||||
optionObject[$(item).attr('name')] = getOptionFieldValue(item);
|
||||
});
|
||||
|
||||
globalForm.find('.selector_image_selector').each(function (i, item) {
|
||||
|
||||
// disable the preview image button if the image
|
||||
// selected could not be mapped to one of the images
|
||||
// that actually exists within the theme
|
||||
const src = $(item).find('option:selected').data('lightbox-src');
|
||||
const missing = src === '';
|
||||
const itemId = $(item).attr('id');
|
||||
const button = $(`button[data-bs-target="#${itemId}"]`);
|
||||
button.prop('disabled', missing);
|
||||
|
||||
// add some feedback to the user, mark field invalid
|
||||
$(item).toggleClass('is-invalid', missing);
|
||||
});
|
||||
|
||||
globalForm.find('.selector_option_radio_field ').each(function (i, item) {
|
||||
|
|
@ -76,11 +106,31 @@ var ThemeOptions = function () {
|
|||
if ($(item).prop('checked')) {
|
||||
optionObject[$(item).attr('name')] = $(item).val();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// THEME ADDITION: checkboxes (checked = "on"); an untouched box that was
|
||||
// "inherit" keeps "inherit" (see prepareCheckboxField)
|
||||
globalForm.find('.selector_option_checkbox_field').each(function (i, item) {
|
||||
if ($(item).prop('disabled')) {
|
||||
optionObject[$(item).attr('name')] = (inheritPossible ? 'inherit' : 'off');
|
||||
} else if ($(item).data('was-inherit')) {
|
||||
optionObject[$(item).attr('name')] = 'inherit';
|
||||
} else {
|
||||
optionObject[$(item).attr('name')] = $(item).prop('checked') ? 'on' : 'off';
|
||||
}
|
||||
});
|
||||
|
||||
globalForm.find('.selector_text_option_value_field').each(function (i, item) {
|
||||
//disabled items should be inherit or false
|
||||
if ($(item).prop('disabled')) {
|
||||
$(item).val((inheritPossible ? 'inherit' : false));
|
||||
}
|
||||
|
||||
optionObject[$(item).attr('name')] = $(item).val();
|
||||
});
|
||||
|
||||
var newOptionObject = $.extend(true, {}, optionObject);
|
||||
delete newOptionObject.general_inherit;
|
||||
|
||||
|
|
@ -91,9 +141,56 @@ var ThemeOptions = function () {
|
|||
// Utility Methods
|
||||
// -- small utilities i.g. for images or similar, or very specialized functions
|
||||
|
||||
// Color picker text fields are left empty when the value is inherited, so they show the translated placeholder instead of "inherit"
|
||||
var getOptionFieldValue = function (item) {
|
||||
if ($(item).hasClass('selector__color-picker') && $(item).val() === '' && inheritPossible) {
|
||||
return 'inherit';
|
||||
}
|
||||
return $(item).val();
|
||||
};
|
||||
|
||||
var applyColorPickerValue = function (item) {
|
||||
if ($(item).hasClass('selector__color-picker')) {
|
||||
console.ls.log($(item).data('inheritvalue'), $(item).val(), item);
|
||||
if ($(item).val() === 'inherit') {
|
||||
$(item).val('');
|
||||
$(item).closest('.input-group').find('.selector__colorpicker-inherit-value').val($(item).data('inheritvalue')).trigger('change');
|
||||
} else {
|
||||
$(item).closest('.input-group').find('.selector__colorpicker-inherit-value').val($(item).val()).trigger('change');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Special code for numerical
|
||||
var parseNumeric = function (item) {
|
||||
if ($(item).hasClass('selector-numerical-input')) {
|
||||
if (!(/^((\d+)|(inherit))$/.test($(item).val()))) {
|
||||
$(item).val((inheritPossible ? 'inherit' : 1000));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// display inherited options as tooltips
|
||||
var showInheritedValue = function () {
|
||||
$.each($('#simple_edit_add_css > option'), function (i, option) {
|
||||
$.each(optionCssFiles.add, function (i, item) {
|
||||
if (option.value === item && $('#simple_edit_add_css option:first').val() === 'inherit') {
|
||||
$('#simple_edit_add_css option:first').text($('#simple_edit_add_css option:first').text() + ' ' + option.text + ']');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
globalForm.find('.selector-numerical-input').each(function (i, item) {
|
||||
var element = $(item);
|
||||
//element.attr('title', element.attr('title')+optionObjectInheritedValues[$(item).attr('name')]);
|
||||
element.tooltip();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
//Parses the option value for an item
|
||||
var parseOptionValue = function (item, fallbackValue) {
|
||||
fallbackValue = fallbackValue || false;
|
||||
if (fallbackValue == undefined) fallbackValue = false;
|
||||
// If general inherit, then the value of the dropdown is inherit, else it's the value defined in advanced options
|
||||
var itemValue = generalInherit() ? 'inherit' : optionObject[$(item).attr('name')];
|
||||
|
||||
|
|
@ -108,7 +205,7 @@ var ThemeOptions = function () {
|
|||
//Set value and propagate to bootstrapSwitch
|
||||
var setAndPropageteToSwitch = function (item) {
|
||||
$(item).prop('checked', true).trigger('change');
|
||||
$(item).closest('label').addClass('active');
|
||||
//$(item).closest('label').addClass('active');
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -118,10 +215,30 @@ var ThemeOptions = function () {
|
|||
|
||||
// Update values in the form to the template options
|
||||
// selector_option_value_field are the select dropdown (like variations and fonts)
|
||||
// TODO: This seems to be designed for select fields only, but it is also used for other input types. Should be reviewed.
|
||||
var prepareSelectField = function () {
|
||||
globalForm.find('.selector_option_value_field').each(function (i, item) {
|
||||
var itemValue = parseOptionValue(item);
|
||||
$(item).val(itemValue);
|
||||
applyColorPickerValue(item);
|
||||
});
|
||||
};
|
||||
|
||||
// THEME ADDITION: checkbox options (type "checkbox", class
|
||||
// .selector_option_checkbox_field): checked = "on", unchecked = "off".
|
||||
// When the saved value is "inherit" (survey-level inherit), the box shows
|
||||
// the inherited state (data-inheritvalue) and is marked data was-inherit,
|
||||
// so updateFieldSettings() keeps writing "inherit" until the user actually
|
||||
// toggles the box (the change handler in hotSwapFields clears the mark).
|
||||
var prepareCheckboxField = function () {
|
||||
globalForm.find('.selector_option_checkbox_field').each(function (i, item) {
|
||||
var itemValue = parseOptionValue(item, 'off');
|
||||
var effective = (itemValue === 'inherit') ? $(item).data('inheritvalue') : itemValue;
|
||||
$(item).prop('checked', String(effective) === 'on');
|
||||
if (itemValue === 'inherit') {
|
||||
$(item).data('was-inherit', '1');
|
||||
$(item).attr('title', 'Inherited value: ' + $(item).data('inheritvalue'));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -139,7 +256,11 @@ var ThemeOptions = function () {
|
|||
};
|
||||
|
||||
var prepareFontField = function () {
|
||||
optionObject.font = optionObject.font || (inheritPossible ? 'inherit' : 'roboto');
|
||||
var currentPackageObject = 'inherit';
|
||||
// THEME CHANGE: fallback is the bundled default font of this theme
|
||||
// ('noto_sans', self-hosted), never a core package font like roboto/ibm-sans
|
||||
// (privacy: no external font hosts may ever be requested).
|
||||
optionObject.font = optionObject.font || (inheritPossible ? 'inherit' : 'noto_sans');
|
||||
|
||||
if (optionObject.font !== 'inherit') {
|
||||
$('#simple_edit_options_font').val(optionObject.font);
|
||||
|
|
@ -147,30 +268,111 @@ var ThemeOptions = function () {
|
|||
updateFieldSettings();
|
||||
};
|
||||
|
||||
var prepareFruityThemeField = function () {
|
||||
var currentThemeObject = 'inherit';
|
||||
if ($('#TemplateConfiguration_files_css').val() !== 'inherit' && $('body').hasClass('fruity')) {
|
||||
currentThemeObject = {
|
||||
"add": ['css/animate.css', 'css/ajaxify.css', 'css/variations/sea_green.css', 'css/theme.css', 'custom.css']
|
||||
};
|
||||
|
||||
try {
|
||||
currentThemeObject = JSON.parse($('#TemplateConfiguration_files_css').val());
|
||||
} catch (e) {
|
||||
console.error('No valid monochrom theme field!');
|
||||
}
|
||||
|
||||
if (currentThemeObject.add) {
|
||||
$('#simple_edit_add_css').val(currentThemeObject.add.filter(function (item, i) {
|
||||
return /^css\/variations\/.*$/.test(item);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Update values of 'text' options in the form
|
||||
var prepareTextField = function () {
|
||||
globalForm.find('.selector_text_option_value_field').each(function (i, item) {
|
||||
var itemValue = parseOptionValue(item, "");
|
||||
$(item).val(itemValue);
|
||||
});
|
||||
};
|
||||
|
||||
// updates the disabled status of a child field
|
||||
// based on the parent element
|
||||
// NOTE:
|
||||
// for font and variations dropdowns, the childfield
|
||||
// class is added and the data-parent attr exists,
|
||||
// but no parent element exists in the markup
|
||||
// so if we actually have a parent element, enable/disable
|
||||
// based on that, otherwise we enable by default
|
||||
const updateChild = function(parentEl, childEl) {
|
||||
|
||||
let enabled = true;
|
||||
|
||||
if(parentEl.length) {
|
||||
const parentOn = $(parentEl).val() === 'on';
|
||||
const parentChecked = $(parentEl).prop('checked') === true;
|
||||
enabled = parentOn && parentChecked;
|
||||
}
|
||||
|
||||
$(childEl).prop('disabled', !enabled);
|
||||
};
|
||||
|
||||
// grab the parent for a given child field
|
||||
const getParent = function(childEl) {
|
||||
const parentName = $(childEl).data('parent');
|
||||
const parentEl = $(`input[name=${parentName}]`);
|
||||
return parentEl;
|
||||
};
|
||||
|
||||
// go through each child field, grab parent, and update disabled status
|
||||
const updateAllChildren = function() {
|
||||
$('.selector_radio_childfield').each(function (i, childEl) {
|
||||
const parentEl = getParent(childEl);
|
||||
updateChild(parentEl, childEl);
|
||||
});
|
||||
};
|
||||
|
||||
// THEME ADDITION: show/hide whole option fields based on a parent option's value.
|
||||
// A wrapper with class "option-visibility" and data-show-if-parent="<parentName>"
|
||||
// (rendered by options/options.twig for every option that has a parent="..." in
|
||||
// config.xml) is only visible when the checked radio input[name=<parentName>]
|
||||
// has value data-show-if-value (default "on"). This makes e.g. the logo file and
|
||||
// hide-on-small selects disappear when the corresponding logo is set to "No".
|
||||
const updateVisibilityByParent = function() {
|
||||
$('.option-visibility[data-show-if-parent]').each(function (i, wrapperEl) {
|
||||
const parentName = $(wrapperEl).data('show-if-parent');
|
||||
const showValue = $(wrapperEl).data('show-if-value') || 'on';
|
||||
const parentInputs = $('input[name="' + parentName + '"]');
|
||||
// no parent input in the markup (e.g. font's self-parent): always visible,
|
||||
// same fallback as updateChild() above
|
||||
if (parentInputs.length === 0) {
|
||||
$(wrapperEl).removeClass('d-none');
|
||||
return;
|
||||
}
|
||||
const checked = parentInputs.filter(':checked');
|
||||
const visible = checked.length > 0 && checked.val() === String(showValue);
|
||||
$(wrapperEl).toggleClass('d-none', !visible);
|
||||
});
|
||||
};
|
||||
|
||||
///////////////
|
||||
// HotSwap methods
|
||||
// -- These methods connect an input directly to the value in the optionsObject
|
||||
|
||||
// Disable dependent inputs when their parents are set to off, or inherit
|
||||
var hotSwapParentRadioButtons = function () {
|
||||
// hotswapping the select fields to the radiobuttons
|
||||
// If an option is set to off, the attached selectors are disabled
|
||||
$('.selector_radio_childfield').each(function (i, selectorItem) {
|
||||
$('input[name=' + $(selectorItem).data('parent') + ']').on('change', function () {
|
||||
const hotSwapParentRadioButtons = function () {
|
||||
|
||||
if ($(this).val() === 'on' && $(this).prop('checked') == true) {
|
||||
$(selectorItem).prop('disabled', false);
|
||||
} else {
|
||||
$(selectorItem).prop('disabled', true);
|
||||
}
|
||||
|
||||
// disabled this part to always be able to click on "Preview image" button
|
||||
/*
|
||||
if ($(selectorItem).hasClass('selector_image_selector')) {
|
||||
$('button[data-target="#' + $(selectorItem).attr('id') + '"]').prop('disabled', $(selectorItem).val() == 'inherit');
|
||||
}
|
||||
*/
|
||||
// for each child field, add a listener for the
|
||||
// parent's change and update the child's disabled
|
||||
// status accordingly
|
||||
// i = element index in list of matches, unused
|
||||
$('.selector_radio_childfield').each(function (i, childEl) {
|
||||
const parentEl = getParent(childEl);
|
||||
|
||||
parentEl.on('change', function () {
|
||||
updateChild(parentEl, childEl);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
@ -178,47 +380,196 @@ var ThemeOptions = function () {
|
|||
// hotswapping the fields
|
||||
var hotSwapFields = function () {
|
||||
|
||||
globalForm.find('.selector_option_value_field').on('change', function (evt) {
|
||||
globalForm.find('.selector_option_value_field, .selector_text_option_value_field').on('change', function (evt) {
|
||||
updateFieldSettings();
|
||||
parseNumeric(this);
|
||||
});
|
||||
|
||||
globalForm.find('.selector_option_radio_field').on('change', updateFieldSettings);
|
||||
globalForm.find('.selector_option_radio_field').on('change', function (evt) {
|
||||
updateFieldSettings();
|
||||
parseNumeric(this);
|
||||
});
|
||||
|
||||
// THEME ADDITION: checkbox change -> drop the was-inherit mark, re-serialize
|
||||
globalForm.find('.selector_option_checkbox_field').on('change', function (evt) {
|
||||
$(this).removeData('was-inherit');
|
||||
updateFieldSettings();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
var hotswapGeneralInherit = function () {
|
||||
//hotswapping the general inherit
|
||||
$('#general_inherit_on').on('change', function (evt) {
|
||||
$('#TemplateConfiguration_files_css').val('inherit');
|
||||
$('#TemplateConfiguration_files_js').val('inherit');
|
||||
$('#TemplateConfiguration_files_print_css').val('inherit');
|
||||
$('#TemplateConfiguration_options').val('inherit');
|
||||
$('#TemplateConfiguration_cssframework_name').val('inherit');
|
||||
$('#TemplateConfiguration_cssframework_css').val('inherit');
|
||||
$('#TemplateConfiguration_cssframework_js').val('inherit');
|
||||
$('#TemplateConfiguration_packages_to_load').val('inherit');
|
||||
$('.action_hide_on_inherit_wrapper').removeClass('d-none');
|
||||
$('.action_hide_on_inherit').addClass('d-none');
|
||||
$('.tab_action_hide_on_inherit').addClass('ls-tab-disabled');
|
||||
|
||||
|
||||
});
|
||||
$('#general_inherit_off').on('change', function (evt) {
|
||||
$('.action_hide_on_inherit_wrapper').addClass('d-none');
|
||||
$('.action_hide_on_inherit').removeClass('d-none');
|
||||
$('.tab_action_hide_on_inherit').removeClass('ls-tab-disabled');
|
||||
|
||||
updateFieldSettings();
|
||||
});
|
||||
};
|
||||
|
||||
// THEME ADDITION: manage the font packages of ALL font selects, not just the
|
||||
// base "font" dropdown. Every per-element font override (type "fontselect",
|
||||
// class .selector_fontselect) can pick a different font, and each selected
|
||||
// font needs its package (font-<data-font-package>) in packages_to_load,
|
||||
// otherwise the survey page does not load that font's css. Values "inherit"
|
||||
// (survey-level inherit) and "base" (= base font, handled by the font select
|
||||
// itself) contribute no package of their own.
|
||||
// PRIVACY HARD RULE: only LOCAL packages may be added. The only allowed
|
||||
// font package is "websafe" (served from the server's own assets, pure
|
||||
// system-font stacks). Bundled fonts load via the theme's css/fonts.css and
|
||||
// need no package. Any other package (font-roboto, font-noto, ...) is skipped
|
||||
// with a warning, so a survey page can never request a font from Google or
|
||||
// any other external host.
|
||||
var ALLOWED_FONT_PACKAGES = ['websafe'];
|
||||
var hotswapFontField = function () {
|
||||
$('#simple_edit_options_font').on('change', function (evt) {
|
||||
var currentPackageObject = $('#TemplateConfiguration_packages_to_load').val() !== 'inherit'
|
||||
? JSON.parse($('#TemplateConfiguration_packages_to_load').val())
|
||||
: $(this).data('inheritvalue');
|
||||
|
||||
$('.selector_fontselect').on('change', function (evt) {
|
||||
// base font set to "inherit" => inherit the packages as a whole
|
||||
if ($('#simple_edit_options_font').val() === 'inherit') {
|
||||
|
||||
$('#TemplateConfiguration_packages_to_load').val('inherit');
|
||||
return;
|
||||
}
|
||||
var currentPackageObject = $('#TemplateConfiguration_packages_to_load').val() !== 'inherit' ?
|
||||
JSON.parse($('#TemplateConfiguration_packages_to_load').val()) :
|
||||
$(this).data('inheritvalue');
|
||||
|
||||
} else {
|
||||
var selectedFontPackage = $(this).find('option:selected');
|
||||
var packageName = selectedFontPackage.data('font-package');
|
||||
if (currentPackageObject === 'inherit' || !currentPackageObject) {
|
||||
currentPackageObject = {add: []};
|
||||
}
|
||||
|
||||
// drop all font-* packages, then re-add the ones of all current font selects
|
||||
var filteredAdd = (currentPackageObject.add || []).filter(function (value, index) {
|
||||
return !(/^font-.*$/.test(String(value)));
|
||||
});
|
||||
$('.selector_fontselect').each(function (i, item) {
|
||||
var val = $(item).val();
|
||||
if (!val || val === 'inherit' || val === 'base') {
|
||||
return;
|
||||
}
|
||||
var packageName = $(item).find('option:selected').data('font-package');
|
||||
if (!packageName) {
|
||||
return;
|
||||
}
|
||||
// privacy: only allow local packages (see ALLOWED_FONT_PACKAGES)
|
||||
if (ALLOWED_FONT_PACKAGES.indexOf(String(packageName)) === -1) {
|
||||
if (window.console && console.warn) {
|
||||
console.warn('Theme privacy rule: font package "font-' + packageName + '" is not allowed (external hosts are never requested); skipped.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
var formatedPackageName = 'font-' + packageName;
|
||||
if (filteredAdd.indexOf(formatedPackageName) === -1) {
|
||||
filteredAdd.push(formatedPackageName);
|
||||
}
|
||||
});
|
||||
currentPackageObject.add = filteredAdd;
|
||||
$('#TemplateConfiguration_packages_to_load').val(JSON.stringify(currentPackageObject));
|
||||
});
|
||||
};
|
||||
|
||||
var filteredAdd = currentPackageObject.add.filter(function (value, index) {
|
||||
return !(/^font-.*$/.test(String(value)));
|
||||
//hotswapping the colorpickers and adding the reset functionality
|
||||
var hotswapColorPicker = function () {
|
||||
|
||||
globalForm.find('.selector__colorpicker-inherit-value')
|
||||
.on('change', function (e) {
|
||||
$(this).closest('.input-group').find('.selector_option_value_field').val($(this).val()).trigger('change');
|
||||
});
|
||||
|
||||
globalForm.find('.selector__reset-colorfield-to-inherit').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var colorField = $(this).closest('.input-group').find('.selector__color-picker');
|
||||
console.ls.log(colorField, colorField.data('inheritvalue'));
|
||||
$(this).closest('.input-group').find('.selector__colorpicker-inherit-value').val(colorField.data('inheritvalue')).trigger('change');
|
||||
colorField.attr('type', 'text').val('');
|
||||
optionObject[colorField.attr('name')] = 'inherit';
|
||||
updateFieldSettings();
|
||||
});
|
||||
};
|
||||
|
||||
var removeVariationsFromField = function (fieldSelector) {
|
||||
if ($(fieldSelector).val() === 'inherit') {
|
||||
fieldSelector = '#optionCssFiles';
|
||||
}
|
||||
let currentValue = {};
|
||||
try {
|
||||
currentValue = JSON.parse($(fieldSelector).val());
|
||||
} catch (error) {
|
||||
currentValue = {};
|
||||
}
|
||||
let empty = true;
|
||||
['add', 'replace', 'remove'].forEach(function (action) {
|
||||
if (currentValue.hasOwnProperty(action)) {
|
||||
currentValue[action] = currentValue[action].filter(function (item) {
|
||||
return !(/^css\/variations\/.*$/.test(item));
|
||||
});
|
||||
filteredAdd.push(formatedPackageName);
|
||||
currentPackageObject.add = filteredAdd;
|
||||
$('#TemplateConfiguration_packages_to_load').val(JSON.stringify(currentPackageObject));
|
||||
if (currentValue[action].length) {
|
||||
empty = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!empty) {
|
||||
$(fieldSelector).val(JSON.stringify(currentValue));
|
||||
} else {
|
||||
$(fieldSelector).val(inheritPossible ? 'inherit' : JSON.stringify({}));
|
||||
}
|
||||
};
|
||||
|
||||
// update the files_css field to be saved in the database
|
||||
var addVariationToField = function (selectedVariation, filesCssId, selectedMode) {
|
||||
let filesCss = [];
|
||||
try {
|
||||
filesCss = JSON.parse($(filesCssId).val());
|
||||
} catch (error) {
|
||||
}
|
||||
if (!filesCss.hasOwnProperty(selectedMode)) {
|
||||
filesCss[selectedMode] = [];
|
||||
}
|
||||
if (selectedMode === 'replace') {
|
||||
filesCss[selectedMode].push(selectedVariation);
|
||||
} else {
|
||||
filesCss[selectedMode].unshift(selectedVariation);
|
||||
}
|
||||
$(filesCssId).val(JSON.stringify(filesCss));
|
||||
};
|
||||
|
||||
var hotswapTheme = function () {
|
||||
$('#simple_edit_options_cssframework').on('change', function (evt) {
|
||||
let newThemeDataValue = $('option:selected', this).attr('data-value') || false;
|
||||
let selectedVariation = newThemeDataValue || $('#simple_edit_options_cssframework').val();
|
||||
let selectedMode = $('#simple_edit_options_cssframework').find('option[value=\'' + selectedVariation + '\']').attr('data-mode') || 'add';
|
||||
let filesCssId = '#TemplateConfiguration_files_css';
|
||||
let filesCss = {};
|
||||
try {
|
||||
filesCss = JSON.parse($(filesCssId).val());
|
||||
} catch (e) {
|
||||
filesCss = $(filesCssId).val();
|
||||
}
|
||||
// load the parent data if set to inherit, so no data gets lost
|
||||
if (filesCss.length === 0 || filesCss === 'inherit') {
|
||||
$(filesCssId).val($('#optionCssFiles').val());
|
||||
}
|
||||
removeVariationsFromField(filesCssId);
|
||||
removeVariationsFromField('#TemplateConfiguration_cssframework_css');
|
||||
if (selectedVariation !== 'inherit') {
|
||||
addVariationToField(selectedVariation, filesCssId, selectedMode);
|
||||
} else {
|
||||
$(filesCssId).val('inherit');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -229,22 +580,18 @@ var ThemeOptions = function () {
|
|||
var onSaveButtonClickAction = function (evt) {
|
||||
evt.preventDefault();
|
||||
|
||||
if (generalInherit()) {
|
||||
if ($('#general_inherit_on').prop('checked')) {
|
||||
$('#TemplateConfiguration_options').val('inherit');
|
||||
$('#template-options-form').trigger('submit'); // submit the form
|
||||
} else {
|
||||
updateFieldSettings();
|
||||
//Create a copy of the inherent optionObject
|
||||
var newOptionObject = $.extend(true, {}, optionObject);
|
||||
newOptionObject.generalInherit = null;
|
||||
|
||||
// Now write the newly created object to the correspondent field as a json string
|
||||
//now write the newly created object to the correspondent field as a json string
|
||||
$('#TemplateConfiguration_options').val(JSON.stringify(newOptionObject));
|
||||
|
||||
// And submit the form
|
||||
// Beware, we are triggering 'submit' directly, which doesn't trigger HTML5 validations.
|
||||
// No HTML5 validations needed here, so all good.
|
||||
// If not we would need to add a hidden submit button and trigger a 'click' on it. (see fruity theme).
|
||||
// Like these: $('#template-options-form').find('button[type=submit]').trigger('click');
|
||||
//and submit the form
|
||||
$('#template-options-form').trigger('submit');
|
||||
}
|
||||
};
|
||||
|
|
@ -254,13 +601,54 @@ var ThemeOptions = function () {
|
|||
// Instance methods
|
||||
var bind = function () {
|
||||
//if the save button is clicked write everything into the template option field and send the form
|
||||
$('.action_update_options_string_button, #theme-options--submit').on('click', onSaveButtonClickAction);
|
||||
$('#theme-options--submit').on('click', onSaveButtonClickAction);
|
||||
|
||||
//Bind the hotwaps
|
||||
hotSwapParentRadioButtons();
|
||||
hotSwapFields();
|
||||
hotswapGeneralInherit();
|
||||
hotswapColorPicker();
|
||||
hotswapFontField();
|
||||
hotswapTheme();
|
||||
|
||||
// THEME ADDITION: re-evaluate conditional visibility whenever a radio changes
|
||||
globalForm.find('.selector_option_radio_field').on('change', updateVisibilityByParent);
|
||||
};
|
||||
|
||||
// THEME ADDITION: order the font dropdowns' optgroups as:
|
||||
// Custom (this theme) > Bundled open source fonts > User browser > Local server - core/user (LAST).
|
||||
// Core package optgroups are recognized structurally (their options carry
|
||||
// data-font-package equal to their own value; theme/user fonts use "websafe"),
|
||||
// the rest by label keyword, so translated labels still work.
|
||||
var reorderFontDropdowns = function () {
|
||||
var rank = function (label) {
|
||||
var l = String(label || '').toLowerCase();
|
||||
if (l.indexOf('custom') !== -1) { return 0; }
|
||||
if (l.indexOf('bundled') !== -1) { return 1; }
|
||||
if (l.indexOf('user') !== -1) { return 2; }
|
||||
return 3;
|
||||
};
|
||||
var isServerPackageGroup = function ($og) {
|
||||
var $first = $og.children('option').first();
|
||||
return $first.length > 0 && $first.attr('data-font-package') === $first.attr('value');
|
||||
};
|
||||
globalForm.find('.selector_fontselect').each(function () {
|
||||
var $sel = $(this);
|
||||
// THEME ADDITION: drop empty optgroups (e.g. "Custom (this theme)" when
|
||||
// the theme ships no own font) — an empty category is not shown.
|
||||
$sel.children('optgroup').each(function () {
|
||||
if ($(this).children('option').length === 0) { $(this).remove(); }
|
||||
});
|
||||
var groups = $sel.children('optgroup').get();
|
||||
groups.sort(function (a, b) {
|
||||
var aSrv = isServerPackageGroup($(a));
|
||||
var bSrv = isServerPackageGroup($(b));
|
||||
if (aSrv !== bSrv) { return aSrv ? 1 : -1; } // server packages last
|
||||
if (aSrv && bSrv) { return 0; } // keep core before user (original order)
|
||||
return rank($(a).attr('label')) - rank($(b).attr('label'));
|
||||
});
|
||||
$.each(groups, function (i, g) { $sel.append(g); });
|
||||
});
|
||||
};
|
||||
|
||||
var run = function () {
|
||||
|
|
@ -269,34 +657,43 @@ var ThemeOptions = function () {
|
|||
startupGeneralInherit();
|
||||
|
||||
prepareSelectField();
|
||||
prepareTextField();
|
||||
parseParentSwitchFields();
|
||||
prepareCheckboxField();
|
||||
prepareFontField();
|
||||
prepareFruityThemeField();
|
||||
showInheritedValue();
|
||||
|
||||
// THEME ADDITION: font dropdown optgroup order (see above)
|
||||
reorderFontDropdowns();
|
||||
|
||||
bind();
|
||||
|
||||
// set initial disabled status of child fields
|
||||
updateAllChildren();
|
||||
|
||||
// THEME ADDITION: set initial visibility of conditional fields
|
||||
updateVisibilityByParent();
|
||||
};
|
||||
|
||||
return run;
|
||||
|
||||
};
|
||||
|
||||
var prepare = function () {
|
||||
$(function () {
|
||||
var prepare = function () {
|
||||
|
||||
var deferred = $.Deferred();
|
||||
var deferred = $.Deferred();
|
||||
|
||||
//activate the bootstrap switch for checkboxes
|
||||
$('.action_activate_bootstrapswitch').bootstrapSwitch();
|
||||
var themeOptionStarter = new ThemeOptions();
|
||||
themeOptionStarter();
|
||||
|
||||
var themeOptionStarter = new ThemeOptions();
|
||||
themeOptionStarter();
|
||||
setTimeout(function () {
|
||||
deferred.resolve();
|
||||
}, 650);
|
||||
return deferred.promise();
|
||||
};
|
||||
|
||||
setTimeout(function () {
|
||||
deferred.resolve();
|
||||
}, 650);
|
||||
return deferred.promise();
|
||||
};
|
||||
|
||||
|
||||
$(document).off('pjax:scriptcomplete.templateOptions').on('ready pjax:scriptcomplete.templateOptions', function () {
|
||||
$('.simple-template-edit-loading').css('display', 'block');
|
||||
prepare().then(function (runsesolve) {
|
||||
$('.simple-template-edit-loading').css('display', 'none');
|
||||
|
|
@ -308,21 +705,165 @@ $(document).off('pjax:scriptcomplete.templateOptions').on('ready pjax:scriptcomp
|
|||
var imgTitle = $($(this).data('bs-target')).val();
|
||||
imgTitle = imgTitle.split('/').pop();
|
||||
$('#lightbox-modal').find('.selector__title').text(imgTitle);
|
||||
$('#lightbox-modal').find('.selector__image').attr({'src': imgSrc, 'alt': imgTitle});
|
||||
$('#lightbox-modal').find('.selector__image').attr({
|
||||
'src': imgSrc,
|
||||
'alt': imgTitle
|
||||
});
|
||||
$('#lightbox-modal').modal('show');
|
||||
});
|
||||
|
||||
var uploadImageBind = new bindUpload({
|
||||
// Icon values are hexadecimal code points, show them as text so other values can't add markup
|
||||
var iconCharacter = function (hexCode) {
|
||||
hexCode = String(hexCode);
|
||||
var codePoint = parseInt(hexCode, 16);
|
||||
return /^[0-9a-f]{1,6}$/i.test(hexCode) && codePoint <= 0x10FFFF ? String.fromCodePoint(codePoint) : '';
|
||||
};
|
||||
|
||||
$('.simple_edit_options_checkicon').on('change', function () {
|
||||
var preview = $(this).siblings('.selector__checkicon-preview').find('i');
|
||||
var hexCode = $(this).val() == 'inherit' ? preview.attr('data-inheritvalue') : $(this).val();
|
||||
preview.text(iconCharacter(hexCode));
|
||||
});
|
||||
});
|
||||
$(function () {
|
||||
let selectedTabHash = window.location.hash;
|
||||
let selectedTabElement = document.querySelector('[data-bs-target="' + selectedTabHash + '"]');
|
||||
if (selectedTabElement !== null) {
|
||||
let tab = new bootstrap.Tab(selectedTabElement);
|
||||
tab.show();
|
||||
}
|
||||
|
||||
var BindUpload = function (options) {
|
||||
var $activeForm = $(options.form);
|
||||
var $activeInput = $(options.input);
|
||||
var $progressBar = $(options.progress);
|
||||
|
||||
var onSuccess = options.onSuccess || function () {
|
||||
};
|
||||
var onBeforeSend = options.onBeforeSend || function () {
|
||||
};
|
||||
|
||||
var progressHandling = function (event) {
|
||||
var percent = 0;
|
||||
var position = event.loaded || event.position;
|
||||
var total = event.total;
|
||||
if (event.lengthComputable) {
|
||||
percent = Math.ceil(position / total * 100);
|
||||
}
|
||||
// update progressbars classes so it fits your code
|
||||
$progressBar.css('width', String(percent) + '%');
|
||||
$progressBar.find('span.visually-hidden').text(percent + '%');
|
||||
};
|
||||
|
||||
$activeInput.on('change', function (e) {
|
||||
e.preventDefault();
|
||||
var formData = new FormData($activeForm[0]);
|
||||
console.log(JSON.stringify(formData));
|
||||
// add assoc key values, this will be posts values
|
||||
formData.append('file', $activeInput.prop('files')[0]);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $activeForm.attr('action'),
|
||||
xhr: function () {
|
||||
var myXhr = $.ajaxSettings.xhr();
|
||||
if (myXhr.upload) {
|
||||
myXhr.upload.addEventListener('progress', progressHandling, false);
|
||||
}
|
||||
return myXhr;
|
||||
},
|
||||
beforeSend: onBeforeSend,
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
if (data.success === true) {
|
||||
LS.LsGlobalNotifier.createAlert(data.message, 'success', {showCloseButton: true});
|
||||
$progressBar.css('width', '0%');
|
||||
$progressBar.find('span.visually-hidden').text('0%');
|
||||
onSuccess(options.input, data);
|
||||
} else {
|
||||
LS.LsGlobalNotifier.createAlert(data.message, 'danger', {showCloseButton: true});
|
||||
$progressBar.css('width', '0%');
|
||||
$progressBar.find('span.visually-hidden').text('0%');
|
||||
}
|
||||
},
|
||||
error: function (error) {
|
||||
$progressBar.css('width', '0%');
|
||||
$progressBar.find('span.visually-hidden').text('0%');
|
||||
console.log(error);
|
||||
},
|
||||
async: true,
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
timeout: 60000
|
||||
});
|
||||
});
|
||||
return this;
|
||||
};
|
||||
new BindUpload({
|
||||
form: '#upload_frontend',
|
||||
input: '#upload_image',
|
||||
progress: '#upload_progress',
|
||||
onSuccess: function (inputId, data) {
|
||||
addUploadedImageToSelectors(data && data.file);
|
||||
}
|
||||
});
|
||||
new BindUpload({
|
||||
form: '#upload_frontend',
|
||||
input: '#upload_image_frontend',
|
||||
progress: '#upload_progress_frontend',
|
||||
onBeforeSend: function () {
|
||||
$('.simple-template-edit-loading').css('display', 'block');
|
||||
},
|
||||
onSuccess: function () {
|
||||
setTimeout(function () {
|
||||
$(document).trigger('pjax:load', {url: window.location.href});
|
||||
}, 2500);
|
||||
onSuccess: function (inputId, data) {
|
||||
$('.simple-template-edit-loading').css('display', 'none');
|
||||
addUploadedImageToSelectors(data && data.file);
|
||||
}
|
||||
});
|
||||
|
||||
// Adds a freshly uploaded image to the theme options image selectors so it becomes
|
||||
// selectable immediately, without a full page reload. Falls back to a reload if the
|
||||
// server didn't return the file info.
|
||||
function addUploadedImageToSelectors(file) {
|
||||
if (!file || !file.filepath) {
|
||||
let url = new URL(window.location.href);
|
||||
let activeTab = document.querySelector('.CoreThemeOptions--settingsTab.active');
|
||||
url.hash = activeTab !== null ? activeTab.id : '';
|
||||
$(document).trigger('pjax:load', { url: url.href });
|
||||
return;
|
||||
}
|
||||
// Group options by their virtual path prefix (e.g. "image::generalfiles::").
|
||||
let prefixMatch = String(file.filepath).match(/^(image::\w+::)/);
|
||||
let prefix = prefixMatch ? prefixMatch[1] : null;
|
||||
$('.selector_image_selector').each(function () {
|
||||
let select = this;
|
||||
// Skip if the image is already listed (e.g. an existing file was overwritten).
|
||||
let exists = Array.prototype.some.call(select.options, function (opt) {
|
||||
return opt.value === file.filepath;
|
||||
});
|
||||
if (exists) {
|
||||
return;
|
||||
}
|
||||
let option = new Option(file.filename, file.filepath);
|
||||
option.setAttribute('data-lightbox-src', file.preview || '');
|
||||
// Insert after the last option of the same group, otherwise append.
|
||||
let insertAfter = null;
|
||||
if (prefix) {
|
||||
Array.prototype.forEach.call(select.options, function (opt) {
|
||||
if (opt.value.indexOf(prefix) === 0) {
|
||||
insertAfter = opt;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (insertAfter && insertAfter.nextSibling) {
|
||||
insertAfter.parentNode.insertBefore(option, insertAfter.nextSibling);
|
||||
} else if (insertAfter) {
|
||||
insertAfter.parentNode.appendChild(option);
|
||||
} else {
|
||||
select.appendChild(option);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,423 +1,406 @@
|
|||
{#
|
||||
LimeSurvey
|
||||
Copyright (C) 2007-2017 The LimeSurvey Project Team / Louis Gac
|
||||
All rights reserved.
|
||||
License: GNU/GPL License v2 or later, see LICENSE.php
|
||||
LimeSurvey is free software. This version may have been modified pursuant
|
||||
to the GNU General Public License, and as distributed it includes or
|
||||
is derivative of works licensed under the GNU General Public License or
|
||||
other free or open source software licenses.
|
||||
See COPYRIGHT.php for copyright notices and details.
|
||||
Custom options page of this theme. Activated by <optionspage>custom</optionspage>
|
||||
in config.xml: LimeSurvey then renders THIS file inside the "Simple options" tab
|
||||
of themeOptions/update (instead of the core options_core.php partial) and
|
||||
auto-registers options/options.js next to it.
|
||||
|
||||
(¯`·._.·(¯`·._.· Default survey template options ._.·´¯)·._.·´¯)
|
||||
All options are rendered GENERICALLY from config.xml via aOptionAttributes (the
|
||||
same structure the core renderer uses, see TemplateManifest::getOptionAttributes()),
|
||||
grouped by category. Adding an <option> to config.xml is therefore enough - it
|
||||
shows up here automatically. Supported types: buttons, dropdown, fontselect,
|
||||
checkbox, imagefile, colorpicker, duration, text.
|
||||
(fontselect = per-element font override: same choices as the base "font"
|
||||
dropdown plus "Same as base font"; see the branch below.)
|
||||
|
||||
This is the form for the option parameters of the basic default template.
|
||||
Tab order: the "Fonts" category tab is FIRST (default font + per-element font
|
||||
overrides), then the "Top of the page" tab, then the other categories.
|
||||
|
||||
Exception: the options that make up the TOP OF THE PAGE (header menu, logos,
|
||||
header colors, progress bar) are pulled out of their config.xml categories
|
||||
into a dedicated tab, "Top of the page" (see aTopOfPageKeys below).
|
||||
Values are stored per option key, so this regrouping does not touch stored
|
||||
values and needs no theme reset to take effect.
|
||||
|
||||
options/options.js is a copy of the core assets/packages/themeoptions-core/
|
||||
themeoptions-core.js (patched to also hide .action_hide_on_inherit rows when
|
||||
"Inherit everything" is on, because the custom page has no category tabs).
|
||||
#}
|
||||
|
||||
{{ registerPackage('font-roboto') }}
|
||||
{{ registerPackage('font-noto') }}
|
||||
{{ registerPackage('font-news_cycle') }}
|
||||
{{ registerPackage('font-ubuntu') }}
|
||||
{{ registerPackage('font-lato') }}
|
||||
{# PRIVACY: during survey-taking this theme must NEVER make external requests
|
||||
(no calls to Google or any other font host). Therefore only the LOCAL
|
||||
"font-websafe" package is registered here (its css is served from the
|
||||
LimeSurvey server's own assets and only defines system-font stacks), so the
|
||||
browser-font choices in the font dropdowns can be previewed. The Google-hosted
|
||||
core packages (font-roboto, font-noto, ...) are deliberately NOT registered,
|
||||
and the bundled fonts (files/fonts/*.woff2) are self-hosted via css/fonts.css.
|
||||
options/options.js enforces the same rule for packages_to_load: only
|
||||
"websafe" may be added there. variants/export_public.sh aborts the public
|
||||
release if any other external host is referenced anywhere in the theme. #}
|
||||
{{ registerPackage('font-websafe') }}
|
||||
|
||||
{# The default template offers the variety of styles #}
|
||||
{% set fontOptions = '' %}
|
||||
{# CACHE-BUST options.js: core registers it as optionsPath ~ '/options.js' WITHOUT a
|
||||
version query (LSETwigViewRenderer::renderOptionPage), so browsers may serve a
|
||||
heuristically cached copy (the file has only Last-Modified/ETag, no Cache-Control).
|
||||
Re-register it with a version token: bump OPTIONS_JS_TOKEN below whenever
|
||||
options/options.js changes, so every browser fetches the new file once. #}
|
||||
{% set OPTIONS_JS_TOKEN = '20261124.3' %}
|
||||
{{ unregisterScriptFile(optionsPath ~ '/options.js') }}
|
||||
{{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}
|
||||
|
||||
{% set brandlogofileOptions , brandlogofileInheritFilename, brandlogofileInheritPreview = '', '', '' %}
|
||||
{# FONT DROPDOWNS, fixed inline (rendered into the page HTML, so it always runs on
|
||||
a fresh page load — even if the browser serves a heuristically cached
|
||||
options.js; options/options.js has the same logic as a fallback, running twice
|
||||
is idempotent). Core prepends the "Local server" optgroups server-side
|
||||
(TemplateManifest::getOptionAttributes), so the order can only be fixed
|
||||
client-side. Three things are done for every font select (.selector_fontselect):
|
||||
1. EMPTY optgroups are removed (e.g. "Custom (this theme)" when the theme
|
||||
ships no own font) — an empty category is not shown.
|
||||
2. Optgroups are ordered Custom (this theme) > Bundled open source fonts >
|
||||
User browser > Local server - Core/User LAST. Server packages are detected
|
||||
structurally: their first option has data-font-package === value.
|
||||
3. The base font select (#simple_edit_options_font) gets its selected value from
|
||||
the stored options (#TemplateConfiguration_options JSON, fallback
|
||||
data-inheritvalue), and on form submit the chosen value is patched into that
|
||||
JSON — so the base font displays and saves correctly even if options.js did
|
||||
not run. NOTE: registerScript needs an explicit position ('POS_END') — the
|
||||
default position resolves to '' which CClientScript never renders. #}
|
||||
{{ registerScript('respondage-font-dropdown-order', "(function(){var rank=function(label){var l=String(label||'').toLowerCase();if(l.indexOf('custom')!==-1){return 0;}if(l.indexOf('bundled')!==-1){return 1;}if(l.indexOf('user')!==-1){return 2;}return 3;};var isSrv=function(og){var o=og.querySelector('option');return !!(o&&o.getAttribute('data-font-package')===o.getAttribute('value'));};var fix=function(){var selects=document.querySelectorAll('.selector_fontselect');Array.prototype.forEach.call(selects,function(sel){Array.prototype.slice.call(sel.children).forEach(function(el){if(el.tagName==='OPTGROUP'&&!el.querySelector('option')){el.parentNode.removeChild(el);}});var groups=Array.prototype.slice.call(sel.children).filter(function(el){return el.tagName==='OPTGROUP';});groups.sort(function(a,b){var as=isSrv(a),bs=isSrv(b);if(as!==bs){return as?1:-1;}if(as&&bs){return 0;}return rank(a.getAttribute('label'))-rank(b.getAttribute('label'));});groups.forEach(function(g){sel.appendChild(g);});});var base=document.getElementById('simple_edit_options_font');if(base){var stored=null;var f=document.getElementById('TemplateConfiguration_options');if(f){try{var o=JSON.parse(f.value);if(o&&o.font){stored=o.font;}}catch(e){}}if(!stored&&base.getAttribute('data-inheritvalue')){stored=base.getAttribute('data-inheritvalue');}if(stored&&base.querySelector('option[value=\"'+stored+'\"]')){base.value=stored;}}var form=document.querySelector('.action_update_options_string_form');if(form&&base){form.addEventListener('submit',function(){var f2=document.getElementById('TemplateConfiguration_options');if(!f2||!base.value){return;}try{var o2=JSON.parse(f2.value);if(o2&&typeof o2==='object'){o2.font=base.value;f2.value=JSON.stringify(o2);}}catch(e){}},true);}};if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',fix);}else{fix();}})();", 'POS_END') }}
|
||||
|
||||
{# For surveyspecific settings add an inherit option #}
|
||||
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
|
||||
{% set fontOptions = fontOptions ~ '<option value="inherit">'~ gT("Inherit") ~' ( '~ gT("Inherited value:")~' '~ oParentOptions.font ~' )</option>' %}
|
||||
{% endif %}
|
||||
{# CURRENT VALUES FOR SELECTS, inline (rendered into the page HTML, so it always runs
|
||||
on a fresh page load — even if the browser serves a heuristically cached
|
||||
options.js; options.js prepareSelectField() does the same and is idempotent).
|
||||
The <option> HTML of dropdown/fontselect/imagefile comes prebuilt from core
|
||||
(dropdownoptions|raw / imageOptions), so the selected option cannot be marked
|
||||
server-side there — set sel.value from the stored options JSON instead. Buttons,
|
||||
checkboxes, text/color inputs and the inherit options ARE marked server-side in
|
||||
the markup below (checked/selected/value). When the row is "inherit", JSON.parse
|
||||
fails and the server-side selected inherit options stay in charge. #}
|
||||
{{ registerScript('respondage-current-values', "(function(){var f=document.getElementById('TemplateConfiguration_options');if(!f){return;}var stored=null;try{var o=JSON.parse(f.value);if(o&&typeof o==='object'){stored=o;}}catch(e){}if(!stored){return;}var sels=document.querySelectorAll('select.selector_option_value_field');Array.prototype.forEach.call(sels,function(sel){var key=sel.getAttribute('name');if(!key||!Object.prototype.hasOwnProperty.call(stored,key)){return;}var v=stored[key];if(v==null||v==='inherit'){return;}v=String(v);var ok=Array.prototype.some.call(sel.options,function(op){return op.value===v;});if(ok){sel.value=v;}});})();", 'POS_END') }}
|
||||
|
||||
{% set fontOptions %}
|
||||
{{fontOptions}}
|
||||
<optgroup label="{{ gT("Local Server") }}">
|
||||
<option class="font-roboto" value="roboto" data-font-package="roboto" >Roboto</option>
|
||||
<option class="font-news_cycle" value="news_cycle" data-font-package="news_cycle" >News Cycle</option>
|
||||
<option class="font-lato" value="lato" data-font-package="lato" >Lato</option>
|
||||
<option class="font-noto" value="noto" data-font-package="noto" >Noto Sans</option>
|
||||
<option class="font-ubuntu" value="ubuntu" data-font-package="ubuntu" >Ubuntu</option>
|
||||
</optgroup>
|
||||
{% set bInherit = templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
|
||||
|
||||
<optgroup label="{{ gT("User browser") }}">
|
||||
{# CURRENT OPTION VALUES, rendered server-side (so the selected state never depends
|
||||
on options.js being fresh): parse the stored options JSON once. When the whole row
|
||||
is "inherit" (survey/group level with "Inherit everything"), every option value is
|
||||
"inherit" → the Inherit controls get checked/selected. Per key the fallback is the
|
||||
parent (inherited) value from oParentOptions. NOTE: use "is defined" checks, NOT
|
||||
|default — "0" is a legitimate value (e.g. showpopups) and |default would drop it. #}
|
||||
{% set aCurrentOptions = json_decode(templateConfiguration.options) %}
|
||||
{% set bGeneralInherit = templateConfiguration.options == 'inherit' %}
|
||||
|
||||
<option class="font-georgia " value="georgia" data-font-package="websafe" >Georgia</option>
|
||||
<option class="font-palatino " value="palatino" data-font-package="websafe" >Palatino Linotype</option>
|
||||
<option class="font-times_new_roman " value="times_new_roman" data-font-package="websafe" >Times New Roman</option>
|
||||
<option class="font-arial " value="arial" data-font-package="websafe" >Arial</option>
|
||||
<option class="font-arial_black " value="arial_black" data-font-package="websafe" >Arial Black</option>
|
||||
<option class="font-comic_sans " value="comic_sans" data-font-package="websafe" >Comic Sans</option>
|
||||
<option class="font-impact " value="impact" data-font-package="websafe" >Impact</option>
|
||||
<option class="font-lucida_sans " value="lucida_sans" data-font-package="websafe" >Lucida Sans</option>
|
||||
<option class="font-trebuchet " value="trebuchet" data-font-package="websafe" >Trebuchet</option>
|
||||
<option class="font-courier " value="courier" data-font-package="websafe" >Courier New</option>
|
||||
<option class="font-lucida_console " value="lucida_console" data-font-package="websafe" >Lucida Console</option>
|
||||
</optgroup>
|
||||
{% endset %}
|
||||
{# Options list for imagefile selects, with an <optgroup> per image group #}
|
||||
{% set imageOptions = '' %}
|
||||
{% set imgGroup = '' %}
|
||||
{% for image in templateConfiguration.imageFileList %}
|
||||
{% if image.group != imgGroup %}
|
||||
{% if imgGroup != '' %}{% set imageOptions = imageOptions ~ '</optgroup>' %}{% endif %}
|
||||
{% set imageOptions = imageOptions ~ '<optgroup label="' ~ image.group ~ '">' %}
|
||||
{% set imgGroup = image.group %}
|
||||
{% endif %}
|
||||
{% set imageOptions = imageOptions ~ '<option data-lightbox-src="' ~ image.preview ~ '" value="' ~ image.filepath ~ '">' ~ image.filename ~ '</option>' %}
|
||||
{% endfor %}
|
||||
{% if imgGroup != '' %}{% set imageOptions = imageOptions ~ '</optgroup>' %}{% endif %}
|
||||
|
||||
<div class="container-fluid" style="position:relative">
|
||||
{# Small loading animation to give the scripts time to parse and render the correct values #}
|
||||
<div class="" style="display:none;height:100%;width:100%;position:absolute;left:0;top:0;background:rgb(255,255,255);background:rgba(235,235,235,0.8);z-index:2000;">
|
||||
<div style="position:absolute; left:49%;top:35%;" class="text-center">
|
||||
<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
|
||||
<div class="simple-template-edit-loading text-center" style="display:none">
|
||||
<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
|
||||
</div>
|
||||
|
||||
{# If this is a survey-specific (or survey-group) settings page, offer full inheritance of the parent template #}
|
||||
{% if bInherit %}
|
||||
<div class="row" id="general_inherit_active">
|
||||
<label id="inherit_label_announcement" class="form-label">{{ gT("Inherit everything") }}</label>
|
||||
<div class="col-12" role="radiogroup" aria-labelledby="inherit_label_announcement">
|
||||
<div class="btn-group" data-bs-toggle="buttons">
|
||||
<input id="general_inherit_on" name="general_inherit" type="radio" value="on"
|
||||
{% if bGeneralInherit %}checked{% endif %}
|
||||
class="btn-check selector_option_general_inherit" data-id="simple_edit_options_general_inherit"/>
|
||||
<label for="general_inherit_on" class="btn btn-outline-secondary{% if bGeneralInherit %} active{% endif %}">{{ gT("Inherited") }}</label>
|
||||
<input id="general_inherit_off" name="general_inherit" type="radio" value="off"
|
||||
{% if not bGeneralInherit %}checked{% endif %}
|
||||
class="btn-check selector_option_general_inherit" data-id="simple_edit_options_general_inherit"/>
|
||||
<label for="general_inherit_off" class="btn btn-outline-secondary{% if not bGeneralInherit %} active{% endif %}">{{ gT("Customize theme") }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
{# Begin template option form #}
|
||||
<form class='form action_update_options_string_form' action=''>
|
||||
<div class="row action_hide_on_inherit">
|
||||
<hr/>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# If this is a surveyspecific settings page, offer the possibility to do a full inheritance of the parent template #}
|
||||
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
|
||||
<div class='row' id="general_inherit_active">
|
||||
<div class='mb-3 row'>
|
||||
<label for='simple_edit_options_general_inherit' class='control-label'>{{gT("Inherit everything" )}}</label>
|
||||
<div class='col-12'>
|
||||
<div class="btn-group" data-bs-toggle="buttons">
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input id="general_inherit_on" name='general_inherit' type='radio' value='on' class='selector_option_general_inherit ' data-id='simple_edit_options_general_inherit'/>
|
||||
{{ gT("Yes") }}
|
||||
</label>
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input id="general_inherit_off" name='general_inherit' type='radio' value='off' class='selector_option_general_inherit ' data-id='simple_edit_options_general_inherit'/>
|
||||
{{ gT("No") }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row action_hide_on_inherit">
|
||||
<hr/>
|
||||
</div>
|
||||
{# Every tab pane ends with the Respondage footer. The logo uses a dedicated file
|
||||
name (not logo.png) on purpose: variants may ship their own files/logo.png as
|
||||
client logo, and imageSrc() resolves './files/...' in the variant first — with
|
||||
this name it falls through to the mother theme, so the footer always shows the
|
||||
Respondage logo. #}
|
||||
{% set respondageLogo = imageSrc('./files/respondage-logo.png') %}
|
||||
|
||||
{# Options that make up the TOP OF THE PAGE (everything in the header, plus the
|
||||
progress bar which sits in/just under the header): the menu (navbar text color),
|
||||
the left/center/right logos, the header background color, and the progress bar
|
||||
position + colors. These keys are pulled out of their original config.xml
|
||||
categories (Colors / Images / Progress) into a dedicated FIRST tab below.
|
||||
Values are stored per option key, so moving them here does not change any stored
|
||||
value. The order of this list is the order shown in the tab. #}
|
||||
{% set aTopOfPageKeys = [
|
||||
'headerbackgroundcolor', 'navbarfontcolor',
|
||||
'headersticky', 'headerstickycomputer', 'headerstickytablet', 'headerstickymobile',
|
||||
'brandlogo', 'brandlogofile', 'brandlogohideonsmall',
|
||||
'centerlogo', 'centerlogofile', 'centerlogohideonsmall',
|
||||
'rightlogo', 'rightlogofile', 'rightlogohideonsmall',
|
||||
'logotopmargin',
|
||||
'progressbarposition', 'progressbarbackgroundcolor', 'progressbarcolor', 'progressbarfontcolor'
|
||||
] %}
|
||||
|
||||
{# Tab list: FIRST the "Fonts" tab (where the default/base font is chosen and the
|
||||
per-element font overrides live), then the "Top of the page" tab (keys =
|
||||
aTopOfPageKeys), then one tab per remaining category from config.xml like the
|
||||
core options page (keys = null: all options of that category, except the
|
||||
top-of-page keys). Category tab ids are slugs of the category name, so they
|
||||
stay stable regardless of the tab order. #}
|
||||
{% set aTabs = [] %}
|
||||
{% if 'Fonts' in aOptionAttributes.categories %}
|
||||
{% set aTabs = [{ 'id': 'category-fonts', 'label': 'Fonts', 'category': 'Fonts', 'keys': null }] %}
|
||||
{% endif %}
|
||||
{% set aTabs = aTabs|merge([{ 'id': 'top-of-page', 'label': 'Top of the page', 'category': 'Top of the page', 'keys': aTopOfPageKeys }]) %}
|
||||
{% for category in aOptionAttributes.categories %}
|
||||
{% if category != 'Fonts' and category != 'Top of the page' %}
|
||||
{% set aTabs = aTabs|merge([{ 'id': 'category-' ~ category|lower|replace({' ': '-'}), 'label': category, 'category': category, 'keys': null }]) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<ul class="nav nav-tabs mt-3" role="tablist">
|
||||
{% for tab in aTabs %}
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link tab_action_hide_on_inherit {% if loop.first %}active{% endif %}"
|
||||
id="tab-{{ tab.id }}" data-bs-toggle="tab" data-bs-target="#{{ tab.id }}"
|
||||
type="button" role="tab" aria-controls="{{ tab.id }}"
|
||||
aria-selected="{{ loop.first ? 'true' : 'false' }}">{{ gT(tab.label) }}</button>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="tab-content border border-top-0 p-3 mb-3">
|
||||
{% for tab in aTabs %}
|
||||
{# Resolve which option keys this tab shows: the top-of-page tab uses the fixed
|
||||
order of aTopOfPageKeys; a category tab shows its config.xml options (in
|
||||
config.xml order) minus the top-of-page keys. #}
|
||||
{% set aTabKeys = tab.keys %}
|
||||
{% if aTabKeys is null %}
|
||||
{% set aTabKeys = [] %}
|
||||
{% for key, attr in aOptionAttributes.optionAttributes %}
|
||||
{% if key != 'ajaxmode' and attr.category == tab.category and key not in aTopOfPageKeys %}
|
||||
{% set aTabKeys = aTabKeys|merge([key]) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{# the top-of-page tab also picks up options that literally carry the
|
||||
category "Top of the page" (so config.xml may use it after a reset) #}
|
||||
{% for key, attr in aOptionAttributes.optionAttributes %}
|
||||
{% if key != 'ajaxmode' and attr.category == 'Top of the page' and key not in aTabKeys %}
|
||||
{% set aTabKeys = aTabKeys|merge([key]) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<div role="tabpanel" class="CoreThemeOptions--settingsTab tab-pane {% if loop.first %}active{% endif %}"
|
||||
id="{{ tab.id }}" aria-labelledby="tab-{{ tab.id }}">
|
||||
<div class="row action_hide_on_inherit">
|
||||
{% for key in aTabKeys %}
|
||||
{% set attr = aOptionAttributes.optionAttributes[key] ?? null %}
|
||||
{% if attr is not null %}
|
||||
{# server-side current value for this option (checked/selected/value) #}
|
||||
{% set currentValue = bGeneralInherit ? 'inherit' : (aCurrentOptions[key] is defined ? aCurrentOptions[key] : (oParentOptions[key] is defined ? oParentOptions[key] : '')) %}
|
||||
{# parent != '': this field is only visible when the parent option is "on"
|
||||
(options.js toggles .option-visibility via data-show-if-parent);
|
||||
the field itself is additionally disabled via data-parent/selector_radio_childfield #}
|
||||
<div class="col-12 col-md-{{ attr.width|default(2) }} {% if attr.parent != '' %}option-visibility{% endif %}"
|
||||
{% if attr.parent != '' %}data-show-if-parent="{{ attr.parent }}" data-show-if-value="on"{% endif %}>
|
||||
<div class="mb-3">
|
||||
{% if attr.type != 'checkbox' %}
|
||||
<label for="simple_edit_options_{{ key }}" id="lbl_simple_edit_options_{{ key }}" class="form-label">{{ gT(attr.title) }}</label>
|
||||
{% endif %}
|
||||
|
||||
{# First settings row #}
|
||||
<div class='row action_hide_on_inherit'>
|
||||
|
||||
{# Container #}
|
||||
<div class='col-12 col-lg-4 col-xl-3'>
|
||||
<div class='mb-3 row'>
|
||||
<label for='simple_edit_options_container' class='control-label'> {{ gT("Survey container") }} </label>
|
||||
<div class='col-12'>
|
||||
<div class="btn-group" data-bs-toggle="buttons">
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='container' value='on' class='selector_option_radio_field simple_edit_options_container ' data-id='container'/>
|
||||
{{ gT("Yes") }}
|
||||
</label>
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='container' value='off' class='selector_option_radio_field simple_edit_options_container ' data-id='container'/>
|
||||
{{ gT("No") }}
|
||||
</label>
|
||||
{# If this is a root template setting, don't show the inherit button #}
|
||||
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='container' value='inherit' class='selector_option_radio_field simple_edit_options_container ' data-id='container'/>
|
||||
{{ gT("Inherit") }} [{{ oParentOptions.brandlogo }}]
|
||||
</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# hideprivacyinfo #}
|
||||
<div class='col-12 col-lg-4 col-xl-3'>
|
||||
<div class='mb-3 row'>
|
||||
<label for='simple_edit_options_hideprivacyinfo' class='control-label'>{{ gT("Hide privacy info") }}</label>
|
||||
<div class='col-12'>
|
||||
<div class="btn-group" data-bs-toggle="buttons">
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='hideprivacyinfo' value='on' class='selector_option_radio_field simple_edit_options_hideprivacyinfo ' data-id='hideprivacyinfo'/>
|
||||
{{ gT("Yes") }}
|
||||
</label>
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='hideprivacyinfo' value='off' class='selector_option_radio_field simple_edit_options_hideprivacyinfo ' data-id='hideprivacyinfo'/>
|
||||
{{ gT("No") }}
|
||||
</label>
|
||||
{# If this is a root template setting, don't show the inherit button #}
|
||||
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='hideprivacyinfo' value='inherit' class='selector_option_radio_field simple_edit_options_hideprivacyinfo ' data-id='hideprivacyinfo'/>
|
||||
{{ gT("Inherit") }} [{{ oParentOptions.brandlogo }}]
|
||||
</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# Show Clear And Exit #}
|
||||
<div class='col-12 col-lg-4 col-xl-3'>
|
||||
<div class='mb-3 row'>
|
||||
<label for='simple_edit_options_showclearall' class='control-label'> {{ gT("Show link/button to delete response & exit survey") }} </label>
|
||||
<div class='col-12'>
|
||||
<div class="btn-group" data-bs-toggle="buttons">
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='showclearall' value='on' class='selector_option_radio_field simple_edit_options_showclearall ' data-id='showclearall'/>
|
||||
{{ gT("Yes") }}
|
||||
</label>
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='showclearall' value='off' class='selector_option_radio_field simple_edit_options_showclearall ' data-id='showclearall'/>
|
||||
{{ gT("No") }}
|
||||
</label>
|
||||
{# If this is a root template setting, don't show the inherit button #}
|
||||
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
|
||||
<label class="btn btn-outline-secondary" title="{{ gT("Inherited value:") }} ">
|
||||
<input type='radio' name='showclearall' value='inherit' class='selector_option_radio_field simple_edit_options_showclearall ' data-id='showclearall'/>
|
||||
{{ gT("Inherit") }} [{{ oParentOptions.showclearall }}]
|
||||
</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# Second settings row #}
|
||||
<div class='row action_hide_on_inherit'>
|
||||
|
||||
{# questionhelptextposition #}
|
||||
<div class='col-12 col-lg-4 col-xl-3'>
|
||||
<div class='mb-3 row'>
|
||||
<label for='simple_edit_options_questionhelptextposition' class='control-label'>{{ gT("Question help text position") }}</label>
|
||||
<div class='col-12'>
|
||||
<div class="btn-group" data-bs-toggle="buttons">
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='questionhelptextposition' value='top' class='selector_option_radio_field simple_edit_options_questionhelptextposition ' data-id='questionhelptextposition'/>
|
||||
{{ gT("Top") }}
|
||||
</label>
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='questionhelptextposition' value='bottom' class='selector_option_radio_field simple_edit_options_questionhelptextposition ' data-id='questionhelptextposition'/>
|
||||
{{ gT("Bottom") }}
|
||||
</label>
|
||||
{# If this is a root template setting, don't show the inherit button #}
|
||||
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='questionhelptextposition' value='inherit' class='selector_option_radio_field simple_edit_options_questionhelptextposition ' data-id='questionhelptextposition'/>
|
||||
{{ gT("Inherit") }} [{{ oParentOptions.questionhelptextposition }}]
|
||||
</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# Show popups #}
|
||||
<div class='col-12 col-lg-4 col-xl-4'>
|
||||
<div class='mb-3 row'>
|
||||
<label for='simple_edit_options_showpopups' class='control-label' {{ showpopups_disabled_qtip }}>{{ gT("Show popups") }}</label>
|
||||
<div class='col-12'>
|
||||
<div class="btn-group" data-bs-toggle="buttons">
|
||||
<label class="btn btn-outline-secondary control-label" {{ showpopups_disabled }}>
|
||||
<input type='radio' name='showpopups' value='1' {{ showpopups_disabled }} class='selector_option_radio_field simple_edit_options_showpopups ' data-id='showpopups'/>
|
||||
{{ gT("Popup") }}
|
||||
</label>
|
||||
<label class="btn btn-outline-secondary" {{ showpopups_disabled }}>
|
||||
<input type='radio' name='showpopups' value='0' {{ showpopups_disabled }} class='selector_option_radio_field simple_edit_options_showpopups ' data-id='showpopups'/>
|
||||
{{ gT("On page") }}
|
||||
</label>
|
||||
<label class="btn btn-outline-secondary" {{ showpopups_disabled }}>
|
||||
<input type='radio' name='showpopups' value='-1' {{ showpopups_disabled }} class='selector_option_radio_field simple_edit_options_showpopups ' data-id='showpopups'/>
|
||||
{{ gT("No") }}
|
||||
</label>
|
||||
{# If this is a root template setting, don't show the inherit button #}
|
||||
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
|
||||
<label class="btn btn-outline-secondary" {{ showpopups_disabled }}>
|
||||
<input type='radio' name='showpopups' value='inherit' class='selector_option_radio_field simple_edit_options_showpopups ' data-id='showpopups'/>
|
||||
{{ gT("Inherit") }} [{{ oParentOptions.showpopups }}]
|
||||
</label>
|
||||
{% if attr.type == 'buttons' %}
|
||||
{# buttons type: one radio per value of options="a|b", labels from optionlabels="A|B" #}
|
||||
{% set optValues = attr.options|split('|') %}
|
||||
{% set optLabels = attr.optionlabels|split('|') %}
|
||||
<div class="btn-group" role="group" data-bs-toggle="buttons">
|
||||
{% for optValue in optValues %}
|
||||
<input id="{{ key }}_{{ optValue }}" type="radio" name="{{ key }}" value="{{ optValue }}"
|
||||
{% if currentValue == optValue %}checked{% endif %}
|
||||
class="btn-check selector_option_radio_field simple_edit_options_{{ key }}"/>
|
||||
<label for="{{ key }}_{{ optValue }}" class="btn btn-outline-secondary{% if currentValue == optValue %} active{% endif %}">{{ gT(optLabels[loop.index0]|default(optValue)) }}</label>
|
||||
{% endfor %}
|
||||
{% if bInherit %}
|
||||
<input id="{{ key }}_inherit" type="radio" name="{{ key }}" value="inherit"
|
||||
{% if currentValue == 'inherit' %}checked{% endif %}
|
||||
class="btn-check selector_option_radio_field simple_edit_options_{{ key }}"/>
|
||||
<label for="{{ key }}_inherit" class="btn btn-outline-secondary{% if currentValue == 'inherit' %} active{% endif %}">{{ gT("Inherit") }} [{{ oParentOptions[key] }}]</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# Fix num auto (and real num value) #}
|
||||
<div class='col-12 col-lg-4 col-xl-3'>
|
||||
<div class='mb-3 row'>
|
||||
<label for='simple_edit_options_fixnumauto' class='control-label'>{{ gT("Fix automatically numeric value") }}</label>
|
||||
<div class='col-12'>
|
||||
<div class="btn-group" data-bs-toggle="buttons">
|
||||
<label class="btn btn-outline-secondary">
|
||||
{# bFixNumAuto : 1 and bNumRealValue : 0 #}
|
||||
<input type='radio' name='fixnumauto' value='enable' class='selector_option_radio_field simple_edit_options_fixnumauto' data-id='fixnumauto'/>
|
||||
{{ gT("Yes") }}
|
||||
</label>
|
||||
<label class="btn btn-outline-secondary">
|
||||
{# bFixNumAuto : 0 and bNumRealValue : 0 #}
|
||||
<input type='radio' name='fixnumauto' value='partial' class='selector_option_radio_field simple_edit_options_fixnumauto' data-id='fixnumauto'/>
|
||||
{{ gT("For expression") }}
|
||||
</label>
|
||||
<label class="btn btn-outline-secondary">
|
||||
{# bFixNumAuto : 0 and bNumRealValue : 1 #}
|
||||
<input type='radio' name='fixnumauto' value='disable' class='selector_option_radio_field simple_edit_options_fixnumauto' data-id='fixnumauto'/>
|
||||
{{ gT("No") }}
|
||||
</label>
|
||||
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='fixnumauto' value='inherit' class='selector_option_radio_field simple_edit_options_fixnumauto' data-id='fixnumauto'/>
|
||||
{{ gT("Inherit") }} [{{ oParentOptions.fixnumauto == gT("No") ? gT("Default") : oParentOptions.fixnumauto }}]
|
||||
</label>
|
||||
{% else %}
|
||||
{# Since added after theme distribution and don't want reset : use empty value for leave default #}
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='fixnumauto' value='off' class='selector_option_radio_field simple_edit_options_fixnumauto' data-id='fixnumauto'/>
|
||||
{{ gT("Default") }}
|
||||
</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% elseif attr.type == 'checkbox' %}
|
||||
{# checkbox: checked = "on", unchecked = "off". The label is inline
|
||||
(form-check-label), so the generic label above is skipped for this
|
||||
type. With survey-level inherit, an untouched box keeps the value
|
||||
"inherit" (options.js: data was-inherit). Children of a parent
|
||||
switch get selector_radio_childfield + data-parent like the rest. #}
|
||||
<div class="form-check">
|
||||
<input type="checkbox" value="on"
|
||||
{% if currentValue == 'on' %}checked{% endif %}
|
||||
class="form-check-input selector_option_checkbox_field {% if attr.parent != '' %}selector_radio_childfield{% endif %}"
|
||||
{% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %}
|
||||
data-inheritvalue="{{ oParentOptions[key] }}"
|
||||
id="simple_edit_options_{{ key }}" name="{{ key }}">
|
||||
<label class="form-check-label" for="simple_edit_options_{{ key }}">{{ gT(attr.title) }}</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class='row action_hide_on_inherit'>
|
||||
<hr/>
|
||||
</div>
|
||||
|
||||
<!-- Brand Logo -->
|
||||
<div class='row action_hide_on_inherit'>
|
||||
<div class='col-12 col-lg-4'>
|
||||
{# Brandlogo #}
|
||||
<div class='mb-3 row'>
|
||||
<label for='simple_edit_options_brandlogo' class='control-label'>Brandlogo</label>
|
||||
<div class='col-12'>
|
||||
<div class="btn-group" data-bs-toggle="buttons">
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='brandlogo' value='on' class='selector_option_radio_field ' data-id='simple_edit_options_brandlogo'/>
|
||||
{{gT("Yes" )}}
|
||||
</label>
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='brandlogo' value='off' class='selector_option_radio_field ' data-id='simple_edit_options_brandlogo'/>
|
||||
{{ gT("No") }}
|
||||
</label>
|
||||
{# If this is a root template setting, don't show the inherit button #}
|
||||
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
|
||||
<label class="btn btn-outline-secondary">
|
||||
<input type='radio' name='brandlogo' value='inherit' class='selector_option_radio_field ' data-id='simple_edit_options_brandlogo'/>
|
||||
{{ gT("Inherit") }} [{{ oParentOptions.brandlogo }}]
|
||||
</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='col-md-8 col-lg-6'>
|
||||
{# Brandlogo file selector #}
|
||||
<div class='mb-3 row'>
|
||||
<label for='simple_edit_options_brandlogofile' class='control-label'>Brandlogo file</label>
|
||||
<div class='col-12'>
|
||||
<select class='form-select selector_option_value_field selector_radio_childfield selector_image_selector' data-parent="brandlogo" id='simple_edit_options_brandlogofile' name='brandlogofile'>
|
||||
{% set optgroup = '' %}
|
||||
{% for image in templateConfiguration.imageFileList %}
|
||||
{% if image.group != optgroup %}
|
||||
{% if optgroup != '' %}
|
||||
{% set brandlogofileOptions = brandlogofileOptions ~ '</optgroup>' %}
|
||||
{% endif %}
|
||||
{% set brandlogofileOptions = brandlogofileOptions ~ '<optgroup label="' ~ image.group ~ '">' %}
|
||||
{% set optgroup = image.group %}
|
||||
{% elseif attr.type == 'dropdown' %}
|
||||
{% set ddClasses = 'form-select selector_option_value_field' %}
|
||||
{% if attr.parent != '' %}{% set ddClasses = ddClasses ~ ' selector_radio_childfield' %}{% endif %}
|
||||
{% if tab.category == 'Images' %}{% set ddClasses = ddClasses ~ ' selector_image_selector' %}{% endif %}
|
||||
{% if key == 'font' %}{% set ddClasses = ddClasses ~ ' selector_fontselect' %}{% endif %}
|
||||
<select class="{{ ddClasses }}"
|
||||
{% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %}
|
||||
data-inheritvalue="{{ oParentOptions[key] }}"
|
||||
id="simple_edit_options_{{ key }}" name="{{ key }}">
|
||||
{% if bInherit %}
|
||||
<option value="inherit" {% if currentValue == 'inherit' %}selected{% endif %}>{{ gT("Inherit") }} [{{ gT("Inherited value:") }} {{ oParentOptions[key] }}]</option>
|
||||
{% endif %}
|
||||
{% if oParentOptions.brandlogofile == image.filepath %}
|
||||
{% set brandlogofileInheritPreview = brandlogofileInheritPreview ~ image.preview %}
|
||||
{% set brandlogofileInheritFilename = brandlogofileInheritFilename ~ image.filename %}
|
||||
{{ attr.dropdownoptions|raw }}
|
||||
</select>
|
||||
|
||||
{% elseif attr.type == 'fontselect' %}
|
||||
{# fontselect (per-element font override): the SAME font choices as the
|
||||
base "font" dropdown — the optgroups are shared, so bundled and
|
||||
variant-custom fonts appear here automatically — plus a first option
|
||||
"Same as base font" (value "base": the views then put no extra class
|
||||
on the element, it inherits the body font). options.js collects the
|
||||
packages of ALL .selector_fontselect selects into packages_to_load. #}
|
||||
{% set fontAttr = aOptionAttributes.optionAttributes['font'] ?? null %}
|
||||
<select class="form-select selector_option_value_field selector_fontselect {% if attr.parent != '' %}selector_radio_childfield{% endif %}"
|
||||
{% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %}
|
||||
data-inheritvalue="{{ oParentOptions[key] }}"
|
||||
id="simple_edit_options_{{ key }}" name="{{ key }}">
|
||||
{% if bInherit %}
|
||||
<option value="inherit" {% if currentValue == 'inherit' %}selected{% endif %}>{{ gT("Inherit") }} [{{ gT("Inherited value:") }} {{ oParentOptions[key] }}]</option>
|
||||
{% endif %}
|
||||
{% set brandlogofileOptions = brandlogofileOptions ~ '<option data-lightbox-src="' ~ image.preview ~ '" value="' ~ image.filepath ~ '">' ~ image.filename ~ '</option>' %}
|
||||
{% endfor %}
|
||||
{% set brandlogofileOptions = brandlogofileOptions ~ '</optgroup>' %}
|
||||
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
|
||||
{% set brandlogofileOptions = '<option data-lightbox-src="' ~ brandlogofileInheritPreview ~ '" value="inherit">' ~ gT("Inherit")~ ' [' ~ gT("inherited value:") ~ ' ' ~ brandlogofileInheritFilename ~ ']</option>' ~ brandlogofileOptions %}
|
||||
{% endif %}
|
||||
{{ brandlogofileOptions }}
|
||||
</select>
|
||||
<option value="base" {% if currentValue == 'base' %}selected{% endif %}>{{ gT("Same as base font") }} [{{ oParentOptions['font']|default('') }}]</option>
|
||||
{{ fontAttr ? fontAttr.dropdownoptions|raw : '' }}
|
||||
</select>
|
||||
|
||||
{% elseif attr.type == 'imagefile' %}
|
||||
<select class="form-select selector_option_value_field selector_image_selector {% if attr.parent != '' %}selector_radio_childfield{% endif %}"
|
||||
{% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %}
|
||||
data-inheritvalue="{{ oParentOptions[key] }}"
|
||||
id="simple_edit_options_{{ key }}" name="{{ key }}">
|
||||
{% if bInherit %}
|
||||
<option value="inherit" {% if currentValue == 'inherit' %}selected{% endif %}>{{ gT("Inherit") }} [{{ gT("Inherited value:") }} {{ oParentOptions[key] }}]</option>
|
||||
{% endif %}
|
||||
{{ imageOptions|raw }}
|
||||
</select>
|
||||
<button class="btn btn-outline-secondary btn-sm mt-1 selector__open_lightbox" data-bs-target="#simple_edit_options_{{ key }}">
|
||||
{{ gT("Preview image") }}
|
||||
</button>
|
||||
|
||||
{% elseif attr.type == 'colorpicker' %}
|
||||
<div class="input-group">
|
||||
<div class="input-group-text style__colorpicker">
|
||||
<input type="color" name="{{ key }}_picker" data-value="{{ oParentOptions[key] }}"
|
||||
{% if currentValue matches '/^#[0-9a-fA-F]{3,8}$/' %}value="{{ currentValue }}"{% endif %}
|
||||
class="selector__colorpicker-inherit-value"/>
|
||||
</div>
|
||||
<input type="text" name="{{ key }}" data-inheritvalue="{{ oParentOptions[key] }}"
|
||||
value="{% if currentValue != '' and currentValue != 'inherit' %}{{ currentValue }}{% endif %}"
|
||||
{% if bInherit %}placeholder="{{ gT("Inherit") }} [{{ gT("Inherited value:") }} {{ oParentOptions[key] }}]"{% endif %}
|
||||
id="simple_edit_options_{{ key }}"
|
||||
class="selector_option_value_field selector__color-picker form-control simple_edit_options_{{ key }}"/>
|
||||
{% if bInherit %}
|
||||
<div class="input-group-text">
|
||||
<button class="btn btn-outline-secondary btn-xs selector__reset-colorfield-to-inherit"><i class="ri-refresh-line"></i></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% elseif attr.type == 'duration' %}
|
||||
<input type="text"
|
||||
class="form-control selector-numerical-input selector_text_option_value_field {% if attr.parent != '' %}selector_radio_childfield{% endif %}"
|
||||
{% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %}
|
||||
{% if currentValue != '' and currentValue != 'inherit' %}value="{{ currentValue }}"{% endif %}
|
||||
id="simple_edit_options_{{ key }}" name="{{ key }}"
|
||||
title="{{ gT("Inherited value:") }} {{ oParentOptions[key] }}"/>
|
||||
|
||||
{% elseif attr.type == 'text' %}
|
||||
<input type="text"
|
||||
class="form-control selector-text-input selector_text_option_value_field {% if attr.parent != '' %}selector_radio_childfield{% endif %}"
|
||||
{% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %}
|
||||
{% if currentValue != '' and currentValue != 'inherit' %}value="{{ currentValue }}"{% endif %}
|
||||
id="simple_edit_options_{{ key }}" name="{{ key }}"
|
||||
title="{{ gT("Inherited value:") }} {{ oParentOptions[key] }}"/>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='col-md-4 col-lg-2'>
|
||||
<br/>
|
||||
<button class="btn btn-outline-secondary selector__open_lightbox" data-target="#simple_edit_options_brandlogofile"> {{ gT('Preview image')}}</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class='row ls-space margin top-15 bottom-15 '>
|
||||
<hr/>
|
||||
</div>
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-12'>
|
||||
<div class='panel panel-default'>
|
||||
<div class='panel-heading'>{{ sprintf( gT("%s fonts"), templateConfiguration.template_name)|capitalize }}</div>
|
||||
<div class='panel-body'>
|
||||
<div class='mb-3 row'>
|
||||
<label for='simple_edit_options_font' class='control-label'>{{ gT("Select font:") }}</label>
|
||||
<div class='col-12'>
|
||||
<select class='form-select selector_option_value_field' id='simple_edit_options_font' name='font' data-inheritvalue='{{oParentOptions.packages_to_load}}'>
|
||||
{{ fontOptions }}
|
||||
</select>
|
||||
{% if tab.category == 'Images' %}
|
||||
{# Upload an image; the actual upload form (#upload_frontend) is rendered by themeOptions/update.php #}
|
||||
<div class="row action_hide_on_inherit">
|
||||
<div class="ls-space margin bottom-15 top-15">
|
||||
<div class="row ls-space margin bottom-15">
|
||||
<div class="col-4">
|
||||
<label>{{ sprintf(gT("Upload an image (maximum size: %d MB):"), templateConfiguration.maxFileSize / 1024 / 1024) }}</label>
|
||||
</div>
|
||||
<div class="col-8">
|
||||
<span id="fileselector_frontend">
|
||||
<label class="btn btn-outline-secondary" for="upload_image_frontend" role="button" tabindex="0">
|
||||
<input class="d-none" id="upload_image_frontend" name="upload_image_frontend" type="file">
|
||||
<i class="ri-upload-fill ls-space margin right-10"></i>
|
||||
{{ gT("Upload") }}
|
||||
</label>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="progress">
|
||||
<div id="upload_progress_frontend" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
|
||||
<span class="visually-hidden">0%</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='row d-none'>
|
||||
<div class='col-12'>
|
||||
<button class='btn btn-success col-lg-2 col-md-4 col-6 action_update_options_string_button'>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class='row action_hide_on_inherit'>
|
||||
{# Upload an image #}
|
||||
<div class="container-fluid ls-space margin bottom-15">
|
||||
<div class="row ls-space margin bottom-15">
|
||||
<div class="col-md-6">
|
||||
{{ sprintf( gT("Upload an image (maximum size: %d MB):"), (templateConfiguration.maxFileSize/1024/1024) ) }}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{{ C.Html.form(createUrl('/admin/themes/sa/upload'), 'post', { 'id' : 'upload_frontend', 'name' : 'upload_frontend', 'enctype' :'multipart/form-data' }) }}
|
||||
<span id="fileselector_frontend">
|
||||
<label class="btn btn-outline-secondary col-8" for="upload_image_frontend">
|
||||
<input class="d-none" id="upload_image_frontend" name="upload_image_frontend" type="file">
|
||||
<i class="fa fa-upload ls-space margin right-10"></i>
|
||||
{{ gT("Upload") }}
|
||||
</label>
|
||||
</span>
|
||||
<input type='hidden' name='surveyid' value='{{ templateConfiguration.sid }}' />
|
||||
<input type='hidden' name='templatename' value='{{ templateConfiguration.template_name }}' />
|
||||
<input type='hidden' name='templateconfig' value='{{ templateConfiguration.id }}' />
|
||||
<input type='hidden' name='action' value='templateuploadimagefile' />
|
||||
</form>
|
||||
{# Footer at the bottom of every tab: "Proudly developed by [Respondage logo]",
|
||||
linking to https://www.respondage.nl #}
|
||||
{% if respondageLogo %}
|
||||
<div class="row action_hide_on_inherit respondage-footer">
|
||||
<div class="col-12 text-center mt-4 pt-3 border-top">
|
||||
<a href="https://www.respondage.nl" target="_blank" rel="noopener noreferrer">
|
||||
{{ gT("Proudly developed by") }}
|
||||
<img src="{{ respondageLogo }}" alt="Respondage" style="max-height: 24px; width: auto; vertical-align: middle;">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="progress">
|
||||
<div id="upload_progress_frontend" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
|
||||
<span class="visually-hidden">0%</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{# Lightbox modal for the image preview buttons #}
|
||||
<div class="modal fade" tabindex="-1" role="dialog" id="lightbox-modal">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h2 class="modal-title selector__title h5"></h2>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
<h4 class="modal-title selector__title"> </h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<img class="selector__image img-fluid" src="" alt="title" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<img class="selector__image img-fluid" src="" alt="title"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue