GUI Components JavaScript DHTML




Yahoo! UI Library - Slider Widget











 

Slider Widget

 

  
    

  
    

    #logButtonHeader input { font-size: 80% }
/* logger default styles */
/* font size is controlled here: default 77% */
#yui-log {position:absolute;top:1em;right:1em;font-size:77%;text-align:left;}
/* width is controlled here: default 31em */
.yui-log {background-color:#AAA;border:1px solid black;font-family:monospace;z-index:9000;}
.yui-log p {margin:1px;padding:.1em;}
.yui-log button {font-family:monospace;}
.yui-log .yui-log-hd {padding:.5em;background-color:#575757;color:#FFF;}
/* height is controlled here: default 20em*/
.yui-log .yui-log-bd {width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;}
.yui-log .yui-log-ft {margin-top:.5em;margin-bottom:1em;}
.yui-log .yui-log-ft .yui-log-categoryfilters {}
.yui-log .yui-log-ft .yui-log-sourcefilters {width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;}
.yui-log .yui-log-btns {position:relative;float:right;bottom:.25em;}
.yui-log .yui-log-filtergrp {margin-right:.5em;}
.yui-log .info {background-color:#A7CC25;} /* A7CC25 green */
.yui-log .warn {background-color:#F58516;} /* F58516 orange */
.yui-log .error {background-color:#E32F0B;} /* E32F0B red */
.yui-log .time {background-color:#A6C9D7;} /* A6C9D7 blue */
.yui-log .window {background-color:#F2E886;} /* F2E886 tan */


  
    

Links


    
    YAHOO.example.logApp = function() {
        return {
            init: function() {
                if (YAHOO.widget.Logger) {
                    var reader = new YAHOO.widget.LogReader( "logDiv", 
                            { newestOnTop: true, height: "400px" } );
                    reader._onClickPauseBtn(null, reader);
                }
            }
        };
    } (); 
    YAHOO.util.Event.on(window, "load", YAHOO.example.logApp.init);
    
    

  


 
     
       
      

Slider


        


              This example uses a scale factor to convert pixels into
              a "real" value.
        


              


The logger is paused for performance reasons.  Click "Resume" to re-enable it.


              
                                 tabindex="0" 
                 id="vertBGDiv"
                 name="vertBGDiv"
                 title="Vertical Slider">
                    
                
                
                  
                      
                      
                  
                
              
              

              
              

     
    
  


// YAHOO.widget.SliderThumb.prototype.toString = function () { 
    // return "ASDF";
// }
YAHOO.example.SliderApp = function() {
  var verticalSlider;
    // The slider can move 0 pixels up
    var topConstraint = 0;
    // The slider can move 200 pixels down
    var bottomConstraint = 200;
    // Custom scale factor for converting the pixel offset into a real value
    var scaleFactor = 1.5;
    return {
        init: function() {
            YAHOO.util.Event.addListener("formV", "submit", this.updateVert);
            YAHOO.util.Event.addListener("vertButton", "click", this.updateVert);
            verticalSlider = YAHOO.widget.Slider.getVertSlider("vertBGDiv", 
                             "vertHandleDiv", topConstraint, bottomConstraint, 20);
            verticalSlider.onChange = function(offsetFromStart) {
                // use the scale factor to convert the pixel offset into a
                // real value
                var actualValue = parseInt(offsetFromStart * scaleFactor, 10);
                document.getElementById("vertVal").value = actualValue;
                document.getElementById("vertBGDiv").title = 
                            "Vertical Slider, value = " + actualValue;
            };
            verticalSlider.onSlideStart = function() {
                YAHOO.log("slidestart");
            };
            verticalSlider.onSlideEnd = function() {
                YAHOO.log("slideend");
            };
            // verticalSlider.unreg();
            // verticalSlider.backgroundEnabled = false;
            verticalSlider.setValue(20);
        },
        updateVert: function() {
            var v = parseFloat(document.forms['formV']['vertVal'].value, 10);
            if ( isNaN(v) ) v = 0;
            // convert the real value into a pixel offset
            verticalSlider.setValue(Math.round(v/scaleFactor));
            return false;
        },
        clearConstraints: function() {
            verticalSlider.getThumb().clearConstraints();
        },
        clearTicks: function() {
            verticalSlider.getThumb().clearTicks();
        }
    };
} ();
//YAHOO.example.SliderApp.init();
YAHOO.util.Event.addListener(window, "load", YAHOO.example.SliderApp.init, 
                             YAHOO.example.SliderApp, true);
YAHOO.util.Event.addListener("re2", "click", YAHOO.example.SliderApp.clearTicks);



           
       
yui.zip( 3,714 k)