From 8cea24e472b1d1b1cc2d4811be20566d92b22fc9 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Wed, 25 Jun 2014 11:00:00 -0700 Subject: [PATCH] Update OOjs UI to v0.1.0-pre (9aad824bd6) New changes: 414c051 build: Update jscs and use new "wikimedia" preset 0401aff Accessibility: Set aria-hidden attribute on elements while dialogs are open 9aad824 Revert "Accessibility: Restore element focus when a window closes" Change-Id: I8df631bdce8446ab9845c4e971c2c58cf94bc7e4 --- resources/lib/oojs-ui/oojs-ui.js | 159 +++++++++++++------------- resources/lib/oojs-ui/oojs-ui.svg.css | 4 +- 2 files changed, 81 insertions(+), 82 deletions(-) diff --git a/resources/lib/oojs-ui/oojs-ui.js b/resources/lib/oojs-ui/oojs-ui.js index 7e3aadfa98..22bf46f77f 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 (7a0e222a75) + * OOjs UI v0.1.0-pre (9aad824bd6) * 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: Wed Jun 18 2014 16:19:15 GMT-0700 (PDT) + * Date: Wed Jun 25 2014 10:59:56 GMT-0700 (PDT) */ ( function ( OO ) { @@ -94,82 +94,82 @@ OO.ui.getLocalValue = function ( obj, lang, fallback ) { ( function () { -/** - * Message store for the default implementation of OO.ui.msg - * - * Environments that provide a localization system should not use this, but should override - * OO.ui.msg altogether. - * - * @private - */ -var messages = { - // Label text for button to exit from dialog - 'ooui-dialog-action-close': 'Close', - // Tool tip for a button that moves items in a list down one place - 'ooui-outline-control-move-down': 'Move item down', - // Tool tip for a button that moves items in a list up one place - 'ooui-outline-control-move-up': 'Move item up', - // Tool tip for a button that removes items from a list - '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 generic dialog used to confirm things - 'ooui-dialog-confirm-title': 'Confirm', - // The default prompt of a confirmation dialog - 'ooui-dialog-confirm-default-prompt': 'Are you sure?', - // The default OK button text on a confirmation dialog - 'ooui-dialog-confirm-default-ok': 'OK', - // The default cancel button text on a confirmation dialog - 'ooui-dialog-confirm-default-cancel': 'Cancel' -}; + /** + * Message store for the default implementation of OO.ui.msg + * + * Environments that provide a localization system should not use this, but should override + * OO.ui.msg altogether. + * + * @private + */ + var messages = { + // Label text for button to exit from dialog + 'ooui-dialog-action-close': 'Close', + // Tool tip for a button that moves items in a list down one place + 'ooui-outline-control-move-down': 'Move item down', + // Tool tip for a button that moves items in a list up one place + 'ooui-outline-control-move-up': 'Move item up', + // Tool tip for a button that removes items from a list + '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 generic dialog used to confirm things + 'ooui-dialog-confirm-title': 'Confirm', + // The default prompt of a confirmation dialog + 'ooui-dialog-confirm-default-prompt': 'Are you sure?', + // The default OK button text on a confirmation dialog + 'ooui-dialog-confirm-default-ok': 'OK', + // The default cancel button text on a confirmation dialog + 'ooui-dialog-confirm-default-cancel': 'Cancel' + }; -/** - * Get a localized message. - * - * In environments that provide a localization system, this function should be overridden to - * return the message translated in the user's language. The default implementation always returns - * English messages. - * - * After the message key, message parameters may optionally be passed. In the default implementation, - * any occurrences of $1 are replaced with the first parameter, $2 with the second parameter, etc. - * Alternative implementations of OO.ui.msg may use any substitution system they like, as long as - * they support unnamed, ordered message parameters. - * - * @abstract - * @param {string} key Message key - * @param {Mixed...} [params] Message parameters - * @return {string} Translated message with parameters substituted - */ -OO.ui.msg = function ( key ) { - var message = messages[key], params = Array.prototype.slice.call( arguments, 1 ); - if ( typeof message === 'string' ) { - // Perform $1 substitution - message = message.replace( /\$(\d+)/g, function ( unused, n ) { - var i = parseInt( n, 10 ); - return params[i - 1] !== undefined ? params[i - 1] : '$' + n; - } ); - } else { - // Return placeholder if message not found - message = '[' + key + ']'; - } - return message; -}; + /** + * Get a localized message. + * + * In environments that provide a localization system, this function should be overridden to + * return the message translated in the user's language. The default implementation always returns + * English messages. + * + * After the message key, message parameters may optionally be passed. In the default implementation, + * any occurrences of $1 are replaced with the first parameter, $2 with the second parameter, etc. + * Alternative implementations of OO.ui.msg may use any substitution system they like, as long as + * they support unnamed, ordered message parameters. + * + * @abstract + * @param {string} key Message key + * @param {Mixed...} [params] Message parameters + * @return {string} Translated message with parameters substituted + */ + OO.ui.msg = function ( key ) { + var message = messages[key], params = Array.prototype.slice.call( arguments, 1 ); + if ( typeof message === 'string' ) { + // Perform $1 substitution + message = message.replace( /\$(\d+)/g, function ( unused, n ) { + var i = parseInt( n, 10 ); + return params[i - 1] !== undefined ? params[i - 1] : '$' + n; + } ); + } else { + // Return placeholder if message not found + message = '[' + key + ']'; + } + return message; + }; -/** */ -OO.ui.deferMsg = function ( key ) { - return function () { - return OO.ui.msg( key ); + /** */ + OO.ui.deferMsg = function ( key ) { + return function () { + return OO.ui.msg( key ); + }; }; -}; -/** */ -OO.ui.resolveMsg = function ( msg ) { - if ( $.isFunction( msg ) ) { - return msg(); - } - return msg; -}; + /** */ + OO.ui.resolveMsg = function ( msg ) { + if ( $.isFunction( msg ) ) { + return msg(); + } + return msg; + }; } )(); /** @@ -1286,8 +1286,8 @@ OO.ui.Window.prototype.open = function ( data ) { // Open the window this.opening = $.Deferred(); - // So we can restore focus on closing - this.$prevFocus = $( document.activeElement ); + this.$ariaHidden = $( 'body' ).children().not( this.$element.parentsUntil( 'body' ).last() ) + .attr( 'aria-hidden', '' ); this.frame.load().done( OO.ui.bind( function () { this.$element.show(); @@ -1352,10 +1352,9 @@ OO.ui.Window.prototype.close = function ( data ) { this.opened.resolve(); } this.$element.hide(); - // Restore focus to whatever was focused before opening - if ( this.$prevFocus ) { - this.$prevFocus.focus(); - this.$prevFocus = undefined; + if ( this.$ariaHidden ) { + this.$ariaHidden.removeAttr( 'aria-hidden' ); + this.$ariaHidden = undefined; } this.visible = false; this.closing.resolve(); diff --git a/resources/lib/oojs-ui/oojs-ui.svg.css b/resources/lib/oojs-ui/oojs-ui.svg.css index 76feb5d656..04bcfe95bb 100644 --- a/resources/lib/oojs-ui/oojs-ui.svg.css +++ b/resources/lib/oojs-ui/oojs-ui.svg.css @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.1.0-pre (7a0e222a75) + * OOjs UI v0.1.0-pre (9aad824bd6) * 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: Wed Jun 18 2014 16:19:15 GMT-0700 (PDT) + * Date: Wed Jun 25 2014 10:59:56 GMT-0700 (PDT) */ /* Textures */ -- 2.20.1