Skip to content

Commit

Permalink
Fixed issue #3299: Layout not right at Multiple Numerical when questi…
Browse files Browse the repository at this point in the history
…on is mandatory

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@7104 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Jun 13, 2009
1 parent e65d52c commit 5d25bac
Show file tree
Hide file tree
Showing 15 changed files with 378 additions and 654 deletions.
55 changes: 0 additions & 55 deletions common.php
Expand Up @@ -1229,61 +1229,6 @@ function longest_string( $new_string , $longest_length )
return $longest_length;
};

function label_class_width( $longest_length , $type = 'text' )
{
/**
* label_class_width() generates a class identifyer to be inserted into an HTML element
*
* @peram integer representing the length longest string in a list.
* @peram string representing possible options: 'text' (default), checkbox, numeric
*
* @return string representing a CSS class.
*/
if($type == 'numeric')
{ // numeric input box is generally smaller than so the label can afford to be longer
$too_long = 30;
}
else
{
$too_long = 20;
};
if($type == 'checkbox')
{ // if a other is being used for a single option list question, there is a preceeding radio button, pushing the label text over by about 3ems
$longest_length = $longest_length + 2;
}

$longest_length = round($longest_length * 0.6);
if($longest_length < 2) $longest_length = 2;
switch($longest_length / 2)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15: $longest_length = $longest_length;
break;
default: ++$longest_length;
}
if($longest_length > $too_long)
{
$label_width = 'X-large';
}
else
{
$label_width = 'X'.$longest_length;
};
return $label_width;
};


