From 4950eafb2504e75b4b1eb57fac77af310ae2b6f6 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Mon, 20 Oct 2014 07:47:58 -0700 Subject: [PATCH] Update OOjs UI to v0.1.0-pre (db065e5a9f) 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 --- resources/Resources.php | 2 + resources/lib/oojs-ui/i18n/de.json | 2 + resources/lib/oojs-ui/i18n/en.json | 2 + resources/lib/oojs-ui/i18n/lb.json | 2 + resources/lib/oojs-ui/i18n/mk.json | 2 + resources/lib/oojs-ui/i18n/qqq.json | 2 + resources/lib/oojs-ui/i18n/ru.json | 2 + resources/lib/oojs-ui/i18n/sk.json | 2 +- resources/lib/oojs-ui/i18n/zh-hans.json | 2 + resources/lib/oojs-ui/i18n/zh-hant.json | 1 + resources/lib/oojs-ui/oojs-ui-apex.css | 5 +- resources/lib/oojs-ui/oojs-ui-apex.js | 4 +- resources/lib/oojs-ui/oojs-ui-apex.svg.css | 5 +- resources/lib/oojs-ui/oojs-ui-mediawiki.css | 5 +- resources/lib/oojs-ui/oojs-ui-mediawiki.js | 4 +- .../lib/oojs-ui/oojs-ui-mediawiki.svg.css | 5 +- resources/lib/oojs-ui/oojs-ui.js | 247 +++++++++++++++++- 17 files changed, 279 insertions(+), 15 deletions(-) diff --git a/resources/Resources.php b/resources/Resources.php index acc937e2e7..ca90efa8dc 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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', diff --git a/resources/lib/oojs-ui/i18n/de.json b/resources/lib/oojs-ui/i18n/de.json index 546689b9e0..50d93eadc0 100644 --- a/resources/lib/oojs-ui/i18n/de.json +++ b/resources/lib/oojs-ui/i18n/de.json @@ -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", diff --git a/resources/lib/oojs-ui/i18n/en.json b/resources/lib/oojs-ui/i18n/en.json index 9e99440c5f..d1abd47c0e 100644 --- a/resources/lib/oojs-ui/i18n/en.json +++ b/resources/lib/oojs-ui/i18n/en.json @@ -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", diff --git a/resources/lib/oojs-ui/i18n/lb.json b/resources/lib/oojs-ui/i18n/lb.json index 1cbcb8adb9..270bae4695 100644 --- a/resources/lib/oojs-ui/i18n/lb.json +++ b/resources/lib/oojs-ui/i18n/lb.json @@ -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", diff --git a/resources/lib/oojs-ui/i18n/mk.json b/resources/lib/oojs-ui/i18n/mk.json index d628034b4b..32856e80d2 100644 --- a/resources/lib/oojs-ui/i18n/mk.json +++ b/resources/lib/oojs-ui/i18n/mk.json @@ -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": "Нешто не е во ред", diff --git a/resources/lib/oojs-ui/i18n/qqq.json b/resources/lib/oojs-ui/i18n/qqq.json index 9b3bb6053c..b94207781e 100644 --- a/resources/lib/oojs-ui/i18n/qqq.json +++ b/resources/lib/oojs-ui/i18n/qqq.json @@ -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", diff --git a/resources/lib/oojs-ui/i18n/ru.json b/resources/lib/oojs-ui/i18n/ru.json index efd106275d..649a9377ea 100644 --- a/resources/lib/oojs-ui/i18n/ru.json +++ b/resources/lib/oojs-ui/i18n/ru.json @@ -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": "Что-то пошло не так", diff --git a/resources/lib/oojs-ui/i18n/sk.json b/resources/lib/oojs-ui/i18n/sk.json index 07d9828692..c8246da97f 100644 --- a/resources/lib/oojs-ui/i18n/sk.json +++ b/resources/lib/oojs-ui/i18n/sk.json @@ -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" } diff --git a/resources/lib/oojs-ui/i18n/zh-hans.json b/resources/lib/oojs-ui/i18n/zh-hans.json index 02bdafad6a..fa86ea7062 100644 --- a/resources/lib/oojs-ui/i18n/zh-hans.json +++ b/resources/lib/oojs-ui/i18n/zh-hans.json @@ -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": "发生一些错误", diff --git a/resources/lib/oojs-ui/i18n/zh-hant.json b/resources/lib/oojs-ui/i18n/zh-hant.json index cde5ffe743..4b5d065d70 100644 --- a/resources/lib/oojs-ui/i18n/zh-hant.json +++ b/resources/lib/oojs-ui/i18n/zh-hant.json @@ -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": "發生不明錯誤", diff --git a/resources/lib/oojs-ui/oojs-ui-apex.css b/resources/lib/oojs-ui/oojs-ui-apex.css index 4b35bc6332..30f4861c94 100644 --- a/resources/lib/oojs-ui/oojs-ui-apex.css +++ b/resources/lib/oojs-ui/oojs-ui-apex.css @@ -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 { @@ -144,6 +144,7 @@ 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; } diff --git a/resources/lib/oojs-ui/oojs-ui-apex.js b/resources/lib/oojs-ui/oojs-ui-apex.js index 65ec878bbb..2e4bb784d9 100644 --- a/resources/lib/oojs-ui/oojs-ui-apex.js +++ b/resources/lib/oojs-ui/oojs-ui-apex.js @@ -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 */ diff --git a/resources/lib/oojs-ui/oojs-ui-apex.svg.css b/resources/lib/oojs-ui/oojs-ui-apex.svg.css index 0d64a22b6c..b93c30c64d 100644 --- a/resources/lib/oojs-ui/oojs-ui-apex.svg.css +++ b/resources/lib/oojs-ui/oojs-ui-apex.svg.css @@ -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 { @@ -144,6 +144,7 @@ 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; } diff --git a/resources/lib/oojs-ui/oojs-ui-mediawiki.css b/resources/lib/oojs-ui/oojs-ui-mediawiki.css index 0132f4c4b3..9f57ea9161 100644 --- a/resources/lib/oojs-ui/oojs-ui-mediawiki.css +++ b/resources/lib/oojs-ui/oojs-ui-mediawiki.css @@ -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 { @@ -154,6 +154,7 @@ .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; } diff --git a/resources/lib/oojs-ui/oojs-ui-mediawiki.js b/resources/lib/oojs-ui/oojs-ui-mediawiki.js index 1e536c85d9..8da381e02c 100644 --- a/resources/lib/oojs-ui/oojs-ui-mediawiki.js +++ b/resources/lib/oojs-ui/oojs-ui-mediawiki.js @@ -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 diff --git a/resources/lib/oojs-ui/oojs-ui-mediawiki.svg.css b/resources/lib/oojs-ui/oojs-ui-mediawiki.svg.css index 17251960d1..08c2350ae4 100644 --- a/resources/lib/oojs-ui/oojs-ui-mediawiki.svg.css +++ b/resources/lib/oojs-ui/oojs-ui-mediawiki.svg.css @@ -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 { @@ -154,6 +154,7 @@ .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; } diff --git a/resources/lib/oojs-ui/oojs-ui.js b/resources/lib/oojs-ui/oojs-ui.js index 42743f52d3..41ef826b4f 100644 --- a/resources/lib/oojs-ui/oojs-ui.js +++ b/resources/lib/oojs-ui/oojs-ui.js @@ -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 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 `` rather than `