Skip to content

Commit

Permalink
Dev: removed ajax mode for minimal template
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jul 18, 2017
1 parent df637e0 commit 1c87ef7
Showing 1 changed file with 0 additions and 76 deletions.
76 changes: 0 additions & 76 deletions templates/minimal/views/subviews/head.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,81 +32,5 @@

<meta name="generator" content="LimeSurvey http://www.limesurvey.org" />
<link rel="shortcut icon" href="{{ aSurveyInfo.oTemplate.sTemplateurl }}favicon.ico" />

{# Ajax mode #}
{% if(aSurveyInfo.options.ajaxmode == "on") %}
<script>
// Submit the form with Ajax
function ajaxSubmit(){
var numPost = 0;
// First we get the value of the button clicked (movenext, submit, prev, etc)
var move = "";
$(".ls-move-btn").on("click", function(){
move = $(this).attr("value");
});
// If the user try to submit the form
$(document).on("submit", "#limesurvey", function (e) {
e.preventDefault();
// Prevent multiposting
numPost++;
if ( numPost > 1){
return;
}
var sUrl = $(this).attr("action");
var aPost = $(this).serialize();
// We add the value of the button clicked to the post request
aPost += "&move="+move;
$.ajax({
url : sUrl,
type : 'POST',
dataType : 'html',
data : aPost,
success : function(body_html, statut){
$('.toRemoveOnAjax').each(function(){
$(this).remove();
});
var currentUrl = window.location.href;
var cleanUrl = currentUrl.replace("&newtest=Y", "");
if (currentUrl != cleanUrl){
window.history.pushState({"html":body_html,"pageTitle":"pwet"},"", cleanUrl);
}
var $dataScripts = $(body_html).filter('script');
$("body").empty().append($.parseHTML(body_html));
$dataScripts.each(function() {
$(this).attr('type', 'text/javascript').addClass('toRemoveOnAjax').appendTo('head');
});
// We reapply the function to the new form
ajaxSubmit();
},
error : function(result, statut, erreur){
alert("ERROR");
console.log(result);
}
});
});
}
$( document ).ready( function(){
ajaxSubmit();
});
</script>
{% endif %}

{{ include('./subviews/google_analytics.twig') }}
</head>

0 comments on commit 1c87ef7

Please sign in to comment.