2 * MediaWiki Widgets - CopyTextLayout class.
4 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
9 * @classdesc Extends CopyTextLayout with MediaWiki notifications.
12 * @extends OO.ui.CopyTextLayout
15 * @description Create an instance of `mw.widgets.CopyTextLayout`.
16 * @param {Object} [config] Configuration options
17 * @param {string} [config.successMessage] Success message,
18 * defaults to the {@link mw.Message} 'mw-widgets-copytextlayout-copy-success'.
19 * @param {string} [config.failMessage] Failure message,
20 * defaults to the {@link mw.Message} 'mw-widgets-copytextlayout-copy-fail'.
22 mw.widgets.CopyTextLayout = function MwWidgetsCopyTextLayout( config ) {
24 mw.widgets.CopyTextLayout.super.apply( this, arguments );
26 this.successMessage = config.successMessage || mw.msg( 'mw-widgets-copytextlayout-copy-success' );
27 this.failMessage = config.failMessage || mw.msg( 'mw-widgets-copytextlayout-copy-fail' );
29 this.connect( this, { copy: 'onMwCopy' } );
34 OO.inheritClass( mw.widgets.CopyTextLayout, OO.ui.CopyTextLayout );
41 * @param {boolean} copied
43 mw.widgets.CopyTextLayout.prototype.onMwCopy = function ( copied ) {
45 mw.notify( this.successMessage );
47 mw.notify( this.failMessage, { type: 'error' } );