/**
Expand Down
175 changes: 13 additions & 162 deletions qanda.php
Expand Up @@ -3022,38 +3022,7 @@ function do_multiplechoice_withcomments($ia)
$inputnames[]=$myfname;
$inputnames[]=$myfname2;
}
$label_width = round($label_width * 0.5);
if($label_width < 2) $label_width = 2;
switch($label_width / 2)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15: $label_width = $label_width;
break;
default: ++$label_width;
}
if($label_width > 20)
{
$label_width = 'X-large';
}
else
{
$label_width = 'X'.$label_width;
}

$answer .= '<ul class="'.$label_width."\">\n".$answer_main."</ul>\n";
$answer .= "<ul>\n".$answer_main."</ul>\n";


if ( $maxansw > 0 )
Expand Down Expand Up @@ -3241,51 +3210,8 @@ function do_multipleshorttext($ia)
$inputnames[]=$myfname;
}
}
$label_width = round($label_width * 0.6);
if($label_width < 2) $label_width = 2;
switch($label_width / 2)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15: $label_width = $label_width;
break;
default: ++$label_width;
}
if (!empty($numbersonly))
{
$class_num_only = ' numbers-only';
if($label_width > 30)
{
$label_width = 'X-large';
}
}
else
{
if($label_width > 20)
{
$label_width = 'X-large';
}
$class_num_only = '';
}

if($label_width != 'X-large')
{
$label_width = 'X'.$label_width;
}

$answer .= '<ul class="'.$label_width.$class_num_only."\">\n".$answer_main."</ul>\n";
$answer .= "<ul>\n".$answer_main."</ul>\n";

return array($answer, $inputnames);
}
Expand Down Expand Up @@ -3575,96 +3501,21 @@ function do_multiplenumeric($ia)
$question_tip .= '<p id="min_num_value_'.$ia[1].'" class="tip">'.sprintf($clang->gT('Total of all entries must be at least %s'),$min_num_value)."</p>\n";
}

$label_width = round($label_width * 0.8);
if($label_width < 2) $label_width = 2;
switch($label_width / 2)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15: $label_width = $label_width;
break;
default: ++$label_width;
}
if ($maxvalue || $equalvalue || $minvalue)
{
$class_computed = ' computed';
if($label_width > 20)
{
$label_width = 'X-large';
$comp_width = $label_width;
}
else
{
$comp_width = $label_width;
if( isset($prefix) && !empty($prefix) )
{
$comp_width = $comp_width + round(strlen($prefix) * 0.8);
};
if(isset($suffix) && !empty($suffix))
{
$comp_width = $comp_width + round(strlen($suffix) * 0.8);
}
if($comp_width > 20)
{
$comp_width = 'X-large';
}
else
{
$comp_width = 'X'.$comp_width;
}
}
}
else
{
if($label_width > 30)
{
$label_width = 'X-large';
}
$class_computed = '';
}

if ($slider_layout)
{
$label_width = 'slider';
$comp_width = $label_width;
}
else
{
if($label_width != 'X-large')
{
$label_width = 'X'.$label_width;
}
}
$answer_computed = '';
if ($maxvalue || $equalvalue || $minvalue)
{
$answer_computed = "\n<ul class=\"multiplenumerichelp $comp_width\">\n";
$answer_computed .= "\t<li>\n\t\t<label for=\"totalvalue_{$ia[1]}\">\n\t\t\t".$clang->gT('Total: ')."\n\t\t</label>\n\t\t<span>\n\t\t\t$prefix\n\t\t\t<input type=\"text\" id=\"totalvalue_{$ia[1]}\" disabled=\"disabled\" />\n\t\t\t$suffix\n\t\t</span>\n\t</li>\n";
if ($equalvalue)
{
$answer_computed .= "\t<li>\n\t\t<label for=\"remainingvalue_{$ia[1]}\">\n\t\t\t".$clang->gT('Remaining: ')."\n\t\t</label>\n\t\t<span>\n\t\t\t$prefix\n\t\t\t<input type='text' id=\"remainingvalue_{$ia[1]}\" disabled=\"disabled\" />\n\t\t\t$suffix\n\t\t</span>\n\t</li>\n";
}
$answer_computed .= "</ul>\n";
$answer_computed = '';
if ($equalvalue)
{
$answer_computed .= "\t<li class='multiplenumerichelp'>\n\t\t<label for=\"remainingvalue_{$ia[1]}\">\n\t\t\t".$clang->gT('Remaining: ')."\n\t\t</label>\n\t\t<span>\n\t\t\t$prefix\n\t\t\t<input size=10 type='text' id=\"remainingvalue_{$ia[1]}\" disabled=\"disabled\" />\n\t\t\t$suffix\n\t\t</span>\n\t</li>\n";
}
$answer_computed .= "\t<li class='multiplenumerichelp'>\n\t\t<label for=\"totalvalue_{$ia[1]}\">\n\t\t\t".$clang->gT('Total: ')."\n\t\t</label>\n\t\t<span>\n\t\t\t$prefix\n\t\t\t<input size=10 type=\"text\" id=\"totalvalue_{$ia[1]}\" disabled=\"disabled\" />\n\t\t\t$suffix\n\t\t</span>\n\t</li>\n";
$answer_main.=$answer_computed;
}
$answer .= $question_tip.'<ul class="'.$label_width.$class_computed."\">\n".$answer_main."</ul>\n".$answer_computed;
$answer .= $question_tip."<ul>\n".$answer_main."</ul>\n";
}
$answer_computed = isset($answer_computed)?$answer_computed:'';
$answer .= $answer_computed;
//just added these here so its easy to change in one place
$errorClass = 'tip error';
$goodClass = ' tip good';
$errorClass = 'tip problem';
$goodClass = 'tip good';
/* ==================================
Style to be applied to all templates.
.numeric-multi p.tip.error
Expand Down Expand Up @@ -3693,7 +3544,7 @@ function do_multiplenumeric($ia)
$answer .= " totalvalue_".$ia[1]."=(";
$answer .= implode(" + ", $javainputnames);
$answer .= ")/1000;\n";
$answer .= " document.getElementById('totalvalue_{$ia[1]}').value=parseFloat(totalvalue_{$ia[1]});\n";
$answer .= " $('#totalvalue_{$ia[1]}').val(parseFloat(totalvalue_{$ia[1]}));\n";
$answer .= " var ua = navigator.appVersion.indexOf('MSIE');\n";
$answer .= " var ieAtt = ua != -1 ? 'className' : 'class';\n";
$answer .= " switch(method)\n";
Expand Down
2 changes: 1 addition & 1 deletion scripts/jquery/lime-calendar.js
Expand Up @@ -9,7 +9,7 @@ $(document).ready(function(){
showOn: 'both',
changeYear: true,
changeMonth: true,
duration: 'fast',
duration: 'fast'
}, $.datepicker.regional[language]);
});
$('.year').change(dateUpdater);
Expand Down
42 changes: 21 additions & 21 deletions templates/basic/template.css
Expand Up @@ -391,20 +391,20 @@ ul.cols-8 li , ul.cols-8-ul , table.cols-8 td { width: 11.5%; }
.language {}

/* The following styles only apply to modern (relatively) complete CSS2 compliant browsers. (Not less than IE 8) */
[class=multiple-opt-comments] td.answer
,[class=multiple-short-txt] td.answer
,[class=numeric-multi] td.answer
.multiple-opt-comments td.answer
,.multiple-short-txt td.answer
,.numeric-multi td.answer
{
}
[class=multiple-opt-comments] ul
,[class=multiple-short-txt] ul
,[class=numeric-multi] ul
.multiple-opt-comments ul
,.multiple-short-txt ul
,.numeric-multi ul
{
display: table;
padding: 0%;
margin: 1em;
}
[class=numeric-multi] ul { margin: 0% 1em 1.5em 1em; }
.numeric-multi ul { margin: 0% 1em 1.5em 1em; }

