diff options
author | Scott González <scott.gonzalez@gmail.com> | 2008-09-19 14:20:14 +0000 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2008-09-19 14:20:14 +0000 |
commit | 7c2e7965e90896b3ccf8525aeebfe2b9242203ff (patch) | |
tree | aec37d89461d5d9b14979523f3f82b8b7440f97c /ui/ui.magnifier.js | |
parent | 8d04c3594c4bd56ee2b86068e002b7566359df14 (diff) | |
download | jquery-ui-7c2e7965e90896b3ccf8525aeebfe2b9242203ff.tar.gz jquery-ui-7c2e7965e90896b3ccf8525aeebfe2b9242203ff.zip |
Reverted r695.
Diffstat (limited to 'ui/ui.magnifier.js')
-rw-r--r-- | ui/ui.magnifier.js | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/ui/ui.magnifier.js b/ui/ui.magnifier.js index ef32c6859..ada0820f2 100644 --- a/ui/ui.magnifier.js +++ b/ui/ui.magnifier.js @@ -18,7 +18,7 @@ $.widget("ui.magnifier", { _init: function() {
var self = this,
o = this.options;
-
+
this.element
.addClass("ui-magnifier")
.bind('click.magnifier', function(e) {
@@ -28,12 +28,12 @@ $.widget("ui.magnifier", { currentOffset: self.current[1]
}]));
});
-
+
// the element must have relative or absolute positioning
if (!(/^(r|a)/).test(this.element.css("position"))) {
this.element.css("position", "relative");
}
-
+
this.items = [];
this.element.find(o.items).each(function() {
var $this = $(this);
@@ -44,10 +44,10 @@ $.widget("ui.magnifier", { [$this.width(),$this.height()],
(o.overlap ? $this.position() : null)
]);
-
+
(o.opacity && $this.css('opacity', o.opacity.min));
});
-
+
// absolutize
(o.overlap && $.each(this.items, function() {
$(this[0]).css({
@@ -56,15 +56,15 @@ $.widget("ui.magnifier", { left: this[3].left
});
}));
-
+
this.identifier = ++counter;
$(document).bind("mousemove.magnifier"+this.identifier, function(e) {
(self.disabled || self._magnify.apply(self, [e]));
});
-
+
this.pp = this.element.offset();
},
-
+
destroy: function() {
this.reset();
this.element
@@ -72,15 +72,15 @@ $.widget("ui.magnifier", { .unbind(".magnifier");
$(document).unbind("mousemove.magnifier"+this.identifier);
},
-
+
disable: function() {
this.reset();
$.widget.prototype.disable.apply(this, arguments);
},
-
+
reset: function(e) {
var o = this.options;
-
+
$.each(this.items, function() {
var item = this;
$(item[0]).css({
@@ -89,16 +89,16 @@ $.widget("ui.magnifier", { top: (item[3] ? item[3].top : 0),
left: (item[3] ? item[3].left : 0)
});
-
+
(o.opacity && $(item[0]).css('opacity', o.opacity.min));
(o.zIndex && $(item[0]).css("z-index", ""));
});
},
-
+
_magnify: function(e) {
var p = [e.pageX,e.pageY], o = this.options, c, distance = 1;
this.current = this.items[0];
-
+
// Compute the parent's distance
// we don't need to fire anything if we are not near the parent
var overlap = ((p[0] > this.pp.left-o.distance) &&
@@ -106,10 +106,10 @@ $.widget("ui.magnifier", { (p[1] > this.pp.top-o.distance) &&
(p[1] < this.pp.top + this.element[0].offsetHeight + o.distance));
if (!overlap) { return false; }
-
+
for (var i=0; i<this.items.length; i++) {
c = this.items[i];
-
+
var olddistance = distance;
if (!o.axis) {
distance = Math.sqrt(
@@ -123,24 +123,24 @@ $.widget("ui.magnifier", { distance = Math.abs(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2));
}
}
-
+
if (distance < o.distance) {
this.current = distance < olddistance ? c : this.current;
-
+
if (!o.axis || o.axis != "y") {
$(c[0]).css({
width: c[2][0]+ (c[2][0] * (o.magnification-1)) - (((distance/o.distance)*c[2][0]) * (o.magnification-1)),
left: (c[3] ? (c[3].left + o.verticalLine * ((c[2][1] * (o.magnification-1)) - (((distance/o.distance)*c[2][1]) * (o.magnification-1)))) : 0)
});
}
-
+
if (!o.axis || o.axis != "x") {
$(c[0]).css({
height: c[2][1]+ (c[2][1] * (o.magnification-1)) - (((distance/o.distance)*c[2][1]) * (o.magnification-1)),
top: (c[3] ? c[3].top : 0) + (o.baseline-0.5) * ((c[2][0] * (o.magnification-1)) - (((distance/o.distance)*c[2][0]) * (o.magnification-1)))
});
}
-
+
if (o.opacity) {
$(c[0]).css('opacity', o.opacity.max-(distance/o.distance) < o.opacity.min ? o.opacity.min : o.opacity.max-(distance/o.distance));
}
@@ -151,13 +151,13 @@ $.widget("ui.magnifier", { top: (c[3] ? c[3].top : 0),
left: (c[3] ? c[3].left : 0)
});
-
+
(o.opacity && $(c[0]).css('opacity', o.opacity.min));
}
-
+
(o.zIndex && $(c[0]).css("z-index", ""));
}
-
+
(o.zIndex && $(this.current[0]).css("z-index", o.zIndex));
}
});
|