mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 20:46:24 +00:00
Adding slider to base engine and jquery engine. Tests added.
This commit is contained in:
parent
4b2504d334
commit
5bc6bcfce1
3 changed files with 58 additions and 0 deletions
|
@ -47,6 +47,10 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
|
||||||
'drop' => array(
|
'drop' => array(
|
||||||
'leave' => 'out',
|
'leave' => 'out',
|
||||||
'hover' => 'over'
|
'hover' => 'over'
|
||||||
|
),
|
||||||
|
'slider' => array(
|
||||||
|
'complete' => 'stop',
|
||||||
|
'direction' => 'orientation'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
|
@ -218,5 +222,19 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
|
||||||
$template = '%s.droppable({%s});';
|
$template = '%s.droppable({%s});';
|
||||||
return $this->_methodTemplate('drop', $template, $options, $callbacks);
|
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 @@ class JsBaseEngineHelper extends AppHelper {
|
||||||
function sortable() {
|
function sortable() {
|
||||||
trigger_error(sprintf(__('%s does not have sortable() implemented', true), get_class($this)), E_USER_WARNING);
|
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.
|
* Parse an options assoc array into an Javascript object literal.
|
||||||
* Similar to object() but treats any non-integer value as a string,
|
* Similar to object() but treats any non-integer value as a string,
|
||||||
|
|
|
@ -217,5 +217,23 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
|
||||||
$expected = '$("#element").droppable({accept:".items", drop:onDrop, out:onExit, over:onHover});';
|
$expected = '$("#element").droppable({accept:".items", drop:onDrop, out:onExit, over:onHover});';
|
||||||
$this->assertEqual($result, $expected);
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue