jQuery: The Write Less, Do More JavaScript Library

Changeset 5074

Show
Ignore:
Timestamp:
03/18/08 09:52:58 (5 months ago)
Author:
joern.zaefferer
Message:

ui.slider: partial fix for #2428

Location:
trunk/ui
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/ui/tests/slider.html

    r5064 r5074  
    6363<body class="flora"> 
    6464 
    65 <div style='background: #eee;'> 
     65<div id="hidden" style='display:none;background: #eee;'> 
    6666 
    6767<input class="range" step="10" max="200" min="-200" name="n" value="0"> I'm a range input! 
     
    120120 
    121121$(document).ready(function(){ 
     122     
    122123    $('#slider3').slider(); 
    123124     
     
    142143     
    143144    $(".range").rangeSlider(); 
     145    $("#hidden").show(); 
     146     
    144147     
    145148     $(".slider").slider({ 
  • trunk/ui/ui.slider.js

    r5065 r5074  
    9191        //Prepare dynamic properties for later use 
    9292        if(o.axis == 'horizontal') { 
    93             this.size = this.element.outerWidth(); 
     93            this.actualSize = this.element.outerWidth(); 
    9494            this.properties = ['left', 'width']; 
    9595        } else { 
    96             this.size = this.element.outerHeight(); 
     96            this.actualSize = this.element.outerHeight(); 
    9797            this.properties = ['top', 'height']; 
    9898        } 
     
    171171        value: function(handle) { 
    172172            if(this.handle.length == 1) this.currentHandle = this.handle; 
    173             var value = ((parseInt($(handle != undefined ? this.handle[handle] || handle : this.currentHandle).css(this.properties[0]),10) / (this.size - this.handleSize())) * this.options.realMaxValue) + this.options.minValue; 
     173            var value = ((parseInt($(handle != undefined ? this.handle[handle] || handle : this.currentHandle).css(this.properties[0]),10) / (this.size() - this.handleSize())) * this.options.realMaxValue) + this.options.minValue; 
    174174            var o = this.options; 
    175175            if (o.stepping) { 
     
    179179        }, 
    180180        convertValue: function(value) { 
    181             return this.options.minValue + (value / (this.size - this.handleSize())) * this.options.realMaxValue; 
     181            return this.options.minValue + (value / (this.size() - this.handleSize())) * this.options.realMaxValue; 
    182182        }, 
    183183        translateValue: function(value) { 
    184             return ((value - this.options.minValue) / this.options.realMaxValue) * (this.size - this.handleSize()); 
     184            return ((value - this.options.minValue) / this.options.realMaxValue) * (this.size() - this.handleSize()); 
    185185        }, 
    186186        handleSize: function(handle) { 
    187187            return $(handle != undefined ? this.handle[handle] : this.currentHandle)['outer'+this.properties[1].substr(0,1).toUpperCase()+this.properties[1].substr(1)]();   
     188        }, 
     189        size: function() { 
     190            // if actualSize is 0, the slider was hidden during initialization 
     191            return this.actualSize || (this.actualSize = this.element.outerWidth()); 
    188192        }, 
    189193        click: function(e) { 
     
    225229         
    226230        oneStep: function() { 
    227             return this.options.stepping ? this.options.stepping : (this.options.realMaxValue / this.size) * 5; 
     231            return this.options.stepping ? this.options.stepping : (this.options.realMaxValue / this.size()) * 5; 
    228232        }, 
    229233         
     
    251255         
    252256        translateLimits: function(value) { 
    253             if (value >= this.size - this.handleSize()) 
    254                 value = this.size - this.handleSize(); 
     257            if (value >= this.size() - this.handleSize()) 
     258                value = this.size() - this.handleSize(); 
    255259            if (value <= 0) 
    256260                value = 0;