Skip to content
Permalink
Browse files

Adding slider to base engine and jquery engine. Tests added.

  • Loading branch information...
markstory committed Apr 19, 2009
1 parent 4b2504d commit 5bc6bcfce17ddcb8000056b67db7f91ca6f77004
@@ -47,6 +47,10 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
'drop' => array(
'leave' => 'out',
'hover' => 'over'
),
'slider' => array(
'complete' => 'stop',
'direction' => 'orientation'
)
);
/**
@@ -218,5 +222,19 @@ function drop($options = array()) {
$template = '%s.droppable({%s});';
return $this->_methodTemplate('drop', $template, $options, $callbacks);
}
/**
* Create a Slider element
*
* Requires both Ui.Core and Ui.Slider to be loaded.
*
* @param array $options Array of options for the droppable element.
* @return string Completed Slider script.
* @see JsHelper::slider() for options list.
**/
function slider($options = array()) {
$callbacks = array('start', 'change', 'slide', 'stop');
$template = '%s.slider({%s});';
return $this->_methodTemplate('slider', $template, $options, $callbacks);
}
}
?>
@@ -650,6 +650,28 @@ function drop($options = array()) {
function sortable() {
trigger_error(sprintf(__('%s does not have sortable() implemented', true), get_class($this)), E_USER_WARNING);
}
/**
* Create a slider control element.
*
* ### Options
*
* - handle - The handle 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
*
* ### Events
*
* - change - Fired when the slider's value is updated
* - complete - Fired when the user stops sliding the handle
*
* @return string Completed slider script
**/
function slider() {
trigger_error(sprintf(__('%s does not have slider() implemented', true), get_class($this)), E_USER_WARNING);
}
/**
* Parse an options assoc array into an Javascript object literal.
* Similar to object() but treats any non-integer value as a string,
@@ -217,5 +217,23 @@ function testDrop() {
$expected = '$("#element").droppable({accept:".items", drop:onDrop, out:onExit, over:onHover});';
$this->assertEqual($result, $expected);
}
/**
* test slider generation
*
* @return void
**/
function testSlider() {
$this->Jquery->get('#element');
$result = $this->Jquery->slider(array(
'complete' => 'onComplete',
'change' => 'onChange',
'min' => 0,
'max' => 10,
'value' => 2,
'direction' => 'vertical'
));
$expected = '$("#element").slider({change:onChange, max:10, min:0, orientation:"vertical", stop:onComplete, value:2});';
$this->assertEqual($result, $expected);
}
}
?>

0 comments on commit 5bc6bcf

Please sign in to comment.
You can’t perform that action at this time.