"OO": false
},
"rules": {
- "max-len": 0
+ "quote-props": [ "error", "as-needed" ],
+ "max-len": "off",
+ "jquery/no-global-selector": "off"
}
}
$( '.config-help-field-data' ).hide()
.closest( '.config-help-field-container' ).find( '.config-help-field-hint' )
.show()
- .click( function () {
+ .on( 'click', function () {
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-slide
$( this ).closest( '.config-help-field-container' ).find( '.config-help-field-data' )
.slideToggle( 'fast' );
} );
$( document.getElementById( $( this ).attr( 'rel' ) ) ).hide();
} );
$( document.getElementById( $( '.dbRadio:checked' ).attr( 'rel' ) ) ).show();
- $( '.dbRadio' ).click( function () {
+ $( '.dbRadio' ).on( 'click', function () {
var $checked = $( '.dbRadio:checked' ),
$wrapper = $( document.getElementById( $checked.attr( 'rel' ) ) );
if ( $wrapper.is( ':hidden' ) ) {
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-animate-toggle
$( '.dbWrapper' ).hide( 'slow' );
+ // eslint-disable-next-line jquery/no-animate-toggle
$wrapper.show( 'slow' );
}
} );
} );
// Show/hide Creative Commons thingy
- $( '.licenseRadio' ).click( function () {
+ $( '.licenseRadio' ).on( 'click', function () {
var $wrapper = $( '#config-cc-wrapper' );
if ( $( '#config__LicenseCode_cc-choose' ).is( ':checked' ) ) {
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-animate-toggle
$wrapper.show( 'slow' );
} else {
+ // eslint-disable-next-line jquery/no-animate-toggle
$wrapper.hide( 'slow' );
}
} );
// Show/hide random stuff (email, upload)
- $( '.showHideRadio' ).click( function () {
+ $( '.showHideRadio' ).on( 'click', function () {
var $wrapper = $( '#' + $( this ).attr( 'rel' ) );
if ( $( this ).is( ':checked' ) ) {
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-animate-toggle
$wrapper.show( 'slow' );
} else {
+ // eslint-disable-next-line jquery/no-animate-toggle
$wrapper.hide( 'slow' );
}
} );
- $( '.hideShowRadio' ).click( function () {
+ $( '.hideShowRadio' ).on( 'click', function () {
var $wrapper = $( '#' + $( this ).attr( 'rel' ) );
if ( $( this ).is( ':checked' ) ) {
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-animate-toggle
$wrapper.hide( 'slow' );
} else {
+ // eslint-disable-next-line jquery/no-animate-toggle
$wrapper.show( 'slow' );
}
} );
}
// Enable/disable "other" textboxes
- $( '.enableForOther' ).click( function () {
+ $( '.enableForOther' ).on( 'click', function () {
var $textbox = $( document.getElementById( $( this ).attr( 'rel' ) ) );
// FIXME: Ugh, this is ugly
if ( $( this ).val() === 'other' ) {
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-slide
$textbox.prop( 'readonly', false ).closest( '.config-block' ).slideDown( 'fast' );
} else {
+ // eslint-disable-next-line jquery/no-slide
$textbox.prop( 'readonly', true ).closest( '.config-block' ).slideUp( 'fast' );
}
} );
$( '#config_wgSitename' ).on( 'keyup change', syncText ).each( syncText );
// Show/Hide memcached servers when needed
- $( 'input[name$="config__MainCacheType"]' ).change( function () {
+ $( 'input[name$="config__MainCacheType"]' ).on( 'change', function () {
var $memc = $( '#config-memcachewrapper' );
if ( $( 'input[name$="config__MainCacheType"]:checked' ).val() === 'memcached' ) {
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-animate-toggle
$memc.show( 'slow' );
} else {
+ // eslint-disable-next-line jquery/no-animate-toggle
$memc.hide( 'slow' );
}
} );
},
"devDependencies": {
"deepmerge": "1.3.2",
- "eslint-config-wikimedia": "0.9.0",
+ "eslint-config-wikimedia": "0.10.0",
"grunt": "1.0.3",
"grunt-banana-checker": "0.6.0",
"grunt-contrib-copy": "1.0.0",
}
// Cancel selection
- } ).mousedown( function () {
+ } ).on( 'mousedown', function () {
if ( config.cancelSelection ) {
this.onselectstart = function () {
return false;
var prevCheckbox = null,
$box = this;
// When our boxes are clicked..
- $box.click( function ( e ) {
+ $box.on( 'click', function ( e ) {
// And one has been clicked before...
if ( prevCheckbox !== null && e.shiftKey ) {
// Check or uncheck this one and all in-between checkboxes,
}
}
+ // eslint-disable-next-line jquery/no-animate-toggle
$containers.toggle( action === 'expand' );
hookCallback();
}
// Only fetch if the value in the textbox changed and is not empty, or if the results were hidden
// if the textbox is empty then clear the result div, but leave other settings intouched
if ( val.length === 0 ) {
+ // eslint-disable-next-line jquery/no-animate-toggle
$.suggestions.hide( context );
context.data.prevText = '';
} else if (
if ( context.data !== undefined ) {
if ( context.data.$textbox.val().length === 0 ) {
// Hide the div when no suggestion exist
+ // eslint-disable-next-line jquery/no-animate-toggle
$.suggestions.hide( context );
} else {
// Rebuild the suggestions list
.addClass( 'suggestions-result' )
.attr( 'rel', i )
.data( 'text', context.config.suggestions[ i ] )
- .mousemove( function () {
+ .on( 'mousemove', function () {
context.data.selectedWithMouse = true;
$.suggestions.highlight(
context,
break;
// Escape
case 27:
+ // eslint-disable-next-line jquery/no-animate-toggle
$.suggestions.hide( context );
$.suggestions.restore( context );
$.suggestions.cancel( context );
case 13:
preventDefault = wasVisible;
selected = context.data.$container.find( '.suggestions-result-current' );
+ // eslint-disable-next-line jquery/no-animate-toggle
$.suggestions.hide( context );
if ( selected.length === 0 || context.data.selectedWithMouse ) {
// If nothing is selected or if something was selected with the mouse
// Can't use click() because the container div is hidden when the
// textbox loses focus. Instead, listen for a mousedown followed
// by a mouseup on the same div.
- .mousedown( function ( e ) {
+ .on( 'mousedown', function ( e ) {
context.data.mouseDownOn = $( e.target ).closest( '.suggestions-results .suggestions-result' );
} )
- .mouseup( function ( e ) {
+ .on( 'mouseup', function ( e ) {
var $result = $( e.target ).closest( '.suggestions-results .suggestions-result' ),
$other = context.data.mouseDownOn;
// This will hide the link we're just clicking on, which causes problems
// when done synchronously in at least Firefox 3.6 (T64858).
setTimeout( function () {
+ // eslint-disable-next-line jquery/no-animate-toggle
$.suggestions.hide( context );
- }, 0 );
+ } );
}
// Always bring focus to the textbox, as that's probably where the user expects it
// if they were just typing.
// Can't use click() because the container div is hidden when the
// textbox loses focus. Instead, listen for a mousedown followed
// by a mouseup on the same div.
- .mousedown( function ( e ) {
+ .on( 'mousedown', function ( e ) {
context.data.mouseDownOn = $( e.target ).closest( '.suggestions-special' );
} )
- .mouseup( function ( e ) {
+ .on( 'mouseup', function ( e ) {
var $special = $( e.target ).closest( '.suggestions-special' ),
$other = context.data.mouseDownOn;
// This will hide the link we're just clicking on, which causes problems
// when done synchronously in at least Firefox 3.6 (T64858).
setTimeout( function () {
+ // eslint-disable-next-line jquery/no-animate-toggle
$.suggestions.hide( context );
- }, 0 );
+ } );
}
// Always bring focus to the textbox, as that's probably where the user expects it
// if they were just typing.
context.data.$textbox.focus();
} )
- .mousemove( function ( e ) {
+ .on( 'mousemove', function ( e ) {
context.data.selectedWithMouse = true;
$.suggestions.highlight(
context, $( e.target ).closest( '.suggestions-special' ), false
$( this )
// Stop browser autocomplete from interfering
.attr( 'autocomplete', 'off' )
- .keydown( function ( e ) {
+ .on( 'keydown', function ( e ) {
// Store key pressed to handle later
context.data.keypressed = e.which;
context.data.keypressedCount = 0;
} )
- .keypress( function ( e ) {
+ .on( 'keypress', function ( e ) {
context.data.keypressedCount++;
+ // eslint-disable-next-line jquery/no-event-shorthand
$.suggestions.keypress( e, context, context.data.keypressed );
} )
- .keyup( function ( e ) {
+ .on( 'keyup', function ( e ) {
// The keypress event is fired when a key is pressed down and that key normally
// produces a character value. We also want to handle some keys that don't
// produce a character value so we also attach to the keydown/keyup events.
e.which === context.data.keypressed &&
allowed.indexOf( e.which ) !== -1
) {
+ // eslint-disable-next-line jquery/no-event-shorthand
$.suggestions.keypress( e, context, context.data.keypressed );
}
} )
- .blur( function () {
+ .on( 'blur', function () {
// When losing focus because of a mousedown
// on a suggestion, don't hide the suggestions
if ( context.data.mouseDownOn.length > 0 ) {
return;
}
+ // eslint-disable-next-line jquery/no-animate-toggle
$.suggestions.hide( context );
$.suggestions.cancel( context );
} );
}
isSample = false;
- $( this ).focus();
+ $( this ).trigger( 'focus' );
if ( options.selectionStart !== undefined ) {
$( this ).textSelection( 'setSelection', { start: options.selectionStart, end: options.selectionEnd } );
}
} );
// Add form submission handler
- $( '#editform' ).submit( function () {
+ $( '#editform' ).on( 'submit', function () {
allowCloseWindow.release();
} );
} );
if ( scrollTop.value ) {
editBox.scrollTop = scrollTop.value;
}
- $editForm.submit( function () {
+ $editForm.on( 'submit', function () {
scrollTop.value = editBox.scrollTop;
} );
}
// Can't use fadeTo because it calls show(), and we might want to keep some elements hidden
// (e.g. empty #catlinks)
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-animate
$copyElements.animate( { opacity: 0.4 }, 'fast' );
api = new mw.Api();
.append( $( '<a>' )
.attr( {
href: mw.util.getUrl( template.title ),
- 'class': ( template.exists ? '' : 'new' )
+ class: ( template.exists ? '' : 'new' )
} )
.text( template.title )
);
mw.hook( 'wikipage.editform' ).fire( $editform );
} ).always( function () {
$spinner.hide();
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-animate
$copyElements.animate( {
opacity: 1
}, 'fast' );
if ( !document.getElementById( 'p-lang' ) && document.getElementById( 'p-tb' ) && mw.config.get( 'skin' ) === 'vector' ) {
$( '.portal:last' ).after(
$( '<div>' ).attr( {
- 'class': 'portal',
+ class: 'portal',
id: 'p-lang',
role: 'navigation',
'aria-labelledby': 'p-lang-label'
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 ) {
+ $historyCompareForm.on( 'submit', function ( e ) {
var $copyForm, $copyRadios, $copyAction;
if ( $historySubmitter ) {
$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.
$a = $( '#ca-edit a' );
// Not every page has an edit link (T59713)
if ( $a.length ) {
+ // eslint-disable-next-line jquery/no-event-shorthand
$a.get( 0 ).click();
}
}
}
$popup = $( '<div>' ).addClass( 'postedit mw-notification' ).append( $content )
- .click( function () {
+ .on( 'click', function () {
clearTimeout( timeoutId );
fadeOutConfirmation();
} );
if ( e.target.nodeName.toLowerCase() !== 'a' ) {
// Trigger native HTMLElement click instead of opening URL (T45052)
e.preventDefault();
+ // eslint-disable-next-line jquery/no-event-shorthand
$edit.get( 0 ).click();
}
} );
}
} );
tokenPromise.done( function () {
- $form.submit();
+ $form.trigger( 'submit' );
} );
} );
$checkboxes.prop( 'checked', check );
}
- $( '.mw-checkbox-all' ).click( function () {
+ $( '.mw-checkbox-all' ).on( 'click', function () {
selectAll( true );
} );
- $( '.mw-checkbox-none' ).click( function () {
+ $( '.mw-checkbox-none' ).on( 'click', function () {
selectAll( false );
} );
- $( '.mw-checkbox-invert' ).click( function () {
+ $( '.mw-checkbox-invert' ).on( 'click', function () {
$checkboxes.prop( 'checked', function ( i, val ) {
return !val;
} );
hovzer.$.append( this.$container );
hovzer.update();
- $( '.mw-debug-panelink' ).click( this.switchPane );
+ $( '.mw-debug-panelink' ).on( 'click', this.switchPane );
},
/**
// Hide the current pane
if ( requestedPaneId === currentPaneId ) {
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-slide
$currentPane.slideUp( updateHov );
debug.$container.data( 'currentPane', null );
return;
debug.$container.data( 'currentPane', requestedPaneId );
if ( currentPaneId === undefined || currentPaneId === null ) {
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-slide
$requestedPane.slideDown( updateHov );
} else {
$currentPane.hide();
// Override toggle handler because we don't need it for this popup
// object at all. Sort of nasty, but it gets the job done.
- dialog.getPopup().toggle = $.noop;
+ dialog.getPopup().toggle = function () {};
}
}() );
$errorBox = this.$errorBox;
if ( errors.length === 0 ) {
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-slide
$errorBox.slideUp( function () {
$errorBox
.removeAttr( 'class' )
.removeAttr( 'class' )
.detach();
}
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-slide
$errorBox
.attr( 'class', 'error' )
.empty()
.slideDown();
};
if ( $oldErrorBox !== $errorBox && $oldErrorBox.hasClass( 'error' ) ) {
+ // eslint-disable-next-line jquery/no-slide
$oldErrorBox.slideUp( showFunc );
} else {
showFunc();
deleteButton.$element.closest( 'li.mw-htmlform-cloner-li' ).remove();
} );
} else {
- $element.filter( ':input' ).click( function ( ev ) {
- ev.preventDefault();
+ $element.filter( ':input' ).on( 'click', function ( e ) {
+ e.preventDefault();
$( this ).closest( 'li.mw-htmlform-cloner-li' ).remove();
} );
}
appendToCloner( createButton.$element );
} );
} else {
- $createElement.filter( ':input' ).click( function ( ev ) {
- ev.preventDefault();
+ $createElement.filter( ':input' ).on( 'click', function ( e ) {
+ e.preventDefault();
appendToCloner( $( this ) );
} );
name: name,
multiple: 'multiple',
'data-placeholder': dataPlaceholder.plain(),
- 'class': 'htmlform-chzn-select mw-input ' + oldClass
+ class: 'htmlform-chzn-select mw-input ' + oldClass
} );
$oldContainer.find( 'input' ).each( function () {
var $oldInput = $( this ),
// cache the current selection to avoid expensive lookup
currentValReasonList = $reasonList.val();
- $reasonList.change( function () {
+ $reasonList.on( 'change', function () {
currentValReasonList = $reasonList.val();
} );
* @param {Array} nodes List of nodes
* @return {string} Other message
*/
- 'int': function ( nodes ) {
+ int: function ( nodes ) {
var msg = textify( nodes[ 0 ] );
return mw.jqueryMsg.getMessageFunction()( msg.charAt( 0 ).toLowerCase() + msg.slice( 1 ) );
},
}
if ( mw.config.get( 'wgCascadeableLevels' ) !== undefined ) {
- $( 'form#mw-Protect-Form' ).submit( this.toggleUnchainedInputs.bind( ProtectionForm, true ) );
+ $( 'form#mw-Protect-Form' ).on( 'submit', this.toggleUnchainedInputs.bind( ProtectionForm, true ) );
}
this.getExpirySelectors().each( function () {
- $( this ).change( ProtectionForm.updateExpiryList.bind( ProtectionForm, this ) );
+ $( this ).on( 'change', ProtectionForm.updateExpiryList.bind( ProtectionForm, this ) );
} );
this.getExpiryInputs().each( function () {
$( this ).on( 'keyup change', ProtectionForm.updateExpiry.bind( ProtectionForm, this ) );
} );
this.getLevelSelectors().each( function () {
- $( this ).change( ProtectionForm.updateLevels.bind( ProtectionForm, this ) );
+ $( this ).on( 'change', ProtectionForm.updateLevels.bind( ProtectionForm, this ) );
} );
$( '#mwProtectSet > tbody > tr:first' ).after( $row );
$cell.append(
$( '<input>' )
.attr( { id: 'mwProtectUnchained', type: 'checkbox' } )
- .click( this.onChainClick.bind( this ) )
+ .on( 'click', this.onChainClick.bind( this ) )
.prop( 'checked', !this.areAllTypesMatching() ),
document.createTextNode( ' ' ),
$( '<label>' )
* @property {Object}
*/
autoHideSeconds: {
- 'short': 5,
- 'long': 30
+ short: 5,
+ long: 30
},
/**
if ( !bound ) {
bound = true;
$( window )
- .resize( $.debounce( 300, true, handleResizeStart ) )
- .resize( $.debounce( 300, handleResizeEnd ) );
+ .on( 'resize', $.debounce( 300, true, handleResizeStart ) )
+ .on( 'resize', $.debounce( 300, handleResizeEnd ) );
}
} );
} );
mw.hook( 'wikipage.categories' ).fire( $nodes );
}
- $( '#t-print a' ).click( function ( e ) {
+ $( '#t-print a' ).on( 'click', function ( e ) {
window.print();
e.preventDefault();
} );
$links = $links.filter( ':not( #bodyContent *, #content * )' );
}
- $links.click( function ( e ) {
+ $links.on( 'click', function ( e ) {
var mwTitle, action, api, $link;
mwTitle = mw.Title.newFromText( title );
// Collect views
allViews = $.extend( true, {
- 'default': {
+ default: {
title: mw.msg( 'rcfilters-filterlist-title' ),
groups: filterGroups
}
id,
obj.label,
normalizedData,
- { 'default': isDefault }
+ { default: isDefault }
)
] );
randomID,
label,
normalizedData,
- { 'default': isDefault }
+ { default: isDefault }
)
] );
name: 'namespace', // parameter name is singular
type: 'string_options',
title: mw.msg( 'namespaces' ),
- labelPrefixKey: { 'default': 'rcfilters-tag-prefix-namespace', inverted: 'rcfilters-tag-prefix-namespace-inverted' },
+ labelPrefixKey: { default: 'rcfilters-tag-prefix-namespace', inverted: 'rcfilters-tag-prefix-namespace-inverted' },
separator: ';',
fullCoverage: true,
filters: items
hidden: true,
filters: [ {
name: 'invert',
- 'default': '0'
+ default: '0'
} ]
} ]
};
max: 1000
},
sortFunc: function ( a, b ) { return Number( a.name ) - Number( b.name ); },
- 'default': mw.user.options.get( this.limitPreferenceName, displayConfig.limitDefault ),
+ default: mw.user.options.get( this.limitPreferenceName, displayConfig.limitDefault ),
sticky: true,
filters: displayConfig.limitArray.map( function ( num ) {
return controller._createFilterDataFromNumber( num, num );
( Number( i ) * 24 ).toFixed( 2 ) :
Number( i );
},
- 'default': mw.user.options.get( this.daysPreferenceName, displayConfig.daysDefault ),
+ default: mw.user.options.get( this.daysPreferenceName, displayConfig.daysDefault ),
sticky: true,
filters: [
// Hours (1, 2, 6, 12)
filters: [
{
name: 'enhanced',
- 'default': String( mw.user.options.get( 'usenewrc', 0 ) )
+ default: String( mw.user.options.get( 'usenewrc', 0 ) )
}
]
}
filters: [
{
name: 'target',
- 'default': ''
+ default: ''
}
]
},
filters: [
{
name: 'showlinkedto',
- 'default': false
+ default: false
}
]
}
$firstNew.after( $indicator );
}
+ // FIXME: Use CSS transition
+ // eslint-disable-next-line jquery/no-fade
$newChanges
.hide()
.fadeIn( 1000 );
this.queriesModel.connect( this, {
itemUpdate: 'onSavedQueriesItemUpdate',
initialize: 'onSavedQueriesInitialize',
- 'default': 'reevaluateResetRestoreState'
+ default: 'reevaluateResetRestoreState'
} );
}
)
)
) {
+ // eslint-disable-next-line jquery/no-animate
$( container ).animate( {
scrollTop: newScrollTop
} );
this.menu = new mw.rcfilters.ui.GroupWidget( {
events: {
click: 'menuItemClick',
- 'delete': 'menuItemDelete',
- 'default': 'menuItemDefault',
+ delete: 'menuItemDelete',
+ default: 'menuItemDefault',
edit: 'menuItemEdit'
},
classes: [ 'mw-rcfilters-ui-savedLinksListWidget-menu' ],
// OO.ui.ButtonWidget doesn't take focus itself (T128054)
$focus = $( '#mw-apisandbox-ui' ).find( document.activeElement );
if ( $focus.length ) {
+ // eslint-disable-next-line jquery/no-event-shorthand
$focus[ 0 ].blur();
}
// it makes it too hard to read and our "disabled"
// isn't really disabled.
widgetField.onFieldDisable( false );
- widgetField.onFieldDisable = $.noop;
+ widgetField.onFieldDisable = function () {};
widgetField.apiParamIndex = ppi.index;
widget = Util.createWidgetForParameter( {
name: name,
type: 'string',
- 'default': ''
+ default: ''
}, {
nooptional: true
} );
}
that.deprecatedItemsFieldset = new OO.ui.FieldsetLayout().addItems( deprecatedItems ).toggle( false );
+ // eslint-disable-next-line jquery/no-animate-toggle
tmp = $( '<fieldset>' )
.toggle( !that.deprecatedItemsFieldset.isEmpty() )
.append(
$( function () {
var $projectField = $( '#mw-import-table-interwiki #interwiki' );
if ( $projectField.length ) {
- $projectField.change( updateImportSubprojectList );
+ $projectField.on( 'change', updateImportSubprojectList );
updateImportSubprojectList();
}
} );
// Bind to change event, and trigger once to set the initial state of the checkboxes.
rc.updateCheckboxes();
- $select.change( rc.updateCheckboxes );
+ $select.on( 'change', rc.updateCheckboxes );
}
};
for ( i = 0; i < results.length; i++ ) {
result = results[ i ];
- imageCaption = mw.html.element( 'span', { 'class': 'iw-result__mini-gallery__caption' }, result.title );
+ imageCaption = mw.html.element( 'span', { class: 'iw-result__mini-gallery__caption' }, result.title );
imageThumbnailSrc = ( result.thumbnail ) ? result.thumbnail.source : '';
resultOutput += '<div class="iw-result__mini-gallery">' +
/* escaping response content */
mw.html.element( 'a', {
href: '/wiki/' + result.title,
- 'class': 'iw-result__mini-gallery__image',
+ class: 'iw-result__mini-gallery__image',
style: 'background-image: url(' + imageThumbnailSrc + ');'
}, new mw.html.Raw( imageCaption ) ) +
'</div>';
// Emulate HTML5 autofocus behavior in non HTML5 compliant browsers
if ( !( 'autofocus' in document.createElement( 'input' ) ) ) {
- $( 'input[autofocus]' ).eq( 0 ).focus();
+ $( 'input[autofocus]' ).eq( 0 ).trigger( 'focus' );
}
// Attach handler for check all/none buttons
$checkboxes = $( '#powersearch input[id^=mw-search-ns]' );
- $( '#mw-search-toggleall' ).click( function () {
+ $( '#mw-search-toggleall' ).on( 'click', function () {
$checkboxes.prop( 'checked', true );
} );
- $( '#mw-search-togglenone' ).click( function () {
+ $( '#mw-search-togglenone' ).on( 'click', function () {
$checkboxes.prop( 'checked', false );
} );
updateHeaderLinks( searchWidget.getValue() );
// When saving settings, use the proper request method (POST instead of GET).
- $( '#mw-search-powersearch-remember' ).change( function () {
+ $( '#mw-search-powersearch-remember' ).on( 'change', function () {
this.form.method = this.checked ? 'post' : 'get';
} ).trigger( 'change' );
summaryByteLimit = mw.config.get( 'wgCommentByteLimit' ),
wpComment = OO.ui.infuse( $( '#wpComment' ).closest( '.oo-ui-widget' ) );
- $( '#mw-undelete-invert' ).click( function () {
+ $( '#mw-undelete-invert' ).on( 'click', function () {
$( '.mw-undelete-revlist input[type="checkbox"]' ).prop( 'checked', function ( i, val ) {
return !val;
} );
*/
( function () {
$( function () {
- $( 'a.mw-watch-link' ).click( function ( e ) {
+ $( 'a.mw-watch-link' ).on( 'click', function ( e ) {
var promise,
api = new mw.Api(),
$link = $( this ),
if ( ajaxUploadDestCheck ) {
// Insert an event handler that fetches upload warnings when wpDestFile
// has been changed
- $( '#wpDestFile' ).change( function () {
+ $( '#wpDestFile' ).on( 'change', function () {
uploadWarning.checkNow( $( this ).val() );
} );
// Insert a row where the warnings will be displayed just below the
if ( mw.config.get( 'wgAjaxLicensePreview' ) && $license.length ) {
// License selector check
- $license.change( function () {
+ $license.on( 'change', function () {
// We might show a preview
uploadTemplatePreview.getPreview( $license, $( '#mw-license-preview' ) );
} );
// fillDestFile setup
mw.config.get( 'wgUploadSourceIds' ).forEach( function ( sourceId ) {
- $( '#' + sourceId ).change( function () {
+ $( '#' + sourceId ).on( 'change', function () {
var path, slash, backslash, fname;
if ( !mw.config.get( 'wgUploadAutoFill' ) ) {
return;
/* Initialization */
if ( hasFileAPI() ) {
// Update thumbnail when the file selection control is updated.
- $( '#wpUploadFile' ).change( function () {
+ $( '#wpUploadFile' ).on( 'change', function () {
var file;
clearPreview();
if ( this.files && this.files.length ) {
namespace: 'uploadwarning'
} );
- $uploadForm.submit( function () {
+ $uploadForm.on( 'submit', function () {
allowCloseWindow.release();
} );
} );
// Change tabindex only when main div has focus
if ( $( this ).is( ':focus' ) ) {
- $( this ).find( 'a' ).first().focus();
+ $( this ).find( 'a' ).first().trigger( 'focus' );
setEditTabindex( '0' );
}
} );
// Dynamically show/hide the "other time" input under each dropdown
$( '.mw-userrights-nested select' ).on( 'change', function ( e ) {
+ // eslint-disable-next-line jquery/no-animate-toggle
$( e.target.parentNode ).find( 'input' ).toggle( $( e.target ).val() === 'other' );
} );
// If the user wants to reset their watchlist, use an API call to do so (no reload required)
// Adapted from a user script by User:NQ of English Wikipedia
// (User:NQ/WatchlistResetConfirm.js)
- $resetForm.submit( function ( event ) {
+ $resetForm.on( 'submit', function ( event ) {
var $button = $resetForm.find( 'input[name=mw-watchlist-reset-submit]' );
event.preventDefault();
} ).fail( function () {
// On error, fall back to server-side reset
// First remove this submit listener and then re-submit the form
- $resetForm.off( 'submit' ).submit();
+ $resetForm.off( 'submit' ).trigger( 'submit' );
} );
} );
// add a listener on all form elements in the header form
$( '#mw-watchlist-form input, #mw-watchlist-form select' ).on( 'change', function () {
// submit the form when one of the input fields is modified
- $( '#mw-watchlist-form' ).submit();
+ $( '#mw-watchlist-form' ).trigger( 'submit' );
} );
}
event.preventDefault();
event.stopPropagation();
- $unwatchLink.blur();
+ $unwatchLink.trigger( 'blur' );
} );
}
} );
// Hide/show the table of contents element
function toggleToc() {
if ( $tocList.is( ':hidden' ) ) {
+ // FIXME: Use CSS transitions
+ // eslint-disable-next-line jquery/no-slide
$tocList.slideDown( 'fast' );
$tocToggleLink.text( mw.msg( 'hidetoc' ) );
$this.removeClass( 'tochidden' );
mw.cookie.set( 'hidetoc', null );
} else {
+ // eslint-disable-next-line jquery/no-slide
$tocList.slideUp( 'fast' );
$tocToggleLink.text( mw.msg( 'showtoc' ) );
$this.addClass( 'tochidden' );
);
}
if ( $field.is( ':input' ) ) {
- $field.select();
+ $field.trigger( 'select' );
}
return false;
}
this.setValue( this.formatter.getDefaultDate() );
}
if ( $field.is( ':input' ) ) {
- $field.select();
+ $field.trigger( 'select' );
}
if ( this.calendar ) {
* are set up. Note: The promise must have an .abort() functionality.
*/
mw.widgets.APIResultsQueue.prototype.setup = function () {
- return $.Deferred().resolve().promise( { abort: $.noop } );
+ return $.Deferred().resolve().promise( { abort: function () {} } );
};
/**
provider = this;
if ( !this.isValid() ) {
- return $.Deferred().reject().promise( { abort: $.noop } );
+ return $.Deferred().reject().promise( { abort: function () {} } );
}
api = this.isLocal ? new mw.Api() : new mw.ForeignApi( this.getAPIurl(), { anonymous: true } );
if ( e.which === OO.ui.Keys.TAB ) {
if ( e.shiftKey ) {
// Tabbing backward from text input: normal browser behavior
- $.noop();
} else {
// Tabbing forward from text input: just focus the calendar
this.calendar.$element.focus();
self = this;
// reuse the searchSuggest function from mw.searchSuggest
- promise = mw.searchSuggest.request( api, this.getQueryValue(), $.noop, this.limit, this.getNamespace() );
+ promise = mw.searchSuggest.request( api, this.getQueryValue(), function () {}, this.limit, this.getNamespace() );
// tracking purposes
promise.done( function ( data, jqXHR ) {
"sinon": false
},
"rules": {
- "operator-linebreak": 0,
+ "operator-linebreak": "off",
"quote-props": [ "error", "as-needed" ],
- "valid-jsdoc": 0,
- "qunit/require-expect": 0,
- "qunit/resolve-async": 0
+ "valid-jsdoc": "off",
+ "qunit/require-expect": "off",
+ "qunit/resolve-async": "off",
+ "jquery/no-parse-html-literal": "off"
}
}
if ( warn === undefined ) {
warn = mw.log.warn;
error = mw.log.error;
- mw.log.warn = mw.log.error = $.noop;
+ mw.log.warn = mw.log.error = function () {};
}
}
var done = assert.async(),
$canvas = $( '<div>' ).css( 'background-color', '#fff' ).appendTo( '#qunit-fixture' );
+ // eslint-disable-next-line jquery/no-animate
$canvas.animate( { 'background-color': '#000' }, 3 ).promise()
.done( function () {
var endColors = $.colorUtil.getRGB( $canvas.css( 'background-color' ) );
callback( $table );
} else {
$table.tablesorter();
- $table.find( '#sortme' ).click();
+ $table.find( '#sortme' ).trigger( 'click' );
}
// Table sorting is done synchronously; if it ever needs to change back
planetsAscName,
function ( $table ) {
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
tableTest(
planetsAscName,
function ( $table ) {
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
tableTest(
planetsAscName,
function ( $table ) {
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
- $table.find( '.headerSort:eq(1)' ).click();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
+ $table.find( '.headerSort:eq(1)' ).trigger( 'click' );
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
tableTest(
reversed( planetsAscName ),
function ( $table ) {
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click().click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' ).trigger( 'click' );
}
);
tableTest(
planetsAscRadius,
function ( $table ) {
$table.tablesorter();
- $table.find( '.headerSort:eq(1)' ).click();
+ $table.find( '.headerSort:eq(1)' ).trigger( 'click' );
}
);
tableTest(
reversed( planetsAscRadius ),
function ( $table ) {
$table.tablesorter();
- $table.find( '.headerSort:eq(1)' ).click().click();
+ $table.find( '.headerSort:eq(1)' ).trigger( 'click' ).trigger( 'click' );
}
);
tableTest(
$table.tablesorter(
{ sortList: [ { 0: 'asc' }, { 1: 'asc' } ] }
);
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
tableTest(
$table.tablesorter(
{ sortList: [ { 0: 'desc' }, { 1: 'desc' } ] }
);
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
// Pretend to click while pressing the multi-sort key
event = $.Event( 'click' );
$table.find( 'tr:eq(0) th:eq(0)' ).attr( 'colspan', '3' );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
tableTest( 'Sorting with colspanned headers: sort spanned column twice',
$table.find( 'tr:eq(0) th:eq(0)' ).attr( 'colspan', '3' );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
tableTest( 'Sorting with colspanned headers: subsequent column',
$table.find( 'tr:eq(0) th:eq(0)' ).attr( 'colspan', '3' );
$table.tablesorter();
- $table.find( '.headerSort:eq(1)' ).click();
+ $table.find( '.headerSort:eq(1)' ).trigger( 'click' );
}
);
tableTest( 'Sorting with colspanned headers: sort subsequent column twice',
$table.find( 'tr:eq(0) th:eq(0)' ).attr( 'colspan', '3' );
$table.tablesorter();
- $table.find( '.headerSort:eq(1)' ).click();
- $table.find( '.headerSort:eq(1)' ).click();
+ $table.find( '.headerSort:eq(1)' ).trigger( 'click' );
+ $table.find( '.headerSort:eq(1)' ).trigger( 'click' );
}
);
$table.find( 'tr:eq(0) > th:eq(0)' ).addClass( 'unsortable' );
$table.tablesorter();
- $table.find( 'tr:eq(0) > th:eq(0)' ).click();
+ $table.find( 'tr:eq(0) > th:eq(0)' ).trigger( 'click' );
assert.deepEqual(
tableExtract( $table ),
);
$cell = $table.find( 'tr:eq(0) > th:eq(0)' );
- $table.find( 'tr:eq(0) > th:eq(1)' ).click();
+ $table.find( 'tr:eq(0) > th:eq(1)' ).trigger( 'click' );
assert.strictEqual(
$cell.hasClass( 'headerSortUp' ) || $cell.hasClass( 'headerSortDown' ),
mw.config.set( 'wgPageContentLanguage', 'de' );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
mw.config.set( 'wgDefaultDateFormat', 'mdy' );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
ipv4Sorted,
function ( $table ) {
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
tableTest(
reversed( ipv4Sorted ),
function ( $table ) {
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click().click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' ).trigger( 'click' );
}
);
} );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
} );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
$table.find( 'tr:eq(2) td:eq(1)' ).attr( 'rowspan', '3' );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
tableTest(
$table.find( 'tr:eq(2) td:eq(0)' ).attr( 'rowspan', '3' );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
mw.config.set( 'wgDefaultDateFormat', 'mdy' );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
currencySorted,
function ( $table ) {
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
function ( $table ) {
$table.find( 'tr:last' ).addClass( 'sortbottom' );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
'</table>'
);
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
assert.strictEqual(
$table.data( 'tablesorter' ).config.parsers[ 0 ].id,
'<tr><td data-sort-value="Cherry">Dolphin</td></tr>' +
'</tbody></table>'
);
- $table.tablesorter().find( '.headerSort:eq(0)' ).click();
+ $table.tablesorter().find( '.headerSort:eq(0)' ).trigger( 'click' );
data = [];
$table.find( 'tbody > tr' ).each( function ( i, tr ) {
'<tr><td><span data-sort-value="D">H</span></td></tr>' +
'</tbody></table>'
);
- $table.tablesorter().find( '.headerSort:eq(0)' ).click();
+ $table.tablesorter().find( '.headerSort:eq(0)' ).trigger( 'click' );
data = [];
$table.find( 'tbody > tr' ).each( function ( i, tr ) {
// initialize table sorter and sort once
$table
.tablesorter()
- .find( '.headerSort:eq(0)' ).click();
+ .find( '.headerSort:eq(0)' ).trigger( 'click' );
// Change the sortValue data properties (T40152)
// - change data
$table.find( 'td:contains(G)' ).removeData( 'sortValue' );
// Now sort again (twice, so it is back at Ascending)
- $table.find( '.headerSort:eq(0)' ).click();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
data = [];
$table.find( 'tbody > tr' ).each( function ( i, tr ) {
[ 'Numbers' ], numbers, numbersAsc,
function ( $table ) {
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
[ 'Numbers' ], numbers, reversed( numbersAsc ),
function ( $table ) {
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click().click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' ).trigger( 'click' );
}
);
// TODO add numbers sorting tests for T10115 with a different language
mw.config.set( 'wgDefaultDateFormat', 'mdy' );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
mw.config.set( 'wgDefaultDateFormat', 'dmy' );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
mw.config.set( 'wgDefaultDateFormat', 'dmy' );
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
}
);
'<tr><td>1</td></tr>' +
'</table>'
);
- $table.tablesorter().find( '.headerSort:eq(0)' ).click();
+ $table.tablesorter().find( '.headerSort:eq(0)' ).trigger( 'click' );
assert.strictEqual(
$table.find( 'td' ).first().text(),
'<tr><td><img alt="A" />C</tr>' +
'</table>'
);
- $table.tablesorter().find( '.headerSort:eq(0)' ).click();
+ $table.tablesorter().find( '.headerSort:eq(0)' ).trigger( 'click' );
assert.strictEqual(
$table.find( 'td' ).text(),
'<tr><td>4</td></tr>' +
'</table>'
);
- $table.tablesorter().find( '.headerSort:eq(0)' ).click();
+ $table.tablesorter().find( '.headerSort:eq(0)' ).trigger( 'click' );
assert.strictEqual(
$table.find( 'td' ).text(),
'</table>'
);
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
// now the first row have 2 columns
- $table.find( '.headerSort:eq(1)' ).click();
+ $table.find( '.headerSort:eq(1)' ).trigger( 'click' );
parsers = $table.data( 'tablesorter' ).config.parsers;
'</table>'
);
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
assert.deepEqual(
tableExtract( $table ),
'</table>'
);
$table.tablesorter();
- $table.find( '.headerSort:eq(0)' ).click();
+ $table.find( '.headerSort:eq(0)' ).trigger( 'click' );
assert.deepEqual(
tableExtract( $table ),
$options = $( '#namespace' ).find( 'option' );
$options.eq( 0 ).removeProp( 'selected' );
$options.eq( 1 ).prop( 'selected', true );
- $( '#namespace' ).change();
+ $( '#namespace' ).trigger( 'change' );
// ... and checkboxes should be enabled again
assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
// select first option ( 'all' namespace)...
$options.eq( 1 ).removeProp( 'selected' );
$options.eq( 0 ).prop( 'selected', true );
- $( '#namespace' ).change();
+ $( '#namespace' ).trigger( 'change' );
// ... and checkboxes should now be disabled
assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
assert.strictEqual( $tocList.is( ':hidden' ), false, 'The table of contents is now visible' );
- $toggleLink.click();
+ $toggleLink.trigger( 'click' );
return $tocList.promise().then( function () {
assert.strictEqual( $tocList.is( ':hidden' ), true, 'The table of contents is now hidden' );
- $toggleLink.click();
+ $toggleLink.trigger( 'click' );
return $tocList.promise();
} );
} );