.numeric-multi ul.computed
{
Expand All @@ -415,42 +415,42 @@ ul.cols-8 li , ul.cols-8-ul , table.cols-8 td { width: 11.5%; }
{
width: 17em;
}
[class=multiple-opt-comments] ul li
,[class=multiple-short-txt] ul li
,[class=numeric-multi] ul li
.multiple-opt-comments ul li
,.multiple-short-txt ul li
,.numeric-multi ul li
{
display: table-row;
}
[class=multiple-opt-comments] ul li span.option
.multiple-opt-comments ul li span.option
{
padding: 0.3em 1em 0% 1.8em;
text-indent: -1.7em;
display: table-cell;
vertical-align: baseline;
}
[class=multiple-short-txt] ul li label
,[class=numeric-multi] ul li label
.multiple-short-txt ul li label
,.numeric-multi ul li label
{
padding: 0.3em 1em 0% 0%;
display: table-cell;
vertical-align: baseline;
}
[class=numeric-multi] ul.computed li label
[class=numeric-multi] ul.slider.computed li label
.numeric-multi ul.computed li label
.numeric-multi ul.slider.computed li label
{
padding-right: 0%;
}

[class=multiple-opt-comments] ul li span.comment
,[class=multiple-short-txt] ul li span
,[class=numeric-multi] ul li span
.multiple-opt-comments ul li span.comment
,.multiple-short-txt ul li span
,.numeric-multi ul li span
{
padding: 0.3em 0% 0% 1em;
display: table-cell;
vertical-align: baseline;
white-space: nowrap;
}
[class=multiple-opt-comments] ul li span
.multiple-opt-comments ul li span
{
padding: 0.3em 1em 0% 0%;
}
Expand All @@ -471,13 +471,13 @@ ul.cols-8 li , ul.cols-8-ul , table.cols-8 td { width: 11.5%; }
display: table-row;
}

[class=numeric-multi] ul.multiplenumerichelp li label
.numeric-multi ul.multiplenumerichelp li label
,.numeric-multi ul.multiplenumerichelp.slider li label
{
padding: 0.3em 0% 0% 0%;
display: table-cell;
}
[class=numeric-multi] ul.multiplenumerichelp li span
.numeric-multi ul.multiplenumerichelp li span
,.numeric-multi ul.multiplenumerichelp.slider li span
{
padding: 0% 0% 0% 0.3em;
Expand Down

0 comments on commit 5d25bac

Please sign in to comment.