Fixing range option for prototype engine. Fixes #1509

This commit is contained in:
mark_story 2011-02-07 19:19:50 -05:00
parent f2a4b1e959
commit 584116524b
2 changed files with 10 additions and 4 deletions

View file

@ -330,10 +330,14 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
unset($options['handle']);
if (isset($options['min']) && isset($options['max'])) {
$options['range'] = array($options['min'], $options['max']);
$options['range'] = sprintf('$R(%s,%s)', $options['min'], $options['max']);
unset($options['min'], $options['max']);
}
$optionString = $this->_processOptions('slider', $options);
$options = $this->_mapOptions('slider', $options);
$options = $this->_prepareCallbacks('slider', $options);
$optionString = $this->_parseOptions(
$options, array_merge(array_keys($this->_callbackArguments['slider']), array('range'))
);
if (!empty($optionString)) {
$optionString = ', {' . $optionString . '}';
}

View file

@ -348,9 +348,11 @@ class PrototypeEngineHelperTestCase extends CakeTestCase {
'handle' => '#handle',
'change' => 'change();',
'complete' => 'complete();',
'value' => 4
'value' => 4,
'min' => 10,
'max' => 100
));
$expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, sliderValue:4});';
$expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, range:$R(10,100), sliderValue:4});';
$this->assertEqual($result, $expected);
}