Last active
August 1, 2018 22:32
-
-
Save DawnPaladin/e0973255617590a49f68fc9f74fc0bb6 to your computer and use it in GitHub Desktop.
scripts/custom.js for hki-limesurvey-theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************** | |
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(){ | |
function animateGroup() { | |
var $group = $('#limesurvey'); | |
$group.hide(); | |
$("#ls-button-submit").on('click', function(event) { | |
if (checkFormValidity()) { | |
$group.slideUp(); // animate hide | |
} | |
}); | |
function checkFormValidity() { | |
var formValid = true; | |
$('#limesurvey input').each(function() { | |
if (!this.validity.valid) formValid = false; | |
}); | |
return formValid; | |
} | |
$group.slideDown(); // animate show | |
}; | |
var isIE = navigator.userAgent.indexOf('MSIE')!==-1 || navigator.appVersion.indexOf('Trident/') > 0; | |
if (!isIE) { | |
animateGroup(); | |
} | |
(function animateShowHideQuestions() { | |
// overriding \\192.168.25.134\htdocs\sites\limesurvey\assets\packages\limesurvey\survey.js | |
$("[id^='question']") | |
.off('relevance:on') | |
.off('relevance:off') | |
.on('relevance:on', function(event, data) { | |
if (event.target != this) return; | |
$(this).removeClass('ls-irrelevant'); | |
$(this).slideDown(); | |
}) | |
.on('relevance:off', function(event, data) { | |
if (event.target != this) return; | |
$(this).addClass('ls-irrelevant'); | |
$(this).slideUp(); | |
}) | |
; | |
})(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment