r3305 committed - Buttons: syntax cleanup.

r3305 committed - Buttons: syntax cleanup.


Revision: 3305
Author: scott.gonzalez
Date: Sat Sep 26 07:05:23 2009
Log: Buttons: syntax cleanup.
http://code.google.com/p/jquery-ui/source/detail?r=3305
Modified:
/branches/dev/ui/jquery.ui.button.js
=======================================
--- /branches/dev/ui/jquery.ui.button.js    Sat Sep 26 07:01:23 2009
+++ /branches/dev/ui/jquery.ui.button.js    Sat Sep 26 07:05:23 2009
@@ -37,7 +37,7 @@
                }
            });
    },
-
+
    destroy: function() {
        this.element
            .removeClass("ui-button ui-widget ui-state-default ui-corner-all
ui-state-hover ui-state-focus")
@@ -48,26 +48,33 @@
$.widget("ui.toggleButton", {
    _init: function() {
-        var self = this;
-        var label = this.label = $("[for='" + this.element.attr("id") + "']");
+        var self = this,
+            label = (this.label = $("[for='" + this.element.attr("id") + "']"));
+
        label.add(this.element).hide();
-        this.button = $("<button/>").html("" +
label.html()).insertAfter(this.element).button().unbind("mousedown.button
mouseup.button mouseleave.button").bind("click", function() {
-            if (self.options.disabled)
-                return;
-            $(this).toggleClass("ui-state-active");
-            self.element.attr("checked", function() {
-                return !!this.checked;
-            }).click();
-        }).bind("mouseleave", function() {
-            if (self.options.disabled)
-                return;
-            $(this).removeClass("ui-state-hover");
-        });
+        this.button = $("<button/>")
+            .html("" + label.html())
+            .insertAfter(this.element)
+            .button()
+            .unbind("mousedown.button mouseup.button mouseleave.button")
+            .bind("click", function() {
+                if (self.options.disabled) { return; }
+                $(this).toggleClass("ui-state-active");
+                self.element.attr("checked", function() {
+                    return !!this.checked;
+                })
+                .click();
+            })
+            .bind("mouseleave", function() {
+                if (self.options.disabled) { return; }
+                $(this).removeClass("ui-state-hover");
+            });
+
        if (this.element.attr("checked")) {
            this.button.addClass("ui-state-active");
        }
    },
-
+
    destroy: function() {
        this.element.add(this.label).show();
        this.button.remove();