Changeset 29505 for trunk/admin/themes/default
- Timestamp:
- Sep 12, 2014, 1:35:32 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/themes/default/js/doubleSlider.js
r29249 r29505 21 21 } 22 22 23 function findClosest(array, value) { 24 var closest = null, index = -1; 25 $.each(array, function(i, v){ 26 if (closest == null || Math.abs(v - value) < Math.abs(closest - value)) { 27 closest = v; 28 index = i; 29 } 30 }); 31 return index; 32 } 33 34 var values = [ 35 options.values.indexOf(options.selected.min), 36 options.values.indexOf(options.selected.max) 37 ]; 38 if (values[0] == -1) { 39 values[0] = findClosest(options.values, options.selected.min); 40 } 41 if (values[1] == -1) { 42 values[1] = findClosest(options.values, options.selected.max); 43 } 44 23 45 var slider = this.find('.slider-slider').slider({ 24 46 range: true, 25 47 min: 0, 26 48 max: options.values.length - 1, 27 values: [ 28 options.values.indexOf(options.selected.min), 29 options.values.indexOf(options.selected.max) 30 ], 49 values: values, 31 50 slide: onChange, 32 51 change: onChange
Note: See TracChangeset
for help on using the changeset viewer.