From 422c3ce9340080e50d58b73a271b6227d5554f61 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Tue, 1 Apr 2014 19:33:44 -0700 Subject: [PATCH] Update OOjs UI to v0.1.0-pre (8986c46d35) New changes: 735cebc Filter calls to selectItem and highlightItem on SelectWidget 897b30f Return null in Element#getDocument b5ede88 Add Element#isElementAttached 68df19f Disable tool groups when all its tools are disabled 1aaa507 Grunt-watch less files e4dd7b2 build: Update devDependencies 64d6c32 Localisation updates from https://translatewiki.net. b5c6db5 Localisation updates from https://translatewiki.net. b9460cb apex/button: Reset border-color of disabled button when not hovered 32c4799 Localisation updates from https://translatewiki.net. 674165e Enable jscs for OOjs UI repo d98b338 grunt: Add messageDocumentation task to ensure each 'en' message has a 'qqq' d421dd6 demos/tools: Indentation fix Change-Id: Ic9b7ff01fe066eb5cba6a0fd0fc515ff3c62b66a --- resources/oojs-ui/i18n/bg.json | 4 +- resources/oojs-ui/i18n/dsb.json | 3 +- resources/oojs-ui/i18n/el.json | 7 +- resources/oojs-ui/i18n/es.json | 2 +- resources/oojs-ui/i18n/et.json | 2 +- resources/oojs-ui/i18n/hi.json | 2 +- resources/oojs-ui/i18n/kk-cyrl.json | 2 +- resources/oojs-ui/i18n/ms.json | 5 +- resources/oojs-ui/i18n/pl.json | 2 +- resources/oojs-ui/i18n/qu.json | 2 +- resources/oojs-ui/i18n/zh-hans.json | 2 +- resources/oojs-ui/oojs-ui-apex.css | 1 + resources/oojs-ui/oojs-ui.js | 119 ++++++++++++++++++++++------ resources/oojs-ui/oojs-ui.svg.css | 4 +- 14 files changed, 114 insertions(+), 43 deletions(-) diff --git a/resources/oojs-ui/i18n/bg.json b/resources/oojs-ui/i18n/bg.json index 939719b4da..6006244274 100644 --- a/resources/oojs-ui/i18n/bg.json +++ b/resources/oojs-ui/i18n/bg.json @@ -8,6 +8,6 @@ ] }, "ooui-dialog-action-close": "Затваряне", - "ooui-outline-control-remove": "Премахване на обекти", + "ooui-outline-control-remove": "Премахване на обекта", "ooui-toolbar-more": "Още" -} \ No newline at end of file +} diff --git a/resources/oojs-ui/i18n/dsb.json b/resources/oojs-ui/i18n/dsb.json index 0f47587c87..ef60093352 100644 --- a/resources/oojs-ui/i18n/dsb.json +++ b/resources/oojs-ui/i18n/dsb.json @@ -7,5 +7,6 @@ "ooui-dialog-action-close": "Zacyniś", "ooui-outline-control-move-down": "Element dołoj pśesunuś", "ooui-outline-control-move-up": "Element górjej pśesunuś", + "ooui-outline-control-remove": "Zapisk wótpóraś", "ooui-toolbar-more": "Wěcej" -} \ No newline at end of file +} diff --git a/resources/oojs-ui/i18n/el.json b/resources/oojs-ui/i18n/el.json index 66051f157f..d1ef8b237e 100644 --- a/resources/oojs-ui/i18n/el.json +++ b/resources/oojs-ui/i18n/el.json @@ -12,7 +12,8 @@ ] }, "ooui-dialog-action-close": "Κλείσιμο", - "ooui-outline-control-move-down": "Μετακίνηση προς τα κάτω", - "ooui-outline-control-move-up": "Μετακίνηση προς τα πάνω", + "ooui-outline-control-move-down": "Μετακίνηση στοιχείου προς τα κάτω", + "ooui-outline-control-move-up": "Μετακίνηση στοιχείου προς τα επάνω", + "ooui-outline-control-remove": "Αφαίρεση στοιχείου", "ooui-toolbar-more": "Περισσότερα" -} \ No newline at end of file +} diff --git a/resources/oojs-ui/i18n/es.json b/resources/oojs-ui/i18n/es.json index eb531386b1..a3be7490d4 100644 --- a/resources/oojs-ui/i18n/es.json +++ b/resources/oojs-ui/i18n/es.json @@ -21,4 +21,4 @@ "ooui-outline-control-move-up": "Mover arriba", "ooui-outline-control-remove": "Eliminar elemento", "ooui-toolbar-more": "Más" -} \ No newline at end of file +} diff --git a/resources/oojs-ui/i18n/et.json b/resources/oojs-ui/i18n/et.json index aa780e4631..f0ddc39145 100644 --- a/resources/oojs-ui/i18n/et.json +++ b/resources/oojs-ui/i18n/et.json @@ -10,4 +10,4 @@ "ooui-outline-control-move-up": "Liiguta üksust ülespoole", "ooui-outline-control-remove": "Eemalda üksus", "ooui-toolbar-more": "Veel" -} \ No newline at end of file +} diff --git a/resources/oojs-ui/i18n/hi.json b/resources/oojs-ui/i18n/hi.json index 3c41b3e447..ae895d128c 100644 --- a/resources/oojs-ui/i18n/hi.json +++ b/resources/oojs-ui/i18n/hi.json @@ -13,4 +13,4 @@ "ooui-outline-control-move-up": "प्रविष्टि ऊपर ले जाएँ", "ooui-outline-control-remove": "आइटम हटाएँ", "ooui-toolbar-more": "अधिक" -} \ No newline at end of file +} diff --git a/resources/oojs-ui/i18n/kk-cyrl.json b/resources/oojs-ui/i18n/kk-cyrl.json index df37fe3a64..7213dad73a 100644 --- a/resources/oojs-ui/i18n/kk-cyrl.json +++ b/resources/oojs-ui/i18n/kk-cyrl.json @@ -9,4 +9,4 @@ "ooui-outline-control-move-up": "Элементті жоғары жылжыту", "ooui-outline-control-remove": "Элементті алып тастау", "ooui-toolbar-more": "толығырақ" -} \ No newline at end of file +} diff --git a/resources/oojs-ui/i18n/ms.json b/resources/oojs-ui/i18n/ms.json index 21aef50f53..4f78aaa6dd 100644 --- a/resources/oojs-ui/i18n/ms.json +++ b/resources/oojs-ui/i18n/ms.json @@ -8,5 +8,6 @@ "ooui-dialog-action-close": "Tutup", "ooui-outline-control-move-down": "Alihkan perkara ke bawah", "ooui-outline-control-move-up": "Alihkan perkara ke atas", - "ooui-toolbar-more": "Lagi" -} \ No newline at end of file + "ooui-outline-control-remove": "Buang perkara", + "ooui-toolbar-more": "Selebihnya" +} diff --git a/resources/oojs-ui/i18n/pl.json b/resources/oojs-ui/i18n/pl.json index 33ff886190..2cb7330795 100644 --- a/resources/oojs-ui/i18n/pl.json +++ b/resources/oojs-ui/i18n/pl.json @@ -21,4 +21,4 @@ "ooui-outline-control-move-up": "Przenieś wyżej", "ooui-outline-control-remove": "Usuń element", "ooui-toolbar-more": "Więcej" -} \ No newline at end of file +} diff --git a/resources/oojs-ui/i18n/qu.json b/resources/oojs-ui/i18n/qu.json index d98b0e4539..4442528fc7 100644 --- a/resources/oojs-ui/i18n/qu.json +++ b/resources/oojs-ui/i18n/qu.json @@ -10,4 +10,4 @@ "ooui-outline-control-move-up": "Qallawata huqariy", "ooui-outline-control-remove": "P'anqa sutikunata qichuy", "ooui-toolbar-more": "Aswan" -} \ No newline at end of file +} diff --git a/resources/oojs-ui/i18n/zh-hans.json b/resources/oojs-ui/i18n/zh-hans.json index 58e8ebe6d6..e8041ca7d3 100644 --- a/resources/oojs-ui/i18n/zh-hans.json +++ b/resources/oojs-ui/i18n/zh-hans.json @@ -23,4 +23,4 @@ "ooui-outline-control-move-up": "上移项", "ooui-outline-control-remove": "移除项", "ooui-toolbar-more": "更多" -} \ No newline at end of file +} diff --git a/resources/oojs-ui/oojs-ui-apex.css b/resources/oojs-ui/oojs-ui-apex.css index 091f4fc594..aa5d78fbfa 100644 --- a/resources/oojs-ui/oojs-ui-apex.css +++ b/resources/oojs-ui/oojs-ui-apex.css @@ -264,6 +264,7 @@ .oo-ui-buttonedElement-framed.oo-ui-widget-disabled .oo-ui-buttonedElement-button.oo-ui-buttonedElement-pressed { color: #333; background: #eee; + border-color: #ccc; opacity: 0.5; box-shadow: none; } diff --git a/resources/oojs-ui/oojs-ui.js b/resources/oojs-ui/oojs-ui.js index 937ff33caa..9a1e324ac4 100644 --- a/resources/oojs-ui/oojs-ui.js +++ b/resources/oojs-ui/oojs-ui.js @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.1.0-pre (23fb1b6144) + * OOjs UI v0.1.0-pre (8986c46d35) * 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: Thu Mar 27 2014 14:49:30 GMT-0700 (PDT) + * Date: Tue Apr 01 2014 19:33:39 GMT-0700 (PDT) */ ( function ( OO ) { @@ -237,13 +237,11 @@ OO.ui.Element.getJQuery = function ( context, frame ) { * * @static * @param {jQuery|HTMLElement|HTMLDocument|Window} obj Object to get the document for - * @return {HTMLDocument} Document object - * @throws {Error} If context is invalid + * @return {HTMLDocument|null} Document object */ OO.ui.Element.getDocument = function ( obj ) { - var doc = - // jQuery - selections created "offscreen" won't have a context, so .context isn't reliable - ( obj[0] && obj[0].ownerDocument ) || + // jQuery - selections created "offscreen" won't have a context, so .context isn't reliable + return ( obj[0] && obj[0].ownerDocument ) || // Empty jQuery selections might have a context obj.context || // HTMLElement @@ -251,13 +249,8 @@ OO.ui.Element.getDocument = function ( obj ) { // Window obj.document || // HTMLDocument - ( obj.nodeType === 9 && obj ); - - if ( doc ) { - return doc; - } - - throw new Error( 'Invalid context' ); + ( obj.nodeType === 9 && obj ) || + null; }; /** @@ -533,6 +526,14 @@ OO.ui.Element.prototype.getTagName = function () { return this.constructor.static.tagName; }; +/** + * Check if the element is attached to the DOM + * @return {boolean} The element is attached to the DOM + */ +OO.ui.Element.prototype.isElementAttached = function () { + return $.contains( this.getElementDocument(), this.$element[0] ); +}; + /** * Get the DOM document. * @@ -1787,7 +1788,7 @@ OO.ui.Widget.prototype.updateDisabled = function () { /** * Set the disabled state of the widget. * - * This should probably change the widgets's appearance and prevent it from being used. + * This should probably change the widgets' appearance and prevent it from being used. * * @param {boolean} disabled Disable widget * @chainable @@ -3231,9 +3232,8 @@ OO.ui.ToolFactory.prototype.extract = function ( collection, used ) { } } } - } // Include tools with matching name and exclude already used tools - else if ( item.name && ( !used || !used[item.name] ) ) { + } else if ( item.name && ( !used || !used[item.name] ) ) { names.push( item.name ); if ( used ) { used[item.name] = true; @@ -3268,7 +3268,9 @@ OO.ui.ToolFactory.prototype.extract = function ( collection, used ) { */ OO.ui.ToolGroup = function OoUiToolGroup( toolbar, config ) { // Configuration initialization - config = config || {}; + config = $.extend( true, { + 'aggregations': { 'disable': 'itemDisable' } + }, config ); // Parent constructor OO.ui.ToolGroup.super.call( this, config ); @@ -3280,6 +3282,7 @@ OO.ui.ToolGroup = function OoUiToolGroup( toolbar, config ) { this.toolbar = toolbar; this.tools = {}; this.pressed = null; + this.autoDisabled = false; this.include = config.include || []; this.exclude = config.exclude || []; this.promote = config.promote || []; @@ -3294,6 +3297,7 @@ OO.ui.ToolGroup = function OoUiToolGroup( toolbar, config ) { 'mouseout': OO.ui.bind( this.onMouseOut, this ) } ); this.toolbar.getToolFactory().connect( this, { 'register': 'onToolFactoryRegister' } ); + this.connect( this, { 'itemDisable': 'updateDisabled' } ); // Initialization this.$group.addClass( 'oo-ui-toolGroup-tools' ); @@ -3335,8 +3339,43 @@ OO.ui.ToolGroup.static.titleTooltips = false; */ OO.ui.ToolGroup.static.accelTooltips = false; +/** + * Automatically disable the toolgroup when all tools are disabled + * + * @static + * @property {boolean} + * @inheritable + */ +OO.ui.ToolGroup.static.autoDisable = true; + /* Methods */ +/** + * @inheritdoc + */ +OO.ui.ToolGroup.prototype.isDisabled = function () { + return this.autoDisabled || OO.ui.ToolGroup.super.prototype.isDisabled.apply( this, arguments ); +}; + +/** + * @inheritdoc + */ +OO.ui.ToolGroup.prototype.updateDisabled = function () { + var i, item, allDisabled = true; + + if ( this.constructor.static.autoDisable ) { + for ( i = this.items.length - 1; i >= 0; i-- ) { + item = this.items[i]; + if ( !item.isDisabled() ) { + allDisabled = false; + break; + } + } + this.autoDisabled = allDisabled; + } + OO.ui.ToolGroup.super.prototype.updateDisabled.apply( this, arguments ); +}; + /** * Handle mouse down events. * @@ -3506,6 +3545,8 @@ OO.ui.ToolGroup.prototype.populate = function () { } // Re-add tools (moving existing ones to new locations) this.addItems( add ); + // Disabled state may depend on items + this.updateDisabled(); }; /** @@ -4668,6 +4709,18 @@ OO.mixinClass( OO.ui.PopupToolGroup, OO.ui.ClippableElement ); /* Methods */ +/** + * @inheritdoc + */ +OO.ui.PopupToolGroup.prototype.setDisabled = function () { + // Parent method + OO.ui.PopupToolGroup.super.prototype.setDisabled.apply( this, arguments ); + + if ( this.isDisabled() && this.isElementAttached() ) { + this.setActive( false ); + } +}; + /** * Handle focus being lost. * @@ -6167,12 +6220,19 @@ OO.ui.SelectWidget.prototype.getItemFromData = function ( data ) { * @chainable */ OO.ui.SelectWidget.prototype.highlightItem = function ( item ) { - var i, len; + var i, len, highlighted, + changed = false; for ( i = 0, len = this.items.length; i < len; i++ ) { - this.items[i].setHighlighted( this.items[i] === item ); + highlighted = this.items[i] === item; + if ( this.items[i].isHighlighted() !== highlighted ) { + this.items[i].setHighlighted( highlighted ); + changed = true; + } + } + if ( changed ) { + this.emit( 'highlight', item ); } - this.emit( 'highlight', item ); return this; }; @@ -6186,12 +6246,19 @@ OO.ui.SelectWidget.prototype.highlightItem = function ( item ) { * @chainable */ OO.ui.SelectWidget.prototype.selectItem = function ( item ) { - var i, len; + var i, len, selected, + changed = false; for ( i = 0, len = this.items.length; i < len; i++ ) { - this.items[i].setSelected( this.items[i] === item ); + selected = this.items[i] === item; + if ( this.items[i].isSelected() !== selected ) { + this.items[i].setSelected( selected ); + changed = true; + } + } + if ( changed ) { + this.emit( 'select', item ); } - this.emit( 'select', item ); return this; }; @@ -6205,7 +6272,7 @@ OO.ui.SelectWidget.prototype.selectItem = function ( item ) { * @param {OO.ui.OptionWidget} [item] Item to select * @chainable */ -OO.ui.SelectWidget.prototype.intializeSelection = function( item ) { +OO.ui.SelectWidget.prototype.intializeSelection = function ( item ) { var i, len, selected; for ( i = 0, len = this.items.length; i < len; i++ ) { @@ -7659,7 +7726,7 @@ OO.ui.TextInputWidget.prototype.onEdit = function () { * * @chainable */ -OO.ui.TextInputWidget.prototype.adjustSize = function() { +OO.ui.TextInputWidget.prototype.adjustSize = function () { var $clone, scrollHeight, innerHeight, outerHeight, maxInnerHeight, idealHeight; if ( this.multiline && this.autosize ) { diff --git a/resources/oojs-ui/oojs-ui.svg.css b/resources/oojs-ui/oojs-ui.svg.css index 887da4d697..58bbad05d2 100644 --- a/resources/oojs-ui/oojs-ui.svg.css +++ b/resources/oojs-ui/oojs-ui.svg.css @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.1.0-pre (23fb1b6144) + * OOjs UI v0.1.0-pre (8986c46d35) * 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: Thu Mar 27 2014 14:49:30 GMT-0700 (PDT) + * Date: Tue Apr 01 2014 19:33:39 GMT-0700 (PDT) */ /* Textures */ -- 2.20.1