Search and Top Navigation
Ticket #3467: slider.patch
File slider.patch, 5.3 KB (added by ahuseynov, May 24, 2009 09:08PM UTC)
fixed slider patch
# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: C:\Users\Anar Huseynov\Projects\projectone\app\webroot\js\jqueryui
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: ui.slider.js
--- ui.slider.js Base (BASE)
+++ ui.slider.js Locally Modified (Based On LOCAL)
@@ -192,12 +192,16 @@
this.elementOffset = this.element.offset();
var position = { x: event.pageX, y: event.pageY };
- var normValue = this._normValueFromMouse(position);
+ var percentValue = this._percentValueFromMouse(position) * 100;
- var distance = this._valueMax() - this._valueMin() + 1, closestHandle;
+ var distance = 101, closestHandle;
var self = this, index;
+ var direction = 'left';
+ if ('vertical' == this.orientation) {
+ direction = 'top';
+ }
this.handles.each(function(i) {
- var thisDistance = Math.abs(normValue - self.values(i));
+ var thisDistance = Math.abs(percentValue - parseFloat($(this).css(direction)));
if (distance > thisDistance) {
distance = thisDistance;
closestHandle = $(this);
@@ -205,13 +209,6 @@
}
});
- // workaround for bug #3736 (if both handles of a range are at 0,
- // the first is always used as the one with least distance,
- // and moving it is obviously prevented by preventing negative ranges)
- if(o.range == true && this.values(1) == o.min) {
- closestHandle = $(this.handles[++index]);
- }
-
this._start(event, index);
self._handleIndex = index;
@@ -231,10 +228,8 @@
+ (parseInt(closestHandle.css('marginTop'),10) || 0)
};
- normValue = this._normValueFromMouse(position);
- this._slide(event, index, normValue);
+ this._slide(event, index, this._normValueFromMouse(position, index));
return true;
-
},
_mouseStart: function(event) {
@@ -244,7 +239,7 @@
_mouseDrag: function(event) {
var position = { x: event.pageX, y: event.pageY };
- var normValue = this._normValueFromMouse(position);
+ var normValue = this._normValueFromMouse(position, this._handleIndex);
this._slide(event, this._handleIndex, normValue);
@@ -268,8 +263,36 @@
this.orientation = this.options.orientation == 'vertical' ? 'vertical' : 'horizontal';
},
- _normValueFromMouse: function(position) {
+ _normValueFromMouse: function(position, index) {
+ var percentMouse = this._percentValueFromMouse(position);
+ if (this.options.values && this.options.values.length) {
+ var size = this.elementSize.width;
+ var handle_size = $(this.handles[index]).width();
+ var actual_size = size - handle_size;
+ var down_ratio = actual_size / size;
+ if (index == 0) {
+ percentMouse = percentMouse / down_ratio;
+ } else if (index == 1) {
+ percentMouse = (percentMouse - handle_size / size) / down_ratio;
+ }
+ }
+ var valueTotal = this._valueMax() - this._valueMin(),
+ valueMouse = percentMouse * valueTotal,
+ valueMouseModStep = valueMouse % this.options.step,
+ normValue = this._valueMin() + valueMouse - valueMouseModStep;
+
+ if (valueMouseModStep > (this.options.step / 2))
+ normValue += this.options.step;
+
+ // Since JavaScript has problems with large floats, round
+ // the final value to 5 digits after the decimal point (see #4124)
+ return parseFloat(normValue.toFixed(5));
+
+ },
+
+ _percentValueFromMouse: function(position) {
+
var pixelTotal, pixelMouse;
if ('horizontal' == this.orientation) {
pixelTotal = this.elementSize.width;
@@ -285,18 +308,7 @@
if ('vertical' == this.orientation)
percentMouse = 1 - percentMouse;
- var valueTotal = this._valueMax() - this._valueMin(),
- valueMouse = percentMouse * valueTotal,
- valueMouseModStep = valueMouse % this.options.step,
- normValue = this._valueMin() + valueMouse - valueMouseModStep;
-
- if (valueMouseModStep > (this.options.step / 2))
- normValue += this.options.step;
-
- // Since JavaScript has problems with large floats, round
- // the final value to 5 digits after the decimal point (see #4124)
- return parseFloat(normValue.toFixed(5));
-
+ return parseFloat(percentMouse.toFixed(5));
},
_start: function(event, index) {
@@ -477,7 +489,16 @@
if (this.options.values && this.options.values.length) {
var vp0, vp1;
this.handles.each(function(i, j) {
+ var size = $(self.element).width();
+ var handle_size = $(this).width();
var valPercent = (self.values(i) - self._valueMin()) / (self._valueMax() - self._valueMin()) * 100;
+ var actual_size = size - handle_size;
+ var down_ratio = actual_size / size;
+ if (i == 0) {
+ valPercent *= down_ratio;
+ } else if (i == 1) {
+ valPercent = valPercent * down_ratio + handle_size / size * 100;
+ }
var _set = {}; _set[self.orientation == 'horizontal' ? 'left' : 'bottom'] = valPercent + '%';
$(this).stop(1,1)[animate ? 'animate' : 'css'](_set, o.animate);
if (self.options.range === true) {
Download in other formats:
Original Format
File slider.patch, 5.3 KB (added by ahuseynov, May 24, 2009 09:08PM UTC)
fixed slider patch
# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: C:\Users\Anar Huseynov\Projects\projectone\app\webroot\js\jqueryui
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: ui.slider.js
--- ui.slider.js Base (BASE)
+++ ui.slider.js Locally Modified (Based On LOCAL)
@@ -192,12 +192,16 @@
this.elementOffset = this.element.offset();
var position = { x: event.pageX, y: event.pageY };
- var normValue = this._normValueFromMouse(position);
+ var percentValue = this._percentValueFromMouse(position) * 100;
- var distance = this._valueMax() - this._valueMin() + 1, closestHandle;
+ var distance = 101, closestHandle;
var self = this, index;
+ var direction = 'left';
+ if ('vertical' == this.orientation) {
+ direction = 'top';
+ }
this.handles.each(function(i) {
- var thisDistance = Math.abs(normValue - self.values(i));
+ var thisDistance = Math.abs(percentValue - parseFloat($(this).css(direction)));
if (distance > thisDistance) {
distance = thisDistance;
closestHandle = $(this);
@@ -205,13 +209,6 @@
}
});
- // workaround for bug #3736 (if both handles of a range are at 0,
- // the first is always used as the one with least distance,
- // and moving it is obviously prevented by preventing negative ranges)
- if(o.range == true && this.values(1) == o.min) {
- closestHandle = $(this.handles[++index]);
- }
-
this._start(event, index);
self._handleIndex = index;
@@ -231,10 +228,8 @@
+ (parseInt(closestHandle.css('marginTop'),10) || 0)
};
- normValue = this._normValueFromMouse(position);
- this._slide(event, index, normValue);
+ this._slide(event, index, this._normValueFromMouse(position, index));
return true;
-
},
_mouseStart: function(event) {
@@ -244,7 +239,7 @@
_mouseDrag: function(event) {
var position = { x: event.pageX, y: event.pageY };
- var normValue = this._normValueFromMouse(position);
+ var normValue = this._normValueFromMouse(position, this._handleIndex);
this._slide(event, this._handleIndex, normValue);
@@ -268,8 +263,36 @@
this.orientation = this.options.orientation == 'vertical' ? 'vertical' : 'horizontal';
},
- _normValueFromMouse: function(position) {
+ _normValueFromMouse: function(position, index) {
+ var percentMouse = this._percentValueFromMouse(position);
+ if (this.options.values && this.options.values.length) {
+ var size = this.elementSize.width;
+ var handle_size = $(this.handles[index]).width();
+ var actual_size = size - handle_size;
+ var down_ratio = actual_size / size;
+ if (index == 0) {
+ percentMouse = percentMouse / down_ratio;
+ } else if (index == 1) {
+ percentMouse = (percentMouse - handle_size / size) / down_ratio;
+ }
+ }
+ var valueTotal = this._valueMax() - this._valueMin(),
+ valueMouse = percentMouse * valueTotal,
+ valueMouseModStep = valueMouse % this.options.step,
+ normValue = this._valueMin() + valueMouse - valueMouseModStep;
+
+ if (valueMouseModStep > (this.options.step / 2))
+ normValue += this.options.step;
+
+ // Since JavaScript has problems with large floats, round
+ // the final value to 5 digits after the decimal point (see #4124)
+ return parseFloat(normValue.toFixed(5));
+
+ },
+
+ _percentValueFromMouse: function(position) {
+
var pixelTotal, pixelMouse;
if ('horizontal' == this.orientation) {
pixelTotal = this.elementSize.width;
@@ -285,18 +308,7 @@
if ('vertical' == this.orientation)
percentMouse = 1 - percentMouse;
- var valueTotal = this._valueMax() - this._valueMin(),
- valueMouse = percentMouse * valueTotal,
- valueMouseModStep = valueMouse % this.options.step,
- normValue = this._valueMin() + valueMouse - valueMouseModStep;
-
- if (valueMouseModStep > (this.options.step / 2))
- normValue += this.options.step;
-
- // Since JavaScript has problems with large floats, round
- // the final value to 5 digits after the decimal point (see #4124)
- return parseFloat(normValue.toFixed(5));
-
+ return parseFloat(percentMouse.toFixed(5));
},
_start: function(event, index) {
@@ -477,7 +489,16 @@
if (this.options.values && this.options.values.length) {
var vp0, vp1;
this.handles.each(function(i, j) {
+ var size = $(self.element).width();
+ var handle_size = $(this).width();
var valPercent = (self.values(i) - self._valueMin()) / (self._valueMax() - self._valueMin()) * 100;
+ var actual_size = size - handle_size;
+ var down_ratio = actual_size / size;
+ if (i == 0) {
+ valPercent *= down_ratio;
+ } else if (i == 1) {
+ valPercent = valPercent * down_ratio + handle_size / size * 100;
+ }
var _set = {}; _set[self.orientation == 'horizontal' ? 'left' : 'bottom'] = valPercent + '%';
$(this).stop(1,1)[animate ? 'animate' : 'css'](_set, o.animate);
if (self.options.range === true) {