2 * Scripts for WatchlistExpiry on action=edit
6 // Toggle the watchlist-expiry dropdown's disabled state according to the
7 // selected state of the watchthis checkbox.
9 // The 'wpWatchthis' and 'wpWatchlistExpiry' fields come from EditPage.php.
10 const watchThisNode = document.getElementById( 'wpWatchthisWidget' ),
11 expiryNode = document.getElementById( 'wpWatchlistExpiryWidget' );
13 if ( watchThisNode && expiryNode ) {
14 const watchThisWidget = OO.ui.infuse( watchThisNode );
15 const expiryWidget = OO.ui.infuse( expiryNode );
16 // Set initial state to match the watchthis checkbox.
17 expiryWidget.setDisabled( !watchThisWidget.isSelected() );
19 // Change state on every change of the watchthis checkbox.
20 watchThisWidget.on( 'change', ( enabled ) => {
21 expiryWidget.setDisabled( !enabled );