Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3305

Show
Ignore:
Timestamp:
12/14/05 10:03:04 (3 years ago)
Author:
madrobby
Message:

Update slider.js in slider plugin to latest version

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/scriptaculous_slider/CHANGELOG

    r2937 r3305  
     1* Updated to slider.js as of script.aculo.us 1.5 final 
     2 
    13* Updated copyright notice 
    24 
  • plugins/scriptaculous_slider/javascripts/slider.js

    r2937 r3305  
    6565     
    6666    this.trackLength = this.maximumOffset() - this.minimumOffset(); 
     67    this.handleLength = this.isVertical() ? this.handles[0].offsetHeight : this.handles[0].offsetWidth; 
    6768 
    6869    this.active   = false; 
     
    152153    this.value = this.values[0]; // assure backwards compat 
    153154     
    154     this.handles[handleIdx].style[ this.isVertical() ? 'top' : 'left'] =  
     155    this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =  
    155156      this.translateToPx(sliderValue); 
    156157     
    157158    this.drawSpans(); 
    158     if(!this.event) this.updateFinished(); 
     159    if(!this.dragging || !this.event) this.updateFinished(); 
    159160  }, 
    160161  setValueBy: function(delta, handleIdx) { 
     
    163164  }, 
    164165  translateToPx: function(value) { 
    165     return Math.round((this.trackLength / (this.range.end - this.range.start)) * (value - this.range.start)) + "px"; 
     166    return Math.round( 
     167      ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *  
     168      (value - this.range.start)) + "px"; 
    166169  }, 
    167170  translateToValue: function(offset) { 
    168     return ((offset/this.trackLength) * (this.range.end - this.range.start)) + this.range.start; 
     171    return ((offset/(this.trackLength-this.handleLength) *  
     172      (this.range.end-this.range.start)) + this.range.start); 
    169173  }, 
    170174  getRange: function(range) { 
     
    216220        if(handle==this.track) { 
    217221          var offsets  = Position.cumulativeOffset(this.track);  
    218           this.event = event;          
     222          this.event = event; 
    219223          this.setValue(this.translateToValue(  
    220             this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0] 
     224           (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2) 
    221225          )); 
    222           offsets  = Position.cumulativeOffset(this.activeHandle); 
     226          var offsets  = Position.cumulativeOffset(this.activeHandle); 
    223227          this.offsetX = (pointer[0] - offsets[0]); 
    224228          this.offsetY = (pointer[1] - offsets[1]); 
     
    242246  update: function(event) { 
    243247   if(this.active) { 
    244       if(!this.dragging) { 
    245         this.dragging = true; 
    246         if(this.activeHandle.style.position=="") style.position = "relative"; 
    247       } 
     248      if(!this.dragging) this.dragging = true; 
    248249      this.draw(event); 
    249250      // fix AppleWebKit rendering 
     
    259260    this.event = event; 
    260261    this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] )); 
    261     if(this.initialized && this.options.onSlide) this.options.onSlide(this.values.length>1 ? this.values : this.value, this); 
     262    if(this.initialized && this.options.onSlide) 
     263      this.options.onSlide(this.values.length>1 ? this.values : this.value, this); 
    262264  }, 
    263265  endDrag: function(event) {