/*!
- * OOUI v0.29.3
+ * OOUI v0.29.6
* https://www.mediawiki.org/wiki/OOUI
*
* Copyright 2011–2018 OOUI Team and other contributors.
* Released under the MIT license
* http://oojs.mit-license.org
*
- * Date: 2018-11-01T02:03:33Z
+ * Date: 2018-12-05T00:15:55Z
*/
( function ( OO ) {
* @return {string} Resolved message
*/
OO.ui.resolveMsg = function ( msg ) {
- if ( $.isFunction( msg ) ) {
+ if ( typeof msg === 'function' ) {
return msg();
}
return msg;
OO.ui.Element.static.getDir = function ( obj ) {
var isDoc, isWin;
- if ( obj instanceof jQuery ) {
+ if ( obj instanceof $ ) {
obj = obj[ 0 ];
}
isDoc = obj.nodeType === Node.DOCUMENT_NODE;
el.removeChild( el.firstChild );
}
// Force reflow
+ // eslint-disable-next-line no-void
void el.offsetHeight;
// Reattach all children
for ( i = 0, len = nodes.length; i < len; i++ ) {
* @param {boolean} [show] Make element visible, omit to toggle visibility
* @fires visible
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.Element.prototype.toggle = function ( show ) {
show = show === undefined ? !this.visible : !!show;
*
* @param {Mixed} data Element data
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.Element.prototype.setData = function ( data ) {
this.data = data;
*
* @param {string} id
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.Element.prototype.setElementId = function ( id ) {
this.elementId = id;
methods = Array.isArray( methods ) ? methods : [ methods ];
for ( i = 0, len = methods.length; i < len; i++ ) {
- if ( $.isFunction( this[ methods[ i ] ] ) ) {
+ if ( typeof this[ methods[ i ] ] === 'function' ) {
support++;
}
}
*
* @param {OO.ui.mixin.GroupElement|null} group Group element, null if none
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.Element.prototype.setElementGroup = function ( group ) {
this.elementGroup = group;
* Reset scroll offsets
*
* @chainable
+ * @return {OO.ui.Layout} The layout, for chaining
*/
OO.ui.Layout.prototype.resetScroll = function () {
this.$element[ 0 ].scrollTop = 0;
*
* @param {boolean} disabled Disable widget
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.Widget.prototype.setDisabled = function ( disabled ) {
var isDisabled;
* Update the disabled state, in case of changes in parent widget.
*
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.Widget.prototype.updateDisabled = function () {
this.setDisabled( this.disabled );
*
* @param {jQuery} $tabIndexed Element that should use the tabindex functionality
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.TabIndexedElement.prototype.setTabIndexedElement = function ( $tabIndexed ) {
var tabIndex = this.tabIndex;
*
* @param {string|number|null} tabIndex Tabindex value, or `null` for no tabindex
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.TabIndexedElement.prototype.setTabIndex = function ( tabIndex ) {
tabIndex = /^-?\d+$/.test( tabIndex ) ? Number( tabIndex ) : null;
*
* @private
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.TabIndexedElement.prototype.updateTabIndex = function () {
if ( this.$tabIndexed ) {
* Focus this element.
*
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.TabIndexedElement.prototype.focus = function () {
if ( !this.isDisabled() ) {
* Blur this element.
*
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.TabIndexedElement.prototype.blur = function () {
this.$tabIndexed.blur();
*
* @protected
* @param {jQuery.Event} e Mouse down event
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.mixin.ButtonElement.prototype.onMouseDown = function ( e ) {
if ( this.isDisabled() || e.which !== OO.ui.MouseButtons.LEFT ) {
* @protected
* @param {jQuery.Event} e Mouse click event
* @fires click
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.mixin.ButtonElement.prototype.onClick = function ( e ) {
if ( !this.isDisabled() && e.which === OO.ui.MouseButtons.LEFT ) {
* @protected
* @param {jQuery.Event} e Key press event
* @fires click
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.mixin.ButtonElement.prototype.onKeyPress = function ( e ) {
if ( !this.isDisabled() && ( e.which === OO.ui.Keys.SPACE || e.which === OO.ui.Keys.ENTER ) ) {
*
* @param {boolean} [framed] Make button framed, omit to toggle
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.ButtonElement.prototype.toggleFramed = function ( framed ) {
framed = framed === undefined ? !this.framed : !!framed;
* @protected
* @param {boolean} value Make button active
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.ButtonElement.prototype.setActive = function ( value ) {
this.active = !!value;
* @param {OO.ui.Element[]} items An array of items to add to the group
* @param {number} [index] Index of the insertion point
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.GroupElement.prototype.addItems = function ( items, index ) {
// Mixin method
*
* @param {OO.ui.Element[]} items An array of items to remove
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.GroupElement.prototype.removeItems = function ( items ) {
var i, len, item, index;
* To remove only a subset of items from a group, use the #removeItems method.
*
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.GroupElement.prototype.clearItems = function () {
var i, len;
* @param {jQuery|string|OO.ui.HtmlSnippet|Function|null} label Label nodes; text; a function that returns nodes or
* text; or null for no label
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.LabelElement.prototype.setLabel = function ( label ) {
label = typeof label === 'function' ? OO.ui.resolveMsg( label ) : label;
- label = ( ( typeof label === 'string' || label instanceof jQuery ) && label.length ) || ( label instanceof OO.ui.HtmlSnippet && label.toString().length ) ? label : null;
+ label = ( ( typeof label === 'string' || label instanceof $ ) && label.length ) || ( label instanceof OO.ui.HtmlSnippet && label.toString().length ) ? label : null;
if ( this.label !== label ) {
if ( this.$label ) {
*
* @param {boolean} invisibleLabel
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.LabelElement.prototype.setInvisibleLabel = function ( invisibleLabel ) {
invisibleLabel = !!invisibleLabel;
* @param {string} query Substring of text to highlight
* @param {Function} [compare] Optional string comparator, e.g. Intl.Collator().compare
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.LabelElement.prototype.setHighlightedQuery = function ( text, query, compare ) {
return this.setLabel( this.constructor.static.highlightQuery( text, query, compare ) );
}
} else if ( label instanceof OO.ui.HtmlSnippet ) {
this.$label.html( label.toString() );
- } else if ( label instanceof jQuery ) {
+ } else if ( label instanceof $ ) {
this.$label.empty().append( label );
} else {
this.$label.empty();
* @param {Object|string|null} icon A symbolic icon name, a {@link #icon map of icon names} keyed
* by language code, or `null` to remove the icon.
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.IconElement.prototype.setIcon = function ( icon ) {
icon = OO.isPlainObject( icon ) ? OO.ui.getLocalValue( icon, null, 'default' ) : icon;
* @param {string|Function|null} iconTitle A text string used as the icon title,
* a function that returns title text, or `null` for no title.
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.IconElement.prototype.setIconTitle = function ( iconTitle ) {
iconTitle =
*
* @param {string|null} indicator Symbolic name of indicator, or `null` for no indicator
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.IndicatorElement.prototype.setIndicator = function ( indicator ) {
indicator = typeof indicator === 'string' && indicator.length ? indicator.trim() : null;
* @param {string|Function|null} indicatorTitle Indicator title text, a function that returns text, or
* `null` for no indicator title
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.IndicatorElement.prototype.setIndicatorTitle = function ( indicatorTitle ) {
indicatorTitle =
* Clear all flags.
*
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
* @fires flag
*/
OO.ui.mixin.FlaggedElement.prototype.clearFlags = function () {
* or an object keyed by flag name with a boolean value that indicates whether the flag should
* be added (`true`) or removed (`false`).
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
* @fires flag
*/
OO.ui.mixin.FlaggedElement.prototype.setFlags = function ( flags ) {
*
* @param {string|Function|null} title Title text, a function that returns text, or `null` for no title
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.TitledElement.prototype.setTitle = function ( title ) {
title = typeof title === 'function' ? OO.ui.resolveMsg( title ) : title;
*
* @protected
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.TitledElement.prototype.updateTitle = function () {
var title = this.getTitle();
*
* @param {string|Function|null} accessKey Key, a function that returns a key, or `null` for no accesskey
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.AccessKeyedElement.prototype.setAccessKey = function ( accessKey ) {
accessKey = typeof accessKey === 'string' ? OO.ui.resolveMsg( accessKey ) : null;
* Set hyperlink location.
*
* @param {string|null} href Hyperlink location, null to remove
+ * @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.ButtonWidget.prototype.setHref = function ( href ) {
href = typeof href === 'string' ? href : null;
*
* @private
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.ButtonWidget.prototype.updateHref = function () {
if ( this.href !== null && !this.isDisabled() ) {
* Set hyperlink target.
*
* @param {string|null} target Hyperlink target, null to remove
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.ButtonWidget.prototype.setTarget = function ( target ) {
target = typeof target === 'string' ? target : null;
* Set search engine traversal hint.
*
* @param {boolean} noFollow True if search engines should avoid traversing this hyperlink
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.ButtonWidget.prototype.setNoFollow = function ( noFollow ) {
noFollow = typeof noFollow === 'boolean' ? noFollow : true;
* Focus the widget
*
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.ButtonGroupWidget.prototype.focus = function () {
if ( !this.isDisabled() ) {
* (i.e., the number of calls to #pushPending and #popPending is the same).
*
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.PendingElement.prototype.pushPending = function () {
if ( this.pending === 0 ) {
* (i.e., the number of calls to #pushPending and #popPending is the same).
*
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.PendingElement.prototype.popPending = function () {
if ( this.pending === 1 ) {
*
* @param {boolean} [positioning] Enable positioning, omit to toggle
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.FloatableElement.prototype.togglePositioning = function ( positioning ) {
var closestScrollableOfContainer;
if ( this.positioning !== positioning ) {
this.positioning = positioning;
- this.needsCustomPosition =
- this.verticalPosition !== 'below' ||
- this.horizontalPosition !== 'start' ||
- !OO.ui.contains( this.$floatableContainer[ 0 ], this.$floatable[ 0 ] );
-
closestScrollableOfContainer = OO.ui.Element.static.getClosestScrollableContainer( this.$floatableContainer[ 0 ] );
// If the scrollable is the root, we have to listen to scroll events
// on the window because of browser inconsistencies.
* This should only be done when both of them are attached to the DOM and visible.
*
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.FloatableElement.prototype.position = function () {
if ( !this.positioning ) {
this.$floatable.removeClass( 'oo-ui-element-hidden' );
}
- if ( !this.needsCustomPosition ) {
- return this;
- }
-
this.$floatable.css( this.computePosition() );
// We updated the position, so re-evaluate the clipping state.
*
* @param {boolean} [clipping] Enable clipping, omit to toggle
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.ClippableElement.prototype.toggleClipping = function ( clipping ) {
clipping = clipping === undefined ? !this.clipping : !!clipping;
* beyond the edge, something reasonable will happen before clip() is called.
*
* @chainable
+ * @return {OO.ui.Element} The element, for chaining
*/
OO.ui.mixin.ClippableElement.prototype.clip = function () {
var extraHeight, extraWidth, viewportSpacing,
// The order matters here. If overflow is not set first, Chrome displays bogus scrollbars. See T157672.
// Forcing a reflow is a smaller workaround than calling reconsiderScrollbars() for this case.
this.$clippable.css( 'overflowX', 'scroll' );
+ // eslint-disable-next-line no-void
void this.$clippable[ 0 ].offsetHeight; // Force reflow
this.$clippable.css( {
width: Math.max( 0, allotedWidth ),
// The order matters here. If overflow is not set first, Chrome displays bogus scrollbars. See T157672.
// Forcing a reflow is a smaller workaround than calling reconsiderScrollbars() for this case.
this.$clippable.css( 'overflowY', 'scroll' );
+ // eslint-disable-next-line no-void
void this.$clippable[ 0 ].offsetHeight; // Force reflow
this.$clippable.css( {
height: Math.max( 0, allotedHeight ),
.append( this.$popup, this.$anchor );
// Move content, which was added to #$element by OO.ui.Widget, to the body
// FIXME This is gross, we should use '$body' or something for the config
- if ( config.$content instanceof jQuery ) {
+ if ( config.$content instanceof $ ) {
this.$body.append( config.$content );
}
*
* @param {boolean} disabled Disable widget
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.mixin.GroupWidget.prototype.setDisabled = function ( disabled ) {
var i, len;
*
* @param {OO.ui.mixin.GroupElement|null} group Group element, null if none
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.mixin.ItemWidget.prototype.setElementGroup = function ( group ) {
// Parent method
*
* @param {boolean} [state=false] Select option
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.OptionWidget.prototype.setSelected = function ( state ) {
if ( this.constructor.static.selectable ) {
*
* @param {boolean} [state=false] Highlight option
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.OptionWidget.prototype.setHighlighted = function ( state ) {
if ( this.constructor.static.highlightable ) {
*
* @param {boolean} [state=false] Press option
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.OptionWidget.prototype.setPressed = function ( state ) {
if ( this.constructor.static.pressable ) {
*
* @private
* @param {jQuery.Event} e Mouse down event
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.SelectWidget.prototype.onMouseDown = function ( e ) {
var item;
*
* @private
* @param {MouseEvent} e Mouse up event
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.SelectWidget.prototype.onDocumentMouseUp = function ( e ) {
var item;
*
* @private
* @param {jQuery.Event} e Mouse over event
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.SelectWidget.prototype.onMouseOver = function ( e ) {
var item;
*
* @private
* @param {jQuery.Event} e Mouse over event
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.SelectWidget.prototype.onMouseLeave = function () {
if ( !this.isDisabled() ) {
*
* @protected
* @param {KeyboardEvent} e Key press event
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.SelectWidget.prototype.onDocumentKeyPress = function ( e ) {
var c, filter, item;
}
return;
}
+ // eslint-disable-next-line no-restricted-properties
if ( String.fromCodePoint ) {
+ // eslint-disable-next-line no-restricted-properties
c = String.fromCodePoint( e.charCode );
} else {
c = String.fromCharCode( e.charCode );
OO.ui.SelectWidget.prototype.getItemMatcher = function ( s, exact ) {
var re;
+ // eslint-disable-next-line no-restricted-properties
if ( s.normalize ) {
+ // eslint-disable-next-line no-restricted-properties
s = s.normalize();
}
s = exact ? s.trim() : s.replace( /^\s+/, '' );
re = new RegExp( re, 'i' );
return function ( item ) {
var matchText = item.getMatchText();
+ // eslint-disable-next-line no-restricted-properties
if ( matchText.normalize ) {
+ // eslint-disable-next-line no-restricted-properties
matchText = matchText.normalize();
}
return re.test( matchText );
* @param {OO.ui.OptionWidget} [item] Item to highlight, omit for no highlight
* @fires highlight
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.SelectWidget.prototype.highlightItem = function ( item ) {
var i, len, highlighted,
* @param {boolean} [prefix=false] Allow a prefix match, if only a single item matches
* @fires select
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.SelectWidget.prototype.selectItemByLabel = function ( label, prefix ) {
var itemFromLabel = this.getItemFromLabel( label, !!prefix );
* @param {Object|string} [data] Value of the item to select, omit to deselect all
* @fires select
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.SelectWidget.prototype.selectItemByData = function ( data ) {
var itemFromData = this.findItemFromData( data );
* @param {OO.ui.OptionWidget} [item] Item to select, omit to deselect all
* @fires select
* @chainable
- */
+ * @return {OO.ui.Widget} The widget, for chaining
+*/
OO.ui.SelectWidget.prototype.selectItem = function ( item ) {
var i, len, selected,
changed = false;
* @param {OO.ui.OptionWidget} [item] Item to press, omit to depress all
* @fires press
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.SelectWidget.prototype.pressItem = function ( item ) {
var i, len, pressed,
* @param {OO.ui.OptionWidget} item Item to choose
* @fires choose
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.SelectWidget.prototype.chooseItem = function ( item ) {
if ( item ) {
* @param {number} [index] Index to insert items after
* @fires add
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.SelectWidget.prototype.addItems = function ( items, index ) {
// Mixin method
* @param {OO.ui.OptionWidget[]} items Items to remove
* @fires remove
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.SelectWidget.prototype.removeItems = function ( items ) {
var i, len, item;
*
* @fires remove
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.SelectWidget.prototype.clearItems = function () {
var items = this.items.slice();
this.scrollItemIntoView( this.items[ 0 ] );
}
+ if ( !anyVisible ) {
+ this.highlightItem( null );
+ }
+
this.$element.toggleClass( 'oo-ui-menuSelectWidget-invisible', !anyVisible );
if ( this.highlightOnFilter ) {
*
* @param {OO.ui.OptionWidget} item Item to choose
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.MenuSelectWidget.prototype.chooseItem = function ( item ) {
OO.ui.MenuSelectWidget.parent.prototype.chooseItem.call( this, item );
selectedLabel = item.getLabel();
// If the label is a DOM element, clone it, because setLabel will append() it
- if ( selectedLabel instanceof jQuery ) {
+ if ( selectedLabel instanceof $ ) {
selectedLabel = selectedLabel.clone();
}
*
* @private
* @param {jQuery.Event} e Mouse click event
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.DropdownWidget.prototype.onClick = function ( e ) {
if ( !this.isDisabled() && e.which === OO.ui.MouseButtons.LEFT ) {
*
* @private
* @param {jQuery.Event} e Key down event
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.DropdownWidget.prototype.onKeyDown = function ( e ) {
if (
*
* @param {boolean} [state=false] Select option
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.MultioptionWidget.prototype.setSelected = function ( state ) {
state = !!state;
*
* @param {OO.ui.MultioptionWidget[]} items Items to select
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.MultiselectWidget.prototype.selectItems = function ( items ) {
this.items.forEach( function ( item ) {
*
* @param {Object[]|string[]} datas Values of items to select
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.MultiselectWidget.prototype.selectItemsByData = function ( datas ) {
var items,
* Focus the widget
*
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.CheckboxMultiselectWidget.prototype.focus = function () {
var item;
*
* @param {string} dir Text directionality: 'ltr', 'rtl' or 'auto'
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.InputWidget.prototype.setDir = function ( dir ) {
this.$input.prop( 'dir', dir );
* @param {string} value New value
* @fires change
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.InputWidget.prototype.setValue = function ( value ) {
value = this.cleanUpValue( value );
*
* @param {string} id
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.InputWidget.prototype.setInputId = function ( id ) {
this.$input.attr( 'id', id );
* @param {jQuery|string|Function|null} label Label nodes, text, a function that returns nodes or
* text, or `null` for no label
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.ButtonInputWidget.prototype.setLabel = function ( label ) {
if ( typeof label === 'function' ) {
*
* @param {string} value New value
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.ButtonInputWidget.prototype.setValue = function ( value ) {
if ( !this.useInputTag ) {
*
* @param {boolean} state `true` for selected
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.CheckboxInputWidget.prototype.setSelected = function ( state ) {
state = !!state;
*
* @param {Object[]} options Array of menu options in the format `{ data: …, label: … }`
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.DropdownInputWidget.prototype.setOptions = function ( options ) {
var value = this.getValue();
*
* @param {boolean} state `true` for selected
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.RadioInputWidget.prototype.setSelected = function ( state ) {
// RadioInputWidget doesn't track its state.
*
* @param {Object[]} options Array of menu options in the format `{ data: …, label: … }`
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.RadioSelectInputWidget.prototype.setOptions = function ( options ) {
var value = this.getValue();
*
* @param {Object[]} options Array of menu options in the format `{ data: …, label: …, disabled: … }`
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.CheckboxMultiselectInputWidget.prototype.setOptions = function ( options ) {
var value = this.getValue();
*
* @private
* @param {jQuery.Event} e Mouse down event
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.TextInputWidget.prototype.onIconMouseDown = function ( e ) {
if ( e.which === OO.ui.MouseButtons.LEFT ) {
*
* @private
* @param {jQuery.Event} e Mouse down event
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.TextInputWidget.prototype.onIndicatorMouseDown = function ( e ) {
if ( e.which === OO.ui.MouseButtons.LEFT ) {
*
* @param {boolean} state Make input read-only
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.TextInputWidget.prototype.setReadOnly = function ( state ) {
this.readOnly = !!state;
*
* @param {boolean} state Make input required
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.TextInputWidget.prototype.setRequired = function ( state ) {
this.required = !!state;
* @param {number} from Select from offset
* @param {number} [to] Select to offset, defaults to from
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.TextInputWidget.prototype.selectRange = function ( from, to ) {
var isBackwards, start, end,
* Focus the input and select the entire text.
*
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.TextInputWidget.prototype.select = function () {
return this.selectRange( 0, this.getInputLength() );
* Focus the input and move the cursor to the start.
*
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.TextInputWidget.prototype.moveCursorToStart = function () {
return this.selectRange( 0 );
* Focus the input and move the cursor to the end.
*
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.TextInputWidget.prototype.moveCursorToEnd = function () {
return this.selectRange( this.getInputLength() );
*
* @param {string} content Content to be inserted
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.TextInputWidget.prototype.insertContent = function ( content ) {
var start, end,
* @param {string} pre Content to be inserted before the selection
* @param {string} post Content to be inserted after the selection
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.TextInputWidget.prototype.encapsulateContent = function ( pre, post ) {
var start, end,
// Run our checks if the browser thinks the field is valid
if ( this.validate instanceof Function ) {
result = this.validate( this.getValue() );
- if ( result && $.isFunction( result.promise ) ) {
+ if ( result && typeof result.promise === 'function' ) {
return result.promise().then( function ( valid ) {
return rejectOrResolve( valid );
} );
*
* @param {string} labelPosition Label position, 'before' or 'after'
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.TextInputWidget.prototype.setLabelPosition = function ( labelPosition ) {
this.labelPosition = labelPosition;
* something causes the label to be mispositioned.
*
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.TextInputWidget.prototype.updatePosition = function () {
var after = this.labelPosition === 'after';
*
* @private
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.TextInputWidget.prototype.positionLabel = function () {
var after, rtl, property, newCss;
* This only affects multiline inputs that are {@link #autosize autosized}.
*
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
* @fires resize
*/
OO.ui.MultilineTextInputWidget.prototype.adjustSize = function () {
*
* @param {Object[]} options Array of menu options in the format `{ data: …, label: … }`
* @chainable
+ * @return {OO.ui.Widget} The widget, for chaining
*/
OO.ui.ComboBoxInputWidget.prototype.setOptions = function ( options ) {
this.getMenu()
* @private
* @param {string} value Alignment mode, either 'left', 'right', 'top' or 'inline'
* @chainable
+ * @return {OO.ui.BookletLayout} The layout, for chaining
*/
OO.ui.FieldLayout.prototype.setAlignment = function ( value ) {
if ( value !== this.align ) {
* @param {Array} errors Error messages about the widget, which will be displayed below the widget.
* The array may contain strings or OO.ui.HtmlSnippet instances.
* @chainable
+ * @return {OO.ui.BookletLayout} The layout, for chaining
*/
OO.ui.FieldLayout.prototype.setErrors = function ( errors ) {
this.errors = errors.slice();
* @param {Array} notices Notices about the widget, which will be displayed below the widget.
* The array may contain strings or OO.ui.HtmlSnippet instances.
* @chainable
+ * @return {OO.ui.BookletLayout} The layout, for chaining
*/
OO.ui.FieldLayout.prototype.setNotices = function ( notices ) {
this.notices = notices.slice();
* @private
* @param {jQuery.Event} e Submit event
* @fires submit
+ * @return {OO.ui.FormLayout} The layout, for chaining
*/
OO.ui.FormLayout.prototype.onFormSubmit = function () {
if ( this.emit( 'submit' ) ) {
*
* @private
* @param {jQuery.Event} event
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.NumberInputWidget.prototype.onWheel = function ( event ) {
var delta = 0;
*
* @private
* @param {jQuery.Event} e Key down event
+ * @return {undefined/boolean} False to prevent default if event is handled
*/
OO.ui.NumberInputWidget.prototype.onKeyDown = function ( e ) {
if ( !this.isDisabled() ) {