aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2008-07-15 01:54:41 +0000
committerScott González <scott.gonzalez@gmail.com>2008-07-15 01:54:41 +0000
commite96c202a3500e1a6a9744313d6acf99019b4559c (patch)
tree98aa2ee9a38f3ec3490bb2b75d6e8ffb3f3d17d2
parentde8a6ea866e596e7777cc70300a906eb54e6794a (diff)
downloadjquery-ui-e96c202a3500e1a6a9744313d6acf99019b4559c.tar.gz
jquery-ui-e96c202a3500e1a6a9744313d6acf99019b4559c.zip
Magnifier: Partial cleanup.
-rw-r--r--ui/ui.magnifier.js44
1 files changed, 20 insertions, 24 deletions
diff --git a/ui/ui.magnifier.js b/ui/ui.magnifier.js
index 754db9273..f49f8489f 100644
--- a/ui/ui.magnifier.js
+++ b/ui/ui.magnifier.js
@@ -19,13 +19,21 @@ $.widget("ui.magnifier", {
var self = this,
o = this.options;
- this.element.addClass("ui-magnifier");
+ this.element
+ .addClass("ui-magnifier")
+ .bind('click.magnifier', function(e) {
+ (!self.disabled && o.click && o.click.apply(this, [e, {
+ options: self.options,
+ current: self.current[0],
+ 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.pp = this.element.offset();
-
this.items = [];
this.element.find(o.items).each(function() {
var $this = $(this);
@@ -40,33 +48,21 @@ $.widget("ui.magnifier", {
(o.opacity && $this.css('opacity', o.opacity.min));
});
- if (o.overlap) {
- for (var i=0; i<this.items.length; i++) {
- //Absolutize
- $(this.items[i][0]).css({
- position: "absolute",
- top: this.items[i][3].top,
- left: this.items[i][3].left
- });
- }
- }
+ // absolutize
+ (o.overlap && $.each(this.items, function() {
+ $(this[0]).css({
+ position: "absolute",
+ top: this[3].top,
+ left: this[3].left
+ });
+ }));
this.identifier = ++counter;
$(document).bind("mousemove.magnifier"+this.identifier, function(e) {
(self.disabled || self.magnify.apply(self, [e]));
});
- if (o.click) {
- this.element.bind('click.magnifier', function(e) {
- if (!self.disabled) {
- o.click.apply(this, [e, {
- options: self.options,
- current: self.current[0],
- currentOffset: self.current[1]
- }]);
- }
- });
- }
+ this.pp = this.element.offset();
},
destroy: function() {