275e96a8d4bb74221e7388ece0e6b43d97d907e9
3 // Return a promise that is resolved when the element is blurred (loses focus).
4 // If it already is blurred, resolved immediately.
5 function whenBlurred( $elem
) {
6 var deferred
= $.Deferred();
7 if ( $elem
.is( ':focus' ) ) {
8 $elem
.one( 'blur', deferred
.resolve
);
12 return deferred
.promise();
16 var startReady
, endReady
;
18 // Do not infuse the date input while it has user focus.
19 // This is especially important on Firefox, where hiding the native date input while the native
20 // date picker is open will cause the date picker to remain visible (but non-functional), but
21 // not replacing the interface while the user is working with it is probably a good idea anyway.
22 startReady
= whenBlurred( $( '#mw-date-start .oo-ui-inputWidget-input' ) ).then( function () {
23 return mw
.widgets
.DateInputWidget
.static.infuse( 'mw-date-start' );
25 endReady
= whenBlurred( $( '#mw-date-end .oo-ui-inputWidget-input' ) ).then( function () {
26 return mw
.widgets
.DateInputWidget
.static.infuse( 'mw-date-end' );
29 $.when( startReady
, endReady
).then( function ( startInput
, endInput
) {
30 startInput
.on( 'deactivate', function ( userSelected
) {