]> source.dussan.org Git - jquery-ui.git/commitdiff
Magnifier: Partial cleanup.
authorScott González <scott.gonzalez@gmail.com>
Wed, 16 Jul 2008 00:08:43 +0000 (00:08 +0000)
committerScott González <scott.gonzalez@gmail.com>
Wed, 16 Jul 2008 00:08:43 +0000 (00:08 +0000)
ui/ui.magnifier.js

index 393a6b6f7bdd1ff251fba664cc476cd0cacbe1f3..0dc8efbf174394853587306b149c585985c13f4a 100644 (file)
@@ -99,15 +99,19 @@ $.widget("ui.magnifier", {
                var p = [e.pageX,e.pageY], o = this.options, c, distance = 1;\r
                this.current = this.items[0];\r
                \r
-               //Compute the parents distance, because we don't need to fire anything if we are not near the parent\r
-               var overlap = ((p[0] > 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));\r
+               // Compute the parent's distance\r
+               // we don't need to fire anything if we are not near the parent\r
+               var overlap = ((p[0] > this.pp.left-o.distance) &&\r
+                       (p[0] < this.pp.left + this.element[0].offsetWidth + o.distance) &&\r
+                       (p[1] > this.pp.top-o.distance) &&\r
+                       (p[1] < this.pp.top + this.element[0].offsetHeight + o.distance));\r
                if (!overlap) { return false; }\r
                \r
                for (var i=0; i<this.items.length; i++) {\r
                        c = this.items[i];\r
                        \r
                        var olddistance = distance;\r
-                       if(!o.axis) {\r
+                       if (!o.axis) {\r
                                distance = Math.sqrt(\r
                                          Math.pow(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2), 2)\r
                                        + Math.pow(p[1] - ((c[3] ? this.pp.top  : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2), 2)\r
@@ -117,11 +121,11 @@ $.widget("ui.magnifier", {
                                        distance = Math.abs(p[1] - ((c[3] ? this.pp.top  : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2));\r
                                } else {\r
                                        distance = Math.abs(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2));\r
-                               }                       \r
+                               }\r
                        }\r
                        \r
                        if (distance < o.distance) {\r
-                               this.current = distance < olddistance ? this.items[i] : this.current;\r
+                               this.current = distance < olddistance ? c : this.current;\r
                                \r
                                if (!o.axis || o.axis != "y") {\r
                                        $(c[0]).css({\r
@@ -134,7 +138,7 @@ $.widget("ui.magnifier", {
                                        $(c[0]).css({\r
                                                height: c[2][1]+ (c[2][1] * (o.magnification-1)) - (((distance/o.distance)*c[2][1]) * (o.magnification-1)),\r
                                                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)))\r
-                                       });                                     \r
+                                       });\r
                                }\r
                                \r
                                if (o.opacity) {\r
@@ -154,9 +158,8 @@ $.widget("ui.magnifier", {
                        (o.zIndex && $(c[0]).css("z-index", ""));\r
                }\r
                \r
-               (this.options.zIndex &&\r
-                       $(this.current[0]).css("z-index", this.options.zIndex));\r
-       }               \r
+               (o.zIndex && $(this.current[0]).css("z-index", o.zIndex));\r
+       }\r
 });\r
 \r
 $.extend($.ui.magnifier, {\r