Update OOjs UI to v0.1.0-pre (db065e5a9f)
authorJames D. Forrester <jforrester@wikimedia.org>
Mon, 20 Oct 2014 14:47:58 +0000 (07:47 -0700)
committerJames D. Forrester <jforrester@wikimedia.org>
Mon, 20 Oct 2014 14:49:23 +0000 (07:49 -0700)
New changes:
8e1a057 ListToolGroup: Implement collapsible/expandable tools
35b58b5 Introduce ButtonInputWidget
9ca3b79 FlaggedElement: Fix PHP notice
db065e5 Localisation updates from https://translatewiki.net.

Locally, add the two new messages to the Resources.php manifest.

Change-Id: I27a925d3f8799fe1f5635cb41de95f5d555d1f5a

17 files changed:
resources/Resources.php
resources/lib/oojs-ui/i18n/de.json
resources/lib/oojs-ui/i18n/en.json
resources/lib/oojs-ui/i18n/lb.json
resources/lib/oojs-ui/i18n/mk.json
resources/lib/oojs-ui/i18n/qqq.json
resources/lib/oojs-ui/i18n/ru.json
resources/lib/oojs-ui/i18n/sk.json
resources/lib/oojs-ui/i18n/zh-hans.json
resources/lib/oojs-ui/i18n/zh-hant.json
resources/lib/oojs-ui/oojs-ui-apex.css
resources/lib/oojs-ui/oojs-ui-apex.js
resources/lib/oojs-ui/oojs-ui-apex.svg.css
resources/lib/oojs-ui/oojs-ui-mediawiki.css
resources/lib/oojs-ui/oojs-ui-mediawiki.js
resources/lib/oojs-ui/oojs-ui-mediawiki.svg.css
resources/lib/oojs-ui/oojs-ui.js

index acc937e..ca90efa 100644 (file)
@@ -1595,6 +1595,8 @@ return array(
                        'ooui-outline-control-move-up',
                        'ooui-outline-control-remove',
                        'ooui-toolbar-more',
+                       'ooui-toolgroup-collapse',
+                       'ooui-toolgroup-expand',
                        'ooui-dialog-message-accept',
                        'ooui-dialog-message-reject',
                        'ooui-dialog-process-dismiss',
index 546689b..50d93ea 100644 (file)
@@ -17,6 +17,8 @@
        "ooui-outline-control-move-up": "Element nach oben verschieben",
        "ooui-outline-control-remove": "Element entfernen",
        "ooui-toolbar-more": "Mehr",
+       "ooui-toolgroup-expand": "Mehr",
+       "ooui-toolgroup-collapse": "Weniger",
        "ooui-dialog-message-accept": "Okay",
        "ooui-dialog-message-reject": "Abbrechen",
        "ooui-dialog-process-error": "Etwas ist schief gelaufen",
index 9e99440..d1abd47 100644 (file)
@@ -20,6 +20,8 @@
        "ooui-outline-control-move-up": "Move item up",
        "ooui-outline-control-remove": "Remove item",
        "ooui-toolbar-more": "More",
+       "ooui-toolgroup-expand": "More",
+       "ooui-toolgroup-collapse": "Fewer",
        "ooui-dialog-message-accept": "OK",
        "ooui-dialog-message-reject": "Cancel",
        "ooui-dialog-process-error": "Something went wrong",
index 1cbcb8a..270bae4 100644 (file)
@@ -14,6 +14,8 @@
        "ooui-outline-control-move-up": "Element erop réckelen",
        "ooui-outline-control-remove": "Element ewechhuelen",
        "ooui-toolbar-more": "Méi",
+       "ooui-toolgroup-expand": "Méi",
+       "ooui-toolgroup-collapse": "Manner",
        "ooui-dialog-message-accept": "OK",
        "ooui-dialog-message-reject": "Ofbriechen",
        "ooui-dialog-process-error": "Et ass eppes schif gaang",
index d628034..32856e8 100644 (file)
@@ -10,6 +10,8 @@
        "ooui-outline-control-move-up": "Помести нагоре",
        "ooui-outline-control-remove": "Отстрани ставка",
        "ooui-toolbar-more": "Повеќе",
+       "ooui-toolgroup-expand": "Повеќе",
+       "ooui-toolgroup-collapse": "Помалку",
        "ooui-dialog-message-accept": "ОК",
        "ooui-dialog-message-reject": "Откажи",
        "ooui-dialog-process-error": "Нешто не е во ред",
index 9b3bb60..b942077 100644 (file)
@@ -24,6 +24,8 @@
        "ooui-outline-control-move-up": "Tool tip for a button that moves items in a list up one place",
        "ooui-outline-control-remove": "Tool tip for a button that removes items from a list.\n{{Identical|Remove item}}",
        "ooui-toolbar-more": "Label for the toolbar group that contains a list of all other available tools.\n{{Identical|More}}",
+       "ooui-toolgroup-expand": "Label for the fake tool that expands the full list of tools in a toolbar group\n{{Identical|More}}",
+       "ooui-toolgroup-collapse": "Label for the fake tool that collapses the full list of tools in a toolbar group\n{{Identical|Fewer}}",
        "ooui-dialog-message-accept": "Default label for the accept button of a message dialog\n{{Identical|OK}}",
        "ooui-dialog-message-reject": "Default label for the reject button of a message dialog\n{{Identical|Cancel}}",
        "ooui-dialog-process-error": "Title for process dialog error description",
index efd1062..649a937 100644 (file)
@@ -22,6 +22,8 @@
        "ooui-outline-control-move-up": "Переместить элемент вверх",
        "ooui-outline-control-remove": "Удалить пункт",
        "ooui-toolbar-more": "Ещё",
+       "ooui-toolgroup-expand": "Больше",
+       "ooui-toolgroup-collapse": "Меньше",
        "ooui-dialog-message-accept": "ОК",
        "ooui-dialog-message-reject": "Отмена",
        "ooui-dialog-process-error": "Что-то пошло не так",
index 07d9828..c8246da 100644 (file)
@@ -5,8 +5,8 @@
                        "Teslaton"
                ]
        },
