4 * On touch devices, make it possible to click on the watchlist expiry clock icon
5 * and get a text display of the remaining days or hours for that watchlist item.
8 * @param {Event} event The click event.
10 function addDaysLeftMessages( event ) {
11 const $clock = $( event.target );
12 const timeLeft = $clock.data( 'days-left' );
13 if ( timeLeft === undefined ) {
14 // Give up if there's no data attribute (e.g. in the watchlist legend).
17 const msg = timeLeft > 0 ?
18 mw.msg( 'watchlist-expiry-days-left', timeLeft ) :
19 mw.msg( 'watchlist-expiry-hours-left' );
20 $clock.after( $( '<span>' )
21 .addClass( 'mw-watchlistexpiry-msg' )
22 .text( mw.msg( 'parentheses', msg ) ) );
26 if ( 'ontouchstart' in document.documentElement ) {
27 $( '.mw-changesList-watchlistExpiry' ).one( 'click', addDaysLeftMessages );