Skip to content

Commit

Permalink
Dev: issue #11734: Reimplement input size
Browse files Browse the repository at this point in the history
Dev: short text only actually
  • Loading branch information
Shnoulle committed Oct 31, 2016
1 parent 16c8d08 commit 6889d84
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 28 deletions.
18 changes: 4 additions & 14 deletions application/core/packages/limesurvey/survey.css
Expand Up @@ -26,18 +26,6 @@
/* For relanceOnOff ? */
.ls-irrelevant {display: none !important;}

/* Todo : default asterisk : why not put directly <i class fa> inside ?
*/
/*
.asterisk {}
.asterisk:before {
content: "\f069";
display: inline-block;
font-family: FontAwesome;
font-size: inherit;
line-height:1;
}
*/
.form-horizontal .control-label.col-sm-12 {
text-align: left;
}
Expand All @@ -63,7 +51,7 @@
border-collapse: separate;
display: table;
position: relative;
width:100%;
/* width:100%; */
}

.ls-input-group .form-control {
Expand All @@ -87,9 +75,11 @@
font-size: inherit;/* 1.4rem; BS use 10px for html and 14px for body */
font-weight: normal;
line-height: 1;
text-align: center;
border: 1px hidden transparent;
}
.answer-item textarea[cols]{width:initial;max-width:100%}
.answer-item input[type='text'][size]{width:initial;max-width:100%}
.answer-item textarea[cols] + .ls-input-group-extra,.answer-item input[type='text'][size] + .ls-input-group-extra{width:initial}