-       "ooui-dialog-action-close": "Zatvoriť",
        "ooui-outline-control-move-down": "Posunúť položku nadol",
        "ooui-outline-control-move-up": "Posunúť položku nahor",
+       "ooui-outline-control-remove": "Odstrániť položku",
        "ooui-toolbar-more": "Viac"
 }
index 02bdafa..fa86ea7 100644 (file)
@@ -23,6 +23,8 @@
        "ooui-outline-control-move-up": "上移项",
        "ooui-outline-control-remove": "删除项",
        "ooui-toolbar-more": "更多",
+       "ooui-toolgroup-expand": "更多",
+       "ooui-toolgroup-collapse": "更少",
        "ooui-dialog-message-accept": "确定",
        "ooui-dialog-message-reject": "取消",
        "ooui-dialog-process-error": "发生一些错误",
index cde5ffe..4b5d065 100644 (file)
@@ -20,6 +20,7 @@
        "ooui-outline-control-move-up": "項目上移",
        "ooui-outline-control-remove": "移除項目",
        "ooui-toolbar-more": "更多",
+       "ooui-toolgroup-expand": "更多",
        "ooui-dialog-message-accept": "確定",
        "ooui-dialog-message-reject": "取消",
        "ooui-dialog-process-error": "發生不明錯誤",
index 4b35bc6..30f4861 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (0d358b167a)
+ * OOjs UI v0.1.0-pre (db065e5a9f)
  * 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-10-17T23:41:15Z
+ * Date: 2014-10-20T14:47:55Z
  */
 /* @noflip */
 .oo-ui-rtl {
        border-color: #aaaaaa;
        outline: none;
 }
+.oo-ui-buttonElement-framed > input.oo-ui-buttonElement-button,
 .oo-ui-buttonElement-framed > .oo-ui-buttonElement-button > .oo-ui-labelElement-label {
        line-height: 1.9em;
 }
index 65ec878..2e4bb78 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (0d358b167a)
+ * OOjs UI v0.1.0-pre (db065e5a9f)
  * 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-10-17T23:41:06Z
+ * Date: 2014-10-20T14:47:45Z
  */
 /* Instantiation */
 
index 0d64a22..b93c30c 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (0d358b167a)
+ * OOjs UI v0.1.0-pre (db065e5a9f)
  * 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-10-17T23:41:15Z
+ * Date: 2014-10-20T14:47:55Z
  */
 /* @noflip */
 .oo-ui-rtl {
        border-color: #aaaaaa;
        outline: none;
 }
