mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding slider to Mootools. Test cases added.
This commit is contained in:
parent
5bc6bcfce1
commit
b7845657a8
3 changed files with 64 additions and 2 deletions
|
@ -655,12 +655,12 @@ class JsBaseEngineHelper extends AppHelper {
|
|||
*
|
||||
* ### Options
|
||||
*
|
||||
* - handle - The handle used in sliding
|
||||
* - handle - The id of the element used in sliding.
|
||||
* - direction - The direction of the slider either 'vertical' or 'horizontal'
|
||||
* - min - The min value for the slider.
|
||||
* - max - The max value for the slider.
|
||||
* - step - The number of steps or ticks the slider will have.
|
||||
* - value - The initial offset of the slider
|
||||
* - value - The initial offset of the slider.
|
||||
*
|
||||
* ### Events
|
||||
*
|
||||
|
|
|
@ -59,6 +59,12 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
'drop' => 'onDrop',
|
||||
'hover' => 'onEnter',
|
||||
'leave' => 'onLeave',
|
||||
),
|
||||
'slider' => array(
|
||||
'complete' => 'onComplete',
|
||||
'change' => 'onChange',
|
||||
'direction' => 'mode',
|
||||
'step' => 'steps'
|
||||
)
|
||||
);
|
||||
/**
|
||||
|
@ -270,6 +276,33 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
$this->selection = $options['droppables'];
|
||||
return $out;
|
||||
}
|
||||
/**
|
||||
* Create a slider control
|
||||
*
|
||||
* Requires `Slider` from MootoolsMore
|
||||
*
|
||||
* @param array $options Array of options for the slider.
|
||||
* @return string Completed slider script.
|
||||
* @see JsHelper::slider() for options list.
|
||||
**/
|
||||
function slider($options = array()) {
|
||||
$slider = $this->selection;
|
||||
$this->get($options['handle']);
|
||||
unset($options['handle']);
|
||||
|
||||
$callbacks = array('onStart', 'onTick', 'onChange', 'onComplete');
|
||||
$options = $this->_mapOptions('slider', $options);
|
||||
if (isset($options['min']) && isset($options['max'])) {
|
||||
$options['range'] = array($options['min'], $options['max']);
|
||||
unset($options['min'], $options['max']);
|
||||
}
|
||||
$optionString = $this->_parseOptions($options, $callbacks);
|
||||
if (!empty($optionString)) {
|
||||
$optionString = ', {' . $optionString . '}';
|
||||
}
|
||||
$out = 'var jsSlider = new Slider(' . $slider . ', ' . $this->selection . $optionString . ');';
|
||||
$this->selection = $slider;
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -250,5 +250,34 @@ class MooEngineHelperTestCase extends CakeTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($this->Moo->selection, '$("drop-me")');
|
||||
}
|
||||
/**
|
||||
* test slider generation
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testSlider() {
|
||||
$this->Moo->get('#slider');
|
||||
$result = $this->Moo->slider(array(
|
||||
'handle' => '#my-handle',
|
||||
'complete' => 'onComplete',
|
||||
'change' => 'onChange',
|
||||
'direction' => 'horizontal',
|
||||
));
|
||||
$expected = 'var jsSlider = new Slider($("slider"), $("my-handle"), {mode:"horizontal", onChange:onChange, onComplete:onComplete});';
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($this->Moo->selection, '$("slider")');
|
||||
|
||||
$this->Moo->get('#slider');
|
||||
$result = $this->Moo->slider(array(
|
||||
'handle' => '#my-handle',
|
||||
'complete' => 'onComplete',
|
||||
'change' => 'onChange',
|
||||
'direction' => 'horizontal',
|
||||
'min' => 10,
|
||||
'max' => 40
|
||||
));
|
||||
$expected = 'var jsSlider = new Slider($("slider"), $("my-handle"), {mode:"horizontal", onChange:onChange, onComplete:onComplete, range:[10,40]});';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue