/*!
- * OOjs UI v0.18.3
+ * OOjs UI v0.19.2
* https://www.mediawiki.org/wiki/OOjs_UI
*
* Copyright 2011–2017 OOjs UI Team and other contributors.
* Released under the MIT license
* http://oojs.mit-license.org
*
- * Date: 2017-01-04T00:22:40Z
+ * Date: 2017-02-14T22:47:20Z
*/
( function ( OO ) {
* }
* OO.inheritClass( MyProcessDialog, OO.ui.ProcessDialog );
* MyProcessDialog.static.title = 'An action set in a process dialog';
+ * MyProcessDialog.static.name = 'myProcessDialog';
* // An action set that uses modes ('edit' and 'help' mode, in this example).
* MyProcessDialog.static.actions = [
* { action: 'continue', modes: 'edit', label: 'Continue', flags: [ 'primary', 'constructive' ] },
* See the [OOjs ui documentation on MediaWiki] [2] for examples.
* [2]: https://www.mediawiki.org/wiki/OOjs_UI/Windows/Window_managers
*
+ * This function can be called in two manners:
+ *
+ * 1. `.addWindows( [ windowA, windowB, ... ] )` (where `windowA`, `windowB` are OO.ui.Window objects)
+ *
+ * This syntax registers windows under the symbolic names defined in their `.static.name`
+ * properties. For example, if `windowA.constructor.static.name` is `'nameA'`, calling
+ * `.openWindow( 'nameA' )` afterwards will open the window `windowA`. This syntax requires the
+ * static name to be set, otherwise an exception will be thrown.
+ *
+ * This is the recommended way, as it allows for an easier switch to using a window factory.
+ *
+ * 2. `.addWindows( { nameA: windowA, nameB: windowB, ... } )`
+ *
+ * This syntax registers windows under the explicitly given symbolic names. In this example,
+ * calling `.openWindow( 'nameA' )` afterwards will open the window `windowA`, regardless of what
+ * its `.static.name` is set to. The static name is not required to be set.
+ *
+ * This should only be used if you need to override the default symbolic names.
+ *
+ * Example:
+ *
+ * var windowManager = new OO.ui.WindowManager();
+ * $( 'body' ).append( windowManager.$element );
+ *
+ * // Add a window under the default name: see OO.ui.MessageDialog.static.name
+ * windowManager.addWindows( [ new OO.ui.MessageDialog() ] );
+ * // Add a window under an explicit name
+ * windowManager.addWindows( { myMessageDialog: new OO.ui.MessageDialog() } );
+ *
+ * // Open window by default name
+ * windowManager.openWindow( 'message' );
+ * // Open window by explicitly given name
+ * windowManager.openWindow( 'myMessageDialog' );
+ *
+ *
* @param {Object.<string,OO.ui.Window>|OO.ui.Window[]} windows An array of window objects specified
* by reference, symbolic name, or explicitly defined symbolic names.
* @throws {Error} An error is thrown if a window is added by symbolic name, but has neither an
list = {};
for ( i = 0, len = windows.length; i < len; i++ ) {
name = windows[ i ].constructor.static.name;
- if ( typeof name !== 'string' ) {
- throw new Error( 'Cannot add window' );
- }
if ( !name ) {
- OO.ui.warnDeprecation( 'OO.ui.WindowManager#addWindows: Windows must have a `name` static property defined.' );
+ throw new Error( 'Windows must have a `name` static property defined.' );
}
list[ name ] = windows[ i ];
}
* MyDialog.parent.call( this, config );
* }
* OO.inheritClass( MyDialog, OO.ui.Dialog );
+ * MyDialog.static.name = 'myDialog';
* MyDialog.prototype.initialize = function () {
* MyDialog.parent.prototype.initialize.call( this );
* this.content = new OO.ui.PanelLayout( { padded: true, expanded: false } );
// Events
this.actions.connect( this, {
click: 'onActionClick',
- resize: 'onActionResize',
change: 'onActionsChange'
} );
this.executeAction( '' );
e.preventDefault();
e.stopPropagation();
- } else if ( e.which === OO.ui.Keys.ENTER && e.ctrlKey ) {
+ } else if ( e.which === OO.ui.Keys.ENTER && ( e.ctrlKey || e.metaKey ) ) {
actions = this.actions.get( { flags: 'primary', visible: true, disabled: false } );
if ( actions.length > 0 ) {
this.executeAction( actions[ 0 ].getAction() );
}
};
-/**
- * Handle action resized events.
- *
- * @private
- * @param {OO.ui.ActionWidget} action Action that was resized
- */
-OO.ui.Dialog.prototype.onActionResize = function () {
- // Override in subclass
-};
-
/**
* Handle action click events.
*
/* Static Properties */
+/**
+ * @static
+ * @inheritdoc
+ */
OO.ui.MessageDialog.static.name = 'message';
+/**
+ * @static
+ * @inheritdoc
+ */
OO.ui.MessageDialog.static.size = 'small';
-OO.ui.MessageDialog.static.verbose = false;
+/**
+ * @static
+ * @deprecated since v0.18.4 as default; TODO: Remove
+ */
+OO.ui.MessageDialog.static.verbose = true;
/**
* Dialog title.
*/
OO.ui.MessageDialog.static.message = null;
-// Note that OO.ui.alert() and OO.ui.confirm() rely on these.
+/**
+ * @static
+ * @inheritdoc
+ */
OO.ui.MessageDialog.static.actions = [
+ // Note that OO.ui.alert() and OO.ui.confirm() rely on these.
{ action: 'accept', label: OO.ui.deferMsg( 'ooui-dialog-message-accept' ), flags: 'primary' },
{ action: 'reject', label: OO.ui.deferMsg( 'ooui-dialog-message-reject' ), flags: 'safe' }
];
return this;
};
-/**
- * @inheritdoc
- */
-OO.ui.MessageDialog.prototype.onActionResize = function ( action ) {
- this.fitActions();
- return OO.ui.MessageDialog.parent.prototype.onActionResize.call( this, action );
-};
-
/**
* Handle window resized events.
*
* @param {Object} [data] Dialog opening data
* @param {jQuery|string|Function|null} [data.title] Description of the action being confirmed
* @param {jQuery|string|Function|null} [data.message] Description of the action's consequence
- * @param {boolean} [data.verbose] Message is verbose and should be styled as a long message
* @param {Object[]} [data.actions] List of OO.ui.ActionOptionWidget configuration options for each
* action item
*/
this.message.setLabel(
data.message !== undefined ? data.message : this.constructor.static.message
);
+ // @deprecated since v0.18.4 as default; TODO: Remove and make default instead.
this.message.$element.toggleClass(
'oo-ui-messageDialog-message-verbose',
data.verbose !== undefined ? data.verbose : this.constructor.static.verbose
* }
* OO.inheritClass( MyProcessDialog, OO.ui.ProcessDialog );
*
+ * MyProcessDialog.static.name = 'myProcessDialog';
* MyProcessDialog.static.title = 'Process dialog';
* MyProcessDialog.static.actions = [
* { action: 'save', label: 'Done', flags: 'primary' },
this.executeAction( this.currentAction );
};
-/**
- * @inheritdoc
- */
-OO.ui.ProcessDialog.prototype.onActionResize = function ( action ) {
- if ( this.actions.isSpecial( action ) ) {
- this.fitLabel();
- }
- return OO.ui.ProcessDialog.parent.prototype.onActionResize.call( this, action );
-};
-
/**
* @inheritdoc
*/
for ( i = 0, len = actions.length; i < len; i++ ) {
config = $.extend( { framed: !OO.ui.isMobile() }, actions[ i ] );
- if ( isMobile && ( config.flags === 'back' || config.flags.indexOf( 'back' ) !== -1 ) ) {
+ if ( isMobile &&
+ ( config.flags === 'back' || ( Array.isArray( config.flags ) && config.flags.indexOf( 'back' ) !== -1 ) )
+ ) {
$.extend( config, {
icon: 'previous',
label: ''
if ( !OO.ui.windowManager ) {
OO.ui.windowManager = new OO.ui.WindowManager();
$( 'body' ).append( OO.ui.windowManager.$element );
- OO.ui.windowManager.addWindows( {
- messageDialog: new OO.ui.MessageDialog()
- } );
+ OO.ui.windowManager.addWindows( [ new OO.ui.MessageDialog() ] );
}
return OO.ui.windowManager;
};
* @return {jQuery.Promise} Promise resolved when the user closes the dialog
*/
OO.ui.alert = function ( text, options ) {
- return OO.ui.getWindowManager().openWindow( 'messageDialog', $.extend( {
+ return OO.ui.getWindowManager().openWindow( 'message', $.extend( {
message: text,
- verbose: true,
actions: [ OO.ui.MessageDialog.static.actions[ 0 ] ]
}, options ) ).then( function ( opened ) {
return opened.then( function ( closing ) {
* `false`.
*/
OO.ui.confirm = function ( text, options ) {
- return OO.ui.getWindowManager().openWindow( 'messageDialog', $.extend( {
- message: text,
- verbose: true
+ return OO.ui.getWindowManager().openWindow( 'message', $.extend( {
+ message: text
}, options ) ).then( function ( opened ) {
return opened.then( function ( closing ) {
return closing.then( function ( data ) {
*
* @param {jQuery|string} text Message text to display
* @param {Object} [options] Additional options, see OO.ui.MessageDialog#getSetupProcess
- * @cfg {Object} [textInput] Additional options for text input widget, see OO.ui.TextInputWidget
+ * @param {Object} [options.textInput] Additional options for text input widget, see OO.ui.TextInputWidget
* @return {jQuery.Promise} Promise resolved when the user closes the dialog. If the user chose to
* confirm, the promise will resolve with the value of the text input widget; otherwise, it will
* resolve to `null`.
// TODO: This is a little hacky, and could be done by extending MessageDialog instead.
- return manager.openWindow( 'messageDialog', $.extend( {
- message: textField.$element,
- verbose: true
+ return manager.openWindow( 'message', $.extend( {
+ message: textField.$element
}, options ) ).then( function ( opened ) {
// After ready
textInput.on( 'enter', function () {