+.oo-ui-buttonElement-framed > input.oo-ui-buttonElement-button,
 .oo-ui-buttonElement-framed > .oo-ui-buttonElement-button > .oo-ui-labelElement-label {
        line-height: 1.9em;
 }
index 0132f4c..9f57ea9 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (0d358b167a)
+ * OOjs UI v0.1.0-pre (db065e5a9f)
  * 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-10-17T23:41:15Z
+ * Date: 2014-10-20T14:47:55Z
  */
 /* @noflip */
 .oo-ui-rtl {
 .oo-ui-buttonElement-framed > .oo-ui-buttonElement-button:focus {
        outline: none;
 }
+.oo-ui-buttonElement-framed > input.oo-ui-buttonElement-button,
 .oo-ui-buttonElement-framed > .oo-ui-buttonElement-button > .oo-ui-labelElement-label {
        line-height: 2.2em;
 }
index 1e536c8..8da381e 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (0d358b167a)
+ * OOjs UI v0.1.0-pre (db065e5a9f)
  * 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-10-17T23:41:06Z
+ * Date: 2014-10-20T14:47:45Z
  */
 /**
  * @class
index 1725196..08c2350 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (0d358b167a)
+ * OOjs UI v0.1.0-pre (db065e5a9f)
  * 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-10-17T23:41:15Z
+ * Date: 2014-10-20T14:47:55Z
  */
 /* @noflip */
 .oo-ui-rtl {
 .oo-ui-buttonElement-framed > .oo-ui-buttonElement-button:focus {
        outline: none;
 }
+.oo-ui-buttonElement-framed > input.oo-ui-buttonElement-button,
 .oo-ui-buttonElement-framed > .oo-ui-buttonElement-button > .oo-ui-labelElement-label {
        line-height: 2.2em;
 }
index 42743f5..41ef826 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (0d358b167a)
+ * OOjs UI v0.1.0-pre (db065e5a9f)
  * 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-10-17T23:41:06Z
+ * Date: 2014-10-20T14:47:45Z
  */
 ( function ( OO ) {
 
@@ -111,6 +111,10 @@ OO.ui.getLocalValue = function ( obj, lang, fallback ) {
                'ooui-outline-control-remove': 'Remove item',
                // Label for the toolbar group that contains a list of all other available tools
                'ooui-toolbar-more': 'More',
+               // Label for the fake tool that expands the full list of tools in a toolbar group
+               'ooui-toolgroup-expand': 'More',
+               // Label for the fake tool that collapses the full list of tools in a toolbar group
+               'ooui-toolgroup-collapse': 'Fewer',
                // Default label for the accept button of a confirmation dialog
                'ooui-dialog-message-accept': 'OK',
                // Default label for the reject button of a confirmation dialog
@@ -7499,14 +7503,29 @@ OO.ui.PopupToolGroup.prototype.setActive = function ( value ) {
 /**
  * Drop down list layout of tools as labeled icon buttons.
  *
+ * This layout allows some tools to be collapsible, controlled by a "More" / "Fewer" option at the
+ * bottom of the main list. These are not automatically positioned at the bottom of the list; you
+ * may want to use the 'promote' and 'demote' configuration options to achieve this.
+ *
  * @class
  * @extends OO.ui.PopupToolGroup
  *
  * @constructor
  * @param {OO.ui.Toolbar} toolbar
  * @param {Object} [config] Configuration options
+ * @cfg {Array} [allowCollapse] List of tools that can be collapsed. Remaining tools will be always
+ *  shown.
+ * @cfg {Array} [forceExpand] List of tools that *may not* be collapsed. All remaining tools will be
+ *  allowed to be collapsed.
+ * @cfg {boolean} [expanded=false] Whether the collapsible tools are expanded by default
  */
 OO.ui.ListToolGroup = function OoUiListToolGroup( toolbar, config ) {
+       // Properties (must be set before parent constructor, which calls #populate)
+       this.allowCollapse = config.allowCollapse;
+       this.forceExpand = config.forceExpand;
+       this.expanded = config.expanded !== undefined ? config.expanded : false;
+       this.collapsibleTools = [];
+
        // Parent constructor
        OO.ui.ListToolGroup.super.call( this, toolbar, config );
 
@@ -7524,6 +7543,96 @@ OO.ui.ListToolGroup.static.accelTooltips = true;
 
 OO.ui.ListToolGroup.static.name = 'list';
 
+/* Methods */
+
+/**
+ * @inheritdoc
+ */
+OO.ui.ListToolGroup.prototype.populate = function () {
+       var i, len, allowCollapse = [];
+
+       OO.ui.ListToolGroup.super.prototype.populate.call( this );
+
+       // Update the list of collapsible tools
+       if ( this.allowCollapse !== undefined ) {
+               allowCollapse = this.allowCollapse;
+       } else if ( this.forceExpand !== undefined ) {
+               allowCollapse = OO.simpleArrayDifference( Object.keys( this.tools ), this.forceExpand );
+       }
+
+       this.collapsibleTools = [];
+       for ( i = 0, len = allowCollapse.length; i < len; i++ ) {
+               if ( this.tools[ allowCollapse[i] ] !== undefined ) {
+                       this.collapsibleTools.push( this.tools[ allowCollapse[i] ] );
+               }
+       }
+
+       // Keep at the end, even when tools are added
+       this.$group.append( this.getExpandCollapseTool().$element );
+
+       this.getExpandCollapseTool().toggle( this.collapsibleTools.length !== 0 );
+
+       // Calling jQuery's .hide() and then .show() on a detached element caches the default value of its
+       // 'display' attribute and restores it, and the tool uses a <span> and can be hidden and re-shown.
+       // Is this a jQuery bug? http://jsfiddle.net/gtj4hu3h/
+       if ( this.getExpandCollapseTool().$element.css( 'display' ) === 'inline' ) {
+               this.getExpandCollapseTool().$element.css( 'display', 'inline-block' );
+       }
+
+       this.updateCollapsibleState();
+};
+
+OO.ui.ListToolGroup.prototype.getExpandCollapseTool = function () {
+       if ( this.expandCollapseTool === undefined ) {
+               var ExpandCollapseTool = function () {
+                       ExpandCollapseTool.super.apply( this, arguments );
+               };
+
+               OO.inheritClass( ExpandCollapseTool, OO.ui.Tool );
+
+               ExpandCollapseTool.prototype.onSelect = function () {
+                       this.toolGroup.expanded = !this.toolGroup.expanded;
+                       this.toolGroup.updateCollapsibleState();
+                       this.setActive( false );
+               };
+               ExpandCollapseTool.prototype.onUpdateState = function () {
+                       // Do nothing. Tool interface requires an implementation of this function.
+               };
+
+               ExpandCollapseTool.static.name = 'more-fewer';
+
+               this.expandCollapseTool = new ExpandCollapseTool( this );
+       }
+       return this.expandCollapseTool;
+};
+
+/**
+ * @inheritdoc
+ */
+OO.ui.ListToolGroup.prototype.onPointerUp = function ( e ) {
+       var ret = OO.ui.ListToolGroup.super.prototype.onPointerUp.call( this, e );
+
+       // Do not close the popup when the user wants to show more/fewer tools
+       if ( this.$( e.target ).closest( '.oo-ui-tool-name-more-fewer' ).length ) {
+               // Prevent the popup list from being hidden
+               this.setActive( true );
+       }
+
+       return ret;
+};
+
+OO.ui.ListToolGroup.prototype.updateCollapsibleState = function () {
+       var i, len;
+
+       this.getExpandCollapseTool()
+               .setIcon( this.expanded ? 'collapse' : 'expand' )
+               .setTitle( OO.ui.msg( this.expanded ? 'ooui-toolgroup-collapse' : 'ooui-toolgroup-expand' ) );
+
+       for ( i = 0, len = this.collapsibleTools.length; i < len; i++ ) {
+               this.collapsibleTools[i].toggle( this.expanded );
+       }
+};
+
 /**
  * Drop down menu layout of tools as selectable menu items.
  *
@@ -8998,6 +9107,140 @@ OO.ui.InputWidget.prototype.blur = function () {
        return this;
 };
 
+/**
+ * A button that is an input widget. Intended to be used within FormLayouts.
+ *
+ * @class
+ * @extends OO.ui.InputWidget
+ * @mixins OO.ui.ButtonElement
+ * @mixins OO.ui.IconElement
+ * @mixins OO.ui.IndicatorElement
+ * @mixins OO.ui.LabelElement
+ * @mixins OO.ui.TitledElement
+ * @mixins OO.ui.FlaggedElement
+ *
+ * @constructor
+ * @param {Object} [config] Configuration options
+ * @cfg {string} [type='button'] HTML tag `type` attribute, may be 'button', 'submit' or 'reset'
+ * @cfg {boolean} [useInputTag=false] Whether to use `<input/>` rather than `<button/>`. Only useful
+ *  if you need IE 6 support in a form with multiple buttons. By using this option, you sacrifice
+ *  icons and indicators, as well as the ability to have non-plaintext label or a label different
+ *  from the value.
+ */
+OO.ui.ButtonInputWidget = function OoUiButtonInputWidget( config ) {
+       // Configuration initialization
+       config = $.extend( { type: 'button', useInputTag: false }, config );
+
+       // Parent constructor
+       OO.ui.ButtonInputWidget.super.call( this, config );
+
+       // Mixin constructors
+       OO.ui.ButtonElement.call( this, $.extend( {}, config, { $button: this.$input } ) );
+       OO.ui.IconElement.call( this, config );
+       OO.ui.IndicatorElement.call( this, config );
+       OO.ui.LabelElement.call( this, config );
+       OO.ui.TitledElement.call( this, $.extend( {}, config, { $titled: this.$input } ) );
+       OO.ui.FlaggedElement.call( this, config );
+
+       // Properties
+       this.useInputTag = config.useInputTag;
+
+       // Events
+       this.$input.on( {
+               click: this.onClick.bind( this ),
+               keypress: this.onKeyPress.bind( this )
+       } );
+
+       // Initialization
+       if ( !config.useInputTag ) {
+               this.$input.append( this.$icon, this.$label, this.$indicator );
+       }
+       this.$element.addClass( 'oo-ui-buttonInputWidget' );
+};
+
+/* Setup */
+
+OO.inheritClass( OO.ui.ButtonInputWidget, OO.ui.InputWidget );
+OO.mixinClass( OO.ui.ButtonInputWidget, OO.ui.ButtonElement );
+OO.mixinClass( OO.ui.ButtonInputWidget, OO.ui.IconElement );
+OO.mixinClass( OO.ui.ButtonInputWidget, OO.ui.IndicatorElement );
+OO.mixinClass( OO.ui.ButtonInputWidget, OO.ui.LabelElement );
+OO.mixinClass( OO.ui.ButtonInputWidget, OO.ui.TitledElement );
+OO.mixinClass( OO.ui.ButtonInputWidget, OO.ui.FlaggedElement );
+
+/* Events */
+
+/**
+ * @event click
+ */
+
+/* Methods */
+
+/**
+ * Get input element.
+ *
+ * @param {Object} [config] Configuration options
+ * @return {jQuery} Input element
+ */
+OO.ui.ButtonInputWidget.prototype.getInputElement = function ( config ) {
+       var html = '<' + ( config.useInputTag ? 'input' : 'button' ) + ' type="' + config.type + '">';
+       return this.$( html );
+};
+
+/**
+ * Set the label.
+ *
+ * Overridden to support setting the 'value' of `<input/>` elements.
+ *
+ * @param {jQuery|string|Function|null} label Label nodes; text; a function that returns nodes or
+ *  text; or null for no label
+ * @chainable
+ */
+OO.ui.ButtonInputWidget.prototype.setLabel = function ( label ) {
+       OO.ui.LabelElement.prototype.setLabel.call( this, label );
+
+       if ( this.useInputTag ) {
+               if ( typeof label === 'function' ) {
+                       label = OO.ui.resolveMsg( label );
+               }
+               if ( label instanceof jQuery ) {
+                       label = label.text();
+               }
+               if ( !label ) {
+                       label = '';
+               }
+               this.$input.val( label );
+       }
+
+       return this;
+};
+
+/**
+ * Handles mouse click events.
+ *
+ * @param {jQuery.Event} e Mouse click event
+ * @fires click
+ */
+OO.ui.ButtonInputWidget.prototype.onClick = function () {
+       if ( !this.isDisabled() ) {
+               this.emit( 'click' );
+       }
+       return false;
+};
+
+/**
+ * Handles keypress events.
+ *
+ * @param {jQuery.Event} e Keypress event
+ * @fires click
+ */
+OO.ui.ButtonInputWidget.prototype.onKeyPress = function ( e ) {
+       if ( !this.isDisabled() && ( e.which === OO.ui.Keys.SPACE || e.which === OO.ui.Keys.ENTER ) ) {
+               this.emit( 'click' );
+       }
+       return false;
+};
+
 /**
  * Checkbox input widget.
  *