2026-11-16 19:36:04 +01:00
|
|
|
/******************
|
|
|
|
|
User custom JS
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
Put JS-functions for your template here.
|
|
|
|
|
If possible use a closure, or add them to the general Template Object "Template"
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(document).on('ready pjax:scriptcomplete',function(){
|
|
|
|
|
/**
|
|
|
|
|
* Code included inside this will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute
|
|
|
|
|
* @see https://learn.jquery.com/using-jquery-core/document-ready/
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Replace classes
|
|
|
|
|
$('.container-fluid').addClass('container');
|
|
|
|
|
$('.container-fluid').removeClass('container-fluid');
|
|
|
|
|
|
|
|
|
|
// Remove classes
|
|
|
|
|
$('.survey-name.text-center').removeClass('text-center');
|
|
|
|
|
$('.survey-description.text-center').removeClass('text-center');
|
|
|
|
|
$('.survey-welcome.h5.text-primary').removeClass('text-primary');
|
|
|
|
|
$('.survey-welcome.h5').removeClass('h5');
|
|
|
|
|
$('.ls-privacy-head.h4.text-primary').removeClass('text-primary');
|
|
|
|
|
$('.ls-privacy-head.h4').removeClass('h4');
|
|
|
|
|
$('.space-col').removeClass('space-col'); //The presence of .space-col is one of the greatest mistakes in the Vanilla theme IMHO
|
|
|
|
|
$('.group-title.text-center.h3').removeClass('h3');
|
|
|
|
|
$('.group-title.text-center').removeClass('text-center');
|
|
|
|
|
$('.text-info').removeClass('text-info');
|
|
|
|
|
$('.text-muted').removeClass('text-muted');
|
|
|
|
|
$('.limit-text-window').removeClass('limit-text-window');
|
|
|
|
|
$('.save-message.card').removeClass('card');
|
|
|
|
|
$('.save-message.bg-light').removeClass('bg-light');
|
|
|
|
|
$('.save-survey-form.col-lg-8.offset-lg-2').removeClass('offset-lg-2');
|
|
|
|
|
$('.save-survey-form.col-lg-8').removeClass('col-lg-8');
|
|
|
|
|
$('.save-message .card-body').removeClass('card-body');
|
|
|
|
|
$('.navbar-light.bg-light').removeClass('bg-light');
|
|
|
|
|
$('.privacy.row').removeClass('row');
|
2026-11-24 22:04:11 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* THEME ADDITION: the header (#survey-nav) is sticky only on the selected
|
|
|
|
|
* screen sizes (theme options headersticky + headersticky{computer,tablet,
|
|
|
|
|
* mobile}, applied as media queries in custom_header.twig). The parent
|
|
|
|
|
* theme.js fixBodyPadding() assumes a permanently fixed header and always
|
2026-11-29 12:59:11 +01:00
|
|
|
* sets body padding-top to the header height (and the parent theme.css
|
|
|
|
|
* statically sets body { padding-top: 90px }); this correction runs after
|
|
|
|
|
* it (custom.js loads after theme.js) and sets the padding to the header
|
|
|
|
|
* height when the header IS fixed at the current viewport width, or to 0
|
|
|
|
|
* when it is NOT (computed position != 'fixed') — so a non-sticky header
|
|
|
|
|
* sits at the very top of the page.
|
2026-11-24 22:04:11 +01:00
|
|
|
*/
|
|
|
|
|
var fixBodyPaddingSticky = function () {
|
|
|
|
|
var nav = $('#survey-nav');
|
|
|
|
|
if (!nav.length) { return; }
|
|
|
|
|
if (nav.css('position') === 'fixed') {
|
|
|
|
|
$('body').css('padding-top', Math.round(nav.height()) + 'px');
|
|
|
|
|
} else {
|
2026-11-29 12:59:11 +01:00
|
|
|
/* NOT '' (clearing the inline style): that would fall back to the
|
|
|
|
|
parent theme.css rule body { padding-top: 90px } and push the
|
|
|
|
|
static header 90px down. Set 0 explicitly. */
|
|
|
|
|
$('body').css('padding-top', '0px');
|
2026-11-24 22:04:11 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// namespaced so re-running on pjax:scriptcomplete never stacks duplicate handlers
|
|
|
|
|
$(window).off('resize.stickyheader').on('resize.stickyheader', fixBodyPaddingSticky);
|
|
|
|
|
fixBodyPaddingSticky();
|
2026-11-30 08:57:23 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* THEME ADDITION: untouched vs touched slider (grey handle when untouched,
|
|
|
|
|
* sliderhandlecolor when touched — styled in css/custom.css).
|
|
|
|
|
* Core toggles slider-untouched/slider-touched on the .slider element, but
|
|
|
|
|
* that class is NOT a reliable state signal (with "slider_default_set" an
|
|
|
|
|
* untouched slider keeps slider-touched). The reliable signal is the real
|
|
|
|
|
* answer input inside .slider-container (#answer<fname>, the .ls-js-hidden
|
|
|
|
|
* one — NOT the #answer<fname>slid bootstrap-slider element): it is empty
|
|
|
|
|
* until the slider is used. Sync a theme class slider-is-untouched onto
|
|
|
|
|
* the li.slider-item row; core fires change+keyup on that input on every
|
|
|
|
|
* slider action (slideStart/slideStop/reset via triggerChanges).
|
|
|
|
|
*/
|
|
|
|
|
var syncSliderItems = function () {
|
|
|
|
|
$('.slider-item').each(function () {
|
|
|
|
|
var item = $(this);
|
|
|
|
|
var container = item.find('.slider-container').first();
|
|
|
|
|
var rootId = (container.attr('id') || '').replace(/slid-container$/, '');
|
|
|
|
|
var root = rootId ? $('#' + rootId) : $();
|
|
|
|
|
if (!root.length) { return; }
|
|
|
|
|
item.toggleClass('slider-is-untouched', String(root.val()) === '');
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
syncSliderItems();
|
|
|
|
|
// namespaced + rebound so re-running on pjax:scriptcomplete never stacks duplicates
|
|
|
|
|
$(document).off('change.sliderstate keyup.sliderstate input.sliderstate');
|
|
|
|
|
$(document).on('change.sliderstate keyup.sliderstate input.sliderstate', '.slider-container input', syncSliderItems);
|
2026-11-16 19:36:04 +01:00
|
|
|
});
|