mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 10:59:56 +00:00
c472b2fe4a
ve.ui.Surface.js * Make local overlay a child of ve-ui-surface and a sibling to ve-ce-surface elements. ** This keeps local overlays relative to their surface and eliminates the need for insane z-indexes. ve.ui.PopupWidget.js * PopupWidget boundaries are now relative to ve-ce-surface and no longer protrude out ve.ce.Node.css, ve.ui.Window.css * Removal or replacement of insane z-indexes. ve.ce.FocusableNode.js, ve.ce.ProtectedNode.js, ve.ce.ResizableNode.js, ve.ui.Context.js * Translate offsets from local overlay ve.init.mw.ViewPageTarget-monobook.css, ve.init.mw.ViewPageTarget-vector.css * Skin specific z-indexes for global overlay ve.init.mw.ViewPageTarget.js * Applied direction specific mw class to ce.Surface vs ui.Surface to prevent mw content styles from being applied to ui elements. ve.ui.Dialog.css * Adjustments to surface inside of dialog so that relative offsets for local overlays can be properly calculated. ve.ui.Surface.css * Explicitly force .ve-ui-surface to be relative so that it's children can be relatively positioned. ve.ui.Widget.css * Removal of unnecessary font-size properties now that local overlay is sibling of surface. ve.js * Added get relative position helper method to translate position offsets from target parent Bug: 50241 Change-Id: Ibadce404a2286bc5dcec48f0d9da89004dbbd867
104 lines
2.4 KiB
JavaScript
104 lines
2.4 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface TextInputMenuWidget class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates an ve.ui.TextInputMenuWidget object.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.MenuWidget
|
|
*
|
|
* @constructor
|
|
* @param {ve.ui.TextInputWidget} input Text input widget to provide menu for
|
|
* @param {Object} [config] Config options
|
|
* @cfg {jQuery} [$container=input.$] Element to render menu under
|
|
*/
|
|
ve.ui.TextInputMenuWidget = function VeUiTextInputMenuWidget( input, config ) {
|
|
// Parent constructor
|
|
ve.ui.MenuWidget.call( this, config );
|
|
|
|
// Properties
|
|
this.input = input;
|
|
this.$container = config.$container || this.input.$;
|
|
this.onWindowResizeHandler = ve.bind( this.onWindowResize, this );
|
|
|
|
// Initialization
|
|
this.$.addClass( 've-ui-textInputMenuWidget' );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.TextInputMenuWidget, ve.ui.MenuWidget );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handle window resize event.
|
|
*
|
|
* @method
|
|
* @param {jQuery.Event} e Window resize event
|
|
*/
|
|
ve.ui.TextInputMenuWidget.prototype.onWindowResize = function () {
|
|
this.position();
|
|
};
|
|
|
|
/**
|
|
* Shows the menu.
|
|
*
|
|
* @method
|
|
* @chainable
|
|
*/
|
|
ve.ui.TextInputMenuWidget.prototype.show = function () {
|
|
// Parent method
|
|
ve.ui.MenuWidget.prototype.show.call( this );
|
|
|
|
this.position();
|
|
$( this.getElementWindow() ).on( 'resize', this.onWindowResizeHandler );
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Hides the menu.
|
|
*
|
|
* @method
|
|
* @chainable
|
|
*/
|
|
ve.ui.TextInputMenuWidget.prototype.hide = function () {
|
|
// Parent method
|
|
ve.ui.MenuWidget.prototype.hide.call( this );
|
|
|
|
$( this.getElementWindow() ).off( 'resize', this.onWindowResizeHandler );
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Positions the menu.
|
|
*
|
|
* @method
|
|
* @chainable
|
|
*/
|
|
ve.ui.TextInputMenuWidget.prototype.position = function () {
|
|
var frameOffset,
|
|
$container = this.$container,
|
|
dimensions = $container.offset();
|
|
|
|
// Position under input
|
|
dimensions.top += $container.height();
|
|
dimensions.width = $container.width();
|
|
|
|
// Compensate for frame position if in a differnt frame
|
|
if ( this.input.$$.frame && this.input.$$.context !== this.$[0].ownerDocument ) {
|
|
frameOffset = ve.Element.getRelativePosition(
|
|
this.input.$$.frame.$, this.$.closest( '.ve-ui-surface' )
|
|
);
|
|
dimensions.left += frameOffset.left;
|
|
dimensions.top += frameOffset.top;
|
|
}
|
|
|
|
this.$.css( dimensions );
|
|
return this;
|
|
};
|