From de8a6ea866e596e7777cc70300a906eb54e6794a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 15 Jul 2008 01:32:24 +0000 Subject: [PATCH] Magnifier: Partial cleanup. --- ui/ui.magnifier.js | 118 +++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 64 deletions(-) diff --git a/ui/ui.magnifier.js b/ui/ui.magnifier.js index e40e6f3f4..754db9273 100644 --- a/ui/ui.magnifier.js +++ b/ui/ui.magnifier.js @@ -12,74 +12,80 @@ */ (function($) { +var counter = 0; + $.widget("ui.magnifier", { init: function() { - - var self = this, o = this.options; - this.items = []; + var self = this, + o = this.options; + this.element.addClass("ui-magnifier"); - if(!(/^(r|a)/).test(this.element.css("position"))) this.element.css("position", "relative"); + if (!(/^(r|a)/).test(this.element.css("position"))) { + this.element.css("position", "relative"); + } this.pp = this.element.offset(); - $(o.items, this.element).each(function() { - + this.items = []; + this.element.find(o.items).each(function() { + var $this = $(this); + // TODO: use a hash so references to this data is readable self.items.push([ this, - $(this).offset(), - [$(this).width(),$(this).height()], - (o.overlap ? $(this).position() : null) + $this.offset(), + [$this.width(),$this.height()], + (o.overlap ? $this.position() : null) ]); - - if(o.opacity) - $(this).css('opacity', o.opacity.min); - + + (o.opacity && $this.css('opacity', o.opacity.min)); }); - - if(o.overlap) { - for(var i=0;i this.pp.left-o.distance && p[0] < this.pp.left + this.element[0].offsetWidth + o.distance) && (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 *" - } + } }); })(jQuery); -- 2.39.5