mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
c13dce97ec
Change-Id: Ibc3f49c55ded5490fcb071f0ccf9f25a71a06c97 Warning: categories.json Class 've.NodeFactory' not found in categories file Warning: ve.ui.ContentDialog.js:8: Unknown type ve.ui.Surface Warning: ve.ui.MetaDialog.js:8: Unknown type ve.ui.Surface Warning: ve.ui.Dialog.js:8: Unknown type ve.ui.Surface
70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface Dialog class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* UserInterface dialog.
|
|
*
|
|
* @class
|
|
* @abstract
|
|
*
|
|
* @constructor
|
|
* @param {ve.Surface} surface
|
|
*/
|
|
ve.ui.Dialog = function VeUiDialog( surface ) {
|
|
// Parent constructor
|
|
ve.EventEmitter.call( this );
|
|
|
|
var dialog = this;
|
|
// Properties
|
|
this.surface = surface;
|
|
this.visible = false;
|
|
this.$ = $( '<div class="ve-ui-dialog"></div>' );
|
|
|
|
// Initialization
|
|
this.cancelButton = new ve.ui.ButtonWidget( { 'label': ve.msg( 'cancel' ) } );
|
|
|
|
//this.cancelButton.on( 'click', ve.bind( this.surface.target.closeDialog, this ) );
|
|
this.cancelButton.on( 'click', function() { dialog.surface.target.closeDialog(); } );
|
|
|
|
this.applyButton = new ve.ui.ButtonWidget( {
|
|
'label': ve.msg( 'visualeditor-dialog-label-apply' ),
|
|
'flags': ['constructive'],
|
|
'disabled': false
|
|
} );
|
|
|
|
// Base elements
|
|
this.$title = $( '<div class="ve-ui-dialog-title"></div>' ).text(
|
|
ve.msg( this.constructor.static.dialogTitleMessage )
|
|
);
|
|
this.$actions = $( '<div class="ve-ui-dialog-actions"><div>' ).append(
|
|
this.cancelButton.$, this.applyButton.$
|
|
);
|
|
this.$.append( this.$title, this.$actions, $( '<div class="ve-ui-dialog-container"></div>' ) );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.Dialog, ve.EventEmitter );
|
|
|
|
/* Methods */
|
|
|
|
ve.ui.Dialog.prototype.isVisible = function () {
|
|
return this.visible;
|
|
};
|
|
|
|
ve.ui.Dialog.prototype.open = function () {
|
|
this.emit( 'open' );
|
|
this.$.show();
|
|
this.visible = true;
|
|
};
|
|
|
|
ve.ui.Dialog.prototype.close = function () {
|
|
this.emit( 'close' );
|
|
this.$.hide();
|
|
this.visible = false;
|
|
};
|