2013-02-20 19:44:44 +00:00
|
|
|
/*!
|
|
|
|
* 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.ui.Surface} surface
|
|
|
|
*/
|
|
|
|
ve.ui.Dialog = function VeUiDialog( surface ) {
|
2013-03-06 22:04:20 +00:00
|
|
|
// Parent constructor
|
|
|
|
ve.EventEmitter.call( this );
|
|
|
|
|
|
|
|
var dialog = this;
|
2013-02-20 19:44:44 +00:00
|
|
|
// Properties
|
|
|
|
this.surface = surface;
|
|
|
|
this.visible = false;
|
|
|
|
this.$ = $( '<div class="ve-ui-dialog"></div>' );
|
2013-03-06 22:04:20 +00:00
|
|
|
|
|
|
|
// 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>' ) );
|
2013-02-20 19:44:44 +00:00
|
|
|
};
|
|
|
|
|
2013-03-06 22:04:20 +00:00
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.inheritClass( ve.ui.Dialog, ve.EventEmitter );
|
|
|
|
|
2013-02-20 19:44:44 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
ve.ui.Dialog.prototype.isVisible = function () {
|
|
|
|
return this.visible;
|
|
|
|
};
|
|
|
|
|
2013-03-06 22:04:20 +00:00
|
|
|
ve.ui.Dialog.prototype.open = function () {
|
|
|
|
this.emit( 'open' );
|
2013-02-20 19:44:44 +00:00
|
|
|
this.$.show();
|
|
|
|
this.visible = true;
|
|
|
|
};
|
|
|
|
|
2013-03-06 22:04:20 +00:00
|
|
|
ve.ui.Dialog.prototype.close = function () {
|
|
|
|
this.emit( 'close' );
|
2013-02-20 19:44:44 +00:00
|
|
|
this.$.hide();
|
|
|
|
this.visible = false;
|
|
|
|
};
|