Merge "Use Parser::SFH_NO_HASH/SFH_OBJECT_ARGS class const"
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui.js
index 80d4c1d..d42139e 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (20c61ec865)
+ * OOjs UI v0.2.3
  * https://www.mediawiki.org/wiki/OOjs_UI
  *
  * Copyright 2011–2014 OOjs Team and other contributors.
  * Released under the MIT license
  * http://oojs.mit-license.org
  *
- * Date: 2014-11-20T18:41:26Z
+ * Date: 2014-11-26T23:37:00Z
  */
 ( function ( OO ) {
 
@@ -101,7 +101,7 @@ OO.ui.getLocalValue = function ( obj, lang, fallback ) {
  *
  * @param {HTMLElement|HTMLElement[]} containers Container node(s) to search in
  * @param {HTMLElement} contained Node to find
- * @param {boolean} [matchContainers] Include the container(s) in the list of nodes to match, otherwise only match descendents
+ * @param {boolean} [matchContainers] Include the container(s) in the list of nodes to match, otherwise only match descendants
  * @return {boolean} The node is in the list of target nodes
  */
 OO.ui.contains = function ( containers, contained, matchContainers ) {
@@ -314,7 +314,7 @@ OO.ui.PendingElement.prototype.popPending = function () {
  * @param {Object} [config] Configuration options
  */
 OO.ui.ActionSet = function OoUiActionSet( config ) {
-       // Configuration intialization
+       // Configuration initialization
        config = config || {};
 
        // Mixin constructors
@@ -656,7 +656,7 @@ OO.ui.ActionSet.prototype.clear = function () {
 /**
  * Organize actions.
  *
- * This is called whenver organized information is requested. It will only reorganize the actions
+ * This is called whenever organized information is requested. It will only reorganize the actions
  * if something has changed since the last time it ran.
  *
  * @private
@@ -673,7 +673,7 @@ OO.ui.ActionSet.prototype.organize = function () {
                for ( i = 0, iLen = this.list.length; i < iLen; i++ ) {
                        action = this.list[i];
                        if ( action.isVisible() ) {
-                               // Populate catgeories
+                               // Populate categories
                                for ( category in this.categories ) {
                                        if ( !this.categorized[category] ) {
                                                this.categorized[category] = {};
@@ -723,6 +723,7 @@ OO.ui.ActionSet.prototype.organize = function () {
  * @cfg {string[]} [classes] CSS class names to add
  * @cfg {string} [text] Text to insert
  * @cfg {jQuery} [$content] Content elements to append (after text)
+ * @cfg {Mixed} [data] Element data
  */
 OO.ui.Element = function OoUiElement( config ) {
        // Configuration initialization
@@ -730,6 +731,7 @@ OO.ui.Element = function OoUiElement( config ) {
 
        // Properties
        this.$ = config.$ || OO.ui.Element.getJQuery( document );
+       this.data = config.data;
        this.$element = this.$( this.$.context.createElement( this.getTagName() ) );
        this.elementGroup = null;
        this.debouncedUpdateThemeClassesHandler = this.debouncedUpdateThemeClasses.bind( this );
@@ -1135,6 +1137,26 @@ OO.ui.Element.offDOMEvent = function ( el, event, callback ) {
 
 /* Methods */
 
+/**
+ * Get element data.
+ *
+ * @return {Mixed} Element data
+ */
+OO.ui.Element.prototype.getData = function () {
+       return this.data;
+};
+
+/**
+ * Set element data.
+ *
+ * @param {Mixed} Element data
+ * @chainable
+ */
+OO.ui.Element.prototype.setData = function ( data ) {
+       this.data = data;
+       return this;
+};
+
 /**
  * Check if element supports one or more methods.
  *
@@ -1158,7 +1180,7 @@ OO.ui.Element.prototype.supports = function ( methods ) {
 /**
  * Update the theme-provided classes.
  *
- * @localdoc This is called in element mixins and widget classes anytime state changes.
+ * @localdoc This is called in element mixins and widget classes any time state changes.
  *   Updating is debounced, minimizing overhead of changing multiple attributes and
  *   guaranteeing that theme updates do not occur within an element's constructor
  */
@@ -1451,8 +1473,8 @@ OO.ui.Widget.prototype.updateDisabled = function () {
  *
  * Each process (setup, ready, hold and teardown) can be extended in subclasses by overriding
  * {@link #getSetupProcess}, {@link #getReadyProcess}, {@link #getHoldProcess} and
- * {@link #getTeardownProcess} respectively. Each process is executed in series, so asynchonous
- * processing can complete. Always assume window processes are executed asychronously. See
+ * {@link #getTeardownProcess} respectively. Each process is executed in series, so asynchronous
+ * processing can complete. Always assume window processes are executed asynchronously. See
  * OO.ui.Process for more details about how to work with processes. Some events, as well as the
  * #open and #close methods, provide promises which are resolved when the window enters a new state.
  *
@@ -1494,7 +1516,7 @@ OO.ui.Window = function OoUiWindow( config ) {
        this.$frame.addClass( 'oo-ui-window-frame' );
        this.$overlay.addClass( 'oo-ui-window-overlay' );
 
-       // NOTE: Additional intitialization will occur when #setManager is called
+       // NOTE: Additional initialization will occur when #setManager is called
 };
 
 /* Setup */
@@ -1734,11 +1756,20 @@ OO.ui.Window.prototype.getSize = function () {
  * @return {number} Content height
  */
 OO.ui.Window.prototype.getContentHeight = function () {
-       // Temporarily resize the frame so getBodyHeight() can use scrollHeight measurements
-       var bodyHeight, oldHeight = this.$frame[0].style.height;
-       this.$frame[0].style.height = '1px';
+       // Temporarily resize the frame so getBodyHeight() can use scrollHeight measurements.
+       // Disable transitions first, otherwise we'll get values from when the window was animating.
+       var bodyHeight, oldHeight, oldTransition,
+               styleObj = this.$frame[0].style;
+       oldTransition = styleObj.transition || styleObj.OTransition || styleObj.MsTransition ||
+               styleObj.MozTransition || styleObj.WebkitTransition;
+       styleObj.transition = styleObj.OTransition = styleObj.MsTransition =
+               styleObj.MozTransition = styleObj.WebkitTransition = 'none';
+       oldHeight = styleObj.height;
+       styleObj.height = '1px';
        bodyHeight = this.getBodyHeight();
-       this.$frame[0].style.height = oldHeight;
+       styleObj.height = oldHeight;
+       styleObj.transition = styleObj.OTransition = styleObj.MsTransition =
+               styleObj.MozTransition = styleObj.WebkitTransition = oldTransition;
 
        return Math.round(
                // Add buffer for border
@@ -1840,7 +1871,7 @@ OO.ui.Window.prototype.getTeardownProcess = function () {
 /**
  * Toggle visibility of window.
  *
- * If the window is isolated and hasn't fully loaded yet, the visiblity property will be used
+ * If the window is isolated and hasn't fully loaded yet, the visibility property will be used
  * instead of display.
  *
  * @param {boolean} [show] Make window visible, omit to toggle visibility
@@ -2013,7 +2044,7 @@ OO.ui.Window.prototype.close = function ( data ) {
 /**
  * Setup window.
  *
- * This is called by OO.ui.WindowManager durring window opening, and should not be called directly
+ * This is called by OO.ui.WindowManager during window opening, and should not be called directly
  * by other systems.
  *
  * @param {Object} [data] Window opening data
@@ -2038,7 +2069,7 @@ OO.ui.Window.prototype.setup = function ( data ) {
 /**
  * Ready window.
  *
- * This is called by OO.ui.WindowManager durring window opening, and should not be called directly
+ * This is called by OO.ui.WindowManager during window opening, and should not be called directly
  * by other systems.
  *
  * @param {Object} [data] Window opening data
@@ -2062,7 +2093,7 @@ OO.ui.Window.prototype.ready = function ( data ) {
 /**
  * Hold window.
  *
- * This is called by OO.ui.WindowManager durring window closing, and should not be called directly
+ * This is called by OO.ui.WindowManager during window closing, and should not be called directly
  * by other systems.
  *
  * @param {Object} [data] Window closing data
@@ -2093,7 +2124,7 @@ OO.ui.Window.prototype.hold = function ( data ) {
 /**
  * Teardown window.
  *
- * This is called by OO.ui.WindowManager durring window closing, and should not be called directly
+ * This is called by OO.ui.WindowManager during window closing, and should not be called directly
  * by other systems.
  *
  * @param {Object} [data] Window closing data
@@ -2253,6 +2284,7 @@ OO.ui.Dialog = function OoUiDialog( config ) {
        this.actions = new OO.ui.ActionSet();
        this.attachedActions = [];
        this.currentAction = null;
+       this.onDocumentKeyDownHandler = this.onDocumentKeyDown.bind( this );
 
        // Events
        this.actions.connect( this, {
@@ -2416,6 +2448,10 @@ OO.ui.Dialog.prototype.getSetupProcess = function ( data ) {
                                );
                        }
                        this.actions.add( items );
+
+                       if ( this.constructor.static.escapable ) {
+                               this.$document.on( 'keydown', this.onDocumentKeyDownHandler );
+                       }
                }, this );
 };
 
@@ -2426,6 +2462,10 @@ OO.ui.Dialog.prototype.getTeardownProcess = function ( data ) {
        // Parent method
        return OO.ui.Dialog.super.prototype.getTeardownProcess.call( this, data )
                .first( function () {
+                       if ( this.constructor.static.escapable ) {
+                               this.$document.off( 'keydown', this.onDocumentKeyDownHandler );
+                       }
+
                        this.actions.clear();
                        this.currentAction = null;
                }, this );
@@ -2441,11 +2481,6 @@ OO.ui.Dialog.prototype.initialize = function () {
        // Properties
        this.title = new OO.ui.LabelWidget( { $: this.$ } );
 
-       // Events
-       if ( this.constructor.static.escapable ) {
-               this.$document.on( 'keydown', this.onDocumentKeyDown.bind( this ) );
-       }
-
        // Initialization
        this.$content.addClass( 'oo-ui-dialog-content' );
        this.setPendingElement( this.$head );
@@ -3162,7 +3197,7 @@ OO.ui.WindowManager.prototype.toggleAriaIsolation = function ( isolate ) {
                                .attr( 'aria-hidden', '' );
                }
        } else if ( this.$ariaHidden ) {
-               // Restore screen reader visiblity
+               // Restore screen reader visibility
                this.$ariaHidden.removeAttr( 'aria-hidden' );
                this.$ariaHidden = null;
        }
@@ -3422,7 +3457,15 @@ OO.inheritClass( OO.ui.ToolFactory, OO.Factory );
 
 /* Methods */
 
-/** */
+/**
+ * Get tools from the factory
+ *
+ * @param {Array} include Included tools
+ * @param {Array} exclude Excluded tools
+ * @param {Array} promote Promoted tools
+ * @param {Array} demote Demoted tools
+ * @return {string[]} List of tools
+ */
 OO.ui.ToolFactory.prototype.getTools = function ( include, exclude, promote, demote ) {
        var i, len, included, promoted, demoted,
                auto = [],
@@ -3592,7 +3635,7 @@ OO.ui.Theme.prototype.getElementClasses = function ( /* element */ ) {
 /**
  * Update CSS classes provided by the theme.
  *
- * For elements with theme logic hooks, this should be called anytime there's a state change.
+ * For elements with theme logic hooks, this should be called any time there's a state change.
  *
  * @param {OO.ui.Element} element Element for which to update classes
  * @return {Object.<string,string[]>} Categorized class names with `on` and `off` lists
@@ -3711,7 +3754,7 @@ OO.ui.ButtonElement.prototype.onMouseUp = function ( e ) {
        if ( this.isDisabled() || e.which !== 1 ) {
                return false;
        }
-       // Restore the tab-index after the button is up to restore the button's accesssibility
+       // Restore the tab-index after the button is up to restore the button's accessibility
        this.$button.attr( 'tabindex', this.tabIndex );
        this.$element.removeClass( 'oo-ui-buttonElement-pressed' );
        // Stop listening for mouseup, since we only needed this once
@@ -3814,7 +3857,7 @@ OO.ui.ButtonElement.prototype.setActive = function ( value ) {
  * @cfg {jQuery} [$group] Container node, assigned to #$group, omit to use a generated `<div>`
  */
 OO.ui.GroupElement = function OoUiGroupElement( config ) {
-       // Configuration intialization
+       // Configuration initialization
        config = config || {};
 
        // Properties
@@ -3862,6 +3905,51 @@ OO.ui.GroupElement.prototype.getItems = function () {
        return this.items.slice( 0 );
 };
 
+/**
+ * Get an item by its data.
+ *
+ * Data is compared by a hash of its value. Only the first item with matching data will be returned.
+ *
+ * @param {Object} data Item data to search for
+ * @return {OO.ui.Element|null} Item with equivalent data, `null` if none exists
+ */
+OO.ui.GroupElement.prototype.getItemFromData = function ( data ) {
+       var i, len, item,
+               hash = OO.getHash( data );
+
+       for ( i = 0, len = this.items.length; i < len; i++ ) {
+               item = this.items[i];
+               if ( hash === OO.getHash( item.getData() ) ) {
+                       return item;
+               }
+       }
+
+       return null;
+};
+
+/**
+ * Get items by their data.
+ *
+ * Data is compared by a hash of its value. All items with matching data will be returned.
+ *
+ * @param {Object} data Item data to search for
+ * @return {OO.ui.Element[]} Items with equivalent data
+ */
+OO.ui.GroupElement.prototype.getItemsFromData = function ( data ) {
+       var i, len, item,
+               hash = OO.getHash( data ),
+               items = [];
+
+       for ( i = 0, len = this.items.length; i < len; i++ ) {
+               item = this.items[i];
+               if ( hash === OO.getHash( item.getData() ) ) {
+                       items.push( item );
+               }
+       }
+
+       return items;
+};
+
 /**
  * Add an aggregate item event.
  *
@@ -4052,7 +4140,7 @@ OO.ui.GroupElement.prototype.clearItems = function () {
  * @cfg {string} [iconTitle] Icon title text or a function that returns text
  */
 OO.ui.IconElement = function OoUiIconElement( config ) {
-       // Configuration intialization
+       // Configuration initialization
        config = config || {};
 
        // Properties
@@ -4474,7 +4562,6 @@ OO.ui.LabelElement.prototype.setLabelContent = function ( label ) {
        } else {
                this.$label.empty();
        }
-       this.$label.css( 'display', !label ? 'none' : '' );
 };
 
 /**
@@ -5812,7 +5899,7 @@ OO.ui.MessageDialog.static.verbose = false;
  * Dialog title.
  *
  * A confirmation dialog's title should describe what the progressive action will do. An alert
- * dialog's title should describe what event occured.
+ * dialog's title should describe what event occurred.
  *
  * @static
  * inheritable
@@ -5822,7 +5909,7 @@ OO.ui.MessageDialog.static.title = null;
 
 /**
  * A confirmation dialog's message should describe the consequences of the progressive action. An
- * alert dialog's message should describe why the event occured.
+ * alert dialog's message should describe why the event occurred.
  *
  * @static
  * inheritable
@@ -5842,7 +5929,7 @@ OO.ui.MessageDialog.static.actions = [
  */
 OO.ui.MessageDialog.prototype.onActionResize = function ( action ) {
        this.fitActions();
-       return OO.ui.ProcessDialog.super.prototype.onActionResize.call( this, action );
+       return OO.ui.MessageDialog.super.prototype.onActionResize.call( this, action );
 };
 
 /**
@@ -5909,7 +5996,45 @@ OO.ui.MessageDialog.prototype.getSetupProcess = function ( data ) {
  * @inheritdoc
  */
 OO.ui.MessageDialog.prototype.getBodyHeight = function () {
-       return Math.round( this.text.$element.outerHeight( true ) );
+       var bodyHeight, oldOverflow,
+               $scrollable = this.container.$element;
+
+       oldOverflow = $scrollable[0].style.overflow;
+       $scrollable[0].style.overflow = 'hidden';
+
+       // Force… ugh… something to happen
+       $scrollable.contents().hide();
+       $scrollable.height();
+       $scrollable.contents().show();
+
+       bodyHeight = Math.round( this.text.$element.outerHeight( true ) );
+       $scrollable[0].style.overflow = oldOverflow;
+
+       return bodyHeight;
+};
+
+/**
+ * @inheritdoc
+ */
+OO.ui.MessageDialog.prototype.setDimensions = function ( dim ) {
+       var $scrollable = this.container.$element;
+       OO.ui.MessageDialog.super.prototype.setDimensions.call( this, dim );
+
+       // Twiddle the overflow property, otherwise an unnecessary scrollbar will be produced.
+       // Need to do it after transition completes (250ms), add 50ms just in case.
+       setTimeout( function () {
+               var oldOverflow = $scrollable[0].style.overflow;
+               $scrollable[0].style.overflow = 'hidden';
+
+               // Force… ugh… something to happen
+               $scrollable.contents().hide();
+               $scrollable.height();
+               $scrollable.contents().show();
+
+               $scrollable[0].style.overflow = oldOverflow;
+       }, 300 );
+
+       return this;
 };
 
 /**
@@ -5968,10 +6093,9 @@ OO.ui.MessageDialog.prototype.attachActions = function () {
                special.primary.toggleFramed( false );
        }
 
+       this.manager.updateWindowSize( this );
        this.fitActions();
-       if ( !this.isOpening() ) {
-               this.manager.updateWindowSize( this );
-       }
+
        this.$body.css( 'bottom', this.$foot.outerHeight( true ) );
 };
 
@@ -6168,7 +6292,7 @@ OO.ui.ProcessDialog.prototype.fitLabel = function () {
 };
 
 /**
- * Handle errors that occured durring accept or reject processes.
+ * Handle errors that occurred during accept or reject processes.
  *
  * @param {OO.ui.Error[]} errors Errors to be handled
  */
@@ -6337,22 +6461,40 @@ OO.ui.BookletLayout.prototype.onStackLayoutFocus = function ( e ) {
  * @param {OO.ui.PanelLayout|null} page The page panel that is now the current panel
  */
 OO.ui.BookletLayout.prototype.onStackLayoutSet = function ( page ) {
-       var $input, layout = this;
+       var layout = this;
        if ( page ) {
                page.scrollElementIntoView( { complete: function () {
                        if ( layout.autoFocus ) {
-                               // Set focus to the first input if nothing on the page is focused yet
-                               if ( !page.$element.find( ':focus' ).length ) {
-                                       $input = page.$element.find( ':input:first' );
-                                       if ( $input.length ) {
-                                               $input[0].focus();
-                                       }
-                               }
+                               layout.focus();
                        }
                } } );
        }
 };
 
+/**
+ * Focus the first input in the current page.
+ *
+ * If no page is selected, the first selectable page will be selected.
+ * If the focus is already in an element on the current page, nothing will happen.
+ */
+OO.ui.BookletLayout.prototype.focus = function () {
+       var $input, page = this.stackLayout.getCurrentItem();
+       if ( !page && this.outlined ) {
+               this.selectFirstSelectablePage();
+               page = this.stackLayout.getCurrentItem();
+               if ( !page ) {
+                       return;
+               }
+       }
+       // Only change the focus if is not already in the current page
+       if ( !page.$element.find( ':focus' ).length ) {
+               $input = page.$element.find( ':input:first' );
+               if ( $input.length ) {
+                       $input[0].focus();
+               }
+       }
+};
+
 /**
  * Handle outline widget select events.
  *
@@ -6444,7 +6586,7 @@ OO.ui.BookletLayout.prototype.getClosestPage = function ( page ) {
 /**
  * Get the outline widget.
  *
- * @return {OO.ui.OutlineSelectWidget|null} Outline widget, or null if boolet has no outline
+ * @return {OO.ui.OutlineSelectWidget|null} Outline widget, or null if booklet has no outline
  */
 OO.ui.BookletLayout.prototype.getOutline = function () {
        return this.outlineSelectWidget;
@@ -6519,7 +6661,7 @@ OO.ui.BookletLayout.prototype.addPages = function ( pages, index ) {
                name = page.getName();
                this.pages[page.getName()] = page;
                if ( this.outlined ) {
-                       item = new OO.ui.OutlineOptionWidget( name, page, { $: this.$ } );
+                       item = new OO.ui.OutlineOptionWidget( { $: this.$, data: name } );
                        page.setOutlineItem( item );
                        items.push( item );
                }
@@ -6527,7 +6669,7 @@ OO.ui.BookletLayout.prototype.addPages = function ( pages, index ) {
 
        if ( this.outlined && items.length ) {
                this.outlineSelectWidget.addItems( items, index );
-               this.updateOutlineSelectWidget();
+               this.selectFirstSelectablePage();
        }
        this.stackLayout.addItems( pages, index );
        this.emit( 'add', pages, index );
@@ -6556,7 +6698,7 @@ OO.ui.BookletLayout.prototype.removePages = function ( pages ) {
        }
        if ( this.outlined && items.length ) {
                this.outlineSelectWidget.removeItems( items );
-               this.updateOutlineSelectWidget();
+               this.selectFirstSelectablePage();
        }
        this.stackLayout.removeItems( pages );
        this.emit( 'remove', pages );
@@ -6629,12 +6771,11 @@ OO.ui.BookletLayout.prototype.setPage = function ( name ) {
 };
 
 /**
- * Call this after adding or removing items from the OutlineSelectWidget.
+ * Select the first selectable page.
  *
  * @chainable
  */
-OO.ui.BookletLayout.prototype.updateOutlineSelectWidget = function () {
-       // Auto-select first item when nothing is selected anymore
+OO.ui.BookletLayout.prototype.selectFirstSelectablePage = function () {
        if ( !this.outlineSelectWidget.getSelectedItem() ) {
                this.outlineSelectWidget.selectItem( this.outlineSelectWidget.getFirstSelectableItem() );
        }
@@ -6669,6 +6810,9 @@ OO.ui.FieldLayout = function OoUiFieldLayout( fieldWidget, config ) {
        // Configuration initialization
        config = $.extend( { align: 'left' }, config );
 
+       // Properties (must be set before parent constructor, which calls #getTagName)
+       this.fieldWidget = fieldWidget;
+
        // Parent constructor
        OO.ui.FieldLayout.super.call( this, config );
 
@@ -6677,7 +6821,6 @@ OO.ui.FieldLayout = function OoUiFieldLayout( fieldWidget, config ) {
 
        // Properties
        this.$field = this.$( '<div>' );
-       this.fieldWidget = fieldWidget;
        this.align = null;
        if ( config.help ) {
                this.popupButtonWidget = new OO.ui.PopupButtonWidget( {
@@ -6717,12 +6860,19 @@ OO.ui.FieldLayout = function OoUiFieldLayout( fieldWidget, config ) {
 OO.inheritClass( OO.ui.FieldLayout, OO.ui.Layout );
 OO.mixinClass( OO.ui.FieldLayout, OO.ui.LabelElement );
 
-/* Static Properties */
-
-OO.ui.FieldLayout.static.tagName = 'label';
-
 /* Methods */
 
+/**
+ * @inheritdoc
+ */
+OO.ui.FieldLayout.prototype.getTagName = function () {
+       if ( this.fieldWidget instanceof OO.ui.InputWidget ) {
+               return 'label';
+       } else {
+               return 'div';
+       }
+};
+
 /**
  * Handle field disable events.
  *
@@ -7038,7 +7188,7 @@ OO.ui.GridLayout.prototype.update = function () {
  *
  * @param {number} x Horizontal position
  * @param {number} y Vertical position
- * @return {OO.ui.PanelLayout} The panel at the given postion
+ * @return {OO.ui.PanelLayout} The panel at the given position
  */
 OO.ui.GridLayout.prototype.getPanel = function ( x, y ) {
        return this.panels[ ( x * this.widths.length ) + y ];
@@ -7588,7 +7738,7 @@ OO.ui.PopupToolGroup.prototype.setActive = function ( value ) {
  * @cfg {boolean} [expanded=false] Whether the collapsible tools are expanded by default
  */
 OO.ui.ListToolGroup = function OoUiListToolGroup( toolbar, config ) {
-       // Configuration intialization
+       // Configuration initialization
        config = config || {};
 
        // Properties (must be set before parent constructor, which calls #populate)
@@ -7865,7 +8015,7 @@ OO.ui.GroupWidget.prototype.setDisabled = function ( disabled ) {
  * Mixin for widgets used as items in widgets that inherit OO.ui.GroupWidget.
  *
  * Item widgets have a reference to a OO.ui.GroupWidget while they are attached to the group. This
- * allows bidrectional communication.
+ * allows bidirectional communication.
  *
  * Use together with OO.ui.GroupWidget to make disabled state inheritable.
  *
@@ -9154,12 +9304,12 @@ OO.ui.InputWidget.prototype.setRTL = function ( isRTL ) {
  * @chainable
  */
 OO.ui.InputWidget.prototype.setValue = function ( value ) {
-       value = this.sanitizeValue( value );
+       value = this.cleanUpValue( value );
        if ( this.value !== value ) {
                this.value = value;
                this.emit( 'change', this.value );
        }
-       // Update the DOM if it has changed. Note that with sanitizeValue, it
+       // Update the DOM if it has changed. Note that with cleanUpValue, it
        // is possible for the DOM value to change without this.value changing.
        if ( this.$input.val() !== this.value ) {
                this.$input.val( this.value );
@@ -9168,15 +9318,15 @@ OO.ui.InputWidget.prototype.setValue = function ( value ) {
 };
 
 /**
- * Sanitize incoming value.
+ * Clean up incoming value.
  *
  * Ensures value is a string, and converts undefined and null to empty string.
  *
  * @private
  * @param {string} value Original value
- * @return {string} Sanitized value
+ * @return {string} Cleaned up value
  */
-OO.ui.InputWidget.prototype.sanitizeValue = function ( value ) {
+OO.ui.InputWidget.prototype.cleanUpValue = function ( value ) {
        if ( value === undefined || value === null ) {
                return '';
        } else if ( this.inputFilter ) {
@@ -9307,7 +9457,7 @@ OO.mixinClass( OO.ui.ButtonInputWidget, OO.ui.FlaggedElement );
  * @return {jQuery} Input element
  */
 OO.ui.ButtonInputWidget.prototype.getInputElement = function ( config ) {
-       // Configuration intialization
+       // Configuration initialization
        config = config || {};
 
        var html = '<' + ( config.useInputTag ? 'input' : 'button' ) + ' type="' + config.type + '">';
@@ -9453,6 +9603,74 @@ OO.ui.CheckboxInputWidget.prototype.onEdit = function () {
        }
 };
 
+/**
+ * Radio input widget.
+ *
+ * Radio buttons only make sense as a set, and you probably want to use the OO.ui.RadioSelectWidget
+ * class instead of using this class directly.
+ *
+ * This class doesn't make it possible to learn whether the radio button is selected ("pressed").
+ *
+ * @class
+ * @extends OO.ui.InputWidget
+ *
+ * @constructor
+ * @param {Object} [config] Configuration options
+ * @param {boolean} [config.selected=false] Whether the radio button is initially selected
+ */
+OO.ui.RadioInputWidget = function OoUiRadioInputWidget( config ) {
+       // Parent constructor
+       OO.ui.RadioInputWidget.super.call( this, config );
+
+       // Initialization
+       this.$element.addClass( 'oo-ui-radioInputWidget' );
+       this.setSelected( config.selected !== undefined ? config.selected : false );
+};
+
+/* Setup */
+
+OO.inheritClass( OO.ui.RadioInputWidget, OO.ui.InputWidget );
+
+/* Methods */
+
+/**
+ * Get input element.
+ *
+ * @private
+ * @return {jQuery} Input element
+ */
+OO.ui.RadioInputWidget.prototype.getInputElement = function () {
+       return this.$( '<input type="radio" />' );
+};
+
+/**
+ * @inheritdoc
+ */
+OO.ui.RadioInputWidget.prototype.onEdit = function () {
+       // RadioInputWidget doesn't track its state.
+};
+
+/**
+ * Set selection state of this radio button.
+ *
+ * @param {boolean} state Whether the button is selected
+ * @chainable
+ */
+OO.ui.RadioInputWidget.prototype.setSelected = function ( state ) {
+       // RadioInputWidget doesn't track its state.
+       this.$input.prop( 'checked', state );
+       return this;
+};
+
+/**
+ * Check if this radio button is selected.
+ *
+ * @return {boolean} Radio is selected
+ */
+OO.ui.RadioInputWidget.prototype.isSelected = function () {
+       return this.$input.prop( 'checked' );
+};
+
 /**
  * Input widget with a text field.
  *
@@ -9588,7 +9806,7 @@ OO.ui.TextInputWidget.prototype.onIndicatorMouseDown = function ( e ) {
  */
 OO.ui.TextInputWidget.prototype.onKeyPress = function ( e ) {
        if ( e.which === OO.ui.Keys.ENTER && !this.multiline ) {
-               this.emit( 'enter' );
+               this.emit( 'enter', e );
        }
 };
 
@@ -9635,7 +9853,7 @@ OO.ui.TextInputWidget.prototype.isReadOnly = function () {
 /**
  * Set the read-only state of the widget.
  *
- * This should probably change the widgets's appearance and prevent it from being used.
+ * This should probably change the widget's appearance and prevent it from being used.
  *
  * @param {boolean} state Make input read-only
  * @chainable
@@ -9822,6 +10040,14 @@ OO.inheritClass( OO.ui.ComboBoxWidget, OO.ui.Widget );
 
 /* Methods */
 
+/**
+ * Get the combobox's menu.
+ * @return {OO.ui.TextInputMenuSelectWidget} Menu widget
+ */
+OO.ui.ComboBoxWidget.prototype.getMenu = function () {
+       return this.menu;
+};
+
 /**
  * Handle input change events.
  *
@@ -9901,6 +10127,7 @@ OO.ui.ComboBoxWidget.prototype.setDisabled = function ( disabled ) {
  *
  * @constructor
  * @param {Object} [config] Configuration options
+ * @cfg {OO.ui.InputWidget} [input] Input widget this label is for
  */
 OO.ui.LabelWidget = function OoUiLabelWidget( config ) {
        // Configuration initialization
@@ -9956,10 +10183,9 @@ OO.ui.LabelWidget.prototype.onClick = function () {
  * @mixins OO.ui.FlaggedElement
  *
  * @constructor
- * @param {Mixed} data Option data
  * @param {Object} [config] Configuration options
  */
-OO.ui.OptionWidget = function OoUiOptionWidget( data, config ) {
+OO.ui.OptionWidget = function OoUiOptionWidget( config ) {
        // Configuration initialization
        config = config || {};
 
@@ -9972,7 +10198,6 @@ OO.ui.OptionWidget = function OoUiOptionWidget( data, config ) {
        OO.ui.FlaggedElement.call( this, config );
 
        // Properties
-       this.data = data;
        this.selected = false;
        this.highlighted = false;
        this.pressed = false;
@@ -10136,15 +10361,6 @@ OO.ui.OptionWidget.prototype.flash = function () {
        return deferred.promise();
 };
 
-/**
- * Get option data.
- *
- * @return {Mixed} Option data
- */
-OO.ui.OptionWidget.prototype.getData = function () {
-       return this.data;
-};
-
 /**
  * Option widget with an option icon and indicator.
  *
@@ -10156,12 +10372,11 @@ OO.ui.OptionWidget.prototype.getData = function () {
  * @mixins OO.ui.IndicatorElement
  *
  * @constructor
- * @param {Mixed} data Option data
  * @param {Object} [config] Configuration options
  */
-OO.ui.DecoratedOptionWidget = function OoUiDecoratedOptionWidget( data, config ) {
+OO.ui.DecoratedOptionWidget = function OoUiDecoratedOptionWidget( config ) {
        // Parent constructor
-       OO.ui.DecoratedOptionWidget.super.call( this, data, config );
+       OO.ui.DecoratedOptionWidget.super.call( this, config );
 
        // Mixin constructors
        OO.ui.IconElement.call( this, config );
@@ -10190,12 +10405,11 @@ OO.mixinClass( OO.ui.OptionWidget, OO.ui.IndicatorElement );
  * @mixins OO.ui.ButtonElement
  *
  * @constructor
- * @param {Mixed} data Option data
  * @param {Object} [config] Configuration options
  */
-OO.ui.ButtonOptionWidget = function OoUiButtonOptionWidget( data, config ) {
+OO.ui.ButtonOptionWidget = function OoUiButtonOptionWidget( config ) {
        // Parent constructor
-       OO.ui.ButtonOptionWidget.super.call( this, data, config );
+       OO.ui.ButtonOptionWidget.super.call( this, config );
 
        // Mixin constructors
        OO.ui.ButtonElement.call( this, config );
@@ -10231,6 +10445,53 @@ OO.ui.ButtonOptionWidget.prototype.setSelected = function ( state ) {
        return this;
 };
 
+/**
+ * Option widget that looks like a radio button.
+ *
+ * Use together with OO.ui.RadioSelectWidget.
+ *
+ * @class
+ * @extends OO.ui.OptionWidget
+ *
+ * @constructor
+ * @param {Object} [config] Configuration options
+ */
+OO.ui.RadioOptionWidget = function OoUiRadioOptionWidget( config ) {
+       // Parent constructor
+       OO.ui.RadioOptionWidget.super.call( this, config );
+
+       // Properties
+       this.radio = new OO.ui.RadioInputWidget( { value: config.data } );
+
+       // Initialization
+       this.$element
+               .addClass( 'oo-ui-radioOptionWidget' )
+               .prepend( this.radio.$element );
+};
+
+/* Setup */
+
+OO.inheritClass( OO.ui.RadioOptionWidget, OO.ui.OptionWidget );
+
+/* Static Properties */
+
+OO.ui.RadioOptionWidget.static.highlightable = false;
+
+OO.ui.RadioOptionWidget.static.pressable = false;
+
+/* Methods */
+
+/**
+ * @inheritdoc
+ */
+OO.ui.RadioOptionWidget.prototype.setSelected = function ( state ) {
+       OO.ui.RadioOptionWidget.super.prototype.setSelected.call( this, state );
+
+       this.radio.setSelected( state );
+
+       return this;
+};
+
 /**
  * Item of an OO.ui.MenuSelectWidget.
  *
@@ -10238,15 +10499,14 @@ OO.ui.ButtonOptionWidget.prototype.setSelected = function ( state ) {
  * @extends OO.ui.DecoratedOptionWidget
  *
  * @constructor
- * @param {Mixed} data Item data
  * @param {Object} [config] Configuration options
  */
-OO.ui.MenuOptionWidget = function OoUiMenuOptionWidget( data, config ) {
+OO.ui.MenuOptionWidget = function OoUiMenuOptionWidget( config ) {
        // Configuration initialization
        config = $.extend( { icon: 'check' }, config );
 
        // Parent constructor
-       OO.ui.MenuOptionWidget.super.call( this, data, config );
+       OO.ui.MenuOptionWidget.super.call( this, config );
 
        // Initialization
        this.$element
@@ -10265,12 +10525,11 @@ OO.inheritClass( OO.ui.MenuOptionWidget, OO.ui.DecoratedOptionWidget );
  * @extends OO.ui.DecoratedOptionWidget
  *
  * @constructor
- * @param {Mixed} data Item data
  * @param {Object} [config] Configuration options
  */
-OO.ui.MenuSectionOptionWidget = function OoUiMenuSectionOptionWidget( data, config ) {
+OO.ui.MenuSectionOptionWidget = function OoUiMenuSectionOptionWidget( config ) {
        // Parent constructor
-       OO.ui.MenuSectionOptionWidget.super.call( this, data, config );
+       OO.ui.MenuSectionOptionWidget.super.call( this, config );
 
        // Initialization
        this.$element.addClass( 'oo-ui-menuSectionOptionWidget' );
@@ -10293,17 +10552,16 @@ OO.ui.MenuSectionOptionWidget.static.highlightable = false;
  * @extends OO.ui.DecoratedOptionWidget
  *
  * @constructor
- * @param {Mixed} data Item data
  * @param {Object} [config] Configuration options
  * @cfg {number} [level] Indentation level
  * @cfg {boolean} [movable] Allow modification from outline controls
  */
-OO.ui.OutlineOptionWidget = function OoUiOutlineOptionWidget( data, config ) {
+OO.ui.OutlineOptionWidget = function OoUiOutlineOptionWidget( config ) {
        // Configuration initialization
        config = config || {};
 
        // Parent constructor
-       OO.ui.OutlineOptionWidget.super.call( this, data, config );
+       OO.ui.OutlineOptionWidget.super.call( this, config );
 
        // Properties
        this.level = 0;
@@ -10334,7 +10592,7 @@ OO.ui.OutlineOptionWidget.static.levels = 3;
 /**
  * Check if item is movable.
  *
- * Movablilty is used by outline controls.
+ * Movability is used by outline controls.
  *
  * @return {boolean} Item is movable
  */
@@ -10345,7 +10603,7 @@ OO.ui.OutlineOptionWidget.prototype.isMovable = function () {
 /**
  * Check if item is removable.
  *
- * Removablilty is used by outline controls.
+ * Removability is used by outline controls.
  *
  * @return {boolean} Item is removable
  */
@@ -10365,7 +10623,7 @@ OO.ui.OutlineOptionWidget.prototype.getLevel = function () {
 /**
  * Set movability.
  *
- * Movablilty is used by outline controls.
+ * Movability is used by outline controls.
  *
  * @param {boolean} movable Item is movable
  * @chainable
@@ -10379,7 +10637,7 @@ OO.ui.OutlineOptionWidget.prototype.setMovable = function ( movable ) {
 /**
  * Set removability.
  *
- * Removablilty is used by outline controls.
+ * Removability is used by outline controls.
  *
  * @param {boolean} movable Item is removable
  * @chainable
@@ -10784,7 +11042,7 @@ OO.ui.ProgressBarWidget.prototype.setProgress = function ( progress ) {
  * @cfg {string} [value] Initial query value
  */
 OO.ui.SearchWidget = function OoUiSearchWidget( config ) {
-       // Configuration intialization
+       // Configuration initialization
        config = config || {};
 
        // Parent constructor
@@ -10927,8 +11185,8 @@ OO.ui.SearchWidget.prototype.getResults = function () {
 /**
  * Generic selection of options.
  *
- * Items can contain any rendering, and are uniquely identified by a hash of their data. Any widget
- * that provides options, from which the user must choose one, should be built on this class.
+ * Items can contain any rendering. Any widget that provides options, from which the user must
+ * choose one, should be built on this class.
  *
  * Use together with OO.ui.OptionWidget.
  *
@@ -10953,7 +11211,6 @@ OO.ui.SelectWidget = function OoUiSelectWidget( config ) {
        // Properties
        this.pressed = false;
        this.selecting = null;
-       this.hashes = {};
        this.onMouseUpHandler = this.onMouseUp.bind( this );
        this.onMouseMoveHandler = this.onMouseMove.bind( this );
 
@@ -11175,22 +11432,6 @@ OO.ui.SelectWidget.prototype.getHighlightedItem = function () {
        return null;
 };
 
-/**
- * Get an existing item with equivilant data.
- *
- * @param {Object} data Item data to search for
- * @return {OO.ui.OptionWidget|null} Item with equivilent value, `null` if none exists
- */
-OO.ui.SelectWidget.prototype.getItemFromData = function ( data ) {
-       var hash = OO.getHash( data );
-
-       if ( Object.prototype.hasOwnProperty.call( this.hashes, hash ) ) {
-               return this.hashes[hash];
-       }
-
-       return null;
-};
-
 /**
  * Toggle pressed state.
  *
@@ -11338,7 +11579,7 @@ OO.ui.SelectWidget.prototype.getRelativeSelectableItem = function ( item, direct
 /**
  * Get the next selectable item.
  *
- * @return {OO.ui.OptionWidget|null} Item, `null` if ther aren't any selectable items
+ * @return {OO.ui.OptionWidget|null} Item, `null` if there aren't any selectable items
  */
 OO.ui.SelectWidget.prototype.getFirstSelectableItem = function () {
        var i, len, item;
@@ -11356,31 +11597,12 @@ OO.ui.SelectWidget.prototype.getFirstSelectableItem = function () {
 /**
  * Add items.
  *
- * When items are added with the same values as existing items, the existing items will be
- * automatically removed before the new items are added.
- *
  * @param {OO.ui.OptionWidget[]} items Items to add
  * @param {number} [index] Index to insert items after
  * @fires add
  * @chainable
  */
 OO.ui.SelectWidget.prototype.addItems = function ( items, index ) {
-       var i, len, item, hash,
-               remove = [];
-
-       for ( i = 0, len = items.length; i < len; i++ ) {
-               item = items[i];
-               hash = OO.getHash( item.getData() );
-               if ( Object.prototype.hasOwnProperty.call( this.hashes, hash ) ) {
-                       // Remove item with same value
-                       remove.push( this.hashes[hash] );
-               }
-               this.hashes[hash] = item;
-       }
-       if ( remove.length ) {
-               this.removeItems( remove );
-       }
-
        // Mixin method
        OO.ui.GroupWidget.prototype.addItems.call( this, items, index );
 
@@ -11400,15 +11622,11 @@ OO.ui.SelectWidget.prototype.addItems = function ( items, index ) {
  * @chainable
  */
 OO.ui.SelectWidget.prototype.removeItems = function ( items ) {
-       var i, len, item, hash;
+       var i, len, item;
 
+       // Deselect items being removed
        for ( i = 0, len = items.length; i < len; i++ ) {
                item = items[i];
-               hash = OO.getHash( item.getData() );
-               if ( Object.prototype.hasOwnProperty.call( this.hashes, hash ) ) {
-                       // Remove existing item
-                       delete this.hashes[hash];
-               }
                if ( item.isSelected() ) {
                        this.selectItem( null );
                }
@@ -11433,10 +11651,10 @@ OO.ui.SelectWidget.prototype.removeItems = function ( items ) {
 OO.ui.SelectWidget.prototype.clearItems = function () {
        var items = this.items.slice();
 
-       // Clear all items
-       this.hashes = {};
        // Mixin method
        OO.ui.GroupWidget.prototype.clearItems.call( this );
+
+       // Clear selection
        this.selectItem( null );
 
        this.emit( 'remove', items );
@@ -11467,6 +11685,29 @@ OO.ui.ButtonSelectWidget = function OoUiButtonSelectWidget( config ) {
 
 OO.inheritClass( OO.ui.ButtonSelectWidget, OO.ui.SelectWidget );
 
+/**
+ * Select widget containing radio button options.
+ *
+ * Use together with OO.ui.RadioOptionWidget.
+ *
+ * @class
+ * @extends OO.ui.SelectWidget
+ *
+ * @constructor
+ * @param {Object} [config] Configuration options
+ */
+OO.ui.RadioSelectWidget = function OoUiRadioSelectWidget( config ) {
+       // Parent constructor
+       OO.ui.RadioSelectWidget.super.call( this, config );
+
+       // Initialization
+       this.$element.addClass( 'oo-ui-radioSelectWidget' );
+};
+
+/* Setup */
+
+OO.inheritClass( OO.ui.RadioSelectWidget, OO.ui.SelectWidget );
+
 /**
  * Overlaid menu of options.
  *
@@ -11771,7 +12012,7 @@ OO.ui.MenuSelectWidget.prototype.toggle = function ( visible ) {
  * @cfg {jQuery} [$container=input.$element] Element to render menu under
  */
 OO.ui.TextInputMenuSelectWidget = function OoUiTextInputMenuSelectWidget( input, config ) {
-       // Configuration intialization
+       // Configuration initialization
        config = config || {};
 
        // Parent constructor