Bug Tracker

Ticket #1883: bug1883.patch

File bug1883.patch, 2.7 kB (added by nostrademons, 1 year ago)

Lets slider() be applied to elements invisible or not in the DOM

  • ui.slider.js

     
    7979        o = o || {}; 
    8080        $.extend(options, o); 
    8181        $.extend(options, { 
    82             axis: o.axis || (el.offsetWidth < el.offsetHeight ? 'vertical' : 'horizontal'), 
    8382            maxValue: parseInt(o.maxValue) || 100, 
    8483            minValue: parseInt(o.minValue) || 0, 
    8584            startValue: parseInt(o.startValue) || 0, 
    8685            _start: function(h, p, c, t, e) { 
     86                calcDimensions(t.options); 
    8787                self.start.apply(t, [self, e]); // Trigger the start callback                
    8888            }, 
    8989            _beforeStop: function(h, p, c, t, e) { 
    90                 self.stop.apply(t, [self, e]); // Trigger the start callback 
     90                self.stop.apply(t, [self, e]); // Trigger the stop callback 
    9191            }, 
    9292            _drag: function(h, p, c, t, e) { 
    93                 self.drag.apply(t, [self, e]); // Trigger the start callback 
     93                self.drag.apply(t, [self, e, p]); // Trigger the drag callback 
    9494            }, 
    9595            startCondition: function() { 
    9696                return !self.disabled; 
     
    103103        o.stepping = parseInt(o.stepping) || (o.steps ? o.maxValue/o.steps : 0); 
    104104        o.realValue = (o.maxValue - o.minValue); 
    105105 
     106        function calcDimensions(opt) { 
     107            opt.axis = options.axis || (el.offsetWidth < el.offsetHeight ? 'vertical' : 'horizontal'); 
     108            if(opt.axis == 'horizontal') { 
     109                self.parentSize = $(self.element).outerWidth() - self.handle.outerWidth(); 
     110                self.prop = 'left'; 
     111            } 
     112             
     113            if(opt.axis == 'vertical') { 
     114                self.parentSize = $(self.element).outerHeight() - self.handle.outerHeight(); 
     115                self.prop = 'top'; 
     116            } 
     117        } 
    106118 
     119 
    107120        this.handle = options.handle ? $(options.handle, el) : $('.ui-slider-handle', el); 
    108121        if(this.handle.length == 1) { 
    109122            this.interaction = new $.ui.mouseInteraction(this.handle[0], options); 
     
    119132        this.element = el; 
    120133        $(this.element).addClass("ui-slider"); 
    121134         
     135        calcDimensions(o); 
    122136         
    123         if(o.axis == 'horizontal') { 
    124             this.parentSize = $(this.element).outerWidth() - this.handle.outerWidth(); 
    125             this.prop = 'left'; 
    126         } 
    127          
    128         if(o.axis == 'vertical') { 
    129             this.parentSize = $(this.element).outerHeight() - this.handle.outerHeight(); 
    130             this.prop = 'top'; 
    131         } 
    132          
    133137        if(!this.multipleHandles) { 
    134138            $(el).bind('click', function(e) { self.click.apply(self, [e]); }); 
    135139            if(!isNaN(o.startValue)) this.moveTo(o.startValue,options.realValue, null, false); 
     
    258262            if(this.multipleHandles) return false; //TODO: Multiple handle moveTo function 
    259263             
    260264            var o = this.interaction.options; 
    261             var offset = $(this.interaction.element).offsetParent().offset({ border: false }); 
    262265            this.interaction.pickValue = this.interaction.curValue; 
    263266            value = value-o.minValue; 
    264267