Skip to content

Commit

Permalink
Fixed issue #13291: Next button not working under Edge.
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Feb 16, 2018
1 parent 4e1eb8d commit b87a034
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions themes/survey/vanilla/scripts/ajaxify.js
Expand Up @@ -23,7 +23,7 @@
var AjaxSubmitObject = function () {
var activeSubmit = false;
// First we get the value of the button clicked (movenext, submit, prev, etc)
var move = "";
var move = '';

var startLoadingBar = function () {
//Scroll to the top of the page
Expand All @@ -46,50 +46,53 @@ var AjaxSubmitObject = function () {
};

var checkScriptNotLoaded = function(scriptNode){
if(!!scriptNode.src){
if(scriptNode.src){
return ($('head').find('script[src="'+scriptNode.src+'"]').length > 0);
}
return true;
}
};

var appendScript = function(scriptText, scriptPosition, src){
src = src || '';
scriptPosition = scriptPosition || null;
var scriptNode = document.createElement('script');
scriptNode.type = "text/javascript";
scriptNode.type = 'text/javascript';
if(src != false){
scriptNode.src = src;
}
scriptNode.text = scriptText;
scriptNode.attributes.class = "toRemoveOnAjax";
scriptNode.attributes.class = 'toRemoveOnAjax';
switch(scriptPosition) {
case "head": if(checkScriptNotLoaded(scriptNode)){ document.head.appendChild(scriptNode); } break;
case "body": document.body.appendChild(scriptNode); break;
case "beginScripts": document.getElementById('beginScripts').appendChild(scriptNode); break;
case "bottomScripts": //fallthrough
default: document.getElementById('bottomScripts').appendChild(scriptNode); break;
case 'head': if(checkScriptNotLoaded(scriptNode)){ document.head.appendChild(scriptNode); } break;
case 'body': document.body.appendChild(scriptNode); break;
case 'beginScripts': document.getElementById('beginScripts').appendChild(scriptNode); break;
case 'bottomScripts': //fallthrough
default: document.getElementById('bottomScripts').appendChild(scriptNode); break;

}
};

var bindActions = function () {
var globalPjax = new Pjax({
elements: "#limesurvey", // default is "a[href], form[action]"
selectors: ["#dynamicReloadContainer", "#beginScripts", "#bottomScripts"],
elements: '#limesurvey', // default is "a[href], form[action]"
selectors: ['#dynamicReloadContainer', '#beginScripts', '#bottomScripts'],
debug: window.debugState.frontend,
forceRedirectOnFail: true,
reRenderCSS : true,
logObject : console.ls ? (window.debugState.frontend ? console.ls : console.ls.silent) : console,
scriptloadtimeout: 1500
});
// Always bind to document to not need to bind again
$(document).on("click", ".ls-move-btn",function () {
$("#limesurvey").append("<input name='"+$(this).attr("name")+"' value='"+$(this).attr("value")+"' type='hidden' />");
$(document).on('click', '.ls-move-btn',function (e) {
e.preventDefault();
$('#limesurvey').append('<input name=\''+$(this).attr('name')+'\' value=\''+$(this).attr('value')+'\' type=\'hidden\' />');
$('#limesurvey').trigger('submit');
return false;
});

// If the user try to submit the form
// Always bind to document to not need to bind again
$(document).on("submit", "#limesurvey", function (e) {
$(document).on('submit', '#limesurvey', function (e) {
// Prevent multiposting
//Check if there is an active submit
//If there is -> return immediately
Expand All @@ -105,10 +108,10 @@ var AjaxSubmitObject = function () {
//free submitting again
activeSubmit = false;
if (/<###begin###>/.test($('#beginScripts').text())) {
$('#beginScripts').text("");
$('#beginScripts').text('');
}
if (/<###end###>/.test($('#bottomScripts').text())){
$('#bottomScripts').text("");
$('#bottomScripts').text('');
}

$(document).off('pjax:scriptcomplete.onreload');
Expand All @@ -124,5 +127,5 @@ var AjaxSubmitObject = function () {
endLoadingBar: endLoadingBar,
unsetSubmit: function(){activeSubmit = false;},
blockSubmit: function(){activeSubmit = true;}
}
}
};
};

0 comments on commit b87a034

Please sign in to comment.