Bug Tracker

Ticket #2053: ui-slider-startValue.patch

File ui-slider-startValue.patch, 2.1 kB (added by joern, 6 months ago)

startvalue as array for multiple handles patch, requires #2500 to be fixed

  • ui/ui.slider.js

     
    3232        $.extend(o, { 
    3333            axis: o.axis || (element.offsetWidth < element.offsetHeight ? 'vertical' : 'horizontal'), 
    3434            maxValue: !isNaN(parseInt(o.maxValue,10)) ? parseInt(o.maxValue,10) :  100, 
    35             minValue: parseInt(o.minValue,10) || 0, 
    36             startValue: parseInt(o.startValue,10) || 'none'      
     35            minValue: parseInt(o.minValue,10) || 0 
    3736        }); 
    3837         
    3938        //Prepare the real maxValue 
     
    9392        this.element.bind('click', function(e) { self.click.apply(self, [e]); }); 
    9493         
    9594        //Move the first handle to the startValue 
    96         if(!isNaN(o.startValue)) this.moveTo(o.startValue, 0); 
     95        if (o.startValue && o.startValue.length) { 
     96            $.each(o.startValue, function(index, value) { 
     97                self.moveTo(value, index); 
     98            }); 
     99        } else if (!isNaN(o.startValue)) 
     100            this.moveTo(o.startValue, 0); 
    97101         
    98102        //If we only have one handle, set the previous handle to this one to allow clicking before selecting the handle 
    99103        if(this.handle.length == 1) this.previousHandle = this.handle; 
     
    237241            if(handle == undefined && !this.currentHandle && this.handle.length != 1) return false; //If no handle has been passed, no current handle is available and we have multiple handles, return false 
    238242            if(handle == undefined && !this.currentHandle) handle = 0; //If only one handle is available, use it 
    239243            if(handle != undefined) this.currentHandle = this.previousHandle = $(this.handle[handle] || handle); 
    240  
    241             if(value.constructor == String) value = /\-\=/.test(value) ? this.value() - parseInt(value.replace('-=', ''),10) : this.value() + parseInt(value.replace('+=', ''),10); 
     244     
     245            if(value.constructor == String) { 
     246                if (/^\-\=/.test(value) ) { 
     247                    value = this.value() - parseInt(value.replace('-=', ''), 10) 
     248                } else if (/^\+\=/.test(value) ) { 
     249                    value = this.value() + parseInt(value.replace('+=', ''), 10) 
     250                } else { 
     251                    value = parseInt(value, 10); 
     252                } 
     253            } 
     254             
    242255            if(o.stepping) value = Math.round(value / o.stepping) * o.stepping; 
    243256            value = this.translateValue(value); 
    244257