]> source.dussan.org Git - jquery-ui.git/commitdiff
Magnifier: Partial cleanup.
authorScott González <scott.gonzalez@gmail.com>
Tue, 15 Jul 2008 01:54:41 +0000 (01:54 +0000)
committerScott González <scott.gonzalez@gmail.com>
Tue, 15 Jul 2008 01:54:41 +0000 (01:54 +0000)
ui/ui.magnifier.js

index 754db9273272640f1fcb55e3aa65892a5a5631f4..f49f8489fd07c3071b9a92aea52f703eb26faba7 100644 (file)
@@ -19,13 +19,21 @@ $.widget("ui.magnifier", {
                var self = this,\r
                        o = this.options;\r
                \r
-               this.element.addClass("ui-magnifier");\r
+               this.element\r
+                       .addClass("ui-magnifier")\r
+                       .bind('click.magnifier', function(e) {\r
+                               (!self.disabled && o.click && o.click.apply(this, [e, {\r
+                                       options: self.options,\r
+                                       current: self.current[0],\r
+                                       currentOffset: self.current[1]\r
+                               }]));\r
+                       });\r
+               \r
+               // the element must have relative or absolute positioning\r
                if (!(/^(r|a)/).test(this.element.css("position"))) {\r
                        this.element.css("position", "relative");\r
                }\r
                \r
-               this.pp = this.element.offset();\r
-               \r
                this.items = [];\r
                this.element.find(o.items).each(function() {\r
                        var $this = $(this);\r
@@ -40,33 +48,21 @@ $.widget("ui.magnifier", {
                        (o.opacity && $this.css('opacity', o.opacity.min));\r
                });\r
                \r
-               if (o.overlap) {\r
-                       for (var i=0; i<this.items.length; i++) {\r
-                               //Absolutize\r
-                               $(this.items[i][0]).css({\r
-                                       position: "absolute",\r
-                                       top: this.items[i][3].top,\r
-                                       left: this.items[i][3].left\r
-                               });\r
-                       }\r
-               }\r
+               // absolutize\r
+               (o.overlap && $.each(this.items, function() {\r
+                       $(this[0]).css({\r
+                               position: "absolute",\r
+                               top: this[3].top,\r
+                               left: this[3].left\r
+                       });\r
+               }));\r
                \r
                this.identifier = ++counter;\r
                $(document).bind("mousemove.magnifier"+this.identifier, function(e) {\r
                        (self.disabled || self.magnify.apply(self, [e]));\r
                });\r
                \r
-               if (o.click) {\r
-                       this.element.bind('click.magnifier', function(e) {\r
-                               if (!self.disabled) {\r
-                                       o.click.apply(this, [e, {\r
-                                               options: self.options,\r
-                                               current: self.current[0],\r
-                                               currentOffset: self.current[1]\r
-                                       }]);\r
-                               }\r
-                       });\r
-               }\r
+               this.pp = this.element.offset();\r
        },\r
        \r
        destroy: function() {\r