Skip to content

Commit

Permalink
Dev: fixed some rendering bugs in frontend and backend
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Aug 24, 2017
1 parent 1288eff commit 81020b8
Show file tree
Hide file tree
Showing 26 changed files with 271 additions and 226 deletions.
4 changes: 4 additions & 0 deletions assets/packages/adminpanel/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ gulp.task('webpack:watch', function () {
gulp.watch(['./src/**/**.js', './src/**/**.vue'], ['webpack']);
});

gulp.task('lint:watch', function () {
gulp.watch(['./src/**/**.js', './src/**/**.vue'], ['js:lint']);
});


//compile tasks
gulp.task('sass', function () {
Expand Down
4 changes: 3 additions & 1 deletion assets/packages/adminpanel/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ if (document.getElementById('vue-app-main-container')) {
const maxHeight = ($('#in_survey_common').height() - 35) || 400;
this.$store.commit('changeMaxHeight', maxHeight);
this.updatePjaxLinks();
$(document).on('click', 'ul.pagination>li>a', function(){
this.updatePjaxLinks();
});
}
});
}
Expand All @@ -74,7 +77,6 @@ $(document).on('pjax:complete', () => {
}, 2200);
});


// const topmenu = new Vue(
// {
// el: '#vue-top-menu-app',
Expand Down
13 changes: 6 additions & 7 deletions assets/packages/adminpanel/src/mixins/logSystem.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// globals console
/* eslint-disable no-alert, no-console */

/* global console */
/**
* Check the browsers console capabilities and bundle them into general functions
* If the build environment was "production" only put out error messages.
Expand Down Expand Up @@ -72,7 +71,7 @@ class ConsoleShim {

time() {
if (typeof console.time === 'function') {
console.time(args);
console.time(arguments);
return;
}

Expand All @@ -81,7 +80,7 @@ class ConsoleShim {

timeEnd() {
if (typeof console.timeEnd === 'function') {
console.timeEnd(args);
console.timeEnd(arguments);
return;
}
const diff = (new Date()) - this.timeHolder;
Expand All @@ -91,7 +90,7 @@ class ConsoleShim {

error(){
if (typeof console.error === 'function') {
console.error(args);
console.error(arguments);
return;
}

Expand All @@ -101,7 +100,7 @@ class ConsoleShim {

warn(){
if (typeof console.warn === 'function') {
console.warn(args);
console.warn(arguments);
return;
}

Expand All @@ -114,7 +113,7 @@ class ConsoleShim {
const env = process.env.NODE_ENV;
const debugConsole = new ConsoleShim();

exports.install = function (Vue, options) {
exports.install = function (Vue) {
console.log(`The systen is currently in ${process.env.NODE_ENV} mode.`);

const debugmode = (env=='developement');
Expand Down
2 changes: 1 addition & 1 deletion assets/packages/adminpanel/src/store/vuex-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const getAppState = function (userid) {
updatePjax(state) {
state.pjax = null;
state.pjax = new Pjax({
elements: 'a.pjax', // default is "a[href], form[action]"
elements: ['a.pjax'], // default is "a[href], form[action]"
selectors: [
'#pjax-content',
'#breadcrumb-container',
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/admin/viewAttribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var LS = LS || {
onDocumentReady: {}
};

$(document).on(' pjax:complete', function() {
$(document).on('ready pjax:complete', function() {
$.each(removeitem, function(index, value) {
$("select#langdata option[value='"+value+"']").remove();
});
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/array-totalsum.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
*/

