All files / src/ui/dialogs ve.ui.FragmentDialog.js

40% Statements 8/20
0% Branches 0/2
0% Functions 0/6
40% Lines 8/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104                                  1x                   1x   1x       1x                                                     1x                       1x                   1x                   1x                      
/*!
 * VisualEditor UserInterface FragmentDialog class.
 *
 * @copyright See AUTHORS.txt
 */
 
/**
 * Dialog for working with fragments of content.
 *
 * @class
 * @abstract
 * @extends OO.ui.ProcessDialog
 * @mixins ve.ui.FragmentWindow
 *
 * @constructor
 * @param {Object} [config] Configuration options
 */
ve.ui.FragmentDialog = function VeUiFragmentDialog( config ) {
	// Parent constructor
	ve.ui.FragmentDialog.super.call( this, config );
 
	// Mixin constructor
	ve.ui.FragmentWindow.call( this, config );
};
 
/* Inheritance */
 
OO.inheritClass( ve.ui.FragmentDialog, OO.ui.ProcessDialog );
 
OO.mixinClass( ve.ui.FragmentDialog, ve.ui.FragmentWindow );
 
/* Static Properties */
 
ve.ui.FragmentDialog.static.actions = [
	{
		label: OO.ui.deferMsg( 'visualeditor-dialog-action-cancel' ),
		flags: [ 'safe', 'close' ],
		modes: [ 'readonly', 'edit', 'insert' ]
	},
	{
		action: 'done',
		label: OO.ui.deferMsg( 'visualeditor-dialog-action-apply' ),
		flags: [ 'progressive', 'primary' ],
		modes: 'edit'
	},
	{
		action: 'done',
		label: OO.ui.deferMsg( 'visualeditor-dialog-action-insert' ),
		flags: [ 'progressive', 'primary' ],
		modes: 'insert'
	}
	// The message visualeditor-dialog-action-goback is also available
	// but currently only used in ve-mw.
];
 
/* Methods */
 
/**
 * @inheritdoc
 */
ve.ui.FragmentDialog.prototype.initialize = function ( data ) {
	// Parent method
	ve.ui.FragmentDialog.super.prototype.initialize.call( this, data );
 
	this.tabIndexScope = new ve.ui.TabIndexScope( {
		root: this.$content
	} );
};
 
/**
 * @inheritdoc OO.ui.Dialog
 */
ve.ui.FragmentDialog.prototype.getActionWidgetConfig = function ( config ) {
	// Mixin method
	config = ve.ui.FragmentWindow.prototype.getActionWidgetConfig.call( this, config );
	// Parent method
	return ve.ui.FragmentDialog.super.prototype.getActionWidgetConfig.call( this, config );
};
 
/**
 * @inheritdoc
 */
ve.ui.FragmentDialog.prototype.getSetupProcess = function ( data ) {
	// Parent method
	var process = ve.ui.FragmentDialog.super.prototype.getSetupProcess.call( this, data );
	// Mixin method
	return ve.ui.FragmentWindow.prototype.getSetupProcess.call( this, data, process );
};
 
/**
 * @inheritdoc
 */
ve.ui.FragmentDialog.prototype.getTeardownProcess = function ( data ) {
	// Parent method
	var process = ve.ui.FragmentDialog.super.prototype.getTeardownProcess.call( this, data )
		.first( function () {
			if ( this.selectFragmentOnClose ) {
				this.fragment.select();
			}
		}, this );
	// Mixin method
	return ve.ui.FragmentWindow.prototype.getTeardownProcess.call( this, data, process );
};