Changeset 2191 for branches/3.2-dev

Show
Ignore:
Timestamp:
09/03/2007 10:24:23 AM (16 months ago)
Author:
tof
Message:

TSlider : Add some docs - Move JS part in control.js

Location:
branches/3.2-dev/framework/Web
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/3.2-dev/framework/Web/Javascripts/source/packages.php

    r2188 r2191  
    4949        'slider'=>array( 
    5050                'scriptaculous/slider.js', 
    51                 'prado/slider/slider.js' 
    5251        ), 
    5352); 
  • branches/3.2-dev/framework/Web/Javascripts/source/prado/controls/controls.js

    r1932 r2191  
    289289        } 
    290290}); 
     291 
     292Prado.WebUI.TSlider = Class.extend(Prado.WebUI.PostBackControl, 
     293{        
     294        onInit : function (options) 
     295        { 
     296                this.options=options; 
     297                this.onChange=options.onChange; 
     298                options.onChange=this.change.bind(this); 
     299                 
     300                this.hiddenField=$(this.options.ID+'_1'); 
     301                new Control.Slider(options.ID+'_handle',options.ID, options); 
     302                 
     303                if(this.options['AutoPostBack']==true) 
     304                        Event.observe(this.hiddenField, "change", Prado.PostBack.bindEvent(this,options)); 
     305        }, 
     306         
     307        change : function (value) 
     308        { 
     309                this.hiddenField.value=value; 
     310                if (this.onChange) 
     311                { 
     312                        this.onChange(value); 
     313                } 
     314                if(this.options['AutoPostBack']==true) 
     315                { 
     316                        Event.fireEvent(this.hiddenField, "change"); 
     317                } 
     318        } 
     319}); 
  • branches/3.2-dev/framework/Web/UI/WebControls/TSlider.php

    r2190 r2191  
    1414 * TSlider class 
    1515 * 
    16  * TODO: Class Documentation 
    17  * 
    18  * Quick ex : 
    19  * 
    20  * <com:TSlider id="hSlider" AutoPostBack="true" HandleType="Image" Axis="Horizontal" Enabled="true" Width="200px" Minimum="0" Maximum="100" OnSliderChanged="sliderChanged"> 
    21  *      <prop:ClientSide.onSlide> 
    22  *              $('hslidervalue').innerHTML = value; 
    23  *      </prop:ClientSide.onSlide> 
    24  * </com:TSlider> 
    25  * Value  : <span id="hslidervalue"><%=$this->slider->value%></span> 
    26  * 
    27  * Properties : 
    28  * AutoPostBack=true ==> postback occured if slider changes. 
    29  * HandleType ==> "Cursor" or "Image" or "Custom" 
    30  *              "Cursor" : display a simple cursor as handle on the track (see TSliderHandleCursor) 
    31  *              "Image" : display an image as handle on the track (see TSliderHandleImage) 
    32  *              "Custom" : Use a custom control as handle (extends from TSliderHandle, and specify with HandleClass Property) 
    33  * Axis ==> Horizontal or Vertical 
    34  * Width ==> Width of track 
    35  * Height ==> Height of track 
    36  * Minimum & Maximum => min & max values 
    37  * Values ==> Allowed values (default = all values between Minimum and Maximum) 
    38  * 
    39  * Handle.* ==> Properties for handle (widht, height, color for Cursor, Width, Height, ImageUrl for Image) 
    40  * 
    41  * CssClass => Track Css Class. Defaults to 'slider'. The classname is appended with -horitontal or -vertical depending on the Direction. 
    42  * Events : 
    43  * ClientSide.onSlide : JS code to be executed when cursor is slided 
    44  * ClientSide.onChange : JS code to be executed when the value has changed 
    45  * onSliderChanged : Serverside Event raised on postback when value has changed. 
    46  * 
     16 * TSlider displays a slider for numeric input purpose. A slider consists of a 'track',  
     17 * which define the range of possible value, and a 'handle' which can slide on the track, to select  
     18 * a value in the range. The track can be either Horizontal or Vertical, depending of the {@link SetDirection Direction} 
     19 * property. By default, it's horizontal. 
     20 * 
     21 * The range boundaries is defined by {@link SetMinValue MinValue} and {@link SetMaxValue MaxValue} properties.  
     22 * The default range is from 0 to 100.  
     23 * The {@link SetStepSize StepSize} property can be used to define the <b>step</b> between 2 values inside the range. 
     24 * Notice that this step will be recomputed if there is more than 200 values between the range boundaries. 
     25 * You can also provide the allowed values by setting the {@link SetValues Values} array. 
     26 *  
     27 * The handle sub-properties can be accessed by {@link GetHandle Handle} property. You can also provide your own control 
     28 * for the handle, using {@link SetHandleClass HandleClass} property. Note that this class must be a subclass of  
     29 * {@link TSliderHandle} 
     30 *  
     31 * The TSlider control can be easily customized using CssClasses. You can provide your own css file, using the  
     32 * {@link SetCssUrl CssUrl} property. 
     33 * The css class for TSlider can be set by the {@link setCssClass CssClass} property. Defaults values are "hslider" for 
     34 * an Horizontal slider, or "vslider" for a Vertical one.  
     35 * The css class for the Handle can be set by the <b>Handle.CssClass</b> subproperty. Defaults is "handle", which just 
     36 * draw a red block as a cursor. 'handle-image' css class is also provided for your convenience, which display an image 
     37 * as the handle. 
     38 *  
     39 * If {@link SetAutoPostBack AutoPostBack} property is true, postback is sent as soon as the value changed. 
     40 *  
     41 * TSlider raises the {@link onValueChanged} event when the value of the slider has changed during postback. 
     42 *  
     43 * You can also attach ClientSide javascript events handler to the slider : 
     44 * - ClientSide.onSlide is called when the handle is slided on the track. You can get the current value in the <b>value</b> 
     45 * javascript variable. You can use this event to update on client side a label with the current value 
     46 * - ClientSide.onChange is called when the slider value has changed (at the end of a move).  
    4747 * 
    4848 * @author Christophe Boulain <Christophe.Boulain@gmail.com> 
     
    557557        private $_track; 
    558558 
     559        /** 
     560         * Override parent constructor to get the track control as parameter 
     561         * 
     562         * @param TSlider track control 
     563         */ 
    559564        public function __construct ($track) 
    560565        { 
     
    567572        } 
    568573 
     574        /** 
     575         * @return TSlider track control 
     576         */ 
    569577        public function getTrack() { 
    570578                return $this->_track; 
     
    584592                return ($class=='')?'handle':$class; 
    585593        } 
    586  
     594         
     595        /** 
     596         * Add the specified css classes to the handle 
     597         * @param THtmlWriter writer 
     598         */ 
    587599        public function addAttributesToRender($writer) 
    588600        { 
  • branches/3.2-dev/framework/Web/UI/WebControls/assets/TSlider.css

    r2189 r2191  
     1/* Css class for an Horizontal Slider */ 
    12.hslider 
    23{ 
     
    67} 
    78 
     9/* Css class for a Vertical Slider */ 
    810.vslider 
    911{ 
     
    1315} 
    1416 
     17/* Css class for a block cursor as handle */ 
    1518.handle 
    1619{ 
     
    1922} 
    2023 
     24/* Dimensions of cursor depend on Direction */ 
    2125.hslider .handle 
    2226{ 
     
    3135} 
    3236 
     37/* Css class for an image as handle */ 
    3338.handle-image 
    3439{ 
     
    3944} 
    4045 
     46/* Center the image on the track */ 
    4147.hslider .handle-image 
    4248{ 
    43         top: -5px; /* Center the image on the track */ 
     49        top: -5px; 
    4450} 
    4551