mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Magnifier: Partial cleanup.
This commit is contained in:
parent
de8a6ea866
commit
e96c202a35
@ -19,13 +19,21 @@ $.widget("ui.magnifier", {
|
|||||||
var self = this,
|
var self = this,
|
||||||
o = this.options;
|
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"))) {
|
if (!(/^(r|a)/).test(this.element.css("position"))) {
|
||||||
this.element.css("position", "relative");
|
this.element.css("position", "relative");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pp = this.element.offset();
|
|
||||||
|
|
||||||
this.items = [];
|
this.items = [];
|
||||||
this.element.find(o.items).each(function() {
|
this.element.find(o.items).each(function() {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
@ -40,33 +48,21 @@ $.widget("ui.magnifier", {
|
|||||||
(o.opacity && $this.css('opacity', o.opacity.min));
|
(o.opacity && $this.css('opacity', o.opacity.min));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (o.overlap) {
|
// absolutize
|
||||||
for (var i=0; i<this.items.length; i++) {
|
(o.overlap && $.each(this.items, function() {
|
||||||
//Absolutize
|
$(this[0]).css({
|
||||||
$(this.items[i][0]).css({
|
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
top: this.items[i][3].top,
|
top: this[3].top,
|
||||||
left: this.items[i][3].left
|
left: this[3].left
|
||||||
});
|
});
|
||||||
}
|
}));
|
||||||
}
|
|
||||||
|
|
||||||
this.identifier = ++counter;
|
this.identifier = ++counter;
|
||||||
$(document).bind("mousemove.magnifier"+this.identifier, function(e) {
|
$(document).bind("mousemove.magnifier"+this.identifier, function(e) {
|
||||||
(self.disabled || self.magnify.apply(self, [e]));
|
(self.disabled || self.magnify.apply(self, [e]));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (o.click) {
|
this.pp = this.element.offset();
|
||||||
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]
|
|
||||||
}]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user