Skip to content

Commit

Permalink
Dev: Fixed issue #11879: Mobile view: top of header overlaps title
Browse files Browse the repository at this point in the history
Dev: height() VS height
Dev: some other js in default
  • Loading branch information
Shnoulle committed Nov 7, 2016
1 parent 86b140f commit 28e3ddb
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 88 deletions.
2 changes: 1 addition & 1 deletion templates/default/config.xml
Expand Up @@ -17,7 +17,7 @@
<license>GNU General Public License version 2 or later</license>
<version>1.0</version>
<description>Default LimeSurvey Template.</description>
<last_update>2016-05-13 10:46:00</last_update>
<last_update>2016-11-07 23:59:00</last_update>
</metadatas>

<!--
Expand Down
4 changes: 2 additions & 2 deletions templates/default/css/template.css
Expand Up @@ -34,10 +34,10 @@ body
border-bottom: none;
background-color: #ecf0f1;
color: inherit;
margin-bottom:2em;

}
.top-container .top-content{
padding-top:1em;padding-bottom:1em;
padding-top:1em;padding-bottom:1em;margin-bottom:2em;
}
.top-container .top-content:empty{display:none}
.group-description:empty{display:none}
Expand Down
137 changes: 56 additions & 81 deletions templates/default/scripts/template.js
Expand Up @@ -43,8 +43,9 @@ $(document).ready(function(){
$(document).ready(function()
{
/* Some function are launched in endpage.pstpl */
fixBodyPadding();
hideEmptyPart();
addHoverColumn();
triggerEmClassChangeTemplate();

// If list of nav-bar action is empty: remove it (else .navbar-toggle is shown on small screen) //
if(!$("#navbar li").length){
Expand All @@ -70,65 +71,6 @@ $(document).ready(function()
}
});

$('.group-description-container').each(function(){
$that = $(this);
if(!$.trim($that.children('div').html()))
{
$that.hide();
}
});

// Hide question help container if empty
$('.questionhelp').each(function(){
$that = $(this);
if(!$.trim($that.html()))
{
$that.hide();
}
});

// Errors
if($('.ls-em-tip').length>0)
{
// On Document Load (the EM js is done before ? */
$('.ls-em-tip').each(function(){
if($(this).hasClass('ls-em-error'))
{
$(this).parents('div.questionhelp').removeClass('text-info').addClass('text-danger');
}
});

// On em change
$('.ls-em-tip').each(function(){
$(this).on('classChangeError', function() {
$parent = $(this).parent('div.questionhelp');
$parent.removeClass('text-info',1);
$parent.addClass('text-danger',1);

if ($parent.hasClass('hide-tip'))
{
$parent.removeClass('hide-tip',1);
$parent.addClass('tip-was-hidden',1);
}

$questionContainer = $(this).parents('div.question-container');
$questionContainer.addClass('input-error');
});

$(this).on('classChangeGood', function() {
$parent = $(this).parents('div.questionhelp');
$parent.removeClass('text-danger');
$parent.addClass('text-info');
if ($parent.hasClass('tip-was-hidden'))
{
$parent.removeClass('tip-was-hidden').addClass('hide-tip');
}
$questionContainer = $(this).parents('div.question-container');
$questionContainer.removeClass('input-error');
});
});
}

// Hide the menu buttons at the end of the Survey
if($(".hidemenubutton").length>0)
{
Expand Down Expand Up @@ -176,13 +118,15 @@ window.alert = function(message, title) {

/**
* fix padding of body according to navbar-fixed-top
* in endpage and in $(window).resize
*/
function fixBodyPadding(){
/* The 50 px is fixed in template.css */
$("body").css("padding-top",$(".navbar-fixed-top").height+"px")
console.log($(".navbar-fixed-top").height());
$("body").css("padding-top",$(".navbar-fixed-top").height()+"px")
}
/**
* fix padding of body according to navbar-fixed-top
* Set suffix/prefix clone for little screen (at top)
*/
function sliderSuffixClone(){
$(".numeric-multi .slider-item .slider-right").each(function(){
Expand Down Expand Up @@ -211,22 +155,53 @@ function addHoverColumn(){
}, ".answer-item");

}
//Hide the Answer and the helper field
$(document).ready(
function(){
$('.question-container').each(function(){
if($(this).find('div.answer-container').find('input').length == 1)
{
if($(this).find('div.answer-container').find('input[type=hidden]').length >0
&& $(this).find('div.answer-container').find('select').length < 1)
{
$(this).find('div.answer-container').css({display: 'none'});
}
if(trim($(this).find('div.question-help-container').find('div').html()) == "")
{
$(this).find('div.question-help-container').css({display: 'none'});
}
}
});
}
);
/**
* Hide some part if empty
* Some can be needed if contain only js
* Some are not really needed : little margin only is shown
*/
function hideEmptyPart()
{
$(".question-help-container").each(function(){
if($(this).text().trim()==""){/* Only if have only script tag inside */
$(this).hide();
}
});
$(".group-description").each(function(){
if($(this).text().trim()==""){/* Only if have only script tag inside */
$(this).hide();
}
});
}

/**
* Update some class when em-tips is success/error
* @see core/package/limesurvey/survey.js:triggerEmClassChange
*/
function triggerEmClassChangeTemplate(){
$('.ls-em-tip').on('classChangeError', function() {
/* If user choose hide-tip : leave it */
//~ $parent = $(this).parent('div.qquestion-valid-container');
//~ if ($parent.hasClass('hide-tip'))
//~ {
//~ $parent.removeClass('hide-tip',1);
//~ $parent.addClass('tip-was-hidden',1);
//~ }
$questionContainer = $(this).parents('div.question-container');
$questionContainer.addClass('input-error'); /* No difference betwwen error after submit and error before submit : think (Shnoulle) it's better to have a difference */
});

$('.ls-em-tip').on('classChangeGood', function() {
/* If user choose hide-tip : leave it */
//~ $parent = $(this).parents('div.question-valid-container');
//~ $parent.removeClass('text-danger');
//~ $parent.addClass('text-info');
//~ if ($parent.hasClass('tip-was-hidden'))
//~ {
//~ $parent.removeClass('tip-was-hidden').addClass('hide-tip');
//~ }
$questionContainer = $(this).parents('div.question-container');
$questionContainer.removeClass('input-error');/* Not working with mandatory question ... */
});

}
1 change: 1 addition & 0 deletions templates/default/views/endpage.pstpl
Expand Up @@ -21,5 +21,6 @@
<script type="text/javascript">
/*<![CDATA[*/
sliderSuffixClone();
fixBodyPadding();
/*]]>*/
</script>
6 changes: 2 additions & 4 deletions templates/default/views/question.pstpl
@@ -1,5 +1,5 @@
<!-- Question -->
<div {QUESTION_ESSENTIALS} class="{QUESTION_CLASS}{QUESTION_MAN_CLASS}{QUESTION_INPUT_ERROR_CLASS} question-wrapper row">
<div {QUESTION_ESSENTIALS} class="{QUESTION_CLASS}{QUESTION_MAN_CLASS}{QUESTION_INPUT_ERROR_CLASS} question-container row">

<!-- Question text -->
<div class="question-title-container bg-primary col-xs-12">
Expand All @@ -22,7 +22,5 @@
</div>

<!-- Survey question help -->
<div class="question-help-container text-info col-xs-12">
{QUESTIONHELP}
</div>
<div class="question-help-container text-info col-xs-12">{QUESTIONHELP}</div>
</div>

0 comments on commit 28e3ddb

Please sign in to comment.