r3542 committed - button refactoring: radioButton to use the label instead of creating a...
Revision: 3542
Author: joern.zaefferer
Date: Sun Dec 27 08:04:09 2009
Log: button refactoring: radioButton to use the label instead of creating a
button element
http://code.google.com/p/jquery-ui/source/detail?r=3542
Modified:
/branches/dev/ui/jquery.ui.button.js
=======================================
--- /branches/dev/ui/jquery.ui.button.js Sun Dec 27 06:15:23 2009
+++ /branches/dev/ui/jquery.ui.button.js Sun Dec 27 08:04:09 2009
@@ -164,25 +164,21 @@
_init: function() {
var self = this,
radios = (this.radios = this.element.find(":radio"));
- self.buttons = $([]);
self.labels = $([]);
self.element.addClass("ui-button-set");
- radios.each(function(index) {
+ radios.hide().each(function(index) {
var radio = $(this),
label = $("[for='" + this.id + "']");
- label.add(radio).hide();
- var button = $("<button/>")
- .html("" + label.html())
- .insertAfter(this)
+ var button = label
.button()
.unbind("mousedown.button mouseup.button mouseleave.button")
- .bind("click", function() {
+ .bind("click.button", function() {
if (self.options.disabled) { return; }
- self.buttons.removeClass("ui-state-active");
+ self.labels.removeClass("ui-state-active");
$(this).addClass("ui-state-active");
radio.attr("checked", true).click();
})
- .bind("mouseleave", function() {
+ .bind("mouseleave.button", function() {
if (self.options.disabled) { return; }
$(this).removeClass("ui-state-hover");
});
@@ -191,14 +187,13 @@
button.addClass("ui-state-active");
}
- self.buttons = self.buttons.add(button);
self.labels = self.labels.add(label);
});
},
destroy: function() {
- this.buttons.remove();
- this.labels.add(this.radios).show();
+ this.radios.show();
+ this.labels.button("destroy");
$.Widget.prototype.destroy.call(this);
},
@@ -217,7 +212,7 @@
}
if (!buttons.length && this.element.is(":has(:radio)")) {
this.radio = this.element.radioButton();
- buttons = this.radio.find("button");
+ buttons = this.radio.find(".ui-button");
}
if (buttons.length) {
this.element.addClass("ui-button-set");
--