/* in inline form : width need to be auto */
.form-inline .ls-input-group{display: inline-table;vertical-align: middle;width:auto}
Expand Down
13 changes: 8 additions & 5 deletions application/helpers/qanda_helper.php
Expand Up @@ -3463,9 +3463,8 @@ function do_shortfreetext($ia)
if (intval(trim($aQuestionAttributes['maximum_chars']))>0)
{
// Only maxlength attribute, use textarea[maxlength] jquery selector for textarea
$maximum_chars = intval(trim($aQuestionAttributes['maximum_chars']));
$maxlength = "maxlength='{$maximum_chars}' ";
$extraclass .=" maxchars maxchars-".$maximum_chars;
$maxlength = intval(trim($aQuestionAttributes['maximum_chars']));
$extraclass .=" maxchars maxchars-".$maxlength;
}
else
{
Expand All @@ -3480,7 +3479,11 @@ function do_shortfreetext($ia)
{
$col = 12; /* Add a inline iof no col is set : see https://bugs.limesurvey.org/view.php?id=11734 too */
}
$inputsize=50; /* @todo : move it to attribute ? see https://bugs.limesurvey.org/view.php?id=11734 */
if(ctype_digit(trim($aQuestionAttributes['input_size']))){
$inputsize=trim($aQuestionAttributes['input_size']);
}else{
$inputsize=null;
}
if (trim($aQuestionAttributes['prefix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='')
{
$prefix = $aQuestionAttributes['prefix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']];
Expand Down Expand Up @@ -3672,7 +3675,7 @@ function do_shortfreetext($ia)
);
App()->getClientScript()->registerPackage('leaflet');
Yii::app()->getClientScript()->registerScript('sGlobalMapScriptVar',"LSmap=".ls_json_encode($aGlobalMapScriptVar).";\nLSmaps= new Array();",CClientScript::POS_HEAD);
Yii::app()->getClientScript()->registerScript('sThisMapScriptVar'.$ia[1],"LSmaps['{$ia[1]}']=".ls_json_encode($aThisMapScriptVar),CClientScript::POS_HEAD);
Yii::app()->getClientScript()->registerScript('sThisMapScriptVar'.$ia[1],"LSmaps['{$ia[1]}']=".ls_json_encode($aThisMapScriptVar).";",CClientScript::POS_HEAD);
Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."map.js");
Yii::app()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl') . 'map.css');

Expand Down
12 changes: 11 additions & 1 deletion application/helpers/questionHelper.php
Expand Up @@ -674,10 +674,20 @@ public static function getAttributesDefinitions()
'caption' => gT('Show grand total')
);

self::$attributes["input_size"]=array(
"types"=>"S",
'category'=>gT('Display'),
'sortorder'=>100,
'inputtype'=>'integer',
'default'=>'',
"help"=>gT("Set the size to the input or textarea, the input will be displayed with approximately this size in width."),
"caption"=>gT("Text input size")
);

self::$attributes["input_boxes"]=array(
"types"=>":",
'category'=>gT('Display'),
'sortorder'=>100,
'sortorder'=>110,
'inputtype'=>'switch',
'options'=>array(0=>gT('No'),
1=>gT('Yes')),
Expand Down
Expand Up @@ -79,13 +79,13 @@

// Integer
case 'integer':?>
<input type='text' class="form-control" id='<?php echo $aAttribute['name'];?>' name='<?php echo $aAttribute['name'];?>' value='<?php echo $aAttribute['value'];?>' />
<input type='number' min="1" step="1" pattern="\d+" class="form-control" id='<?php echo $aAttribute['name'];?>' name='<?php echo $aAttribute['name'];?>' value='<?php echo $aAttribute['value'];?>' />
<?php
break;

// Interger
case 'columns':?>
<input type='number' min="1" max="12" class="form-control" id='<?php echo $aAttribute['name'];?>' name='<?php echo $aAttribute['name'];?>' value='<?php echo $aAttribute['value'];?>' />
<input type='number' min="1" max="12" step="1" class="form-control" id='<?php echo $aAttribute['name'];?>' name='<?php echo $aAttribute['name'];?>' value='<?php echo $aAttribute['value'];?>' />
<?php
break;

Expand Down
Expand Up @@ -22,7 +22,7 @@
<?php eT('Your answer'); ?>
</label>
<?php if ($prefix !== '' || $suffix !== ''): ?>
<div class="input-group">
<div class="ls-input-group">
<?php endif; ?>
<!-- Prefix -->
<?php if ($prefix !== ''): ?>
Expand All @@ -36,8 +36,8 @@ class="form-control text <?php echo $kpclass;?>"
name="<?php echo $name; ?>"
id="answer<?php echo $name;?>"
value="<?php echo $dispVal; ?>"
<?php echo $maxlength; ?>
size="<?php echo $inputsize; ?>"
<?php echo ($inputsize ? 'size="'.$inputsize.'"': '') ; ?>
<?php echo ($maxlength ? 'maxlength='.$maxlength: ''); ?>
/>

<!-- Suffix -->
Expand Down
Expand Up @@ -11,6 +11,7 @@
* @var $checkconditionFunction $checkconditionFunction.'(this.value, this.name, this.type)
* @var $dispVal
*/
tracevar($maxlength);
?>

<!-- Short free text, textarea item -->
Expand All @@ -22,7 +23,7 @@
<?php eT('Your answer'); ?>
</label>
<?php if ($prefix !== '' || $suffix !== ''): ?>
<div class="input-group">
<div class="ls-input-group">
<?php endif; ?>
<!-- Prefix -->
<?php if ($prefix !== ''): ?>
Expand All @@ -34,8 +35,8 @@ class="form-control textarea <?php echo $kpclass; ?>"
name="<?php echo $name;?>"
id="<?php echo $freeTextId;?>"
rows="<?php echo $drows; ?>"
cols="<?php echo $inputsize; ?>"
<?php echo $maxlength; ?>
<?php echo ($inputsize ? 'cols="'.$inputsize.'"': '') ; ?>
<?php echo ($maxlength ? 'maxlength='.$maxlength: ''); ?>
><?php echo $dispVal; ?></textarea>

<!-- Suffix -->
Expand Down

0 comments on commit 6889d84

Please sign in to comment.