r3306 committed - Buttons: syntax cleanup.
Revision: 3306
Author: scott.gonzalez
Date: Sat Sep 26 07:08:05 2009
Log: Buttons: syntax cleanup.
http://code.google.com/p/jquery-ui/source/detail?r=3306
Modified:
/branches/dev/ui/jquery.ui.button.js
=======================================
--- /branches/dev/ui/jquery.ui.button.js Sat Sep 26 07:05:23 2009
+++ /branches/dev/ui/jquery.ui.button.js Sat Sep 26 07:08:05 2009
@@ -84,31 +84,36 @@
$.widget("ui.radioButton", {
_init: function() {
- var self = this;
- var radios = this.radios = this.element.find(":radio");
+ var self = this,
+ radios = (this.radios = this.element.find(":radio"));
self.buttons = $([]);
self.labels = $([]);
self.element.addClass("ui-radio-button");
radios.each(function(index) {
- var radio = $(this);
- var label = $("[for='" + this.id + "']");
+ var radio = $(this),
+ label = $("[for='" + this.id + "']");
label.add(radio).hide();
- var button = $("<button/>").html("" +
label.html()).insertAfter(this).button().unbind("mousedown.button
mouseup.button mouseleave.button").bind("click", function() {
- if (self.options.disabled)
- return;
- self.buttons.removeClass("ui-state-active");
- $(this).addClass("ui-state-active");
- radio.attr("checked", true).click();
- }).bind("mouseleave", function() {
- if (self.options.disabled)
- return;
- $(this).removeClass("ui-state-hover");
- });
+ var button = $("<button/>")
+ .html("" + label.html())
+ .insertAfter(this)
+ .button()
+ .unbind("mousedown.button mouseup.button mouseleave.button")
+ .bind("click", function() {
+ if (self.options.disabled) { return; }
+ self.buttons.removeClass("ui-state-active");
+ $(this).addClass("ui-state-active");
+ radio.attr("checked", true).click();
+ })
+ .bind("mouseleave", function() {
+ if (self.options.disabled) { return; }
+ $(this).removeClass("ui-state-hover");
+ });
+
if (this.checked) {
button.addClass("ui-state-active");
}
button.removeClass("ui-corner-all");
- if (index == 0) {
+ if (index === 0) {
button.addClass("ui-corner-left");
}
if (index == radios.length - 1) {
@@ -116,9 +121,9 @@
}
self.buttons = self.buttons.add(button);
self.labels = self.labels.add(label);
- })
+ });
},
-
+
destroy: function() {
this.buttons.remove();
this.labels.add(this.radios).show();