mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-02 01:46:47 +00:00
db9f941fa6
Objectives: * Rename this.$ to this.$element * Rename this.$$ to this.$ * Get rid of the need to use this.frame.$$ * Rename OO.ui.Element.get$$ to OO.ui.Element.getJQuery Changes: (using Sublime Text regex patterns) * Replace "get$$" with "getJQuery" * Replace "\.(\$)([^\$a-zA-Z])" with ".$element$2" * Replace "\.(\$\$)" with ".$" * Replace "'$$'" with "'$'" * Set this.$ to null in constructor of OO.ui.Window * Set this.$ to this.frame.$ in initialize method of OO.ui.Window * Replace "\.(frame.\$)([^\$a-zA-Z])" with ".\$$2" Bonus: * Use this.$() in a bunch of places where $() was erroneously used Change-Id: If3d870124ab8d10f8223532cda95c2b2b075db94
142 lines
3.1 KiB
JavaScript
142 lines
3.1 KiB
JavaScript
/*!
|
|
* ObjectOriented UserInterface Inspector class.
|
|
*
|
|
* @copyright 2011-2013 OOJS Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Non-modal interface in a child frame.
|
|
*
|
|
* @class
|
|
* @abstract
|
|
* @extends OO.ui.Window
|
|
*
|
|
* @constructor
|
|
* @param {OO.ui.WindowSet} windowSet Window set this dialog is part of
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
OO.ui.Inspector = function OoUiInspector( windowSet, config ) {
|
|
// Parent constructor
|
|
OO.ui.Window.call( this, windowSet, config );
|
|
|
|
// Properties
|
|
this.initialSelection = null;
|
|
|
|
// Initialization
|
|
this.$element.addClass( 'oo-ui-inspector' );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( OO.ui.Inspector, OO.ui.Window );
|
|
|
|
/* Static Properties */
|
|
|
|
OO.ui.Inspector.static.titleMessage = 'oo-ui-inspector-title';
|
|
|
|
/**
|
|
* Symbolic name of dialog.
|
|
*
|
|
* @abstract
|
|
* @static
|
|
* @property {string}
|
|
* @inheritable
|
|
*/
|
|
OO.ui.Inspector.static.name = '';
|
|
|
|
/**
|
|
* The inspector comes with a remove button
|
|
|
|
* @static
|
|
* @inheritable
|
|
* @property {boolean}
|
|
*/
|
|
OO.ui.Inspector.static.removeable = true;
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handle frame ready events.
|
|
*
|
|
* @method
|
|
*/
|
|
OO.ui.Inspector.prototype.initialize = function () {
|
|
// Parent method
|
|
OO.ui.Window.prototype.initialize.call( this );
|
|
|
|
// Initialization
|
|
this.frame.$content.addClass( 'oo-ui-inspector-content' );
|
|
this.$form = this.$( '<form>' );
|
|
this.closeButton = new OO.ui.IconButtonWidget( {
|
|
'$': this.$, 'icon': 'previous', 'title': OO.ui.msg( 'ooui-inspector-close-tooltip' )
|
|
} );
|
|
if ( this.constructor.static.removeable ) {
|
|
this.removeButton = new OO.ui.IconButtonWidget( {
|
|
'$': this.$, 'icon': 'remove', 'title': OO.ui.msg( 'ooui-inspector-remove-tooltip' )
|
|
} );
|
|
}
|
|
|
|
// Events
|
|
this.$form.on( {
|
|
'submit': OO.ui.bind( this.onFormSubmit, this ),
|
|
'keydown': OO.ui.bind( this.onFormKeyDown, this )
|
|
} );
|
|
this.closeButton.connect( this, { 'click': 'onCloseButtonClick' } );
|
|
if ( this.constructor.static.removeable ) {
|
|
this.removeButton.connect( this, { 'click': 'onRemoveButtonClick' } );
|
|
}
|
|
|
|
// Initialization
|
|
this.closeButton.$element.addClass( 'oo-ui-inspector-closeButton' );
|
|
this.$head.prepend( this.closeButton.$element );
|
|
if ( this.constructor.static.removeable ) {
|
|
this.removeButton.$element.addClass( 'oo-ui-inspector-removeButton' );
|
|
this.$head.append( this.removeButton.$element );
|
|
}
|
|
this.$body.append( this.$form );
|
|
};
|
|
|
|
/**
|
|
* Handle close button click events.
|
|
*
|
|
* @method
|
|
*/
|
|
OO.ui.Inspector.prototype.onCloseButtonClick = function () {
|
|
this.close( 'back' );
|
|
};
|
|
|
|
/**
|
|
* Handle remove button click events.
|
|
*
|
|
* @method
|
|
*/
|
|
OO.ui.Inspector.prototype.onRemoveButtonClick = function () {
|
|
this.close( 'remove' );
|
|
};
|
|
|
|
/**
|
|
* Handle form submission events.
|
|
*
|
|
* @method
|
|
* @param {jQuery.Event} e Form submit event
|
|
*/
|
|
OO.ui.Inspector.prototype.onFormSubmit = function () {
|
|
this.close( 'apply' );
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Handle form keydown events.
|
|
*
|
|
* @method
|
|
* @param {jQuery.Event} e Key down event
|
|
*/
|
|
OO.ui.Inspector.prototype.onFormKeyDown = function ( e ) {
|
|
// Escape
|
|
if ( e.which === OO.ui.Keys.ESCAPE ) {
|
|
this.close( 'back' );
|
|
return false;
|
|
}
|
|
};
|