Skip to content

Commit

Permalink
New feature: Option to reverse the slider direction.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpartner committed Dec 23, 2016
1 parent 2477ffe commit ada599e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
10 changes: 10 additions & 0 deletions application/helpers/qanda_helper.php
Expand Up @@ -3067,6 +3067,14 @@ function do_multiplenumeric($ia)

$slider_separator= (trim($aQuestionAttributes['slider_separator'])!='')?$aQuestionAttributes['slider_separator']:"";
$slider_reset=($aQuestionAttributes['slider_reset'])?1:0;

/* Slider reversed value */
if($aQuestionAttributes['slider_reversed'] == 1){
$slider_reversed = 'true';
}else{
$slider_reversed = 'false';
}

}
else
{
Expand All @@ -3083,6 +3091,7 @@ function do_multiplenumeric($ia)
$slider_custom_handle = '';
$slider_separator = '';
$slider_reset = 0;
$slider_reversed = 'false';
$slider_startvalue = '';
$slider_displaycallout = '';
}
Expand Down Expand Up @@ -3269,6 +3278,7 @@ function do_multiplenumeric($ia)
'slider_reset_set' => $slider_default_set,
'slider_handle' => (isset($slider_handle ))? $slider_handle:'',
'slider_reset' => $slider_reset,
'slider_reversed' => $slider_reversed,
'slider_custom_handle' => $slider_custom_handle,
'slider_showminmax' => $aQuestionAttributes['slider_showminmax'],
'sSeparator' => $sSeparator,
Expand Down
11 changes: 11 additions & 0 deletions application/helpers/questionHelper.php
Expand Up @@ -1007,6 +1007,17 @@ public static function getAttributesDefinitions()
"caption"=>gT('Use slider layout')
);

self::$attributes["slider_reversed"]=array(
"types"=>"K",
'category'=>gT('Slider'),
'sortorder'=>50,
'inputtype'=>'switch',
'options'=>array(0=>gT('No'),1=>gT('Yes')),
'default'=>0,
"help"=>gT('Reverses the slider direction and repositions the min/max text accoringly.'),
"caption"=>gT('Reverse the slider direction')
);

self::$attributes["slider_reset"]=array(
"types"=>"K",
'category'=>gT('Slider'),
Expand Down
Expand Up @@ -24,6 +24,7 @@
* @var $slider_orientation
* @var $slider_handle
* @var $slider_reset
* @var $slider_reversed
* @var $sSeparator
*/
?>
Expand Down Expand Up @@ -57,12 +58,13 @@
'data-integer'=>$integeronly,
'data-position'=>$slider_position,
'data-set-position'=>$slider_reset_set,
'data-slider-reversed'=>$slider_reversed,
'aria-labelledby'=>"label-{$myfname}"
));
?>
<?php if($slider_showminmax): ?>
<div class='pull-left help-block'><?php echo $slider_min; ?></div>
<div class='pull-right help-block'><?php echo $slider_max; ?></div>
<div class='pull-left help-block'><?php echo $slider_reversed == 'false' ? $slider_min : $slider_max; ?></div>
<div class='pull-right help-block'><?php echo $slider_reversed == 'false' ? $slider_max : $slider_min; ?></div>
<?php endif; ?>
<?php if ($slider_reset): ?>
<div class="ls-input-group-extra ls-no-js-hidden ls-input-group-reset">
Expand Down

9 comments on commit ada599e

@LouisGac
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's really nice. Does it fix the RTL problem?

@tpartner
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. What RTL problem?

@LouisGac
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slider was working in the wrong direction in RTL mode

@tpartner
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... the slider direction is the same in RTL but the Min/Max texts are reversed. I'm hesitant to reverse the slider direction because it will mess with the vertical sliders. I suppose we could adjust the "pull-xx" class here depending on language direction (if I knew how to detect it :) ) - ada599e#diff-0e2b0985e0ef0b94f3155723696faaffR66.

Also, I don't see the Left/Right texts rendered at all in RTL.

@Shnoulle
Copy link
Collaborator

@Shnoulle Shnoulle commented on ada599e Dec 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issue with rtl and default template at a time around 2016-12-22 pull done.

http://testing.sondages.pro/answershtml/index.php/48422/lang/ar

capture du 2016-12-25 15-57-50

boostrap-rtl package fix this without any issue.

@Shnoulle
Copy link
Collaborator

@Shnoulle Shnoulle commented on ada599e Dec 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LouisGac What is the issue in rtl ? Before holiday, it work in develop.

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think rtl is unrelated here : rtl are borken before this fix

in 2.5X or 3.0 : rtl must be inverse (0 at start : then right, not left like currently) by default. If is set 'inverse' (after this new attribute) : shown ltr if rtl and rtl for ltr.

But : i think it'"s must be done only with js/css, not in HTML.

@tpartner
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shnoulle, I fixed it in the HTML rendering - 505d05f

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i see this : but

  1. rtl is unrelated here : it's not featire related, and boirken before this feature
  2. we hav dir-rtl/dir-ltr now : seems tyhe best wayd (for me) to fix rtl currently : https://github.com/LimeSurvey/LimeSurvey/blob/develop/application/core/packages/limesurvey/survey.css#L84 because rtl is aonly a css issue :)

Please sign in to comment.