$(document).ready(function () {
$(document).on('ready pjax:complete',function () {
$('div.array-multi-flexi-text table.show-totals input:enabled').keyup(updatetotals);
$('div.array-multi-flexi-text table.show-totals input:enabled').each(updatetotals);
});
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function doPopupDate(qId) {
*/
function doDropDownDate(qId){
$(document).on("change",'#question'+qId+' select',dateUpdater);
$(document).ready(function(){
$(document).on('ready pjax:complete',function(){
$("#question"+qId+" select").filter(':first').trigger("change");
//dateUpdater();
});
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
*/

$(document).ready(function()
$(document).on('ready pjax:complete',function()
{
$(".ls-answers .location").each(function(index,element){
var question = $(element).attr('name');
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/navigator-countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

function navigator_countdown(n)
{
$(document).ready(function()
$(document).on('ready pjax:complete',function()
{
$('button.disabled').prop("disabled", true);// Double check : already in navbuttonsJqueryUi
$(window).data('countdown', n);
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/numerical_input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(document).ready(function () {
$(document).on('ready pjax:complete',function () {
if (typeof LEMradix === 'undefined') { return; }

if (LEMradix == ',')
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/statistics_user.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(document).ready(function(){
$(document).on('ready pjax:complete',function(){

/* End of show/hide sections */

Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/survey_runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// Some function can be launch before document ready (and seems intersting)
// But put it in ready : allowing update by template.js (before moving at end of HTML : best place */
$(document).ready(function()
$(document).on('ready pjax:complete',function()
{
tableCellAdapters();
doToolTipTable();
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/uploader.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(document).ready(function(){
$(document).on('ready pjax:complete',function(){
doFileUpload();
fixParentHeigth();
});
Expand Down
2 changes: 2 additions & 0 deletions templates/default/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
<css>
<filename>css/template.css</filename>
<filename>css/animate.css</filename>
<filename>css/ajaxify.css</filename>
</css>
<js>
<filename>scripts/template.js</filename>
<filename>scripts/ajaxify.js</filename>
</js>
<print_css>
<filename>css/print_template.css</filename>
Expand Down
24 changes: 24 additions & 0 deletions templates/default/css/ajaxify.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.ajax_loading_indicator {
height: 6px;
position: fixed;
display:none;
top: 1px;
left: 0;
width: 100%;
width: 100vw;
z-index: 20000;
transition: opacity 500ms linear;
transition-delay: 1000ms;
}


.ajax_loading_indicator .ajax_loading_indicator {
display: none;
height: 8px;
border-radius: 1px;
-webkit-transition-timing-function: ease-in-out;
transition-timing-function: ease-in-out;
/* Safari */
-webkit-transition: width 1.6s;
transition: width 1.6s;
}
5 changes: 5 additions & 0 deletions templates/default/css/template.css
Original file line number Diff line number Diff line change
Expand Up @@ -766,3 +766,8 @@ div.yes-no .btn-group label {
p.return-to-survey{
clear:left;
}

.superset {
font-size: 50%;
vertical-align: top;
}
110 changes: 110 additions & 0 deletions templates/default/scripts/ajaxify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// Submit the form with Ajax
var AjaxSubmitObject = function () {
var activeSubmit = false;
// First we get the value of the button clicked (movenext, submit, prev, etc)
var move = "";

var startLoadingBar = function () {
$('#ajax_loading_indicator').css('display','block').find('#ajax_loading_indicator_bar').css({
'width': '20%',
'display': 'block'
});
};


var endLoadingBar = function () {
$('#ajax_loading_indicator').css('opacity','0').find('#ajax_loading_indicator_bar').css('width', '100%');
setTimeout(function () {
$('#ajax_loading_indicator').css({'display': 'none', 'opacity': 1}).find('#ajax_loading_indicator_bar').css({
'width': '0%',
'display': 'none'
});
}, 1800);
};

var bindActions = function () {

// Always bind to document to not need to bind again
$(document).on("click", ".ls-move-btn",function () {
move = $(this).attr("value");
});

// If the user try to submit the form
// Always bind to document to not need to bind again
$(document).on("submit", "#limesurvey", function (e) {
e.preventDefault();

// Prevent multiposting
//Check if there is an active submit
//If there is -> return immediately
if(activeSubmit) return;
//block further submissions
activeSubmit = true;

//start the loading animation
startLoadingBar();

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, status, request) {

$('.toRemoveOnAjax').each(function () {
$(this).remove();
});

var currentUrl = window.location.href;
var cleanUrl = currentUrl.replace("&newtest=Y", "").replace(/\?newtest=Y(\&)?/, '?');

if (currentUrl != cleanUrl) {
window.history.pushState({
"html": body_html,
"pageTitle": request.getResponseHeader('title')
}, "", cleanUrl);
}

var $dataScripts = $(body_html).filter('script');
var $newBody = $($.parseHTML(body_html));
var $replaceableContainer = $newBody.find('div#dynamicReloadContainer');
$("#dynamicReloadContainer").empty().append($replaceableContainer);

$dataScripts.each(function () {
$(this).attr('type', 'text/javascript').addClass('toRemoveOnAjax').prependTo('body');
});

// We end the loading animation
endLoadingBar();

//free submitting again
activeSubmit = false;

//also trigger the pjax:complete event to load all adherent scripts
$(document).trigger('pjax:complete');

},

error: function (result, status, error) {
alert("ERROR");
console.log(result);
}
});
});
};
return {
bindActions: bindActions,
startLoadingBar: startLoadingBar,
endLoadingBar: endLoadingBar,
unsetSubmit: function(){activeSubmit = false;},
blockSubmit: function(){activeSubmit = true;}
}
}

16 changes: 13 additions & 3 deletions templates/default/views/layout_global.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@

</html>

<body class="{{ aSurveyInfo.class.body }} lang-{{aSurveyInfo.languagecode}} {{aSurveyInfo.surveyformat}} {% if( aSurveyInfo.options.brandlogo == "on") %}brand-logo{%endif%}" {{ aSurveyInfo.attr.body }} >

<body class="{{ aSurveyInfo.class.body }} lang-{{aSurveyInfo.languagecode}} {{aSurveyInfo.surveyformat}} {% if( aSurveyInfo.options.brandlogo == "on") %}brand-logo{%endif%}" {{ aSurveyInfo.attr.body }} >
{% if (aSurveyInfo.options.ajaxmode == "on" ) %}
<div class="progress ajax_loading_indicator" id="ajax_loading_indicator">
<div class="progress-bar progress-bar-info ajax_loading_indicator_bar" id="ajax_loading_indicator_bar" role="progressbar">
</div>
</div>
{% endif %}

{% if (aSurveyInfo.options.backgroundimage == "on") %}
{{ registerTemplateCssFile("css/background-image.css") }}
{% endif %}
Expand All @@ -37,8 +44,9 @@
{{ unregisterScriptForAjax()}}
{% endif %}



{# Ajaxify cannot handle an element that is a direct child of body, so => create simple wrapper section #}
<section>
<div id="dynamicReloadContainer">
{% block body %}

{# Bootstrap Navigation Bar: the top menu #}
Expand Down Expand Up @@ -81,6 +89,8 @@
/*]]>*/
</script>
{% endblock %}
</div>
</section>

{% if( not ( aSurveyInfo.options.ajaxmode == "on" and getPost('ajax')=="on" )) %}
</body>
Expand Down

0 comments on commit 81020b8

Please sign in to comment.