"OO": false
},
"rules": {
- "dot-notation": 0,
- "valid-jsdoc": 0
+ "dot-notation": 0
}
}
*
* @method updateTooltipAccessKeys_getAccessKeyPrefix
* @deprecated since 1.27 Use #getAccessKeyModifiers
+ * @param {Object} [ua] An object with a 'userAgent' and 'platform' property.
+ * @return {string}
*/
$.fn.updateTooltipAccessKeys.getAccessKeyPrefix = function ( ua ) {
return getAccessKeyModifiers( ua ).join( '-' ) + '-';
return data;
};
+ // eslint-disable-next-line valid-jsdoc
/**
* Enable inline confirmation for given clickable element (like `<a />` or `<button />`).
*
$.expandableField = {
/**
* Expand the field, make the callback
+ *
+ * @param {jQuery.Event} e Event
+ * @param {Object} context
*/
expandField: function ( e, context ) {
context.config.beforeExpand.call( context.data.$field, context );
},
/**
* Condense the field, make the callback
+ *
+ * @param {jQuery.Event} e Event
+ * @param {Object} context
*/
condenseField: function ( e, context ) {
context.config.beforeCondense.call( context.data.$field, context );
*
* @static
* @inheritable
+ * @param {number} baseRatio Base ratio
* @return {number} Device pixel ratio
*/
$.bracketDevicePixelRatio = function ( baseRatio ) {
// Hard ignores
if ( this.ignoreFn( currVal, this, currPathArray ) ) {
- return null;
+ return;
}
// Handle the lazy limit
this.lazyCounter++;
if ( this.lazyCounter > this.lazyLimit ) {
log( 'CompletenessTest.fn.walkTheObject> Limit reached: ' + this.lazyCounter, currPathArray );
- return null;
+ return;
}
// Functions
* in default (ascending) order when their header cell is clicked the next time.
*
* @param {jQuery} $headers
- * @param {number[][]} sortList
- * @param {number[][]} headerToColumns
+ * @param {Array} sortList 2D number array
+ * @param {Array} headerToColumns 2D number array
*/
function setHeadersOrder( $headers, sortList, headerToColumns ) {
// Loop through all headers to retrieve the indices of the columns the header spans across:
/**
* @param {jQuery} $tables
* @param {Object} [settings]
+ * @return {jQuery}
*/
construct: function ( $tables, settings ) {
return $tables.each( function ( i, table ) {
/**
* Helper function to get an IE TextRange object for an element
+ *
+ * @param {HTMLElement} element
+ * @return {TextRange}
*/
- function rangeForElementIE( e ) {
+ function rangeForElementIE( element ) {
var sel;
- if ( e.nodeName.toLowerCase() === 'input' ) {
- return e.createTextRange();
+ if ( element.nodeName.toLowerCase() === 'input' ) {
+ return element.createTextRange();
} else {
sel = document.body.createTextRange();
- sel.moveToElementText( e );
+ sel.moveToElementText( element );
return sel;
}
}
* Helper function for IE for activating the textarea. Called only in the
* IE-specific code paths below; makes use of IE-specific non-standard
* function setActive() if possible to avoid screen flicker.
+ *
+ * @param {HTMLElement} element
*/
function activateElementOnIE( element ) {
if ( element.setActive ) {
fn = {
/**
* Get the contents of the textarea
+ *
+ * @return {string}
*/
getContents: function () {
return this.val();
},
/**
* Set the contents of the textarea, replacing anything that was there before
+ *
+ * @param {string} content
*/
setContents: function ( content ) {
this.val( content );
/**
* Get the currently selected text in this textarea. Will focus the textarea
* in some browsers (IE/Opera)
+ *
+ * @return {string}
*/
getSelection: function () {
var retval, range,
* Inserts text at the beginning and end of a text selection, optionally
* inserting text at the caret when selection is empty.
*
+ * @param {Object} options Options
* FIXME document the options parameters
+ * @return {jQuery}
*/
encapsulateSelection: function ( options ) {
return this.each( function () {
* Do the splitlines stuff.
*
* Wrap each line of the selected text with pre and post
+ *
+ * @param {string} selText Selected text
+ * @param {string} pre Text before
+ * @param {string} post Text after
+ * @return {string} Wrapped text
*/
function doSplitLines( selText, pre, post ) {
var i,
*
* Will focus the textarea in some browsers (IE/Opera)
*
+ * @param {Object} options Options
* FIXME document the options parameters
+ * @return {number} Position
*/
getCaretPosition: function ( options ) {
function getCaret( e ) {
return getCaret( this.get( 0 ) );
},
/**
+ * @param {Object} options options
* FIXME document the options parameters
+ * @return {jQuery}
*/
setSelection: function ( options ) {
return this.each( function () {
* Scroll a textarea to the current cursor position. You can set the cursor
* position with setSelection()
*
- * @param {boolean} options Whether to force a scroll even if the caret position
- * is already visible. Defaults to false
- *
- * FIXME document the options parameters (function body suggests options.force is a boolean, not options itself)
+ * @param {Object} options options
+ * @cfg {boolean} [force=false] Whether to force a scroll even if the caret position
+ * is already visible.
+ * FIXME document the options parameters
+ * @return {jQuery}
*/
scrollToCaretPosition: function ( options ) {
function getLineLength( e ) {
* @ignore
* @context {Element} input
* @param {jQuery.Event} e
+ * @return {boolean} False to cancel the default event
*/
function updateDiffRadios() {
var nextState = 'before',
/**
* Set up the protection chaining interface (i.e. "unlock move permissions" checkbox)
* on the protection form
+ *
+ * @return {boolean}
*/
init: function () {
var $cell = $( '<td>' ),
$( '#mwProtect-reason' ).byteLimit( 180 );
this.updateCascadeCheckbox();
+ return true;
},
/**
/**
* @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.25.
+ * @param {string} url
+ * @return {HTMLElement} Script tag
*/
function importScriptURI( url ) {
var s;
/**
* @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.25.
+ * @param {string} url
+ * @param {string} media
+ * @return {HTMLElement} Link tag
*/
function importStylesheetURI( url, media ) {
var l = document.createElement( 'link' );
/**
* Update the current query when the page hash changes
+ *
+ * @return {boolean} Successful
*/
loadFromHash: function () {
var params, m, re,
$( function () {
/**
* Is the FileAPI available with sufficient functionality?
+ *
+ * @return {boolean}
*/
function hasFileAPI() {
return window.FileReader !== undefined;
/**
* Check if the file does not exceed the maximum size
+ *
+ * @param {File} file
+ * @return {boolean}
*/
function checkMaxUploadSize( file ) {
var maxSize, $error;
* current cursor position.
* @param {string} [button.imageId] `id` attribute of the button HTML element. Can be
* used to define the image with CSS if it's not provided as `imageFile`.
+ * @param {string} [speedTip]
+ * @param {string} [tagOpen]
+ * @param {string} [tagClose]
+ * @param {string} [sampleText]
+ * @param {string} [imageId]
*/
function insertButton( button, speedTip, tagOpen, tagClose, sampleText, imageId ) {
var $button;
return this.selected;
};
+ // eslint-disable-next-line valid-jsdoc
/**
* Set the selected dates
*
return this.focusedDate;
};
+ // eslint-disable-next-line valid-jsdoc
/**
* Set the currently-focused date
*
*
* @protected
* @param {jQuery.Event} e Key down event
+ * @return {boolean} False to cancel the default event
*/
mw.widgets.datetime.CalendarWidget.prototype.onKeyDown = function ( e ) {
var focusedDate = this.getFocusedDate();
return this.local;
};
+ // eslint-disable-next-line valid-jsdoc
/**
* Toggle whether dates are in local time or UTC
*
* @private
* @param {jQuery} $field
* @param {jQuery.Event} e Key down event
+ * @return {boolean} False to cancel the default event
*/
mw.widgets.datetime.DateTimeInputWidget.prototype.onFieldKeyDown = function ( $field, e ) {
var spec = $field.data( 'mw-widgets-datetime-dateTimeInputWidget-fieldSpec' );
* @private
* @param {jQuery} $field
* @param {jQuery.Event} e Change event
+ * @return {boolean} False to cancel the default event
*/
mw.widgets.datetime.DateTimeInputWidget.prototype.onFieldWheel = function ( $field, e ) {
var delta = 0,
* what gets clicked.
*
* @private
+ * @param {jQuery.Event} e Click event
*/
mw.widgets.CalendarWidget.prototype.onBodyClick = function ( e ) {
var
*
* @private
* @param {jQuery.Event} e Mouse click event
+ * @return {boolean} False to cancel the default event
*/
mw.widgets.CalendarWidget.prototype.onClick = function ( e ) {
if ( !this.isDisabled() && e.which === 1 ) {
*
* @private
* @param {jQuery.Event} e Key down event
+ * @return {boolean} False to cancel the default event
*/
mw.widgets.CalendarWidget.prototype.onKeyDown = function ( e ) {
var
* @extends mw.Title
*
* @constructor
- * @inheritdoc
+ * @param {string} title
+ * @param {number} [namespace]
*/
function ForeignTitle( title, namespace ) {
// We only need to handle categories here... but we don't know the target language.
};
/**
- * @class mw.widgets.CategoryCapsuleItemWidget
- *
* Category selector capsule item widget. Extends OO.ui.CapsuleItemWidget with the ability to link
* to the given page, and to show its existence status (i.e., whether it is a redlink).
*
+ * @class mw.widgets.CategoryCapsuleItemWidget
* @uses mw.Api
* @extends OO.ui.CapsuleItemWidget
*
*
* @private
* @param {jQuery.Event} e Mouse click event
+ * @return {boolean} False to cancel the default event
*/
mw.widgets.DateInputWidget.prototype.onClick = function ( e ) {
if ( !this.isDisabled() && e.which === 1 ) {
*
* @private
* @param {jQuery.Event} e Key press event
+ * @return {boolean} False to cancel the default event
*/
mw.widgets.DateInputWidget.prototype.onKeyPress = function ( e ) {
if ( !this.isDisabled() &&
*
* @private
* @param {jQuery.Event} e Key press event
+ * @return {boolean} False to cancel the default event
*/
mw.widgets.DateInputWidget.prototype.onCalendarKeyPress = function ( e ) {
if ( !this.isDisabled() && e.which === OO.ui.Keys.ENTER ) {
*
* @private
* @param {jQuery.Event} e Mouse click event
+ * @return {boolean} False to cancel the default event
*/
mw.widgets.DateInputWidget.prototype.onCalendarClick = function ( e ) {
if (
/**
* @private
+ * @param {Object} [config] Configuration options
+ * @return {Object[]} Dropdown options
*/
mw.widgets.NamespaceInputWidget.prototype.getNamespaceDropdownOptions = function ( config ) {
var options,
* @extends mw.widgets.TitleInputWidget
*
* @constructor
+ * @param {Object} [config] Configuration options
* @cfg {boolean} [pushPending=true] Visually mark the input field as "pending", while
* requesting suggestions.
* @cfg {boolean} [performSearchOnClick=true] If true, the script will start a search when-
* @mixins OO.ui.mixin.LookupElement
*
* @constructor
+ * @param {Object} [config] Configuration options
* @cfg {boolean} [suggestions=true] Display search suggestions
* @cfg {RegExp|Function|string} [validate] Perform title validation
*/
* @mixins mw.widgets.TitleWidget
*
* @constructor
+ * @param {Object} [config] Configuration options
*/
mw.widgets.TitleSearchWidget = function MwWidgetsTitleSearchWidget( config ) {
config = config || {};
*
* @method
* @param {Mixed} response Response from server
+ * @return {Object}
*/
mw.widgets.UserInputWidget.prototype.getLookupCacheDataFromResponse = function ( response ) {
return response.query.allusers || {};
*
* @since 1.22
* @param {string} type Token type
+ * @param {string} [assert]
* @return {jQuery.Promise} Received token.
*/
getToken: function ( type, assert ) {
* Get new iframe object for an upload.
*
* @private
+ * @param {string} id
* @return {HTMLIframeElement}
*/
function getNewIframe( id ) {
* Shortcut for getting hidden inputs
*
* @private
+ * @param {string} name
+ * @param {string} val
* @return {jQuery}
*/
function getHiddenInput( name, val ) {
*
* @param {string} filekey
* @param {Object} data
+ * @return {jQuery.Promise}
*/
uploadFromStash: function ( filekey, data ) {
data.filekey = filekey;
* @param {string|mw.Title|string[]|mw.Title[]} pages Full page name or instance of mw.Title, or an
* array thereof. If an array is passed, the return value passed to the promise will also be an
* array of appropriate objects.
+ * @param {Object} [addParams]
* @return {jQuery.Promise}
* @return {Function} return.done
* @return {Object|Object[]} return.done.watch Object or list of objects (depends on the `pages`
* Currently only supports passing 'hide-if' data.
*
* @ignore
+ * @param {Object} [config] Configuration options
*/
mw.htmlform.Element = function ( config ) {
// Configuration initialization
* @class mw.ForeignStructuredUpload.BookletLayout
* @uses mw.ForeignStructuredUpload
* @extends mw.Upload.BookletLayout
+ *
+ * @constructor
+ * @param {Object} config Configuration options
* @cfg {string} [target] Used to choose the target repository.
* If nothing is passed, the {@link mw.ForeignUpload#property-target default} is used.
*/
( function ( mw, $, OO ) {
/**
- * @class mw.ForeignStructuredUpload
- * @extends mw.ForeignUpload
- *
* Used to represent an upload in progress on the frontend.
*
* This subclass will upload to a wiki using a structured metadata
* **TODO: This currently only supports uploads under CC-BY-SA 4.0,
* and should really have support for more licenses.**
*
- * @inheritdoc
+ * @class mw.ForeignStructuredUpload
+ * @extends mw.ForeignUpload
+ *
+ * @constructor
+ * @param {string} [target]
+ * @param {Object} [apiconfig]
*/
function ForeignStructuredUpload( target, apiconfig ) {
this.date = undefined;
( function ( mw, OO, $ ) {
/**
- * @class mw.ForeignUpload
- * @extends mw.Upload
- *
* Used to represent an upload in progress on the frontend.
*
* Subclassed to upload to a foreign API, with no other goodies. Use
* an object, we assume you want the default, and treat it as apiconfig
* instead.
*
+ * @class mw.ForeignUpload
+ * @extends mw.Upload
+ *
* @constructor
* @param {string} [target] Used to set up the target
* wiki. If not remote, this class behaves identically to mw.Upload (unless further subclassed)
/**
* Override from mw.Upload to make sure the API info is found and allowed
+ *
+ * @inheritdoc
*/
ForeignUpload.prototype.upload = function () {
var upload = this;
/**
* Override from mw.Upload to make sure the API info is found and allowed
+ *
+ * @inheritdoc
*/
ForeignUpload.prototype.uploadToStash = function () {
var upload = this;
* directly, passing invalid titles will result in an exception. Use #newFromText to use the
* logic directly and get null for invalid titles which is easier to work with.
*
- * @class mw.Title
- */
- /**
* Note that in the constructor and #newFromText method, `namespace` is the **default** namespace
* only, and can be overridden by a namespace prefix in `title`. If you do not want this behavior,
* use #makeTitle. Compare:
* mw.Title.newFromText( 'Template:Foo', NS_TEMPLATE ).getPrefixedText(); // => 'Template:Foo'
* mw.Title.makeTitle( NS_TEMPLATE, 'Template:Foo' ).getPrefixedText(); // => 'Template:Template:Foo'
*
- * @method constructor
+ * @class mw.Title
+ * @constructor
* @param {string} title Title of the page. If no second argument given,
* this will be searched for a namespace
* @param {number} [namespace=NS_MAIN] If given, will used as default namespace for the given title
this.title = parsed.title;
this.ext = parsed.ext;
this.fragment = parsed.fragment;
-
- return this;
}
/* Private members */
* @uses mw.Upload
* @uses mw.Upload.BookletLayout
* @extends OO.ui.ProcessDialog
+ *
+ * @constructor
+ * @param {Object} [config] Configuration options
* @cfg {Function} [bookletClass=mw.Upload.BookletLayout] Booklet class to be
* used for the steps
* @cfg {Object} [booklet] Booklet constructor configuration
var UP;
/**
- * @class mw.Upload
- *
* Used to represent an upload in progress on the frontend.
* Most of the functionality is implemented in mw.Api.plugin.upload,
* but this model class will tie it together as well as let you perform
* } );
* } );
*
+ * @class mw.Upload
+ *
* @constructor
* @param {Object|mw.Api} [apiconfig] A mw.Api object (or subclass), or configuration
* to pass to the constructor of mw.Api.
* @param {string|Function} documentLocation A full url, or function returning one.
* If passed a function, the return value may change over time and this will be honoured. (T74334)
* @member mw
+ * @return {Function} Uri class
*/
mw.UriRelative = function ( documentLocation ) {
var getDefaultUri = ( function () {
( function ( mw, $ ) {
/**
- * @method confirmCloseWindow
- * @member mw
- *
* Prevent the closing of a window with a confirm message (the onbeforeunload event seems to
* work in most browsers.)
*
* // do whatever you wanted to do
* }
*
+ * @method confirmCloseWindow
+ * @member mw
* @param {Object} [options]
* @param {string} [options.namespace] Namespace for the event registration
* @param {string} [options.message]
/**
* Build the console panel
+ *
+ * @return {jQuery} Console panel
*/
buildConsoleTable: function () {
var $table, entryTypeText, i, length, entry;
/**
* Dumb window.onerror handler which forwards the errors via mw.track.
*
+ * @param {string} errorMessage
+ * @param {string} url
+ * @param {number} lineNumber
+ * @param {number} [columnNumber]
+ * @param {Error|Mixed} [errorObject]
+ * @return {boolean} True to prevent the default action
* @fires global_error
*/
window.onerror = function ( errorMessage, url, lineNumber, columnNumber, errorObject ) {
/**
* Generate a breakdown of all loaded modules and their size in
* kilobytes. Modules are ordered from largest to smallest.
+ *
+ * @return {Object[]} Size reports
*/
size: function () {
// Map each module to a descriptor object.
/**
* For each module with styles, count the number of selectors, and
* count how many match against some element currently in the DOM.
+ *
+ * @return {Object[]} CSS reports
*/
css: function () {
var modules = [];
* Report stats on mw.loader.store: the number of localStorage
* cache hits and misses, the number of items purged from the
* cache, and the total size of the module blob in localStorage.
+ *
+ * @return {Object[]} Store stats
*/
store: function () {
var raw, stats = { enabled: mw.loader.store.enabled };
/**
* Starts the parse
*
- * @param {Function} rootExpression root parse function
+ * @param {Function} rootExpression Root parse function
+ * @return {Array|null}
*/
function start( rootExpression ) {
var result = nOrMore( 0, rootExpression )();
/**
* htmlEmitter - object which primarily exists to emit HTML from parser ASTs
+ *
+ * @param {Object} language
+ * @param {Object} magic
*/
mw.jqueryMsg.htmlEmitter = function ( language, magic ) {
var jmsg = this;
* It may, though, if the wikitext appears in extension-controlled content.
*
* @param {string[]} nodes
+ * @return {jQuery}
*/
wikilink: function ( nodes ) {
var page, anchor, url, $el;
return mw.format.apply( null, [ this.map.get( this.key ) ].concat( this.parameters ) );
},
+ // eslint-disable-next-line valid-jsdoc
/**
* Add (does not replace) parameters for `$N` placeholder values.
*
}
};
+ /* eslint-disable no-console */
log = ( function () {
// Also update the restoration of methods in mediawiki.log.js
// when adding or removing methods here.
return log;
}() );
+ /* eslint-enable no-console */
/**
* @class mw
* Utility function for execute()
*
* @ignore
+ * @param {string} [media] Media attribute
+ * @param {string} url URL
*/
function addLink( media, url ) {
var el = document.createElement( 'link' );
* to a query string of the form foo.bar,baz|bar.baz,quux
*
* @private
+ * @param {Object} moduleMap Module map
+ * @return {string} Module query string
*/
function buildModulesString( moduleMap ) {
var p, prefix,
*
* @protected
* @since 1.27
+ * @param {string} moduleName Module name
+ * @return {Mixed} Exported value
*/
require: function ( moduleName ) {
var state = mw.loader.getState( moduleName );
*
* @param {string} module Module name
* @param {Object} descriptor The module's descriptor as set in the registry
+ * @return {boolean} Module was set
*/
set: function ( module, descriptor ) {
var args, key, src;
}
} catch ( e ) {
mw.track( 'resourceloader.exception', { exception: e, source: 'store-localstorage-json' } );
- return;
+ return false;
}
src = 'mw.loader.implement(' + args.join( ',' ) + ');';
}
mw.loader.store.items[ key ] = src;
mw.loader.store.update();
+ return true;
},
/**
* Iterate through the module store, removing any item that does not correspond
* (in name and version) to an item in the module registry.
+ *
+ * @return {boolean} Store was pruned
*/
prune: function () {
var key, module;
delete mw.loader.store.items[ key ];
}
}
+ return true;
},
/**
* Wrapper object for raw HTML passed to mw.html.element().
*
* @class mw.html.Raw
+ * @constructor
+ * @param {string} value
*/
Raw: function ( value ) {
this.value = value;
* Wrapper object for CDATA element contents passed to mw.html.element()
*
* @class mw.html.Cdata
+ * @constructor
+ * @param {string} value
*/
Cdata: function ( value ) {
this.value = value;
*/
remove: list.remove,
+ // eslint-disable-next-line valid-jsdoc
/**
* Run a hook.
*
* @param {string} [data.module] Name of module which caused the error
*/
function logError( topic, data ) {
+ /* eslint-disable no-console */
var msg,
e = data.exception,
source = data.source,
console.error( String( e ), e );
}
}
+ /* eslint-enable no-console */
}
// Subscribe to error streams
* @alternateClassName mw.Notification
* @constructor
* @private
+ * @param {mw.Message|jQuery|HTMLElement|string} message
+ * @param {Object} options
*/
function Notification( message, options ) {
var $notification, $notificationContent;
}
/**
- * defines the location of autocomplete. Typically either
+ * Defines the location of autocomplete. Typically either
* header, which is in the top right of vector (for example)
* and content which identifies the main search bar on
- * Special:Search. Defaults to header for skins that don't set
+ * Special:Search. Defaults to header for skins that don't set
* explicitly.
*
* @ignore
+ * @param {Object} context
+ * @return {string}
*/
function getInputLocation( context ) {
return context.config.$region
* 'this' is the search input box (jQuery object)
*
* @ignore
+ * @param {Object} metadata
*/
function onAfterUpdate( metadata ) {
var context = this.data( 'suggestionsContext' );
* @param {Object} data Data to render
* @param {Object} partialTemplates Map partial names to Mustache template objects
* returned by mw.template.get()
+ * @return {jQuery} Rendered HTML
*/
render: function ( data, partialTemplates ) {
var partials = {};
* Encode the string like PHP's rawurlencode
*
* @param {string} str String to be encoded.
+ * @return {string} Encoded string
*/
rawurlencode: function ( str ) {
str = String( str );
* Encode the string like Sanitizer::escapeId in PHP
*
* @param {string} str String to be encoded.
+ * @return {string} Encoded string
*/
escapeId: function ( str ) {
str = String( str );
* of `wfUrlencode` in PHP.
*
* @param {string} str String to be encoded.
+ * @return {string} Encoded string
*/
wikiUrlencode: function ( str ) {
return util.rawurlencode( str )
*
* @ignore
* @private
+ * @return {Object} Viewport positions
*/
makeViewportFromWindow: function () {
var $window = $( window ),
/**
* Gets the height of the interface elements and the
* gallery's caption.
+ *
+ * @return {number} Height
*/
mw.GallerySlideshow.prototype.getChromeHeight = function () {
return this.$interface.outerHeight() + this.$galleryCaption.outerHeight();
* - Google Glass
*
* Other browsers that pass the check are considered Grade X.
+ *
+ * @param {string} [str] User agent, defaults to navigator.userAgent
+ * @return {boolean} User agent is compatible with MediaWiki JS
*/
function isCompatible( str ) {
var ua = str || navigator.userAgent;