Skip to content

Commit 37b0861

Browse files
committed
Use event delegation for hover state, _hoverable adds too much overhead
each refresh.
1 parent ae07303 commit 37b0861

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

datepicker-rewrite/picker.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,19 @@ $.widget( "ui.datepicker", {
5353
});
5454
});
5555

56+
this.picker.delegate( ".ui-datepicker-header a, .ui-datepicker-calendar a", "mouseenter.datepicker mouseleave.datepicker", function() {
57+
$( this ).toggleClass( "ui-state-hover" );
58+
});
59+
5660
this.refresh();
5761
},
5862
refresh: function() {
5963
this.date.refresh();
6064
this.picker.empty();
6165

62-
$( this.options.tmpl ).tmpl({
66+
$( this.options.tmpl ).tmpl( {
6367
date: this.date,
64-
labels: $.global.localize("datepicker")
68+
labels: $.global.localize( "datepicker" )
6569
}).appendTo( this.picker )
6670
.find( "button" ).button().end()
6771

@@ -70,8 +74,6 @@ $.widget( "ui.datepicker", {
7074
}
7175
// against display:none in datepicker.css
7276
this.picker.find( ".ui-datepicker" ).css( "display", "block" );
73-
this._hoverable( this.picker.find( ".ui-datepicker-header a" ) );
74-
this._hoverable( this.picker.find( ".ui-datepicker-header a, .ui-datepicker-calendar a" ) );
7577
},
7678
open: function( event ) {
7779
this.picker.fadeIn( "fast" );

0 commit comments

Comments
 (0)