aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.widget.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-01-21 15:37:18 -0500
committerScott González <scott.gonzalez@gmail.com>2011-01-21 15:37:18 -0500
commit711df1f5e54062d090d92f4e630e4cb0cc137b21 (patch)
tree6dd890763a8163dc9a2db6fe32b26181a6b82728 /ui/jquery.ui.widget.js
parent6072703cd17a04b0de83b337534fd0c12e24aa88 (diff)
downloadjquery-ui-711df1f5e54062d090d92f4e630e4cb0cc137b21.tar.gz
jquery-ui-711df1f5e54062d090d92f4e630e4cb0cc137b21.zip
Widget: Added _hoverable() and _focusable().
Diffstat (limited to 'ui/jquery.ui.widget.js')
-rw-r--r--ui/jquery.ui.widget.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index dd7992da2..1357d40f9 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -130,6 +130,8 @@ $.Widget.prototype = {
options );
this.bindings = $();
+ this.hoverable = $();
+ this.focusable = $();
this._bind({ remove: "destroy" });
this._create();
@@ -151,6 +153,8 @@ $.Widget.prototype = {
destroy: function() {
this._destroy();
+ // we can probably remove the unbind calls in 2.0
+ // all event bindings should go through this._bind()
this.element
.unbind( "." + this.widgetName )
.removeData( this.widgetName );
@@ -160,7 +164,11 @@ $.Widget.prototype = {
.removeClass(
this.widgetBaseClass + "-disabled " +
"ui-state-disabled" );
+
+ // clean up events and states
this.bindings.unbind( "." + this.widgetName );
+ this.hoverable.removeClass( "ui-state-hover" );
+ this.focusable.removeClass( "ui-state-focus" );
},
_destroy: $.noop,
@@ -203,6 +211,8 @@ $.Widget.prototype = {
this.widget()
.toggleClass( this.widgetBaseClass + "-disabled ui-state-disabled", !!value )
.attr( "aria-disabled", value );
+ this.hoverable.removeClass( "ui-state-hover" );
+ this.focusable.removeClass( "ui-state-focus" );
}
return this;
@@ -235,6 +245,30 @@ $.Widget.prototype = {
});
},
+ _hoverable: function( element ) {
+ this.hoverable = this.hoverable.add( element );
+ this._bind( element, {
+ mouseenter: function( event ) {
+ $( event.currentTarget ).addClass( "ui-state-hover" );
+ },
+ mouseleave: function( event ) {
+ $( event.currentTarget ).removeClass( "ui-state-hover" );
+ }
+ });
+ },
+
+ _focusable: function( element ) {
+ this.focusable = this.focusable.add( element );
+ this._bind( element, {
+ focus: function( event ) {
+ $( event.currentTarget ).addClass( "ui-state-focus" );
+ },
+ blur: function( event ) {
+ $( event.currentTarget ).removeClass( "ui-state-focus" );
+ }
+ });
+ },
+
_trigger: function( type, event, data ) {
var callback = this.options[ type ];