Reedy has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/383010 )
Change subject: Revert "SpecialBlock: Tweaks for OOUI HTMLForm" ...................................................................... Revert "SpecialBlock: Tweaks for OOUI HTMLForm" This reverts commit b2a0e3aac8f70802a5f45cc7e7fbb0f9c517fb82. Bug: T177705 Change-Id: Iadc4a82119e6ecc4ac42428e038e43bbb0a0df62 --- M includes/specials/SpecialBlock.php M resources/Resources.php M resources/src/mediawiki.special/mediawiki.special.block.js M resources/src/mediawiki.special/mediawiki.special.css 4 files changed, 35 insertions(+), 48 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/10/383010/1 diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 42e7040..c1a1f78 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -224,7 +224,6 @@ 'type' => 'hidden', 'default' => '', 'label-message' => 'ipb-confirm', - 'cssclass' => 'mw-block-confirm', ]; $this->maybeAlterFormDefaults( $a ); diff --git a/resources/Resources.php b/resources/Resources.php index f697e41..346bc50 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -2013,8 +2013,6 @@ 'mediawiki.special.block' => [ 'scripts' => 'resources/src/mediawiki.special/mediawiki.special.block.js', 'dependencies' => [ - 'oojs-ui-core', - 'mediawiki.widgets.SelectWithInputWidget', 'mediawiki.util', 'mediawiki.htmlform', ], diff --git a/resources/src/mediawiki.special/mediawiki.special.block.js b/resources/src/mediawiki.special/mediawiki.special.block.js index 491a1ff..8d88410 100644 --- a/resources/src/mediawiki.special/mediawiki.special.block.js +++ b/resources/src/mediawiki.special/mediawiki.special.block.js @@ -2,60 +2,57 @@ * JavaScript for Special:Block */ ( function ( mw, $ ) { - // Like OO.ui.infuse(), but if the element doesn't exist, return null instead of throwing an exception. - function infuseOrNull( elem ) { - try { - return OO.ui.infuse( elem ); - } catch ( er ) { - return null; - } - } - $( function () { - // This code is also loaded on the "block succeeded" page where there is no form, - // so username and expiry fields might also be missing. - var blockTargetWidget = infuseOrNull( 'mw-bi-target' ), - anonOnlyField = infuseOrNull( $( '#mw-input-wpHardBlock' ).closest( '.oo-ui-fieldLayout' ) ), - enableAutoblockField = infuseOrNull( $( '#mw-input-wpAutoBlock' ).closest( '.oo-ui-fieldLayout' ) ), - hideUserField = infuseOrNull( $( '#mw-input-wpHideUser' ).closest( '.oo-ui-fieldLayout' ) ), - watchUserField = infuseOrNull( $( '#mw-input-wpWatch' ).closest( '.oo-ui-fieldLayout' ) ), - // mw.widgets.SelectWithInputWidget - expiryWidget = infuseOrNull( 'mw-input-wpExpiry' ); + var $blockTarget = $( '#mw-bi-target' ), + $anonOnlyRow = $( '#mw-input-wpHardBlock' ).closest( 'tr' ), + $enableAutoblockRow = $( '#mw-input-wpAutoBlock' ).closest( 'tr' ), + $hideUser = $( '#mw-input-wpHideUser' ).closest( 'tr' ), + $watchUser = $( '#mw-input-wpWatch' ).closest( 'tr' ), + $expiry = $( '#mw-input-wpExpiry' ), + $otherExpiry = $( '#mw-input-wpExpiry-other' ); - function updateBlockOptions() { - var blocktarget = $.trim( blockTargetWidget.getValue() ), + function updateBlockOptions( instant ) { + var blocktarget = $.trim( $blockTarget.val() ), isEmpty = blocktarget === '', isIp = mw.util.isIPAddress( blocktarget, true ), isIpRange = isIp && blocktarget.match( /\/\d+$/ ), isNonEmptyIp = isIp && !isEmpty, - expiryValue = expiryWidget.dropdowninput.getValue(), + expiryValue = $expiry.val(), // infinityValues are the values the SpecialBlock class accepts as infinity (sf. wfIsInfinity) infinityValues = [ 'infinite', 'indefinite', 'infinity', 'never' ], isIndefinite = $.inArray( expiryValue, infinityValues ) !== -1 || - ( expiryValue === 'other' && $.inArray( expiryWidget.textinput.getValue(), infinityValues ) !== -1 ); + ( expiryValue === 'other' && $.inArray( $otherExpiry.val(), infinityValues ) !== -1 ); - if ( enableAutoblockField ) { - enableAutoblockField.toggle( !( isNonEmptyIp ) ); + if ( isNonEmptyIp ) { + $enableAutoblockRow.goOut( instant ); + } else { + $enableAutoblockRow.goIn( instant ); } - if ( hideUserField ) { - hideUserField.toggle( !( isNonEmptyIp || !isIndefinite ) ); + if ( isNonEmptyIp || !isIndefinite ) { + $hideUser.goOut( instant ); + } else { + $hideUser.goIn( instant ); } - if ( anonOnlyField ) { - anonOnlyField.toggle( !( !isIp && !isEmpty ) ); + if ( !isIp && !isEmpty ) { + $anonOnlyRow.goOut( instant ); + } else { + $anonOnlyRow.goIn( instant ); } - if ( watchUserField ) { - watchUserField.toggle( !( isIpRange && !isEmpty ) ); + if ( isIpRange && !isEmpty ) { + $watchUser.goOut( instant ); + } else { + $watchUser.goIn( instant ); } } - if ( blockTargetWidget ) { + if ( $blockTarget.length ) { // Bind functions so they're checked whenever stuff changes - blockTargetWidget.on( 'change', updateBlockOptions ); - expiryWidget.dropdowninput.on( 'change', updateBlockOptions ); - expiryWidget.textinput.on( 'change', updateBlockOptions ); + $blockTarget.keyup( updateBlockOptions ); + $expiry.change( updateBlockOptions ); + $otherExpiry.keyup( updateBlockOptions ); // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours) - updateBlockOptions(); + updateBlockOptions( /* instant= */ true ); } } ); }( mediaWiki, jQuery ) ); diff --git a/resources/src/mediawiki.special/mediawiki.special.css b/resources/src/mediawiki.special/mediawiki.special.css index 7f3b09a..9ea8019 100644 --- a/resources/src/mediawiki.special/mediawiki.special.css +++ b/resources/src/mediawiki.special/mediawiki.special.css @@ -35,19 +35,12 @@ text-align: right; } -.mw-block-hideuser, -.mw-block-confirm { +label[for='mw-input-wpConfirm'] { font-weight: bold; } -#mw-input-wpReason .oo-ui-dropdownInputWidget, -#mw-input-wpReason .oo-ui-textInputWidget { - display: block; - max-width: 50em; -} - -#mw-input-wpReason .oo-ui-textInputWidget { - margin-top: 0.5em; +.mw-block-hideuser { + font-weight: bold; } /* Special:BlockList */ -- To view, visit https://gerrit.wikimedia.org/r/383010 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iadc4a82119e6ecc4ac42428e038e43bbb0a0df62 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: wmf/1.31.0-wmf.2 Gerrit-Owner: Reedy <re...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits