* JavaScript for History action
*/
$( function () {
- var $historyCompareForm = $( '#mw-history-compare' ),
+ var $historyCompareForm = $( '#mw-history-compare' ),
$historySubmitter,
$lis = $( '#pagehistory > li' );
return true;
}
- $lis.find( 'input[name="diff"], input[name="oldid"]' ).click( updateDiffRadios );
+ $lis.find( 'input[name="diff"], input[name="oldid"]' ).on( 'click', updateDiffRadios );
// Set initial state
updateDiffRadios();
// Ideally we'd use e.target instead of $historySubmitter, but e.target points
// to the form element for submit actions, so.
- $historyCompareForm.find( '.historysubmit' ).click( function () {
+ $historyCompareForm.find( '.historysubmit' ).on( 'click', function () {
$historySubmitter = $( this );
} );
// Without the cloning we'd be changing the real form, which is slower, could make
// the page look broken for a second in slow browsers and might show the form broken
// again when coming back from a "next" page.
- $historyCompareForm.submit( function ( e ) {
- var $copyForm, $copyRadios, $copyAction;
+ $historyCompareForm.on( 'submit', function ( e ) {
+ var $copyForm, $copyRadios, $copyAction;
if ( $historySubmitter ) {
$copyForm = $historyCompareForm.clone();
$copyAction = $copyForm.find( '> [name="action"]' );
// Remove action=historysubmit and ids[..]=..
+ // eslint-disable-next-line no-jquery/no-class-state
if ( $historySubmitter.hasClass( 'mw-history-compareselectedversions-button' ) ) {
$copyAction.remove();
$copyForm.find( 'input[name^="ids["]:checked' ).prop( 'checked', false );
// Remove diff=&oldid=, change action=historysubmit to revisiondelete, remove revisiondelete
- } else if ( $historySubmitter.hasClass( 'mw-history-revisiondelete-button' ) ||
- $historySubmitter.hasClass( 'mw-history-editchangetags-button' ) ) {
+ } else if (
+ // eslint-disable-next-line no-jquery/no-class-state
+ $historySubmitter.hasClass( 'mw-history-revisiondelete-button' ) ||
+ // eslint-disable-next-line no-jquery/no-class-state
+ $historySubmitter.hasClass( 'mw-history-editchangetags-button' )
+ ) {
$copyRadios.remove();
$copyAction.val( $historySubmitter.attr( 'name' ) );
+ // eslint-disable-next-line no-jquery/no-sizzle
$copyForm.find( ':submit' ).remove();
}
- // IE7 doesn't do submission from an off-DOM clone, so insert hidden into document first
+ // Firefox requires the form to be attached, so insert hidden into document first
// Also remove potentially conflicting id attributes that we don't need anyway
$copyForm
.css( 'display', 'none' )
.find( '[id]' ).removeAttr( 'id' )
.end()
.insertAfter( $historyCompareForm )
- .submit();
+ .trigger( 'submit' );
e.preventDefault();
return false; // Because the submit is special, return false as well.