PHP Class Prado\Web\UI\WebControls\TSlider

TSlider displays a slider for numeric input purpose. A slider consists of a 'track', which define the range of possible value, and a 'handle' which can slide on the track, to select a value in the range. The track can be either Horizontal or Vertical, depending of the {@link SetDirection Direction} property. By default, it's horizontal. The range boundaries are defined by {@link SetMinValue MinValue} and {@link SetMaxValue MaxValue} properties. The default range is from 0 to 100. The {@link SetStepSize StepSize} property can be used to define the step between 2 values inside the range. Notice that this step will be recomputed if there is more than 200 values between the range boundaries. You can also provide the allowed values by setting the {@link SetValues Values} array. A 'Progress Indicator' can be displayed within the track with the {@link SetProgressIndicator ProgressIndicator} property. The TSlider control can be easily customized using CssClasses. You can provide your own css file, using the {@link SetCssUrl CssUrl} property. The css class for TSlider can be set by the {@link setCssClass CssClass} property. Default value is "Slider HorizontalSlider" for an horizontal slider, and "Slider VerticalSlider" for a vertical one. If {@link SetAutoPostBack AutoPostBack} property is true, postback is sent as soon as the value changed. TSlider raises the {@link onValueChanged} event when the value of the slider has changed during postback. You can also attach ClientSide javascript events handler to the slider : - ClientSide.onSlide is called when the handle is slided on the track. You can get the current value in the value javascript variable. You can use this event to update on client side a label with the current value - ClientSide.onChange is called when the slider value has changed (at the end of a move).
Since: 3.1.1
Author: Christophe Boulain ([email protected])
Inheritance: extends TWebControl, implements Prado\Web\UI\IPostBackDataHandler, implements Prado\IDataRenderer
Show file Open project: pradosoft/prado

Public Methods

Method Description
getAutoPostBack ( ) : boolean
getClientSide ( ) : TSliderClientScript Gets the TSliderClientScript to set the TSlider event handlers.
getCssUrl ( ) : string
getData ( ) : string Returns the value of the TSlider control.
getDataChanged ( ) : boolean Returns a value indicating whether postback has caused the control data change.
getDirection ( ) : TSliderDirection
getMaxValue ( ) : float
getMinValue ( ) : float
getProgressIndicator ( ) : boolean
getStepSize ( ) : float
getTagName ( ) : string
getValue ( ) : float
getValues ( ) : array
loadPostData ( $key, $values ) : boolean Loads user input data.
onPreRender ( $param ) Registers CSS and JS.
onValueChanged ( $param ) Raises OnValueChanged event.
raisePostDataChangedEvent ( ) Raises postdata changed event.
renderContents ( $writer ) Render the body content
setAutoPostBack ( $value ) Sets the value indicating if postback automatically.
setCssUrl ( $value )
setData ( $value ) Sets the value of the TSlider control.
setDirection ( $value )
setMaxValue ( $value )
setMinValue ( $value )
setProgressIndicator ( $value )
setStepSize ( $value ) Sets the step size used to determine the places where the slider handle can stop at.
setValue ( $value )
setValues ( $value ) Sets the possible values that the slider can take.

Protected Methods

Method Description
addAttributesToRender ( $writer ) Add the specified css classes to the track
createClientScript ( ) : TSliderClientScript
getClientClassName ( ) : string Gets the name of the javascript class responsible for performing postback for this control.
getSliderOptions ( ) : array Get javascript sliderr options.
registerSliderClientScript ( ) Registers the javascript code to initialize the slider.
registerStyleSheet ( ) Registers the CSS relevant to the TSlider.

Method Details

addAttributesToRender() protected method

Add the specified css classes to the track
protected addAttributesToRender ( $writer )

createClientScript() protected method

protected createClientScript ( ) : TSliderClientScript
return TSliderClientScript javascript event options.

getAutoPostBack() public method

public getAutoPostBack ( ) : boolean
return boolean a value indicating whether an automatic postback to the server will occur whenever the user modifies the slider value. Defaults to false.

getClientClassName() protected method

This method overrides the parent implementation.
protected getClientClassName ( ) : string
return string the javascript class name

getClientSide() public method

The slider on the client-side supports the following events. # OnSliderMove -- raised when the slider is moved. # OnSliderChanged -- raised when the slider value is changed You can attach custom javascript code to each of these events
public getClientSide ( ) : TSliderClientScript
return TSliderClientScript javascript validator event options.

getCssUrl() public method

public getCssUrl ( ) : string
return string URL for the CSS file including all relevant CSS class definitions. Defaults to '' (a default CSS file will be applied in this case.)

getData() public method

This method is required by {@link \Prado\IDataRenderer}. It is the same as {@link getValue()}.
See also: getValue
public getData ( ) : string
return string the value of the TSlider control.

getDataChanged() public method

This method is required by the \Prado\Web\UI\IPostBackDataHandler interface.
public getDataChanged ( ) : boolean
return boolean whether postback has caused the control data change. False if the page is not in postback mode.

getDirection() public method

public getDirection ( ) : TSliderDirection
return TSliderDirection Direction of slider (Horizontal or Vertical). Defaults to Horizontal.

getMaxValue() public method

public getMaxValue ( ) : float
return float Maximum value for the slider. Defaults to 100.0.

getMinValue() public method

public getMinValue ( ) : float
return float Minimum value for slider. Defaults to 0.0.

getProgressIndicator() public method

public getProgressIndicator ( ) : boolean
return boolean wether to display a progress indicator or not. Defaults to true.

getSliderOptions() protected method

Get javascript sliderr options.
protected getSliderOptions ( ) : array
return array slider client-side options

getStepSize() public method

public getStepSize ( ) : float
return float Step size. Defaults to 1.0.

getTagName() public method

public getTagName ( ) : string
return string the HTML tag name for slider. Defaults to div.

getValue() public method

public getValue ( ) : float
return float current value of slider

getValues() public method

public getValues ( ) : array
return array list of allowed values the slider can take. Defaults to an empty array.

loadPostData() public method

This method is primarly used by framework developers.
public loadPostData ( $key, $values ) : boolean
return boolean whether the data of the component has been changed

onPreRender() public method

This method is invoked right before the control rendering, if the control is visible.
public onPreRender ( $param )

onValueChanged() public method

This method is invoked when the {@link getValue Value} property changes on postback. If you override this method, be sure to call the parent implementation to ensure the invocation of the attached event handlers.
public onValueChanged ( $param )

raisePostDataChangedEvent() public method

This method is required by {@link \Prado\Web\UI\IPostBackDataHandler} interface. It is invoked by the framework when {@link getValue Value} property is changed on postback. This method is primarly used by framework developers.

registerSliderClientScript() protected method

Registers the javascript code to initialize the slider.

registerStyleSheet() protected method

It will register the CSS file specified by {@link getCssUrl CssUrl}. If that is not set, it will use the default CSS.
protected registerStyleSheet ( )

renderContents() public method

Render the body content
public renderContents ( $writer )

setAutoPostBack() public method

An automatic postback to the server will occur whenever the user modifies the slider value.
public setAutoPostBack ( $value )

setCssUrl() public method

public setCssUrl ( $value )

setData() public method

This method is required by {@link \Prado\IDataRenderer}. It is the same as {@link setValue()}.
See also: setValue
public setData ( $value )

setDirection() public method

public setDirection ( $value )

setMaxValue() public method

public setMaxValue ( $value )

setMinValue() public method

public setMinValue ( $value )

setProgressIndicator() public method

public setProgressIndicator ( $value )

setStepSize() public method

An evenly distributed stop marks will be generated according to {@link getMinValue MinValue}, {@link getMaxValue MaxValue} and StepSize. To use uneven stop marks, set {@link setValues Values}.
public setStepSize ( $value )

setValue() public method

public setValue ( $value )

setValues() public method

If this is set, {@link setStepSize StepSize} will be ignored. The latter generates a set of evenly distributed candidate values.
public setValues ( $value )