mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 08:34:54 +00:00
f7335d4729
This is one of the blockers for splitting VE up into separate repositories or extending VE with an extension. ve.ui.Frame.js It's critical that we don't emit initialize from ve.ui.Frame until it's completely loaded, especially its styles, because we will begin measuring it straight away. Involved loading the stylesheets using $.ajax and setting base URL of the iframe to the ve.ui styles directory so all the image URLs still worked. This won't work for stylesheets from multiple locations, so we needed a more robust solution. The new solution uses some trickery described in the code documentation, but essentially no longer depends on all stylesheets being located in the same folder. ve.ui.Dialog.js, ve.ui.Inspector.js, ve.ui.Window.js Static methods are now being used to extend a window class to include different stylesheets rather than simple array concatenation. Change-Id: I619238732f975d41305f81f8f818a577a40f49da
92 lines
1.9 KiB
JavaScript
92 lines
1.9 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
|
|
* @extends ve.ui.Window
|
|
*
|
|
* @constructor
|
|
* @param {ve.Surface} surface
|
|
*/
|
|
ve.ui.Dialog = function VeUiDialog( surface ) {
|
|
// Parent constructor
|
|
ve.ui.Window.call( this, surface );
|
|
|
|
// Properties
|
|
this.visible = false;
|
|
|
|
// Initialization
|
|
this.$.addClass( 've-ui-dialog' );
|
|
this.$.on( 'mousedown', ve.bind( this.onMouseDown, this ) );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.Dialog, ve.ui.Window );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handle mouse down events.
|
|
*
|
|
* @method
|
|
* @param {jQuery.Event} e Mouse down event
|
|
*/
|
|
ve.ui.Dialog.prototype.onMouseDown = function () {
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Handle cancel button click events.
|
|
*
|
|
* @method
|
|
*/
|
|
ve.ui.Dialog.prototype.onCancelButtonClick = function () {
|
|
this.close();
|
|
};
|
|
|
|
/**
|
|
* Handle apply button click events.
|
|
*
|
|
* @method
|
|
*/
|
|
ve.ui.Dialog.prototype.onApplyButtonClick = function () {
|
|
this.close( true );
|
|
};
|
|
|
|
/**
|
|
* Initialize frame contents.
|
|
*
|
|
* @method
|
|
*/
|
|
ve.ui.Dialog.prototype.initialize = function () {
|
|
// Call parent method
|
|
ve.ui.Window.prototype.initialize.call( this );
|
|
|
|
// Properties
|
|
this.cancelButton = new ve.ui.ButtonWidget( {
|
|
'$$': this.$$, 'label': ve.msg( 'visualeditor-dialog-action-cancel' )
|
|
} );
|
|
this.applyButton = new ve.ui.ButtonWidget( {
|
|
'$$': this.$$, 'label': ve.msg( 'visualeditor-dialog-action-apply' ), 'flags': ['primary']
|
|
} );
|
|
|
|
// Events
|
|
this.cancelButton.on( 'click', ve.bind( this.onCancelButtonClick, this ) );
|
|
this.applyButton.on( 'click', ve.bind( this.onApplyButtonClick, this ) );
|
|
|
|
// Initialization
|
|
this.$head.append( this.applyButton.$, this.cancelButton.$ );
|
|
};
|
|
|
|
/* Initialization */
|
|
|
|
ve.ui.Dialog.static.addLocalStylesheets( [ 've.ui.Dialog.css' ] );
|