X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Flib%2Foojs-ui%2Foojs-ui-core.js;h=082b7eca3f7f0c03030ef38b8d2394091611d021;hb=641c6d1f15f866770d44b67c1efc5f9fc0763d9e;hp=543672e6ac1c8249f6663506854ad8f66acdfdea;hpb=f2bb88c90ba8e44e141fb9481dc9eef5ad32bd36;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/lib/oojs-ui/oojs-ui-core.js b/resources/lib/oojs-ui/oojs-ui-core.js index 543672e6ac..082b7eca3f 100644 --- a/resources/lib/oojs-ui/oojs-ui-core.js +++ b/resources/lib/oojs-ui/oojs-ui-core.js @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.23.1 + * OOjs UI v0.24.0 * https://www.mediawiki.org/wiki/OOjs_UI * * Copyright 2011–2017 OOjs UI Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: 2017-09-20T00:31:56Z + * Date: 2017-10-17T23:18:51Z */ ( function ( OO ) { @@ -581,7 +581,9 @@ OO.ui.mixin = {}; * Data can also be specified with the #setData method. */ OO.ui.Element = function OoUiElement( config ) { - this.initialConfig = config; + if ( OO.ui.isDemo ) { + this.initialConfig = config; + } // Configuration initialization config = config || {}; @@ -2953,23 +2955,38 @@ OO.ui.mixin.LabelElement.static.label = null; * * @param {string} text Text * @param {string} query Query to find + * @param {Function} [compare] Optional string comparator, e.g. Intl.Collator().compare * @return {jQuery} Text with the first match of the query * sub-string wrapped in highlighted span */ -OO.ui.mixin.LabelElement.static.highlightQuery = function ( text, query ) { - var $result = $( '' ), +OO.ui.mixin.LabelElement.static.highlightQuery = function ( text, query, compare ) { + var i, tLen, qLen, + offset = -1, + $result = $( '' ); + + if ( compare ) { + tLen = text.length; + qLen = query.length; + for ( i = 0; offset === -1 && i <= tLen - qLen; i++ ) { + if ( compare( query, text.slice( i, i + qLen ) ) === 0 ) { + offset = i; + } + } + } else { offset = text.toLowerCase().indexOf( query.toLowerCase() ); + } if ( !query.length || offset === -1 ) { - return $result.text( text ); - } - $result.append( - document.createTextNode( text.slice( 0, offset ) ), - $( '' ) - .addClass( 'oo-ui-labelElement-label-highlight' ) - .text( text.slice( offset, offset + query.length ) ), - document.createTextNode( text.slice( offset + query.length ) ) - ); + $result.text( text ); + } else { + $result.append( + document.createTextNode( text.slice( 0, offset ) ), + $( '' ) + .addClass( 'oo-ui-labelElement-label-highlight' ) + .text( text.slice( offset, offset + query.length ) ), + document.createTextNode( text.slice( offset + query.length ) ) + ); + } return $result.contents(); }; @@ -3023,10 +3040,11 @@ OO.ui.mixin.LabelElement.prototype.setLabel = function ( label ) { * * @param {string} text Text label to set * @param {string} query Substring of text to highlight + * @param {Function} [compare] Optional string comparator, e.g. Intl.Collator().compare * @chainable */ -OO.ui.mixin.LabelElement.prototype.setHighlightedQuery = function ( text, query ) { - return this.setLabel( this.constructor.static.highlightQuery( text, query ) ); +OO.ui.mixin.LabelElement.prototype.setHighlightedQuery = function ( text, query, compare ) { + return this.setLabel( this.constructor.static.highlightQuery( text, query, compare ) ); }; /** @@ -3076,25 +3094,21 @@ OO.ui.mixin.LabelElement.prototype.setLabelContent = function ( label ) { * * - **progressive**: Progressive styling is applied to convey that the widget will move the user forward in a process. * - **destructive**: Destructive styling is applied to convey that the widget will remove something. - * - **constructive**: Constructive styling is applied to convey that the widget will create something. + * - **constructive**: Constructive styling is deprecated since v0.23.2 and equivalent to progressive. * * The flags affect the appearance of the buttons: * * @example * // FlaggedElement is mixed into ButtonWidget to provide styling flags * var button1 = new OO.ui.ButtonWidget( { - * label: 'Constructive', - * flags: 'constructive' + * label: 'Progressive', + * flags: 'progressive' * } ); * var button2 = new OO.ui.ButtonWidget( { * label: 'Destructive', * flags: 'destructive' * } ); - * var button3 = new OO.ui.ButtonWidget( { - * label: 'Progressive', - * flags: 'progressive' - * } ); - * $( 'body' ).append( button1.$element, button2.$element, button3.$element ); + * $( 'body' ).append( button1.$element, button2.$element ); * * {@link OO.ui.ActionWidget ActionWidgets}, which are a special kind of button that execute an action, use these flags: **primary** and **safe**. * Please see the [OOjs UI documentation on MediaWiki] [1] for more information. @@ -3106,7 +3120,7 @@ OO.ui.mixin.LabelElement.prototype.setLabelContent = function ( label ) { * * @constructor * @param {Object} [config] Configuration options - * @cfg {string|string[]} [flags] The name or names of the flags (e.g., 'constructive' or 'primary') to apply. + * @cfg {string|string[]} [flags] The name or names of the flags (e.g., 'progressive' or 'primary') to apply. * Please see the [OOjs UI documentation on MediaWiki] [2] for more information about available flags. * [2]: https://www.mediawiki.org/wiki/OOjs_UI/Elements/Flagged * @cfg {jQuery} [$flagged] The flagged element. By default, @@ -5346,7 +5360,9 @@ OO.ui.PopupWidget.prototype.computePosition = function () { floatablePos = this.$floatableContainer.offset(); floatablePos[ far ] = floatablePos[ near ] + this.$floatableContainer[ 'outer' + sizeProp ](); // Measure where the offsetParent is and compute our position based on that and parentPosition - offsetParentPos = this.$element.offsetParent().offset(); + offsetParentPos = this.$element.offsetParent()[ 0 ] === document.documentElement ? + { top: 0, left: 0 } : + this.$element.offsetParent().offset(); if ( positionProp === near ) { popupPos[ near ] = offsetParentPos[ near ] + parentPosition[ near ]; @@ -5382,7 +5398,9 @@ OO.ui.PopupWidget.prototype.computePosition = function () { } // Check if the popup will go beyond the edge of this.$container - containerPos = this.$container.offset(); + containerPos = this.$container[ 0 ] === document.documentElement ? + { top: 0, left: 0 } : + this.$container.offset(); containerPos[ far ] = containerPos[ near ] + this.$container[ 'inner' + sizeProp ](); // Take into account how much the popup will move because of the adjustments we're going to make popupPos[ near ] += ( positionProp === near ? 1 : -1 ) * positionAdjustment; @@ -6071,9 +6089,16 @@ OO.ui.SelectWidget.prototype.onFocus = function ( event ) { item = this.findFirstSelectableItem(); } } else { - // One of the options got focussed (and the event bubbled up here). - // They can't be tabbed to, but they can be activated using accesskeys. - item = this.findTargetItem( event ); + if ( event.target.tabIndex === -1 ) { + // One of the options got focussed (and the event bubbled up here). + // They can't be tabbed to, but they can be activated using accesskeys. + // OptionWidgets and focusable UI elements inside them have tabindex="-1" set. + item = this.findTargetItem( event ); + } else { + // There is something actually user-focusable in one of the labels of the options, and the + // user focussed it (e.g. by tabbing to it). Do nothing (especially, don't change the focus). + return; + } } if ( item ) { @@ -9929,7 +9954,7 @@ OO.ui.TextInputWidget.prototype.getInputElement = function ( config ) { * * @param {Object} config Configuration options * @return {string|null} - * @private + * @protected */ OO.ui.TextInputWidget.prototype.getSaneType = function ( config ) { var allowedTypes = [ @@ -10257,10 +10282,6 @@ OO.ui.SearchInputWidget = function OoUiSearchInputWidget( config ) { icon: 'search' }, config ); - // Set type to text so that TextInputWidget doesn't - // get stuck in an infinite loop. - config.type = 'text'; - // Parent constructor OO.ui.SearchInputWidget.parent.call( this, config ); @@ -10270,7 +10291,6 @@ OO.ui.SearchInputWidget = function OoUiSearchInputWidget( config ) { } ); // Initialization - this.$element.addClass( 'oo-ui-textInputWidget-type-search' ); this.updateSearchIndicator(); this.connect( this, { disable: 'onDisable' @@ -10287,8 +10307,8 @@ OO.inheritClass( OO.ui.SearchInputWidget, OO.ui.TextInputWidget ); * @inheritdoc * @protected */ -OO.ui.SearchInputWidget.prototype.getInputElement = function () { - return $( '' ).attr( 'type', 'search' ); +OO.ui.SearchInputWidget.prototype.getSaneType = function () { + return 'search'; }; /**