/*!
- * OOUI v0.29.2
+ * OOUI v0.29.3
* 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-10-08T22:42:55Z
+ * Date: 2018-11-01T02:03:33Z
*/
( function ( OO ) {
* by setting the #continuous option to 'true'.
*
* @example
- * // A stack layout with two panels, configured to be displayed continously
+ * // A stack layout with two panels, configured to be displayed continuously
* var myStack = new OO.ui.StackLayout( {
* items: [
* new OO.ui.PanelLayout( {
return this;
};
+/**
+ * Reset the scroll offset of all panels, or the container if continuous
+ *
+ * @inheritdoc
+ */
+OO.ui.StackLayout.prototype.resetScroll = function () {
+ if ( this.continuous ) {
+ // Parent method
+ return OO.ui.StackLayout.parent.prototype.resetScroll.call( this );
+ }
+ // Reset each panel
+ this.getItems().forEach( function ( panel ) {
+ var hidden = panel.$element.hasClass( 'oo-ui-element-hidden' );
+ // Scroll can only be reset when panel is visible
+ panel.$element.removeClass( 'oo-ui-element-hidden' );
+ panel.resetScroll();
+ if ( hidden ) {
+ panel.$element.addClass( 'oo-ui-element-hidden' );
+ }
+ } );
+
+ return this;
+};
+
/**
* Update the visibility of all items in case of non-continuous view.
*
this.$content.empty();
};
+/**
+ * Reset the scroll offset of all panels and the tab select widget
+ *
+ * @inheritdoc
+ */
+OO.ui.MenuLayout.prototype.resetScroll = function () {
+ if ( this.menuPanel ) {
+ this.menuPanel.resetScroll();
+ }
+ if ( this.contentPanel ) {
+ this.contentPanel.resetScroll();
+ }
+
+ return this;
+};
+
/**
* BookletLayouts contain {@link OO.ui.PageLayout page layouts} as well as
* an {@link OO.ui.OutlineSelectWidget outline} that allows users to easily navigate
* outlined: true
* } );
*
- * booklet.addPages ( [ page1, page2 ] );
+ * booklet.addPages( [ page1, page2 ] );
* $( 'body' ).append( booklet.$element );
*
* @class
}
};
+/**
+ * For outlined-continuous booklets, also reset the outlineSelectWidget to the first item.
+ *
+ * @inheritdoc
+ */
+OO.ui.BookletLayout.prototype.resetScroll = function () {
+ // Parent method
+ OO.ui.BookletLayout.parent.prototype.resetScroll.call( this );
+
+ if ( this.outlined && this.stackLayout.continuous && this.outlineSelectWidget.findFirstSelectableItem() ) {
+ this.scrolling = true;
+ this.outlineSelectWidget.selectItem( this.outlineSelectWidget.findFirstSelectableItem() );
+ this.scrolling = false;
+ }
+ return this;
+};
+
/**
* Select the first selectable page.
*
OO.ui.IndexLayout.prototype.setTabPanel = function ( name ) {
var selectedItem,
$focused,
- tabPanel = this.tabPanels[ name ],
- previousTabPanel = this.currentTabPanelName && this.tabPanels[ this.currentTabPanelName ];
+ previousTabPanel,
+ tabPanel = this.tabPanels[ name ];
if ( name !== this.currentTabPanelName ) {
+ previousTabPanel = this.getCurrentTabPanel();
selectedItem = this.tabSelectWidget.findSelectedItem();
if ( selectedItem && selectedItem.getData() !== name ) {
this.tabSelectWidget.selectItemByData( name );
if ( this.inputPosition === 'outline' ) {
// Override max-height for the input widget
// in the case the widget is outline so it can
- // stretch all the way if the widet is wide
+ // stretch all the way if the widget is wide
this.input.$element.css( 'max-width', 'inherit' );
this.$element
.addClass( 'oo-ui-tagMultiselectWidget-outlined' )
// Some safety margin for sanity, because I *really* don't feel like finding out where the few
// pixels this is off by are coming from.
- bestWidth -= 10;
+ bestWidth -= 13;
if ( contentWidth > bestWidth ) {
// This will result in the input getting shifted to the next line
- bestWidth = this.$content.innerWidth() - 10;
+ bestWidth = this.$content.innerWidth() - 13;
}
this.input.$input.width( Math.floor( bestWidth ) );
this.updateIfHeightChanged();