Changeset 5074
- Timestamp:
- 03/18/08 09:52:58 (5 months ago)
- Location:
- trunk/ui
- Files:
-
- 2 modified
-
tests/slider.html (modified) (3 diffs)
-
ui.slider.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ui/tests/slider.html
r5064 r5074 63 63 <body class="flora"> 64 64 65 <div style='background: #eee;'>65 <div id="hidden" style='display:none;background: #eee;'> 66 66 67 67 <input class="range" step="10" max="200" min="-200" name="n" value="0"> I'm a range input! … … 120 120 121 121 $(document).ready(function(){ 122 122 123 $('#slider3').slider(); 123 124 … … 142 143 143 144 $(".range").rangeSlider(); 145 $("#hidden").show(); 146 144 147 145 148 $(".slider").slider({ -
trunk/ui/ui.slider.js
r5065 r5074 91 91 //Prepare dynamic properties for later use 92 92 if(o.axis == 'horizontal') { 93 this. size = this.element.outerWidth();93 this.actualSize = this.element.outerWidth(); 94 94 this.properties = ['left', 'width']; 95 95 } else { 96 this. size = this.element.outerHeight();96 this.actualSize = this.element.outerHeight(); 97 97 this.properties = ['top', 'height']; 98 98 } … … 171 171 value: function(handle) { 172 172 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; 174 174 var o = this.options; 175 175 if (o.stepping) { … … 179 179 }, 180 180 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; 182 182 }, 183 183 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()); 185 185 }, 186 186 handleSize: function(handle) { 187 187 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()); 188 192 }, 189 193 click: function(e) { … … 225 229 226 230 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; 228 232 }, 229 233 … … 251 255 252 256 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(); 255 259 if (value <= 0) 256 260 value = 0;